getInstance() public static method

This is to ensure only one instance exists.
Since: 3.5.0
public static getInstance ( $sOptionKey = '' )
 /**
  * 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
     }
 }
 /**
  * User constructor.
  * 
  * @since       3.5.0
  */
 public function start()
 {
     if (!$this->oProp->bIsAdmin) {
         return;
     }
     if (!is_network_admin()) {
         return;
     }
     // Enable / disable the demo pages
     if (isset($_GET['enable_apfl_demo_pages'])) {
         // Update the options and reload the page
         $_oOption = AdminPageFrameworkLoader_Option::getInstance(AdminPageFrameworkLoader_Registry::$aOptionKeys['main']);
         $_oOption->update('enable_demo', $_GET['enable_apfl_demo_pages']);
         exit(wp_safe_redirect(remove_query_arg('enable_apfl_demo_pages')));
     }
 }
 /**
  * @since       3.7.4
  * @return      boolean
  */
 private function _shouldLoadDemo()
 {
     if (AdminPageFrameworkLoader_Utility::isSilentMode()) {
         return false;
     }
     // Check if the demo is enabled.
     $_oOption = AdminPageFrameworkLoader_Option::getInstance();
     if (!$_oOption->get('enable_admin_pages')) {
         return false;
     }
     if (!$_oOption->get('enable_demo')) {
         $this->_setPointerToolTips();
         return false;
     }
     return true;
 }
 /**
  * User constructor.
  * 
  * @since       3.5.0
  */
 public function start()
 {
     if (!$this->oProp->bIsAdmin) {
         return;
     }
     if (!is_network_admin()) {
         return;
     }
     // Enable / disable the demo pages
     if (isset($_GET['enable_apfl_demo_pages'])) {
         // Update the options and reload the page
         $_oOption = AdminPageFrameworkLoader_Option::getInstance(AdminPageFrameworkLoader_Registry::$aOptionKeys['main']);
         $_oOption->update('enable_demo', $_GET['enable_apfl_demo_pages']);
         $this->setSettingNotice(__('Enabled demo!', 'admin-page-framework-loader'), 'updated');
         $this->oUtil->goToLocalURL(remove_query_arg('enable_apfl_demo_pages'), array('AdminPageFrameworkLoader_Utility', 'replyToShowRedirectError'));
     }
 }
 /**
  * Sets up admin pages.
  * 
  * @since       3.5.0
  * @callback    action      wp_loaded
  */
 public function setUp()
 {
     $_oOption = AdminPageFrameworkLoader_Option::getInstance();
     if (!$_oOption->get('enable_admin_pages')) {
         return;
     }
     $this->sPageSlug = AdminPageFrameworkLoader_Registry::$aAdminPages['about'];
     // Root page
     $this->setRootMenuPage('Dashboard');
     // Sub-pages
     $this->addSubMenuItems(array('title' => AdminPageFrameworkLoader_Registry::SHORTNAME, 'page_slug' => AdminPageFrameworkLoader_Registry::$aAdminPages['about'], 'show_in_menu' => false, 'style' => array(AdminPageFrameworkLoader_Registry::$sDirPath . '/asset/css/about.css', AdminPageFrameworkLoader_Registry::$sDirPath . '/asset/css/column.css', AdminPageFrameworkLoader_Registry::$sDirPath . '/asset/javascript/flip/jquery.m.flip.css', version_compare($GLOBALS['wp_version'], '3.8', '<') ? ".about-wrap .introduction h2 {\n                                padding: 1em;\n                            }" : "", ".admin-page-framework-section-tab h4 {\n                            padding: 6px 16px 8px;\n                            font-size: 1.2em;\n                            font-weight: 400;\n                        }"), 'script' => array(AdminPageFrameworkLoader_Registry::$sDirPath . '/asset/javascript/flip/jquery.m.flip.js', "jQuery( document ).ready( function() {\n                        jQuery( '.apf-badge-image' ).mflip();\n                    } );")));
     $this->setPluginSettingsLinkLabel('');
     // pass an empty string to disable it.
     // Hook
     add_action("load_" . $this->oProp->sClassName, array($this, 'replyToLoadClassPages'));
     add_action("load_" . AdminPageFrameworkLoader_Registry::$aAdminPages['about'], array($this, 'replyToLoadPage'));
 }
 public function __construct()
 {
     // Check if the demo is enabled.
     $_oOption = AdminPageFrameworkLoader_Option::getInstance();
     if (!$_oOption->get('enable_demo')) {
         return;
     }
     // Otherwise, load it.
     $this->_registerClasses();
     // Backward compatibility.
     define('APFDEMO_FILE', AdminPageFrameworkLoader_Registry::$sFilePath);
     define('APFDEMO_DIRNAME', AdminPageFrameworkLoader_Registry::$sDirPath);
     do_action('admin_page_framework_loader_action_before_loading_demo');
     // Include example components.
     new AdminPageFrameworkLoader_Demo_PostType();
     new AdminPageFrameworkLoader_Demo_AdminPage();
     new AdminPageFrameworkLoader_Demo_Widget();
     new AdminPageFrameworkLoader_Demo_UserMeta();
     do_action('admin_page_framework_loader_action_after_loading_demo');
 }
 /**
  * 
  * @return      array       The demo content.
  */
 private function _getDemo()
 {
     $_oOption = AdminPageFrameworkLoader_Option::getInstance(AdminPageFrameworkLoader_Registry::$aOptionKeys['main']);
     $_bEnabled = $_oOption->get('enable_demo');
     $_sTitle = __('Demo', 'admin=page-framework-loader');
     return array($_sTitle => array('title' => $_sTitle, 'description' => '<div style="text-align: center;" class="aligncenter"><img class="aligncenter" src="' . AdminPageFrameworkLoader_Registry::getPluginURL('/asset/image/icon-128x128.png') . '" alt="' . esc_attr($_sTitle) . '"/></div>' . '<p>' . __('Showcases the features of Admin Page Framework.', 'admin-page-framework-loader') . '</p>', 'link' => add_query_arg(array('enable_apfl_demo_pages' => $_bEnabled ? 0 : 1) + $_GET, admin_url($GLOBALS['pagenow'])), 'label' => $_bEnabled ? __('Deactivate', 'admin-page-framework-loader') : __('Activate', 'admin-page-framework-loader')));
 }