';
239 | echo '
' . sprintf( __( 'WDS CMB2 Customizer is missing requirements and has been deactivated. Please make sure all requirements are available.', 'wds-cmb2-customizer' ), admin_url( 'plugins.php' ) ) . '
';
240 | echo '
';
241 | }
242 |
243 | /**
244 | * Magic getter for our object.
245 | *
246 | * @since 0.1.0
247 | * @param string $field
248 | * @throws Exception Throws an exception if the field is invalid.
249 | * @return mixed
250 | */
251 | public function __get( $field ) {
252 | switch ( $field ) {
253 | case 'version':
254 | return self::VERSION;
255 | case 'basename':
256 | case 'url':
257 | case 'path':
258 | return $this->$field;
259 | default:
260 | throw new Exception( 'Invalid '. __CLASS__ .' property: ' . $field );
261 | }
262 | }
263 |
264 | /**
265 | * Include a file from the includes directory
266 | *
267 | * @since 0.1.0
268 | * @param string $filename Name of the file to be included
269 | * @return bool Result of include call.
270 | */
271 | public static function include_file( $filename ) {
272 | $file = self::dir( 'includes/'. $filename .'.php' );
273 | if ( file_exists( $file ) ) {
274 | return include_once( $file );
275 | }
276 | return false;
277 | }
278 |
279 | /**
280 | * This plugin's directory
281 | *
282 | * @since 0.1.0
283 | * @param string $path (optional) appended path
284 | * @return string Directory and path
285 | */
286 | public static function dir( $path = '' ) {
287 | static $dir;
288 | $dir = $dir ? $dir : trailingslashit( dirname( __FILE__ ) );
289 | return $dir . $path;
290 | }
291 |
292 | /**
293 | * This plugin's url
294 | *
295 | * @since 0.1.0
296 | * @param string $path (optional) appended path
297 | * @return string URL and path
298 | */
299 | public static function url( $path = '' ) {
300 | static $url;
301 | $url = $url ? $url : trailingslashit( plugin_dir_url( __FILE__ ) );
302 | return $url . $path;
303 | }
304 | }
305 |
306 | /**
307 | * Grab the WDS_CMB2_Customizer object and return it.
308 | * Wrapper for WDS_CMB2_Customizer::get_instance()
309 | *
310 | * @since 0.1.0
311 | * @return WDS_CMB2_Customizer Singleton instance of plugin class.
312 | */
313 | function wds_cmb2_customizer() {
314 | return WDS_CMB2_Customizer::get_instance();
315 | }
316 |
317 | // Kick it off
318 | add_action( 'plugins_loaded', array( wds_cmb2_customizer(), 'hooks' ) );
319 |
--------------------------------------------------------------------------------