_have( '_hooked_action-' . $tag ); if ( did_action( $tag ) ) { $this->$function(); } else { $this->_add( '_hooked_action-' . $tag, true ); add_action( $tag, array( $this, $function ), $priority ); } } } class Admin_Core extends Admin { public $array = null; public $debug = null; public $html = null; public $net = null; public $session = null; public $updates = null; public $ui = null; public function __construct() { parent::__construct(); self::$core = $this; // A List of all components. $components = array( 'array', 'debug', 'html', 'net', 'session', 'updates', 'ui', ); // Create instances of each component. foreach ( $components as $component ) { if ( ! property_exists( $this, $component ) ) { continue; } $class_name = 'Admin_' . ucfirst( $component ); $this->$component = new $class_name(); } } public function is_true( $value ) { if ( false === $value || null === $value || '' === $value ) { return false; } elseif ( true === $value ) { return true; } elseif ( is_numeric( $value ) ) { $value = intval( $value ); return $value != 0; } elseif ( is_string( $value ) ) { $value = strtolower( trim( $value ) ); return in_array( $value, array( 'true', 'yes', 'on', '1' ) ); } return false; } public function is_false( $value ) { return ! $this->is_true( $value ); } //Converts a number from any base to another base public function convert( $number, $base_from = '0123456789', $base_to = '0123456789ABCDEF' ) { if ( $base_from == $base_to ) { // No conversion needed. return $number; } $retval = ''; $number_len = strlen( $number ); if ( '0123456789' == $base_to ) { // Convert a value to normal decimal base. $arr_base_from = str_split( $base_from, 1 ); $arr_number = str_split( $number, 1 ); $base_from_len = strlen( $base_from ); $retval = 0; for ( $i = 1; $i <= $number_len; $i += 1 ) { $retval = bcadd( $retval, bcmul( array_search( $arr_number[$i - 1], $arr_base_from ), bcpow( $base_from_len, $number_len - $i ) ) ); } } else { // Convert a value to a NON-decimal base. if ( '0123456789' != $base_from ) { // Base value is non-decimal, convert it to decimal first. $base10 = $this->convert( $number, $base_from, '0123456789' ); } else { // Base value is decimal. $base10 = $number; } $arr_base_to = str_split( $base_to, 1 ); $base_to_len = strlen( $base_to ); if ( $base10 < strlen( $base_to ) ) { $retval = $arr_base_to[$base10]; } else { while ( 0 != $base10 ) { $retval = $arr_base_to[bcmod( $base10, $base_to_len )] . $retval; $base10 = bcdiv( $base10, $base_to_len, 0 ); } } } return $retval; } }