-
Notifications
You must be signed in to change notification settings - Fork 4
/
lifterlms-labs.php
156 lines (131 loc) · 3 KB
/
lifterlms-labs.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
146
147
148
149
150
151
152
153
154
155
156
<?php
/**
* Main LifterLMS Labs file
*
* @package LifterLMS_Labs
*
* @since 1.0.0
* @version 1.0.0
*
* Plugin Name: LifterLMS Labs
* Plugin URI: https://lifterlms.com/
* Description: A collection of experimental, conceptual, and possibly silly features which improve and enhance the functionality of the LifterLMS core.
* Version: 1.8.1
* Author: LifterLMS
* Author URI: https://lifterlms.com
* Text Domain: lifterlms-labs
* Domain Path: /i18n
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
* Requires at least: 5.3
* Tested up to: 6.7
*/
defined( 'ABSPATH' ) || exit;
/**
* LifterLMS Labs Main Class.
*
* @since 1.0.0
*/
final class LifterLMS_Labs {
/**
* Plugin version.
*
* @var string
*/
public $version = '1.8.1';
/**
* Singleton Instance.
*
* @var null|LifterLMS_Labs
*/
protected static $_instance = null; // phpcs:ignore.
/**
* Main Instance of LifterLMS_Labs class.
*
* @since 1.0.0
*
* @see llms_labs()
*
* @return LifterLMS_Labs
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Constructor.
*
* @since 1.0.0
*
* @return void
*/
private function __construct() {
do_action( 'llms_labs_load_before' );
$this->define_constants();
$this->includes();
add_action( 'plugins_loaded', array( $this, 'localize' ) );
do_action( 'llms_labs_load_after' );
}
/**
* Define Constants.
*
* @since 1.0.0
*
* @return void
*/
private function define_constants() {
if ( ! defined( 'LLMS_LABS_PLUGIN_FILE' ) ) {
define( 'LLMS_LABS_PLUGIN_FILE', __FILE__ );
}
if ( ! defined( 'LLMS_LABS_VERSION' ) ) {
define( 'LLMS_LABS_VERSION', $this->version );
}
if ( ! defined( 'LLMS_LABS_PLUGIN_DIR' ) ) {
define( 'LLMS_LABS_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . plugin_basename( __DIR__ ) . '/' );
}
}
/**
* Include required files.
* @since 1.0.0
* @since 1.1.0 Unknown.
*
* @return void
*/
private function includes() {
require_once 'inc/class.llms.labs.labtech.php';
require_once 'inc/class.llms.labs.settings.page.php';
require_once 'inc/labs/abstract.llms.lab.php';
foreach ( glob( LLMS_LABS_PLUGIN_DIR . 'inc/labs/class.llms.lab.*.php', GLOB_NOSORT ) as $lab ) {
require_once $lab;
}
}
/**
* Load Localization files.
*
* @since 1.0.0
* @since 1.2.0 Unknown.
*
* @return void
*/
public function localize() {
// Load locale.
$locale = apply_filters( 'plugin_locale', get_locale(), 'lifterlms-labs' );
// Load a lifterlms specific locale file if one exists.
load_textdomain( 'lifterlms', WP_LANG_DIR . '/lifterlms/lifterlms-labs-' . $locale . '.mo' );
// Load localization files.
load_plugin_textdomain( 'lifterlms', false, dirname( plugin_basename( __FILE__ ) ) . '/i18n' );
}
}
/**
* Returns the main instance of LifterLMS Labs.
*
* @since 1.0.0
*
* @return LifterLMS_Labs
*/
function llms_labs() {
return LifterLMS_Labs::instance();
}
return llms_labs();