1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* The initation loader for CMB2, and the main plugin file. |
4
|
|
|
* |
5
|
|
|
* @category WordPress_Plugin |
6
|
|
|
* @package CMB2 |
7
|
|
|
* @author CMB2 team |
8
|
|
|
* @license GPL-2.0+ |
9
|
|
|
* @link https://cmb2.io |
10
|
|
|
* |
11
|
|
|
* Plugin Name: CMB2 |
12
|
|
|
* Plugin URI: https://github.com/CMB2/CMB2 |
13
|
|
|
* Description: CMB2 will create metaboxes and forms with custom fields that will blow your mind. |
14
|
|
|
* Author: CMB2 team |
15
|
|
|
* Author URI: https://cmb2.io |
16
|
|
|
* Contributors: Justin Sternberg (@jtsternberg / dsgnwrks.pro) |
17
|
|
|
* WebDevStudios (@webdevstudios / webdevstudios.com) |
18
|
|
|
* Zao (zao.is) |
19
|
|
|
* Human Made (@humanmadeltd / hmn.md) |
20
|
|
|
* Jared Atchison (@jaredatch / jaredatchison.com) |
21
|
|
|
* Bill Erickson (@billerickson / billerickson.net) |
22
|
|
|
* Andrew Norcross (@norcross / andrewnorcross.com) |
23
|
|
|
* |
24
|
|
|
* Version: 2.4.2 |
25
|
|
|
* |
26
|
|
|
* Text Domain: cmb2 |
27
|
|
|
* Domain Path: languages |
28
|
|
|
* |
29
|
|
|
* |
30
|
|
|
* Released under the GPL license |
31
|
|
|
* http://www.opensource.org/licenses/gpl-license.php |
32
|
|
|
* |
33
|
|
|
* This is an add-on for WordPress |
34
|
|
|
* https://wordpress.org/ |
35
|
|
|
* |
36
|
|
|
* ********************************************************************** |
37
|
|
|
* This program is free software; you can redistribute it and/or modify |
38
|
|
|
* it under the terms of the GNU General Public License as published by |
39
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
40
|
|
|
* (at your option) any later version. |
41
|
|
|
* |
42
|
|
|
* This program is distributed in the hope that it will be useful, |
43
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
44
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
45
|
|
|
* GNU General Public License for more details. |
46
|
|
|
* ********************************************************************** |
47
|
|
|
*/ |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* ********************************************************************* |
51
|
|
|
* You should not edit the code below |
52
|
|
|
* (or any code in the included files) |
53
|
|
|
* or things might explode! |
54
|
|
|
* *********************************************************************** |
55
|
|
|
*/ |
56
|
|
|
|
57
|
|
|
if ( ! class_exists( 'CMB2_Bootstrap_242_Trunk', false ) ) { |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Handles checking for and loading the newest version of CMB2 |
61
|
|
|
* |
62
|
|
|
* @since 2.0.0 |
63
|
|
|
* |
64
|
|
|
* @category WordPress_Plugin |
65
|
|
|
* @package CMB2 |
66
|
|
|
* @author CMB2 team |
67
|
|
|
* @license GPL-2.0+ |
68
|
|
|
* @link https://cmb2.io |
69
|
|
|
*/ |
70
|
|
|
class CMB2_Bootstrap_242_Trunk { |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Current version number |
74
|
|
|
* |
75
|
|
|
* @var string |
76
|
|
|
* @since 1.0.0 |
77
|
|
|
*/ |
78
|
|
|
const VERSION = '2.4.2'; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Current version hook priority. |
82
|
|
|
* Will decrement with each release |
83
|
|
|
* |
84
|
|
|
* @var int |
85
|
|
|
* @since 2.0.0 |
86
|
|
|
*/ |
87
|
|
|
const PRIORITY = 9966; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Single instance of the CMB2_Bootstrap_242_Trunk object |
91
|
|
|
* |
92
|
|
|
* @var CMB2_Bootstrap_242_Trunk |
93
|
|
|
*/ |
94
|
|
|
public static $single_instance = null; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Creates/returns the single instance CMB2_Bootstrap_242_Trunk object |
98
|
|
|
* |
99
|
|
|
* @since 2.0.0 |
100
|
|
|
* @return CMB2_Bootstrap_242_Trunk Single instance object |
101
|
|
|
*/ |
102
|
|
|
public static function initiate() { |
103
|
|
|
if ( null === self::$single_instance ) { |
104
|
|
|
self::$single_instance = new self(); |
105
|
|
|
} |
106
|
|
|
return self::$single_instance; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Starts the version checking process. |
111
|
|
|
* Creates CMB2_LOADED definition for early detection by other scripts |
112
|
|
|
* |
113
|
|
|
* Hooks CMB2 inclusion to the init hook on a high priority which decrements |
114
|
|
|
* (increasing the priority) with each version release. |
115
|
|
|
* |
116
|
|
|
* @since 2.0.0 |
117
|
|
|
*/ |
118
|
|
|
private function __construct() { |
119
|
|
|
/** |
120
|
|
|
* A constant you can use to check if CMB2 is loaded |
121
|
|
|
* for your plugins/themes with CMB2 dependency |
122
|
|
|
*/ |
123
|
|
|
if ( ! defined( 'CMB2_LOADED' ) ) { |
124
|
|
|
define( 'CMB2_LOADED', self::PRIORITY ); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
add_action( 'init', array( $this, 'include_cmb' ), self::PRIORITY ); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* A final check if CMB2 exists before kicking off our CMB2 loading. |
132
|
|
|
* CMB2_VERSION and CMB2_DIR constants are set at this point. |
133
|
|
|
* |
134
|
|
|
* @since 2.0.0 |
135
|
|
|
*/ |
136
|
|
|
public function include_cmb() { |
137
|
|
|
if ( class_exists( 'CMB2', false ) ) { |
138
|
|
|
return; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
if ( ! defined( 'CMB2_VERSION' ) ) { |
142
|
|
|
define( 'CMB2_VERSION', self::VERSION ); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
if ( ! defined( 'CMB2_DIR' ) ) { |
146
|
|
|
define( 'CMB2_DIR', trailingslashit( dirname( __FILE__ ) ) ); |
|
|
|
|
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
$this->l10ni18n(); |
150
|
|
|
|
151
|
|
|
// Include helper functions. |
152
|
|
|
require_once CMB2_DIR . 'includes/CMB2_Base.php'; |
153
|
|
|
require_once CMB2_DIR . 'includes/CMB2.php'; |
154
|
|
|
require_once CMB2_DIR . 'includes/helper-functions.php'; |
155
|
|
|
|
156
|
|
|
// Now kick off the class autoloader. |
157
|
|
|
spl_autoload_register( 'cmb2_autoload_classes' ); |
158
|
|
|
|
159
|
|
|
// Kick the whole thing off. |
160
|
|
|
require_once( cmb2_dir( 'bootstrap.php' ) ); |
161
|
|
|
cmb2_bootstrap(); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Registers CMB2 text domain path |
166
|
|
|
* |
167
|
|
|
* @since 2.0.0 |
168
|
|
|
*/ |
169
|
|
|
public function l10ni18n() { |
170
|
|
|
|
171
|
|
|
$loaded = load_plugin_textdomain( 'cmb2', false, '/languages/' ); |
|
|
|
|
172
|
|
|
|
173
|
|
|
if ( ! $loaded ) { |
174
|
|
|
$loaded = load_muplugin_textdomain( 'cmb2', '/languages/' ); |
|
|
|
|
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
if ( ! $loaded ) { |
178
|
|
|
$loaded = load_theme_textdomain( 'cmb2', get_stylesheet_directory() . '/languages/' ); |
|
|
|
|
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
if ( ! $loaded ) { |
182
|
|
|
$locale = apply_filters( 'plugin_locale', get_locale(), 'cmb2' ); |
|
|
|
|
183
|
|
|
$mofile = dirname( __FILE__ ) . '/languages/cmb2-' . $locale . '.mo'; |
184
|
|
|
load_textdomain( 'cmb2', $mofile ); |
|
|
|
|
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
// Make it so... |
192
|
|
|
CMB2_Bootstrap_242_Trunk::initiate(); |
193
|
|
|
|
194
|
|
|
}// End if(). |
|
|
|
|
195
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.