AdminPageFrameworkLoader_Option::getInstance PHP Метод

getInstance() публичный статический Метод

This is to ensure only one instance exists.
С версии: 3.5.0
public static getInstance ( $sOptionKey = '' )
    public static function getInstance($sOptionKey = '')
    {
        $sOptionKey = $sOptionKey ? $sOptionKey : AdminPageFrameworkLoader_Registry::$aOptionKeys['main'];
        if (isset(self::$aInstances[$sOptionKey])) {
            return self::$aInstances[$sOptionKey];
        }
        $_sClassName = __CLASS__;
        self::$aInstances[$sOptionKey] = new $_sClassName($sOptionKey);
        return self::$aInstances[$sOptionKey];
    }

Usage Example

 /**
  * Handles page redirects.
  * 
  * This is called to prevent the plugin from performing the redirect when the plugin is not activated or intervene the activation process.
  * If this is called in the start() method above, it will redirect the user to the page during the activation process 
  * and the user gets a page that is not created because the plugin is not activated.
  * 
  * @callback    action      admin_menu
  * @since       3.5.0
  * @sicne       3.5.3       Change the hook from `admin_init` as the resetting option results in an error 'You do not have permission to access this page.'
  */
 public function _replyToHandleRedirects()
 {
     // When newly installed, the 'welcomed' value is not set.
     $_oOption = AdminPageFrameworkLoader_Option::getInstance();
     if (!$_oOption->get('welcomed')) {
         $this->_setInitialOptions($_oOption, AdminPageFrameworkLoader_Registry::VERSION);
         $this->_gotToWelcomePage();
         // will exit
     }
     if ($_oOption->hasUpgraded()) {
         $this->_setInitialOptions($_oOption, $_oOption->get('version_saved'));
         $this->_gotToWelcomePage();
         // will exit
     }
 }
All Usage Examples Of AdminPageFrameworkLoader_Option::getInstance