CMB2_Bootstrap_208

Handles checking for and loading the newest version of CMB2.

Defined (1)

The class is defined in the following location(s).

/includes/libraries/metabox/init.php  
  1. class CMB2_Bootstrap_208 { 
  2.  
  3. /** 
  4. * Current version number 
  5. * @var string 
  6. * @since 1.0.0 
  7. */ 
  8. const VERSION = '2.0.8'; 
  9.  
  10. /** 
  11. * Current version hook priority. 
  12. * Will decrement with each release 
  13. * @var int 
  14. * @since 2.0.0 
  15. */ 
  16. const PRIORITY = 9991; 
  17.  
  18. /** 
  19. * Single instance of the CMB2_Bootstrap_208 object 
  20. * @var CMB2_Bootstrap_208 
  21. */ 
  22. public static $single_instance = null; 
  23.  
  24. /** 
  25. * Creates/returns the single instance CMB2_Bootstrap_208 object 
  26. * @since 2.0.0 
  27. * @return CMB2_Bootstrap_208 Single instance object 
  28. */ 
  29. public static function initiate() { 
  30. if ( null === self::$single_instance ) { 
  31. self::$single_instance = new self(); 
  32. return self::$single_instance; 
  33.  
  34. /** 
  35. * Starts the version checking process. 
  36. * Creates CMB2_LOADED definition for early detection by other scripts 
  37. * Hooks CMB2 inclusion to the init hook on a high priority which decrements 
  38. * (increasing the priority) with each version release. 
  39. * @since 2.0.0 
  40. */ 
  41. private function __construct() { 
  42. /** 
  43. * A constant you can use to check if CMB2 is loaded 
  44. * for your plugins/themes with CMB2 dependency 
  45. */ 
  46. if ( ! defined( 'CMB2_LOADED' ) ) { 
  47. define( 'CMB2_LOADED', true ); 
  48. add_action( 'init', array( $this, 'include_cmb' ), self::PRIORITY ); 
  49.  
  50. /** 
  51. * A final check if CMB2 exists before kicking off our CMB2 loading. 
  52. * CMB2_VERSION and CMB2_DIR constants are set at this point. 
  53. * @since 2.0.0 
  54. */ 
  55. public function include_cmb() { 
  56. if ( class_exists( 'CMB2', false ) ) { 
  57. return; 
  58.  
  59. if ( ! defined( 'CMB2_VERSION' ) ) { 
  60. define( 'CMB2_VERSION', self::VERSION ); 
  61.  
  62. if ( ! defined( 'CMB2_DIR' ) ) { 
  63. define( 'CMB2_DIR', trailingslashit( dirname( __FILE__ ) ) ); 
  64.  
  65. $this->l10ni18n(); 
  66.  
  67. // Include helper functions 
  68. require_once 'includes/helper-functions.php'; 
  69.  
  70. // Now kick off the class autoloader 
  71. spl_autoload_register( 'cmb2_autoload_classes' ); 
  72.  
  73. // Kick the whole thing off 
  74. require_once 'bootstrap.php'; 
  75.  
  76. /** 
  77. * Registers CMB2 text domain path 
  78. * @since 2.0.0 
  79. */ 
  80. public function l10ni18n() { 
  81. $loaded = load_plugin_textdomain( 'cmb2', false, '/languages/' ); 
  82. if ( ! $loaded ) { 
  83. $loaded = load_muplugin_textdomain( 'cmb2', '/languages/' ); 
  84. if ( ! $loaded ) { 
  85. $loaded = load_theme_textdomain( 'cmb2', '/languages/' ); 
  86.  
  87. if ( ! $loaded ) { 
  88. $locale = apply_filters( 'plugin_locale', get_locale(), 'cmb2' ); 
  89. $mofile = dirname( __FILE__ ) . '/languages/cmb2-' . $locale . '.mo'; 
  90. load_textdomain( 'cmb2', $mofile ); 
  91.