Skip to content

Commit

Permalink
Document methods in Bootstrap class
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsternberg committed Apr 9, 2015
1 parent d6560c7 commit e59b170
Showing 1 changed file with 55 additions and 24 deletions.
79 changes: 55 additions & 24 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,43 @@ class CMB2_Bootstrap_205_Trunk {
const VERSION = '2.0.5';

/**
* Current version hook priority
* Current version hook priority.
* Will decrement with each release
*
* @var int
* @since 2.0.0
*/
const PRIORITY = 9993;

public static $single = null;
/**
* Single instance of the CMB2_Bootstrap_205_Trunk object
*
* @var CMB2_Bootstrap_205_Trunk
*/
public static $single_instance = null;

public static function go() {
if ( null === self::$single ) {
self::$single = new self();
/**
* Creates/returns the single instance CMB2_Bootstrap_205_Trunk object
*
* @since 2.0.0
* @return CMB2_Bootstrap_205_Trunk Single instance object
*/
public static function initiate() {
if ( null === self::$single_instance ) {
self::$single_instance = new self();
}
return self::$single;
return self::$single_instance;
}

/**
* Starts the version checking process.
* Creates CMB2_LOADED definition for early detection by other scripts
*
* Hooks CMB2 inclusion to the init hook on a high priority which decrements
* (increasing the priority) with each version release.
*
* @since 2.0.0
*/
private function __construct() {
/**
* A constant you can use to check if CMB2 is loaded
Expand All @@ -99,30 +119,39 @@ private function __construct() {
add_action( 'init', array( $this, 'include_cmb' ), self::PRIORITY );
}

/**
* A final check if CMB2 exists before kicking off our CMB2 loading.
* CMB2_VERSION and CMB2_DIR constants are set at this point.
*
* @since 2.0.0
*/
public function include_cmb() {
if ( ! class_exists( 'CMB2', false ) ) {
if ( class_exists( 'CMB2', false ) ) {
return;
}

if ( ! defined( 'CMB2_VERSION' ) ) {
define( 'CMB2_VERSION', self::VERSION );
}
if ( ! defined( 'CMB2_VERSION' ) ) {
define( 'CMB2_VERSION', self::VERSION );
}

if ( ! defined( 'CMB2_DIR' ) ) {
define( 'CMB2_DIR', trailingslashit( dirname( __FILE__ ) ) );
}
if ( ! defined( 'CMB2_DIR' ) ) {
define( 'CMB2_DIR', trailingslashit( dirname( __FILE__ ) ) );
}

$this->l10ni18n();
$this->l10ni18n();

// Include helper functions
require_once 'includes/helper-functions.php';
// Now kick off the class autoloader
spl_autoload_register( 'cmb2_autoload_classes' );
// Kick the whole thing off
require_once 'bootstrap.php';
}
// Include helper functions
require_once 'includes/helper-functions.php';

// Now kick off the class autoloader
spl_autoload_register( 'cmb2_autoload_classes' );

// Kick the whole thing off
require_once 'bootstrap.php';
}

/**
* Load CMB2 text domain
* Registers CMB2 text domain path
* @since 2.0.0
*/
public function l10ni18n() {
Expand All @@ -142,6 +171,8 @@ public function l10ni18n() {
}

}
CMB2_Bootstrap_205_Trunk::go();

} // class exists check
// Make it so...
CMB2_Bootstrap_205_Trunk::initiate();

}

0 comments on commit e59b170

Please sign in to comment.