Completed
Pull Request — trunk (#731)
by Rami
06:34
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 184.

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.2.3.beta
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_223_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_223_Trunk {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
65
66
		/**
67
		 * Current version number
68
		 * @var   string
69
		 * @since 1.0.0
70
		 */
71
		const VERSION = '2.2.3.beta';
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 = 9980;
81
82
		/**
83
		 * Single instance of the CMB2_Bootstrap_223_Trunk object
84
		 *
85
		 * @var CMB2_Bootstrap_223_Trunk
86
		 */
87
		public static $single_instance = null;
88
89
		/**
90
		 * Creates/returns the single instance CMB2_Bootstrap_223_Trunk object
91
		 *
92
		 * @since  2.0.0
93
		 * @return CMB2_Bootstrap_223_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', self::PRIORITY );
118
			}
119
120
			add_action( 'init', array( $this, 'include_cmb' ), self::PRIORITY );
121
		}
122
123
		/**
124
		 * A final check if CMB2 exists before kicking off our CMB2 loading.
125
		 * CMB2_VERSION and CMB2_DIR constants are set at this point.
126
		 *
127
		 * @since  2.0.0
128
		 */
129
		public function include_cmb() {
130
			if ( class_exists( 'CMB2', false ) ) {
131
				return;
132
			}
133
134
			if ( ! defined( 'CMB2_VERSION' ) ) {
135
				define( 'CMB2_VERSION', self::VERSION );
136
			}
137
138
			if ( ! defined( 'CMB2_DIR' ) ) {
139
				define( 'CMB2_DIR', trailingslashit( dirname( __FILE__ ) ) );
140
			}
141
142
			$this->l10ni18n();
143
144
			// Include helper functions
145
			require_once 'includes/CMB2_Base.php';
146
			require_once 'includes/CMB2.php';
147
			require_once 'includes/helper-functions.php';
148
149
			// Now kick off the class autoloader
150
			spl_autoload_register( 'cmb2_autoload_classes' );
151
152
			// Kick the whole thing off
153
			require_once 'bootstrap.php';
154
			cmb2_bootstrap();
155
		}
156
157
		/**
158
		 * Registers CMB2 text domain path
159
		 * @since  2.0.0
160
		 */
161
		public function l10ni18n() {
162
163
			$loaded = load_plugin_textdomain( 'cmb2', false, '/languages/' );
164
165
			if ( ! $loaded ) {
166
				$loaded = load_muplugin_textdomain( 'cmb2', '/languages/' );
167
			}
168
169
			if ( ! $loaded ) {
170
				$loaded = load_theme_textdomain( 'cmb2', get_stylesheet_directory() . '/languages/' );
171
			}
172
173
			if ( ! $loaded ) {
174
				$locale = apply_filters( 'plugin_locale', get_locale(), 'cmb2' );
175
				$mofile = dirname( __FILE__ ) . '/languages/cmb2-' . $locale . '.mo';
176
				load_textdomain( 'cmb2', $mofile );
177
			}
178
179
		}
180
181
	}
182
183
	// Make it so...
184
	CMB2_Bootstrap_223_Trunk::initiate();
185
186
}
187