CMB2_Bootstrap_223_Trunk

Handles checking for and loading the newest version of CMB2.

Defined (1)

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

/init.php  
  1. class CMB2_Bootstrap_223_Trunk { 
  2.  
  3. /** 
  4. * Current version number 
  5. * @var string 
  6. * @since 1.0.0 
  7. */ 
  8. const VERSION = '2.2.3.beta'; 
  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 = 9980; 
  17.  
  18. /** 
  19. * Single instance of the CMB2_Bootstrap_223_Trunk object 
  20. * @var CMB2_Bootstrap_223_Trunk 
  21. */ 
  22. public static $single_instance = null; 
  23.  
  24. /** 
  25. * Creates/returns the single instance CMB2_Bootstrap_223_Trunk object 
  26. * @since 2.0.0 
  27. * @return CMB2_Bootstrap_223_Trunk 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', self::PRIORITY ); 
  48.  
  49. add_action( 'init', array( $this, 'include_cmb' ), self::PRIORITY ); 
  50.  
  51. /** 
  52. * A final check if CMB2 exists before kicking off our CMB2 loading. 
  53. * CMB2_VERSION and CMB2_DIR constants are set at this point. 
  54. * @since 2.0.0 
  55. */ 
  56. public function include_cmb() { 
  57. if ( class_exists( 'CMB2', false ) ) { 
  58. return; 
  59.  
  60. if ( ! defined( 'CMB2_VERSION' ) ) { 
  61. define( 'CMB2_VERSION', self::VERSION ); 
  62.  
  63. if ( ! defined( 'CMB2_DIR' ) ) { 
  64. define( 'CMB2_DIR', trailingslashit( dirname( __FILE__ ) ) ); 
  65.  
  66. $this->l10ni18n(); 
  67.  
  68. // Include helper functions 
  69. require_once 'includes/CMB2_Base.php'; 
  70. require_once 'includes/CMB2.php'; 
  71. require_once 'includes/helper-functions.php'; 
  72.  
  73. // Now kick off the class autoloader 
  74. spl_autoload_register( 'cmb2_autoload_classes' ); 
  75.  
  76. // Kick the whole thing off 
  77. require_once 'bootstrap.php'; 
  78. cmb2_bootstrap(); 
  79.  
  80. /** 
  81. * Registers CMB2 text domain path 
  82. * @since 2.0.0 
  83. */ 
  84. public function l10ni18n() { 
  85.  
  86. $loaded = load_plugin_textdomain( 'cmb2', false, '/languages/' ); 
  87.  
  88. if ( ! $loaded ) { 
  89. $loaded = load_muplugin_textdomain( 'cmb2', '/languages/' ); 
  90.  
  91. if ( ! $loaded ) { 
  92. $loaded = load_theme_textdomain( 'cmb2', get_stylesheet_directory() . '/languages/' ); 
  93.  
  94. if ( ! $loaded ) { 
  95. $locale = apply_filters( 'plugin_locale', get_locale(), 'cmb2' ); 
  96. $mofile = dirname( __FILE__ ) . '/languages/cmb2-' . $locale . '.mo'; 
  97. load_textdomain( 'cmb2', $mofile ); 
  98.  
  99.