Properties

$oScreen

$oScreen : object

Stores the screen object.

Type

object

Methods

fixPageTitleForHiddenPages()

fixPageTitleForHiddenPages( $strAdminTitle,  $strPageTitle)

A callback function for the admin_title filter to fix the page title for hidden pages.

Parameters

$strAdminTitle
$strPageTitle

buildMenus()

buildMenus()

Builds menus.

finalizeInPageTabs()

finalizeInPageTabs() : void

Finalizes the in-page tab property array.

This finalizes the added in-page tabs and sets the default in-page tab for each page. Also this sorts the in-page tab property array. This must be done before registering settings sections because the default tab needs to be determined in the process.

setRootMenuPage()

setRootMenuPage(string $strRootMenuLabel, string $strURLIcon16x16, string $intMenuPosition) : void

Sets to which top level page is going to be adding sub-pages.

Example

$this->setRootMenuPage( 'Settings' ); $this->setRootMenuPage( 'APF Form', plugins_url( 'image/screen_icon32x32.jpg', FILE ) );

Parameters

string $strRootMenuLabel

If the method cannot find the passed string from the following listed items, it will create a top level menu item with the passed string. ( case insensitive )

Dashboard, Posts, Media, Links, Pages, Comments, Appearance, Plugins, Users, Tools, Settings, Network Admin
string $strURLIcon16x16

( optional ) the URL or the file path of the menu icon. The size should be 16 by 16 in pixel.

string $intMenuPosition

( optional ) the position number that is passed to the $position parameter of the add_menu_page() function.

setRootMenuPageBySlug()

setRootMenuPageBySlug(string $strRootMenuSlug) : void

Sets the top level menu page by page slug.

The page should be already created or scheduled to be created separately.

Example

$this->setRootMenuPageBySlug( 'edit.php?post_type=apf_posts' );

Parameters

string $strRootMenuSlug

The page slug of the top-level root page.

addSubMenuPage()

addSubMenuPage(string $strPageTitle, string $strPageSlug, string $strScreenIcon, string $strCapability, integer $numOrder, boolean $fShowPageHeadingTab, boolean $fShowInMenu) : void

Adds a single sub-menu page.

Example

$this->addSubMenuPage( 'My Page', 'my_page', 'edit-pages' );

Parameters

string $strPageTitle

The title of the page.

string $strPageSlug

The slug of the page.

string $strScreenIcon

( optional ) Either a screen icon ID, a url of the icon, or a file path to the icon, with the size of 32 by 32 in pixel. The accepted icon IDs are as follows.

edit, post, index, media, upload, link-manager, link, link-category, edit-pages, page, edit-comments, themes, plugins, users, profile, user-edit, tools, admin, options-general, ms-admin, generic

Note: the generic ID is available since WordPress 3.5.

string $strCapability

( optional ) The access level to the page.

integer $numOrder

( optional ) the order number of the page. The lager the number is, the lower the position it is placed in the menu.

boolean $fShowPageHeadingTab

( optional ) If this is set to false, the page title won't be displayed in the page heading tab. Default: true.

boolean $fShowInMenu

( optional ) If this is set to false, the page title won't be displayed in the sidebar menu while the page is still accessible. Default: true.

showPageTitle()

showPageTitle(boolean $fShow,  $strPageSlug) : void

Sets whether the page title is displayed or not.

Example

$this->showPageTitle( false ); // disables the page title.

Parameters

boolean $fShow

If false, the page title will not be displayed.

$strPageSlug

showPageHeadingTabs()

showPageHeadingTabs(boolean $fShow, string $strPageSlug)

Sets whether page-heading tabs are displayed or not.

Example

$this->showPageHeadingTabs( false ); // disables the page heading tabs by passing false.

Parameters

boolean $fShow

If false, page-heading tabs will be disabled; otherwise, enabled.

string $strPageSlug

The page to apply the visibility setting. If not set, it applies to all the pages.

showInPageTabs()

showInPageTabs(boolean $fShow, string $strPageSlug)

Sets whether in-page tabs are displayed or not.

Sometimes, it is required to disable in-page tabs in certain pages. In that case, use the second parameter.

Parameters

boolean $fShow

If false, in-page tabs will be disabled.

string $strPageSlug

The page to apply the visibility setting. If not set, it applies to all the pages.

setInPageTabTag()

setInPageTabTag(string $strTag, string $strPageSlug)

Sets in-page tab's HTML tag.

Example

$this->setInPageTabTag( 'h2' );

Parameters

string $strTag

The HTML tag that encloses each in-page tab title. Default: h3.

string $strPageSlug

The page slug that applies the setting.

setPageHeadingTabTag()

setPageHeadingTabTag(string $strTag, string $strPageSlug)

Sets page-heading tab's HTML tag.

Example

$this->setPageHeadingTabTag( 'h2' );

Parameters

string $strTag

The HTML tag that encloses the page-heading tab title. Default: h2.

string $strPageSlug

The page slug that applies the setting.

addInPageTab()

addInPageTab(string $strPageSlug, string $strTabTitle, string $strTabSlug, integer $numOrder, boolean $fHide, string $strParentTabSlug) : void

