Code

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