class-learndash-admin-data-upgrades-group-leader-role.php
1.41 KB
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
<?php
/**
* LearnDash Data Upgrades for Group Leader Role.
*
* @since 2.5.6
* @package LearnDash\Data_Upgrades
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ( class_exists( 'Learndash_Admin_Data_Upgrades' ) ) && ( ! class_exists( 'Learndash_Admin_Data_Upgrades_Group_Leader_Role' ) ) ) {
/**
* Class LearnDash Data Upgrades for Group Leader Role.
*
* @since 2.5.6
* @uses Learndash_Admin_Data_Upgrades
*/
class Learndash_Admin_Data_Upgrades_Group_Leader_Role extends Learndash_Admin_Data_Upgrades {
/**
* Protected constructor for class
*
* @since 2.5.6
*/
protected function __construct() {
$this->data_slug = 'group-leader-role';
parent::__construct();
add_action( 'init', array( $this, 'create_group_leader_role' ) );
parent::register_upgrade_action();
}
/**
* Create Group Leader Role
* Checks to see if settings needs to be updated.
*
* @since 2.5.6
*/
public function create_group_leader_role() {
if ( is_admin() ) {
$gl_role_created = $this->get_data_settings( 'gl_role_created' );
if ( ( defined( 'LEARNDASH_ACTIVATED' ) && LEARNDASH_ACTIVATED ) || ( ! $gl_role_created ) ) {
learndash_add_group_admin_role();
$this->set_data_settings( 'gl_role_created', time() );
}
}
}
// End of functions.
}
}
add_action(
'learndash_data_upgrades_init',
function() {
Learndash_Admin_Data_Upgrades_Group_Leader_Role::add_instance();
}
);