Наследование: extends AdminPageFramework_Utility_SystemInformation
Пример #1
0
 /**
  * Registers necessary callbacks ans sets up internal components including properties.
  * 
  * <h4>Example</h4>
  * <code>if ( is_admin() ) {
  *     new MyAdminPageClass( 'my_custom_option_key', __FILE__ );
  * }</code>
  * 
  * @access      public
  * @since       2.0.0
  * @see         http://codex.wordpress.org/Roles_and_Capabilities
  * @see         http://codex.wordpress.org/I18n_for_WordPress_Developers#Text_Domains
  * @param       string      $sOptionKey         (optional) specifies the option key name to store in the options table. If this is not set, the instantiated class name will be used.
  * @param       string      $sCallerPath        (optional) used to retrieve the plugin/theme details to auto-insert the information into the page footer.
  * @param       string      $sCapability        (optional) sets the overall access level to the admin pages created by the framework. The used capabilities are listed <a href="http://codex.wordpress.org/Roles_and_Capabilities">here</a>. The capability can be set per page, tab, setting section, setting field. Default: `manage_options`
  * @param       string      $sTextDomain        (optional) the <a href="http://codex.wordpress.org/I18n_for_WordPress_Developers#Text_Domains" target="_blank">text domain</a> used for the framework's system messages. Default: admin-page-framework.
  * @return      void        returns nothing.
  */
 public function __construct($sOptionKey = null, $sCallerPath = null, $sCapability = 'manage_options', $sTextDomain = 'admin-page-framework')
 {
     if (!$this->_isInstantiatable()) {
         return;
     }
     parent::__construct($sOptionKey, $sCallerPath ? trim($sCallerPath) : ($sCallerPath = is_admin() && (isset($GLOBALS['pagenow']) && in_array($GLOBALS['pagenow'], array('plugins.php')) || isset($_GET['page'])) ? AdminPageFramework_Utility::getCallerScriptPath(__FILE__) : null), $sCapability, $sTextDomain);
     $this->oUtil->addAndDoAction($this, 'start_' . $this->oProp->sClassName, $this);
 }
 public static function getSRCFromPath($sFilePath)
 {
     $_oWPStyles = new WP_Styles();
     $_sRelativePath = AdminPageFramework_Utility::getRelativePath(ABSPATH, $sFilePath);
     $_sRelativePath = preg_replace("/^\\.[\\/\\\\]/", '', $_sRelativePath, 1);
     $_sHref = trailingslashit($_oWPStyles->base_url) . $_sRelativePath;
     unset($_oWPStyles);
     return $_sHref;
 }
 public function __construct($sOptionKey = null, $sCallerPath = null, $sCapability = 'manage_network', $sTextDomain = 'admin-page-framework')
 {
     if (!$this->_isInstantiatable()) {
         return;
     }
     $sCallerPath = $sCallerPath ? $sCallerPath : AdminPageFramework_Utility::getCallerScriptPath(__FILE__);
     parent::__construct($sOptionKey, $sCallerPath, $sCapability, $sTextDomain);
     new AdminPageFramework_Model_Menu__RegisterMenu($this, 'network_admin_menu');
 }
 public function __construct($sOptionKey = null, $sCallerPath = null, $sCapability = 'manage_network', $sTextDomain = 'admin-page-framework')
 {
     if (!$this->_isInstantiatable()) {
         return;
     }
     add_action('network_admin_menu', array($this, '_replyToBuildMenu'), 98);
     $sCallerPath = $sCallerPath ? $sCallerPath : AdminPageFramework_Utility::getCallerScriptPath(__FILE__);
     $this->oProp = new AdminPageFramework_Property_NetworkAdmin($this, $sCallerPath, get_class($this), $sOptionKey, $sCapability, $sTextDomain);
     parent::__construct($sOptionKey, $sCallerPath, $sCapability, $sTextDomain);
 }
 public function __construct($sPostType, $aArgs = array(), $sCallerPath = null, $sTextDomain = 'admin-page-framework')
 {
     if (empty($sPostType)) {
         return;
     }
     $this->oProp = new AdminPageFramework_Property_PostType($this, $sCallerPath ? trim($sCallerPath) : (is_admin() && isset($GLOBALS['pagenow']) && in_array($GLOBALS['pagenow'], array('edit.php', 'post.php', 'post-new.php', 'plugins.php', 'tags.php', 'edit-tags.php')) ? AdminPageFramework_Utility::getCallerScriptPath(__FILE__) : null), get_class($this), 'publish_posts', $sTextDomain, 'post_type');
     $this->oProp->sPostType = AdminPageFramework_WPUtility::sanitizeSlug($sPostType);
     $this->oProp->aPostTypeArgs = $aArgs;
     parent::__construct($this->oProp);
     $this->oUtil->addAndDoAction($this, "start_{$this->oProp->sClassName}", $this);
 }
 /**
  * Registers necessary callbacks ans sets up internal components including properties.
  * 
  * <h4>Example</h4>
  * <code>if ( is_admin() )
  *     new MyAdminPageClass( 'my_custom_option_key', __FILE__ );</code>
  * 
  * @access      public
  * @since       3.1.0
  * @see         http://codex.wordpress.org/Roles_and_Capabilities
  * @see         http://codex.wordpress.org/I18n_for_WordPress_Developers#Text_Domains
  * @param       string      $sOptionKey         (optional) specifies the option key name to store in the options table. If this is not set, the instantiated class name will be used.
  * @param       string      $sCallerPath        (optional) used to retrieve the plugin/theme details to auto-insert the information into the page footer.
  * @param       string      $sCapability        (optional) sets the overall access level to the admin pages created by the framework. The used capabilities are listed <a href="http://codex.wordpress.org/Roles_and_Capabilities">here</a>. The capability can be set per page, tab, setting section, setting field. Default: `manage_options.`
  * @param       string      $sTextDomain        (optional) the <a href="http://codex.wordpress.org/I18n_for_WordPress_Developers#Text_Domains" target="_blank">text domain</a> used for the framework's system messages. Default: `admin-page-framework`.
  * @return      void        returns nothing.
  */
 public function __construct($sOptionKey = null, $sCallerPath = null, $sCapability = 'manage_network', $sTextDomain = 'admin-page-framework')
 {
     if (!$this->_isInstantiatable()) {
         return;
     }
     add_action('network_admin_menu', array($this, '_replyToBuildMenu'), 98);
     $sCallerPath = $sCallerPath ? $sCallerPath : AdminPageFramework_Utility::getCallerScriptPath(__FILE__);
     // this is important to attempt to find the caller script path here when separating the library into multiple files.
     $this->oProp = new AdminPageFramework_Property_NetworkAdmin($this, $sCallerPath, get_class($this), $sOptionKey, $sCapability, $sTextDomain);
     parent::__construct($sOptionKey, $sCallerPath, $sCapability, $sTextDomain);
 }
 /**
  * Calculates the URL from the given path.
  * 
  * @since   2.1.5
  * @static
  * @access  public
  * @return  string The source url
  */
 public static function getSRCFromPath($sFilePath)
 {
     $oWPStyles = new WP_Styles();
     // It doesn't matter whether the file is a style or not. Just use the built-in WordPress class to calculate the SRC URL.
     $sRelativePath = AdminPageFramework_Utility::getRelativePath(ABSPATH, $sFilePath);
     $sRelativePath = preg_replace("/^\\.[\\/\\\\]/", '', $sRelativePath, 1);
     // removes the heading ./ or .\
     $sHref = trailingslashit($oWPStyles->base_url) . $sRelativePath;
     unset($oWPStyles);
     // for PHP 5.2.x or below
     return esc_url($sHref);
 }
 public static function getAttributes(array $aAttributes)
 {
     AdminPageFramework_Utility::showDeprecationNotice(__METHOD__, 'AdminPageFramework_WPUtility::getAttributes()');
     $_sQuoteCharactor = "'";
     $_aOutput = array();
     foreach ($aAttributes as $sAttribute => $sProperty) {
         if (in_array(gettype($sProperty), array('array', 'object'))) {
             continue;
         }
         $_aOutput[] = "{$sAttribute}={$_sQuoteCharactor}{$sProperty}{$_sQuoteCharactor}";
     }
     return implode(' ', $_aOutput);
 }
 public function __get($sName)
 {
     if ('aScriptInfo' === $sName) {
         $this->sCallerPath = $this->sCallerPath ? $this->sCallerPath : AdminPageFramework_Utility::getCallerScriptPath(__FILE__);
         $this->aScriptInfo = $this->getCallerInfo($this->sCallerPath);
         return $this->aScriptInfo;
     }
     if ('aOptions' === $sName) {
         $this->aOptions = $this->_getOptions();
         return $this->aOptions;
     }
     if ('aLastInput' === $sName) {
         $this->aLastInput = $this->_getLastInput();
         return $this->aLastInput;
     }
 }
 private function _getCallerPath($sCallerPath)
 {
     if ($sCallerPath) {
         return trim($sCallerPath);
     }
     if (!is_admin()) {
         return null;
     }
     if (!isset($GLOBALS['pagenow'])) {
         return null;
     }
     $_sCalllerPath = in_array($GLOBALS['pagenow'], array('plugins.php')) || isset($_GET['page']) ? AdminPageFramework_Utility::getCallerScriptPath(__FILE__) : null;
     return $_sCalllerPath;
 }
 private function _getCallerScriptPath($sCallerPath)
 {
     $sCallerPath = trim($sCallerPath);
     if ($sCallerPath) {
         return $sCallerPath;
     }
     if (!is_admin()) {
         return null;
     }
     $_sPageNow = AdminPageFramework_Utility::getElement($GLOBALS, 'pagenow');
     if (in_array($_sPageNow, array('edit.php', 'post.php', 'post-new.php', 'plugins.php', 'tags.php', 'edit-tags.php', 'term.php'))) {
         return AdminPageFramework_Utility::getCallerScriptPath(__FILE__);
     }
     return null;
 }
 /**
  * 
  * @since 3.1.3
  */
 public function __get($sName)
 {
     if ('aScriptInfo' === $sName) {
         $this->sCallerPath = $this->sCallerPath ? $this->sCallerPath : AdminPageFramework_Utility::getCallerScriptPath(__FILE__);
         $this->aScriptInfo = $this->getCallerInfo($this->sCallerPath);
         return $this->aScriptInfo;
     }
     // 3.4.1+ Moved from `AdminPageFramework_Property_Page` as meta box classes also access it.
     // If $this->aOptions is called for the first time, retrieve the option data from the database and assign them to the property.
     // Once this is done, calling $this->aOptions will not trigger the __get() magic method any more.
     if ('aOptions' === $sName) {
         $this->aOptions = $this->_getOptions();
         return $this->aOptions;
     }
     // 3.3.0+   Sets and returns the last user form input data as an array.
     // 3.4.1+   Moved from `AdminPageFramework_Property_Page` as meta box classes also access it.
     if ('aLastInput' === $sName) {
         $this->aLastInput = $this->_getLastInput();
         return $this->aLastInput;
     }
     // For regular undefined items,
     // return 'undefined';
 }
 /**
  * Returns the default value from the given field definition array.
  * 
  * This is a helper function for the above getDefaultOptions() method.
  * 
  * @since 3.0.0
  */
 private function _getDefautValue($aField)
 {
     // Check if sub-fields exist whose keys are numeric
     $_aSubFields = AdminPageFramework_Utility::getIntegerElements($aField);
     // If there are no sub-fields
     if (count($_aSubFields) == 0) {
         $_aField = $aField;
         return isset($_aField['value']) ? $_aField['value'] : (isset($_aField['default']) ? $_aField['default'] : null);
     }
     // Otherwise, there are sub-fields
     $_aDefault = array();
     array_unshift($_aSubFields, $aField);
     // insert the main field into the very first index.
     foreach ($_aSubFields as $_iIndex => $_aField) {
         $_aDefault[$_iIndex] = isset($_aField['value']) ? $_aField['value'] : (isset($_aField['default']) ? $_aField['default'] : null);
     }
     return $_aDefault;
 }
Пример #14
0
 private function _getDefautValue($aField)
 {
     $_aSubFields = AdminPageFramework_Utility::getIntegerElements($aField);
     if (count($_aSubFields) == 0) {
         $_aField = $aField;
         return isset($_aField['value']) ? $_aField['value'] : (isset($_aField['default']) ? $_aField['default'] : null);
     }
     $_aDefault = array();
     array_unshift($_aSubFields, $aField);
     foreach ($_aSubFields as $_iIndex => $_aField) {
         $_aDefault[$_iIndex] = isset($_aField['value']) ? $_aField['value'] : (isset($_aField['default']) ? $_aField['default'] : null);
     }
     return $_aDefault;
 }