forked from CMB2/CMB2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.php
198 lines (172 loc) · 5.31 KB
/
init.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
/**
* The initation loader for CMB2, and the main plugin file.
*
* @category WordPress_Plugin
* @package CMB2
* @author CMB2 team
* @license GPL-2.0+
* @link https://cmb2.io
*
* Plugin Name: CMB2
* Plugin URI: https://github.com/CMB2/CMB2
* Description: CMB2 will create metaboxes and forms with custom fields that will blow your mind.
* Author: CMB2 team
* Author URI: https://cmb2.io
* Contributors: Justin Sternberg (@jtsternberg / dsgnwrks.pro)
* WebDevStudios (@webdevstudios / webdevstudios.com)
* Human Made (@humanmadeltd / hmn.md)
* Jared Atchison (@jaredatch / jaredatchison.com)
* Bill Erickson (@billerickson / billerickson.net)
* Andrew Norcross (@norcross / andrewnorcross.com)
*
* Version: 2.10.1
*
* Text Domain: cmb2
* Domain Path: languages
*
*
* Released under the GPL license
* http://www.opensource.org/licenses/gpl-license.php
*
* This is an add-on for WordPress
* https://wordpress.org/
*
* **********************************************************************
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 not edit the code below
* (or any code in the included files)
* or things might explode!
* ***********************************************************************
*/
if ( ! class_exists( 'CMB2_Bootstrap_2101', false ) ) {
/**
* Handles checking for and loading the newest version of CMB2
*
* @since 2.0.0
*
* @category WordPress_Plugin
* @package CMB2
* @author CMB2 team
* @license GPL-2.0+
* @link https://cmb2.io
*/
class CMB2_Bootstrap_2101 {
/**
* Current version number
*
* @var string
* @since 1.0.0
*/
const VERSION = '2.10.1';
/**
* Current version hook priority.
* Will decrement with each release
*
* @var int
* @since 2.0.0
*/
const PRIORITY = 9957;
/**
* Single instance of the CMB2_Bootstrap_2101 object
*
* @var CMB2_Bootstrap_2101
*/
public static $single_instance = null;
/**
* Creates/returns the single instance CMB2_Bootstrap_2101 object
*
* @since 2.0.0
* @return CMB2_Bootstrap_2101 Single instance object
*/
public static function initiate() {
if ( null === self::$single_instance ) {
self::$single_instance = new self();
}
return self::$single_instance;
}
/**
* Starts the version checking process.
* Creates CMB2_LOADED definition for early detection by other scripts
*
* Hooks CMB2 inclusion to the init hook on a high priority which decrements
* (increasing the priority) with each version release.
*
* @since 2.0.0
*/
private function __construct() {
/**
* A constant you can use to check if CMB2 is loaded
* for your plugins/themes with CMB2 dependency
*/
if ( ! defined( 'CMB2_LOADED' ) ) {
define( 'CMB2_LOADED', self::PRIORITY );
}
if ( ! function_exists( 'add_action' ) ) {
// We are running outside of the context of WordPress.
return;
}
add_action( 'init', array( $this, 'include_cmb' ), self::PRIORITY );
}
/**
* A final check if CMB2 exists before kicking off our CMB2 loading.
* CMB2_VERSION and CMB2_DIR constants are set at this point.
*
* @since 2.0.0
*/
public function include_cmb() {
if ( class_exists( 'CMB2', false ) ) {
return;
}
if ( ! defined( 'CMB2_VERSION' ) ) {
define( 'CMB2_VERSION', self::VERSION );
}
if ( ! defined( 'CMB2_DIR' ) ) {
define( 'CMB2_DIR', trailingslashit( dirname( __FILE__ ) ) );
}
$this->l10ni18n();
// Include helper functions.
require_once CMB2_DIR . 'includes/CMB2_Base.php';
require_once CMB2_DIR . 'includes/CMB2.php';
require_once CMB2_DIR . 'includes/helper-functions.php';
// Now kick off the class autoloader.
spl_autoload_register( 'cmb2_autoload_classes' );
// Kick the whole thing off.
require_once( cmb2_dir( 'bootstrap.php' ) );
cmb2_bootstrap();
}
/**
* Registers CMB2 text domain path
*
* @since 2.0.0
*/
public function l10ni18n() {
$loaded = load_plugin_textdomain( 'cmb2', false, '/languages/' );
if ( ! $loaded ) {
$loaded = load_muplugin_textdomain( 'cmb2', '/languages/' );
}
if ( ! $loaded ) {
$loaded = load_theme_textdomain( 'cmb2', get_stylesheet_directory() . '/languages/' );
}
if ( ! $loaded ) {
$locale = apply_filters( 'plugin_locale', function_exists( 'determine_locale' ) ? determine_locale() : get_locale(), 'cmb2' );
$mofile = dirname( __FILE__ ) . '/languages/cmb2-' . $locale . '.mo';
load_textdomain( 'cmb2', $mofile );
}
}
}
// Make it so...
CMB2_Bootstrap_2101::initiate();
}// End if().