-
Notifications
You must be signed in to change notification settings - Fork 3
/
mai-engine.php
121 lines (112 loc) · 2.98 KB
/
mai-engine.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
<?php
/**
* Mai Engine.
*
* Plugin Name: Mai Engine
* Plugin URI: https://bizbudding.com/mai-theme/
* GitHub Plugin URI: https://github.com/maithemewp/mai-engine/
* Description: The required plugin to power Mai child themes.
* Version: 2.35.1
* Requires at least: 6.4
* Requires PHP: 7.4
* Author: BizBudding
* Author URI: https://bizbudding.com/
* Text Domain: mai-engine
* License: GPL-2.0-or-later
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /assets/lang
*
* @package BizBudding\MaiEngine
* @author BizBudding <[email protected]>
* @license GPL-2.0-or-later
* @link https://bizbudding.com/
* @copyright 2020 BizBudding
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Main Mai_Engine Class.
*
* @since 2.18.0
*/
final class Mai_Engine {
/**
* @var Mai_Engine The one true Mai_Engine
* @since 2.18.0
*/
private static $instance;
/**
* Main Mai_Engine Instance.
*
* Insures that only one instance of Mai_Engine exists in memory at any one
* time. Also prevents needing to define globals all over the place.
*
* @since 2.18.0
* @static var array $instance
* @uses Mai_Engine::setup_constants() Setup the constants needed.
* @uses Mai_Engine::includes() Include the required files.
* @uses Mai_Engine::hooks() Activate, deactivate, etc.
* @see Mai_Engine()
* @return object | Mai_Engine The one true Mai_Engine
*/
public static function instance() {
if ( ! isset( self::$instance ) ) {
// Setup the setup.
self::$instance = new Mai_Engine;
// Methods.
self::$instance->includes();
}
return self::$instance;
}
/**
* Throw error on object clone.
*
* The whole idea of the singleton design pattern is that there is a single
* object therefore, we don't want the object to be cloned.
*
* @since 2.18.0
* @access protected
* @return void
*/
public function __clone() {
// Cloning instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'mai-engine' ), '1.0' );
}
/**
* Disable unserializing of the class.
*
* @since 2.18.0
* @access protected
* @return void
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'mai-engine' ), '1.0' );
}
/**
* Include required files.
*
* @access private
* @since 2.18.0
* @return void
*/
private function includes() {
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/lib/init.php';
}
}
/**
* The main function for that returns Mai_Engine
*
* The main function responsible for returning the one true Mai_Engine
* Instance to functions everywhere.
*
* @since 2.18.0
*
* @return object|Mai_Engine The one true Mai_Engine Instance.
*/
function mai_engine() {
return Mai_Engine::instance();
}
// Get Mai_Engine Running.
mai_engine();