/** * Main Instance. * * Ensures only one instance of this class is loaded or can be loaded. * * @since 1.6 * @access public * @static * @param object|bool $caller The referrer class * @return VAA_View_Admin_As_View|bool */ public static function get_instance($caller = false) { if (is_object($caller) && 'VAA_View_Admin_As' == get_class($caller)) { if (is_null(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; } return false; }
/** * Init function to register plugin hook * Private to make sure it isn't declared elsewhere * * @since 0.1 * @since 1.3.3 changes init hook to plugins_loaded for theme compatibility * @since 1.4.1 creates instance * @since 1.5 make private * @since 1.5.1 added notice on class name conflict + validate versions * @access private */ private function __construct() { self::$_instance = $this; add_action('init', array($this, 'load_textdomain')); add_action('admin_notices', array($this, 'do_admin_notices')); // Returns true on conflict if ((bool) $this->validate_versions()) { return; } if ((bool) $this->load()) { $this->store = VAA_View_Admin_As_Store::get_instance($this); $this->view = VAA_View_Admin_As_View::get_instance($this); // Lets start! add_action('plugins_loaded', array($this, 'init'), 0); } else { $this->add_notice('class-error-base', array('type' => 'notice-error', 'message' => '<strong>' . __('View Admin As', 'view-admin-as') . ':</strong> ' . __('Plugin not loaded because of a conflict with an other plugin or theme', 'view-admin-as') . ' <code>(' . sprintf(__('Class %s already exists', 'view-admin-as'), 'VAA_View_Admin_As_Class_Base') . ')</code>')); } }