PluginProbe
Gallery Box / trunk
Gallery Box vtrunk
trunk 1.3.1 1.3.3 1.4.0 1.4.1 1.4.2 1.5.1 1.7.35
gallery-box / admin / src / CMB2 / init.php

init.php in Gallery Box trunk, at admin/src/CMB2/init.php

180 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The initation loader for CMB2, and the main plugin file.
5 *
6 *
7 *
8 * Released under the GPL license
9 * http://www.opensource.org/licenses/gpl-license.php
10 *
11 * This is an add-on for WordPress
12 * https://wordpress.org/
13 *
14 * **********************************************************************
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 * **********************************************************************
25 */
26
27 /**
28 * *********************************************************************
29 * You should not edit the code below
30 * (or any code in the included files)
31 * or things might explode!
32 * ***********************************************************************
33 */
34
35 if (!class_exists('CMB2_Bootstrap_2100_Develop', false)) {
36
37 /**
38 * Handles checking for and loading the newest version of CMB2
39 *
40 * @since 2.0.0
41 *
42 * @category WordPress_Plugin
43 * @package CMB2
44 * @author CMB2 team
45 * @license GPL-2.0+
46 * @link https://cmb2.io
47 */
48 class CMB2_Bootstrap_2100_Develop
49 {
50
51 /**
52 * Current version number
53 *
54 * @var string
55 * @since 1.0.0
56 */
57 const VERSION = '2.10.0';
58
59 /**
60 * Current version hook priority.
61 * Will decrement with each release
62 *
63 * @var int
64 * @since 2.0.0
65 */
66 const PRIORITY = 9958;
67
68 /**
69 * Single instance of the CMB2_Bootstrap_2100_Develop object
70 *
71 * @var CMB2_Bootstrap_2100_Develop
72 */
73 public static $single_instance = null;
74
75 /**
76 * Creates/returns the single instance CMB2_Bootstrap_2100_Develop object
77 *
78 * @since 2.0.0
79 * @return CMB2_Bootstrap_2100_Develop Single instance object
80 */
81 public static function initiate()
82 {
83 if (null === self::$single_instance) {
84 self::$single_instance = new self();
85 }
86 return self::$single_instance;
87 }
88
89 /**
90 * Starts the version checking process.
91 * Creates CMB2_LOADED definition for early detection by other scripts
92 *
93 * Hooks CMB2 inclusion to the init hook on a high priority which decrements
94 * (increasing the priority) with each version release.
95 *
96 * @since 2.0.0
97 */
98 private function __construct()
99 {
100 /**
101 * A constant you can use to check if CMB2 is loaded
102 * for your plugins/themes with CMB2 dependency
103 */
104 if (!defined('CMB2_LOADED')) {
105 define('CMB2_LOADED', self::PRIORITY);
106 }
107
108 if (!function_exists('add_action')) {
109 // We are running outside of the context of WordPress.
110 return;
111 }
112
113 add_action('init', array($this, 'include_cmb'), self::PRIORITY);
114 }
115
116 /**
117 * A final check if CMB2 exists before kicking off our CMB2 loading.
118 * CMB2_VERSION and CMB2_DIR constants are set at this point.
119 *
120 * @since 2.0.0
121 */
122 public function include_cmb()
123 {
124 if (class_exists('CMB2', false)) {
125 return;
126 }
127
128 if (!defined('CMB2_VERSION')) {
129 define('CMB2_VERSION', self::VERSION);
130 }
131
132 if (!defined('CMB2_DIR')) {
133 define('CMB2_DIR', trailingslashit(dirname(__FILE__)));
134 }
135
136 $this->l10ni18n();
137
138 // Include helper functions.
139 require_once CMB2_DIR . 'includes/CMB2_Base.php';
140 require_once CMB2_DIR . 'includes/CMB2.php';
141 require_once CMB2_DIR . 'includes/helper-functions.php';
142
143 // Now kick off the class autoloader.
144 spl_autoload_register('cmb2_autoload_classes');
145
146 // Kick the whole thing off.
147 require_once(cmb2_dir('bootstrap.php'));
148 cmb2_bootstrap();
149 }
150
151 /**
152 * Registers CMB2 text domain path
153 *
154 * @since 2.0.0
155 */
156 public function l10ni18n()
157 {
158
159 $loaded = load_plugin_textdomain('cmb2', false, '/languages/');
160
161 if (!$loaded) {
162 $loaded = load_muplugin_textdomain('cmb2', '/languages/');
163 }
164
165 if (!$loaded) {
166 $loaded = load_theme_textdomain('cmb2', get_stylesheet_directory() . '/languages/');
167 }
168
169 if (!$loaded) {
170 $locale = apply_filters('plugin_locale', function_exists('determine_locale') ? determine_locale() : get_locale(), 'cmb2');
171 $mofile = dirname(__FILE__) . '/languages/cmb2-' . $locale . '.mo';
172 load_textdomain('cmb2', $mofile);
173 }
174 }
175 }
176
177 // Make it so...
178 CMB2_Bootstrap_2100_Develop::initiate();
179 }// End if().
180