Admin Page Framework Documentation
  • Package
  • Class
  • Tree

Packages

  • AdminPageFramework
    • FieldType
    • MetaBox
    • NetworkAdmin
      • Page
    • Page
    • PageMetaBox
    • PostType
    • TaxonomyField
  • None

Classes

  • AdminPageFramework_NetworkAdmin
  1 <?php
  2 /**
  3  * Admin Page Framework
  4  * 
  5  * http://en.michaeluno.jp/admin-page-framework/
  6  * Copyright (c) 2013-2014 Michael Uno; Licensed MIT
  7  * 
  8  */
  9 if ( ! class_exists( 'AdminPageFramework_NetworkAdmin' ) ) :
 10 /**
 11  * The factory class that creates network admin pages.
 12  *
 13  * @abstract
 14  * @since 3.1.0
 15  * @remark This class stems from several abstract classes.
 16  * @extends AdminPageFramework
 17  * @package AdminPageFramework_NetworkAdmin
 18  * @subpackage Page
 19  */
 20 abstract class AdminPageFramework_NetworkAdmin extends AdminPageFramework {
 21         
 22     /**
 23      * Used to refer the built-in root menu slugs.
 24      * 
 25      * @since 3.1.0
 26      * @remark Not for the user.
 27      * @var array Holds the built-in root menu slugs.
 28      * @internal
 29      */ 
 30     protected $_aBuiltInRootMenuSlugs = array(
 31         // All keys must be lower case to support case insensitive look-ups.
 32         'dashboard' =>             'index.php',
 33         'sites' =>                 'sites.php', // not work
 34         'themes' =>             'themes.php', // not work
 35         'plugins' =>             'plugins.php',
 36         'users' =>                 'users.php',
 37         'settings' =>             'settings.php',
 38         'updates' =>             'update-core.php', // does not work
 39     );     
 40         
 41     /**
 42      * Registers necessary callbacks ans sets up internal components including properties.
 43      * 
 44      * <h4>Example</h4>
 45      * <code>if ( is_admin() )
 46      *     new MyAdminPageClass( 'my_custom_option_key', __FILE__ );</code>
 47      * 
 48      * @access public
 49      * @since 3.1.0
 50      * @see http://codex.wordpress.org/Roles_and_Capabilities
 51      * @see http://codex.wordpress.org/I18n_for_WordPress_Developers#Text_Domains
 52      * @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.
 53      * @param string $sCallerPath ( optional ) used to retrieve the plugin/theme details to auto-insert the information into the page footer.
 54      * @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: <em>manage_options</em>
 55      * @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.
 56      * @return void returns nothing.
 57      */
 58     public function __construct( $sOptionKey=null, $sCallerPath=null, $sCapability='manage_network', $sTextDomain='admin-page-framework' ){
 59             
 60         if ( ! $this->_isInstantiatable() ) {
 61             return;
 62         }
 63         
 64         add_action( 'network_admin_menu', array( $this, '_replyToBuildMenu' ), 98 );     
 65         // add_action( 'network_admin_menu', array( $this, '_replyToFinalizeInPageTabs' ), 99 ); // must be called before the _replyToRegisterSettings() method which uses the same hook.
 66 
 67         $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.
 68         
 69         $this->oProp = new AdminPageFramework_Property_NetworkAdmin( $this, $sCallerPath, get_class( $this ), $sOptionKey, $sCapability, $sTextDomain );
 70         
 71         parent::__construct( $sOptionKey, $sCallerPath, $sCapability, $sTextDomain );
 72         
 73     }    
 74 
 75     /**
 76      * Checks whether the class should be instantiated.
 77      * 
 78      * @since 3.1.0
 79      * @internal
 80      */
 81     protected function _isInstantiatable() {
 82         
 83         if ( isset( $GLOBALS['pagenow'] ) && 'admin-ajax.php' === $GLOBALS['pagenow'] ) {
 84             return false;
 85         }     
 86         
 87         // Nothing to do in the non-network admin area.
 88         if ( is_network_admin() ) {
 89             return true;
 90         }
 91         
 92         return false;
 93         
 94     }
 95     
 96     
 97     /**
 98      * Retrieves the saved option value from the given option key and the dimensional array key representation.
 99      * 
100      * <h4>Example</h4>
101      * <code>
102      * $aData = AdminPageFramework::getOption( 'APF' );
103      * $aSection = AdminPageFramework::getOption( 'APF', 'my_section' );
104      * $sText = AdminPageFramework::getOption( 'APF', array( 'my_section', 'my_text_field' ), 'foo' );
105      * $sColor = AdminPageFramework::getOption( 'APF', 'my_color_field', '#FFF' );
106      * </code>
107      * 
108      * @since 3.1.0
109      * @param string $sOptionKey     the option key of the options table.
110      * @param string $asKey     the representation of dimensional array keys. If the returning option structure is like the following,
111      * <code>
112      * array(
113      *     'a' => array(
114      *         'b' => array(
115      *             'c' => 'ccc',
116      *         ),
117      *     ),
118      * )
119      * </code>
120      * then the value 'ccc' can be retrieved with the key representation array of 
121      * <code>
122      * array( 'a', 'b', 'c' )
123      * </code>
124      * @param mixed $vDefault     the default value that will be returned if nothing is stored.
125      * @return mixed If the field ID is not specified
126      */
127     static public function getOption( $sOptionKey, $asKey=null , $vDefault=null ) {
128         return AdminPageFramework_WPUtility::getSiteOption( $sOptionKey, $asKey, $vDefault );
129     }
130     
131 }
132 endif;
Admin Page Framework Documentation API documentation generated by ApiGen 2.8.0