Adds an in-page tab.

Parameters

string $strPageSlug

The page slug that the tab belongs to.

string $strTabTitle

The title of the tab.

string $strTabSlug

The tab slug. Non-alphabetical characters should not be used including dots(.) and hyphens(-).

integer $numOrder

( optional ) the order number of the tab. The lager the number is, the lower the position it is placed in the menu.

boolean $fHide

( optional ) default: false. If this is set to false, the tab title will not be displayed in the tab navigation menu; however, it is still accessible from the direct URL.

string $strParentTabSlug

( optional ) this needs to be set if the above fHide is true so that the parent tab will be emphasized as active when the hidden page is accessed.

addInPageTabs()

addInPageTabs(array $arrTab1, array $arrTab2, array $_and_more) : void

Adds in-page tabs.

The parameters accept in-page tab arrays and they must have the following array keys.

In-Page Tab Array

  • strPageSlug - ( string ) the page slug that the tab belongs to.
  • strTabSlug - ( string ) the tab slug. Non-alphabetical characters should not be used including dots(.) and hyphens(-).
  • strTitle - ( string ) the title of the tab.
  • numOrder - ( optional, integer ) the order number of the tab. The lager the number is, the lower the position it is placed in the menu.
  • fHide - ( optional, boolean ) default: false. If this is set to false, the tab title will not be displayed in the tab navigation menu; however, it is still accessible from the direct URL.
  • strParentTabSlug - ( optional, string ) this needs to be set if the above fHide is true so that the parent tab will be emphasized as active when the hidden page is accessed.

Example

$this->addInPageTabs( array( 'strTabSlug' => 'firsttab', 'strTitle' => __( 'Text Fields', 'my-text-domain' ), 'strPageSlug' => 'myfirstpage' ), array( 'strTabSlug' => 'secondtab', 'strTitle' => __( 'Selectors and Checkboxes', 'my-text-domain' ), 'strPageSlug' => 'myfirstpage' ) );

Parameters

array $arrTab1

The in-page tab array.

array $arrTab2

Another in-page tab array.

array $_and_more

Add in-page tab arrays as many as necessary to the next parameters.

addHelpTab()

addHelpTab(array $arrHelpTab) : void

Adds the given contextual help tab contents into the property.

Contextual Help Tab Array Structure

  • strPageSlug - the page slug of the page that the contextual help tab and its contents are displayed.
  • strPageTabSlug - ( optional ) the tab slug of the page that the contextual help tab and its contents are displayed.
  • strHelpTabTitle - the title of the contextual help tab.
  • strHelpTabID - the id of the contextual help tab.
  • strHelpTabContent - the HTML string content of the the contextual help tab.
  • strHelpTabSidebarContent - ( optional ) the HTML string content of the sidebar of the contextual help tab.

Example

$this->addHelpTab( array( 'strPageSlug' => 'first_page', // ( mandatory ) // 'strPageTabSlug' => null, // ( optional ) 'strHelpTabTitle' => 'Admin Page Framework', 'strHelpTabID' => 'admin_page_framework', // ( mandatory ) 'strHelpTabContent' => __( 'This contextual help text can be set with the addHelpTab() method.', 'admin-page-framework' ), 'strHelpTabSidebarContent' => __( 'This is placed in the sidebar of the help pane.', 'admin-page-framework' ), ) );

Parameters

array $arrHelpTab

The help tab array. The key structure is explained in the description part.

setHelpTab()

setHelpTab( $strID,  $strTitle,  $arrContents,  $arrSideBarContents)

Sets the contextual help tab.

On contrary to other methods relating to contextual help tabs that just modify the class properties, this finalizes the help tab contents. In other words, the set values here will take effect.

Parameters

$strID
$strTitle
$arrContents
$arrSideBarContents

registerRootMenuPage()

registerRootMenuPage()

Registers the root menu page.

registerSubMenuPage()

registerSubMenuPage( $arrArgs)

Registers the sub-menu page.

Parameters

$arrArgs

getScreenIcon()

getScreenIcon( $strPageSlug)

Retrieves the screen icon output as HTML.

Parameters

$strPageSlug

getScreenIDAttribute()

getScreenIDAttribute( $oScreen)

Retrieves the screen ID attribute from the given screen object.

Parameters

$oScreen

getPageHeadingTabs()

getPageHeadingTabs( $strCurrentPageSlug,  $strTag,  $arrOutput) : string

Retrieves the output of page heading tab navigation bar as HTML.

Parameters

$strCurrentPageSlug
$strTag
$arrOutput

Returns

string —

the output of page heading tabs.

getInPageTabs()

getInPageTabs( $strCurrentPageSlug,  $strTag,  $arrOutput) : string

Retrieves the output of in-page tab navigation bar as HTML.

Parameters

$strCurrentPageSlug
$strTag
$arrOutput

Returns

string —

the output of in-page tabs.

getParentTabSlug()

getParentTabSlug( $strPageSlug,  $strTabSlug) : string

Retrieves the parent tab slug from the given tab slug.

Parameters

$strPageSlug
$strTabSlug

Returns

string —

the parent tab slug.