Passed
Pull Request — trunk (#1007)
by
unknown
11:05
created

CMB2_Bootstrap_260_Develop::initiate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
rs 10
ccs 0
cts 4
cp 0
cc 2
nc 2
nop 0
crap 6
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
 *               Human Made (@humanmadeltd / hmn.md)
19
 *               Jared Atchison (@jaredatch / jaredatchison.com)
20
 *               Bill Erickson (@billerickson / billerickson.net)
21
 *               Andrew Norcross (@norcross / andrewnorcross.com)
22
 *
23
 * Version:      2.6.0
24
 *
25
 * Text Domain:  cmb2
26
 * Domain Path:  languages
27
 *
28
 *
29
 * Released under the GPL license
30
 * http://www.opensource.org/licenses/gpl-license.php
31
 *
32
 * This is an add-on for WordPress
33
 * https://wordpress.org/
34
 *
35
 * **********************************************************************
36
 * This program is free software; you can redistribute it and/or modify
37
 * it under the terms of the GNU General Public License as published by
38
 * the Free Software Foundation; either version 2 of the License, or
39
 * (at your option) any later version.
40
 *
41
 * This program is distributed in the hope that it will be useful,
42
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
43
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
44
 * GNU General Public License for more details.
45
 * **********************************************************************
46
 */
47
48
/**
49
 * *********************************************************************
50
 *               You should not edit the code below
51
 *               (or any code in the included files)
52
 *               or things might explode!
53
 * ***********************************************************************
54
 */
55
56
if ( ! class_exists( 'CMB2_Bootstrap_260_Develop', false ) ) {
57
58
	/**
59
	 * Handles checking for and loading the newest version of CMB2
60
	 *
61
	 * @since  2.0.0
62
	 *
63
	 * @category  WordPress_Plugin
64
	 * @package   CMB2
65
	 * @author    CMB2 team
66
	 * @license   GPL-2.0+
67
	 * @link      https://cmb2.io
68
	 */
69
	class CMB2_Bootstrap_260_Develop {
70
71
		/**
72
		 * Current version number
73
		 *
74
		 * @var   string
75
		 * @since 1.0.0
76
		 */
77
		const VERSION = '2.6.0';
78
79
		/**
80
		 * Current version hook priority.
81
		 * Will decrement with each release
82
		 *
83
		 * @var   int
84
		 * @since 2.0.0
85
		 */
86
		const PRIORITY = 9964;
87
88
		/**
89
		 * Single instance of the CMB2_Bootstrap_260_Develop object
90
		 *
91
		 * @var CMB2_Bootstrap_260_Develop
92
		 */
93
		public static $single_instance = null;
94
95
		/**
96
		 * Creates/returns the single instance CMB2_Bootstrap_260_Develop object
97
		 *
98
		 * @since  2.0.0
99
		 * @return CMB2_Bootstrap_260_Develop Single instance object
100
		 */
101
		public static function initiate() {
102
			if ( null === self::$single_instance ) {
103
				self::$single_instance = new self();
104
			}
105
			return self::$single_instance;
106
		}
107
108
		/**
109
		 * Starts the version checking process.
110
		 * Creates CMB2_LOADED definition for early detection by other scripts
111
		 *
112
		 * Hooks CMB2 inclusion to the init hook on a high priority which decrements
113
		 * (increasing the priority) with each version release.
114
		 *
115
		 * @since 2.0.0
116
		 */
117
		private function __construct() {
118
			/**
119
			 * A constant you can use to check if CMB2 is loaded
120
			 * for your plugins/themes with CMB2 dependency
121
			 */
122
			if ( ! defined( 'CMB2_LOADED' ) ) {
123
				define( 'CMB2_LOADED', self::PRIORITY );
124
			}
125
126
			add_action( 'init', array( $this, 'include_cmb' ), self::PRIORITY );
127
		}
128
129
		/**
130
		 * A final check if CMB2 exists before kicking off our CMB2 loading.
131
		 * CMB2_VERSION and CMB2_DIR constants are set at this point.
132
		 *
133
		 * @since  2.0.0
134
		 */
135
		public function include_cmb() {
136
			if ( class_exists( 'CMB2', false ) ) {
137
				return;
138
			}
139
140
			if ( ! defined( 'CMB2_VERSION' ) ) {
141
				define( 'CMB2_VERSION', self::VERSION );
142
			}
143
144
			if ( ! defined( 'CMB2_DIR' ) ) {
145
				define( 'CMB2_DIR', trailingslashit( dirname( __FILE__ ) ) );
0 ignored issues
show
Bug introduced by
The function trailingslashit was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

145
				define( 'CMB2_DIR', /** @scrutinizer ignore-call */ trailingslashit( dirname( __FILE__ ) ) );
Loading history...
146
			}
147
148
			$this->l10ni18n();
149
150
			// Include helper functions.
151
			require_once CMB2_DIR . 'includes/CMB2_Base.php';
152
			require_once CMB2_DIR . 'includes/CMB2.php';
153
			require_once CMB2_DIR . 'includes/helper-functions.php';
154
155
			// Now kick off the class autoloader.
156
			spl_autoload_register( 'cmb2_autoload_classes' );
157
158
			// Kick the whole thing off.
159
			require_once( cmb2_dir( 'bootstrap.php' ) );
160
			cmb2_bootstrap();
161
		}
162
163
		/**
164
		 * Registers CMB2 text domain path
165
		 *
166
		 * @since  2.0.0
167
		 */
168
		public function l10ni18n() {
169
170
			$loaded = load_plugin_textdomain( 'cmb2', false, '/languages/' );
0 ignored issues
show
Bug introduced by
The function load_plugin_textdomain was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

170
			$loaded = /** @scrutinizer ignore-call */ load_plugin_textdomain( 'cmb2', false, '/languages/' );
Loading history...
171
172
			if ( ! $loaded ) {
173
				$loaded = load_muplugin_textdomain( 'cmb2', '/languages/' );
0 ignored issues
show
Bug introduced by
The function load_muplugin_textdomain was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

173
				$loaded = /** @scrutinizer ignore-call */ load_muplugin_textdomain( 'cmb2', '/languages/' );
Loading history...
174
			}
175
176
			if ( ! $loaded ) {
177
				$loaded = load_theme_textdomain( 'cmb2', get_stylesheet_directory() . '/languages/' );
0 ignored issues
show
Bug introduced by
The function load_theme_textdomain was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

177
				$loaded = /** @scrutinizer ignore-call */ load_theme_textdomain( 'cmb2', get_stylesheet_directory() . '/languages/' );
Loading history...
Bug introduced by
The function get_stylesheet_directory was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

177
				$loaded = load_theme_textdomain( 'cmb2', /** @scrutinizer ignore-call */ get_stylesheet_directory() . '/languages/' );
Loading history...
178
			}
179
180
			if ( ! $loaded ) {
181
				$locale = apply_filters( 'plugin_locale', get_locale(), 'cmb2' );
0 ignored issues
show
Bug introduced by
The function get_locale was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

181
				$locale = apply_filters( 'plugin_locale', /** @scrutinizer ignore-call */ get_locale(), 'cmb2' );
Loading history...
182
				$mofile = dirname( __FILE__ ) . '/languages/cmb2-' . $locale . '.mo';
183
				load_textdomain( 'cmb2', $mofile );
0 ignored issues
show
Bug introduced by
The function load_textdomain was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

183
				/** @scrutinizer ignore-call */ 
184
    load_textdomain( 'cmb2', $mofile );
Loading history...
184
			}
185
186
		}
187
188
	}
189
190
	// Make it so...
191
	CMB2_Bootstrap_260_Develop::initiate();
192
193
}// End if().
194