-
Notifications
You must be signed in to change notification settings - Fork 198
/
sensei-lms.php
145 lines (126 loc) · 4.37 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
139
140
141
142
143
144
145
<?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.24.4
* 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: 6.5
* Tested up to: 6.7
* Requires PHP: 7.4
* Text Domain: sensei-lms
* Domain path: /lang/
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! defined( 'SENSEI_LMS_VERSION' ) ) {
define( 'SENSEI_LMS_VERSION', '4.24.4' ); // WRCS: DEFINED_VERSION.
}
if ( ! defined( 'SENSEI_LMS_PLUGIN_FILE' ) ) {
define( 'SENSEI_LMS_PLUGIN_FILE', __FILE__ );
}
if ( ! defined( 'SENSEI_LMS_PLUGIN_PATH' ) ) {
define( 'SENSEI_LMS_PLUGIN_PATH', plugin_dir_path( SENSEI_LMS_PLUGIN_FILE ) );
}
if ( class_exists( 'Sensei_Main', false ) ) {
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' ) );
}
}
/**
* Autoload the vendor dependencies. This includes the prefixed vendor dependencies as well.
*/
require SENSEI_LMS_PLUGIN_PATH . 'vendor/autoload.php';
/**
* Load packages and libraries.
*/
if (
! (
// Check for Automattic private site in WPCOM (Like Learnomattic).
( defined( 'A8C__IS_A8C_PRIVATE_BLOG' ) && A8C__IS_A8C_PRIVATE_BLOG )
// Check for Automattic public site in WPCOM (learn.wordpress.com).
|| ( defined( 'A8C__IS_A8C_BLOG' ) && A8C__IS_A8C_BLOG )
|| ( defined( 'SENSEI_DO_NOT_LOAD_ACTION_SCHEDULER' ) && SENSEI_DO_NOT_LOAD_ACTION_SCHEDULER )
)
) {
require SENSEI_LMS_PLUGIN_PATH . 'vendor/woocommerce/action-scheduler/action-scheduler.php';
}
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' ) );
}
if ( ! function_exists( 'Sensei' ) ) {
/**
* Returns the global Sensei Instance.
* phpcs:disable WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
*
* @since 1.8.0
*
* @return Sensei_Main
*/
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();
}
}
\Sensei\Internal\Installer\Installer::instance( SENSEI_LMS_VERSION )->init();