Completed
Pull Request — trunk (#584)
by Juliette
05:40
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 64 and the first side effect is on line 181.

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.

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