1 | <?php |
||
64 | class CMB2_Bootstrap_223_Trunk { |
||
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() { |
||
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() { |
||
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() { |
||
180 | |||
181 | } |
||
182 | |||
187 |
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.