plugin_context = $context; $this->plugin_context_class = get_class( $context ); } $this->plugin_path = trailingslashit( dirname( dirname( dirname( __FILE__ ) ) ) ); $this->plugin_dir = trailingslashit( basename( $this->plugin_path ) ); $this->plugin_url = plugins_url( $this->plugin_dir ); $this->init_libraries(); } /** * Get's the instantiated context of this class. I.e. the object that instantiated this one. */ public function context() { return $this->plugin_context; } /** * Get's the class name of the instantiated plugin context of this class. I.e. the class name of the object that instantiated this one. */ public function context_class() { return $this->plugin_context_class; } /** * initializes all required libraries */ public function init_libraries() { Tribe__Debug::instance(); Tribe__Settings_Manager::instance(); require_once $this->plugin_path . 'common/functions/template-tags/general.php'; require_once $this->plugin_path . 'common/functions/template-tags/date.php'; require_once $this->plugin_path . 'common/functions/template-tags/day.php'; } /** * Insert an array after a specified key within another array. * * @param $key * @param $source_array * @param $insert_array * * @return array * */ public static function array_insert_after_key( $key, $source_array, $insert_array ) { if ( array_key_exists( $key, $source_array ) ) { $position = array_search( $key, array_keys( $source_array ) ) + 1; $source_array = array_slice( $source_array, 0, $position, true ) + $insert_array + array_slice( $source_array, $position, null, true ); } else { // If no key is found, then add it to the end of the array. $source_array += $insert_array; } return $source_array; } /** * Insert an array immediately before a specified key within another array. * * @param $key * @param $source_array * @param $insert_array * * @return array */ public static function array_insert_before_key( $key, $source_array, $insert_array ) { if ( array_key_exists( $key, $source_array ) ) { $position = array_search( $key, array_keys( $source_array ) ); $source_array = array_slice( $source_array, 0, $position, true ) + $insert_array + array_slice( $source_array, $position, null, true ); } else { // If no key is found, then add it to the end of the array. $source_array += $insert_array; } return $source_array; } /** * Static Singleton Factory Method * * @return Tribe__Main */ public static function instance( $object ) { static $instance = array(); $object_class = ''; if ( is_object( $object ) ) { $object_class = get_class( $object ); } elseif ( is_string( $object ) ) { $object_class = $object; $object = new $object_class; } if ( ! isset( $instance[ $object_class ] ) ) { $class_name = __CLASS__; $instance = new $class_name; } return $instance[ $object_class ]; } }