/** * Returns the Hookr_Plugin derived instance. * * @static * @access protected * @param string $class * @return object Instance of Hookr_Plugin */ protected static function get_instance($class = __CLASS__) { $instance = parent::get_instance($class); add_action('plugins_loaded', array($instance, 'load'), 0); add_action('init', array($instance, 'loaded'), 0); if (is_admin()) { $file = $instance->get_file(); register_activation_hook($file, array($instance, 'activate')); register_deactivation_hook($file, array($instance, 'deactivate')); } return $instance; }
/** * Returns the singleton instance. * * @param string $class * @return string * @throws Exception */ protected static function get_instance($class = __CLASS__) { if (__CLASS__ === $class) { throw new Exception(__METHOD__ . ' must be overridden'); } if (null === self::$_instances) { self::$_instances = array(); } if (@isset(self::$_instances[$class])) { return self::$_instances[$class]; } self::$_instances[$class] = new $class(); $instance = self::$_instances[$class]; return $instance; }