-
Notifications
You must be signed in to change notification settings - Fork 0
/
learndash-history.php
84 lines (77 loc) · 2.86 KB
/
learndash-history.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/**
* Plugin Name: LearnDash LMS - History
* Description: Store all users LearnDash course, quiz, and certificate history
* Version: 0.0.0-development
* Author: Seattle Web Co.
* Author URI: https://seattlewebco.com
* Text Domain: learndash-history
* Domain Path: /languages/
* Contributors: seattlewebco, dkjensen
* Requires PHP: 7.0.0
*
* @package SeattleWebCo\LearnDashHistory
*/
namespace SeattleWebCo\LearnDashHistory;
/**
* Setup plugin
*
* @return void
*/
function initialize() {
if ( defined( '\\LEARNDASH_VERSION' ) ) {
/**
* Load functions and dependencies
*/
require_once plugin_dir_path( __FILE__ ) . '/vendor/autoload.php';
require_once plugin_dir_path( __FILE__ ) . '/lib/functions/triggers.php';
require_once plugin_dir_path( __FILE__ ) . '/lib/functions/views.php';
require_once plugin_dir_path( __FILE__ ) . '/lib/functions/certificates.php';
/**
* Init localization files
*/
load_plugin_textdomain( 'learndash-history', false, plugin_dir_path( __FILE__ ) . '/languages' );
}
}
add_action( 'plugins_loaded', __NAMESPACE__ . '\initialize' );
/**
* Install table
*
* @return void
*/
function install() {
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$table = "CREATE TABLE `{$wpdb->prefix}learndash_history`
(
`id` BIGINT(20) UNSIGNED NOT NULL auto_increment,
`user_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
`post_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
`course_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
`activity_type` VARCHAR(50) NULL DEFAULT NULL,
`activity_status` TINYINT(1) UNSIGNED NULL DEFAULT NULL,
`activity_started` INT(11) UNSIGNED NULL DEFAULT NULL,
`activity_completed` INT(11) UNSIGNED NULL DEFAULT NULL,
`score` INT(11) UNSIGNED NULL DEFAULT NULL,
`count` INT(11) UNSIGNED NULL DEFAULT NULL,
`pass` INT(11) UNSIGNED NULL DEFAULT NULL,
`points` INT(11) UNSIGNED NULL DEFAULT NULL,
`percentage` INT(11) UNSIGNED NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `user_id` (`user_id`),
INDEX `post_id` (`post_id`),
INDEX `course_id` (`course_id`),
INDEX `activity_status` (`activity_status`),
INDEX `activity_type` (`activity_type`),
INDEX `activity_started` (`activity_started`),
INDEX `activity_completed` (`activity_completed`),
INDEX `score` (`score`),
INDEX `count` (`count`),
INDEX `pass` (`pass`),
INDEX `points` (`points`),
INDEX `percentage` (`percentage`)
) {$charset_collate}";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $table );
}
\register_activation_hook( __FILE__, __NAMESPACE__ . '\install' );