-
Notifications
You must be signed in to change notification settings - Fork 198
/
Copy pathsensei-lms.php
138 lines (120 loc) · 4.27 KB
/
sensei-lms.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/**
* Plugin Name: Sensei LMS
* Plugin URI: https://senseilms.com/
* Description: Share your knowledge, grow your network, and strengthen your brand by launching an online course.
* Version: 4.10.0
* Author: Automattic
* Author URI: https://automattic.com
* License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* Requires at least: 5.9
* Tested up to: 6.1
* Requires PHP: 7.2
* Text Domain: sensei-lms
* Domain path: /lang/
*/
/**
* Copyright 2013-2022 Automattic
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! defined( 'SENSEI_LMS_VERSION' ) ) {
define( 'SENSEI_LMS_VERSION', '4.10.0' ); // WRCS: DEFINED_VERSION.
}
if ( ! defined( 'SENSEI_LMS_PLUGIN_FILE' ) ) {
define( 'SENSEI_LMS_PLUGIN_FILE', __FILE__ );
}
if ( class_exists( 'Sensei_Main' ) ) {
if ( ! function_exists( 'is_sensei_activating' ) ) {
/**
* Checks if Sensei is being activated.
*
* @since 2.0.0
* @access private
*
* @param string|bool $activating_plugin Plugin that may be getting activated. False if none.
* @param string $plugin This plugin basename from loading function.
* @return bool
*/
function is_sensei_activating( $activating_plugin, $plugin ) {
return ! empty( $activating_plugin ) && $activating_plugin === $plugin;
}
}
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- false positive
if ( ! isset( $_wp_plugin_file ) ) {
$_wp_plugin_file = false;
}
if ( ! isset( $plugin ) ) {
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- This shouldn't have any effect. Just ensuring variable is set.
$plugin = null;
}
// phpcs:enable
if ( is_sensei_activating( $_wp_plugin_file, $plugin ) && defined( 'SENSEI_IGNORE_ACTIVATION_CONFLICT' ) && true === SENSEI_IGNORE_ACTIVATION_CONFLICT ) {
// Hope that this will just be a conflict that happens during activation.
return;
} else {
die( esc_html__( 'Deactivate other instances of Sensei LMS before activating this plugin.', 'sensei-lms' ) );
}
}
require_once dirname( __FILE__ ) . '/includes/class-sensei-dependency-checker.php';
if ( ! Sensei_Dependency_Checker::check_php_requirement() ) {
add_action( 'admin_notices', array( 'Sensei_Dependency_Checker', 'add_php_version_notice' ) );
return;
}
if ( ! Sensei_Dependency_Checker::check_future_php_requirement() ) {
add_action( 'admin_notices', array( 'Sensei_Dependency_Checker', 'add_future_php_version_notice' ) );
}
if ( ! Sensei_Dependency_Checker::check_assets() ) {
add_action( 'admin_notices', array( 'Sensei_Dependency_Checker', 'add_assets_notice' ) );
}
require_once dirname( __FILE__ ) . '/includes/class-sensei-bootstrap.php';
Sensei_Bootstrap::get_instance()->bootstrap();
if ( ! function_exists( 'Sensei' ) ) {
/**
* Returns the global Sensei Instance.
* phpcs:disable WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
*
* @since 1.8.0
*/
function Sensei() {
// phpcs:enable
return Sensei_Main::instance( array( 'version' => SENSEI_LMS_VERSION ) );
}
}
// For backwards compatibility, put plugin into the global variable.
global $woothemes_sensei;
$woothemes_sensei = Sensei();
/**
* Sensei Activation Hook registration
*
* @since 1.8.0
*/
register_activation_hook( SENSEI_LMS_PLUGIN_FILE, 'activate_sensei' );
if ( ! function_exists( 'activate_sensei' ) ) {
/**
* Activate_sensei
* phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
*
* All the activation checks needed to ensure Sensei is ready for use
*
* @since 1.8.0
*/
function activate_sensei() {
// phpcs:enable
Sensei()->activate();
}
}