\AdminPageFramework

The main class of the framework.

The user should extend this class and define the set-ups in the setUp() method. Most of the public methods are for hook callbacks and the private methods are internal helper functions. So the protected methods are for the users.

Hooks

The class automatically creates WordPress action and filter hooks associated with the class methods. The class methods corresponding to the name of the below actions and filters can be extended to modify the page output. Those methods are the callbacks of the filters and actions.

Methods and Action Hooks

  • start_ + extended class name – triggered at the end of the class constructor. This will be triggered in any admin page.
  • load_ + extended class name[2.1.0+] – triggered when the framework's page is loaded before the header gets sent. This will not be triggered in the admin pages that are not registered by the framework.
  • load_ + page slug[2.1.0+] – triggered when the framework's page is loaded before the header gets sent. This will not be triggered in the admin pages that are not registered by the framework.
  • load_ + page slug + _ + tab slug[2.1.0+] – triggered when the framework's page is loaded before the header gets sent. This will not be triggered in the admin pages that are not registered by the framework.
  • do_before_ + extended class name – triggered before rendering the page. It applies to all pages created by the instantiated class object.
  • do_before_ + page slug – triggered before rendering the page.
  • do_before_ + page slug + _ + tab slug – triggered before rendering the page.
  • do_ + extended class name – triggered in the middle of rendering the page. It applies to all pages created by the instantiated class object.
  • do_ + page slug – triggered in the middle of rendering the page.
  • do_ + page slug + _ + tab slug – triggered in the middle of rendering the page.
  • do_after_ + extended class name – triggered after rendering the page. It applies to all pages created by the instantiated class object.
  • do_after_ + page slug – triggered after rendering the page.
  • do_after_ + page slug + _ + tab slug – triggered after rendering the page.

Methods and Filter Hooks

  • head_ + page slug – receives the output of the top part of the page.
  • head_ + page slug + _ + tab slug – receives the output of the top part of the page.
  • head_ + extended class name – receives the output of the top part of the page, applied to all pages created by the instantiated class object.
  • content_ + page slug – receives the output of the middle part of the page including form input fields.
  • content_ + page slug + _ + tab slug – receives the output of the middle part of the page including form input fields.
  • content_ + extended class name – receives the output of the middle part of the page, applied to all pages created by the instantiated class object.
  • foot_ + page slug – receives the output of the bottom part of the page.
  • foot_ + page slug + _ + tab slug – receives the output of the bottom part of the page.
  • foot_ + extended class name – receives the output of the bottom part of the page, applied to all pages created by the instantiated class object.
  • section_ + extended class name + _ + section ID – receives the description output of the given form section ID. The first parameter: output string. The second parameter: the array of option.
  • field_ + extended class name + _ + field ID – receives the form input field output of the given input field ID. The first parameter: output string. The second parameter: the array of option.
  • validation_ + page slug + _ + tab slug – receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database.
  • validation_ + page slug – receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database.
  • validation_ + extended class name + _ + input id – [2.1.5+] receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database. The input ID is the one used to the name attribute of the submit input tag. For a submit button that is inserted without using the framework's method, it will not take effect.
  • validation_ + extended class name + _ + field id – [2.1.5+] receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database. The field ID is the one that is passed to the field array to create the submit input field.
  • validation_ + extended class name – receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database.
  • style_ + page slug + _ + tab slug – receives the output of the CSS rules applied to the tab page of the slug.
  • style_ + page slug – receives the output of the CSS rules applied to the page of the slug.
  • style_ + extended class name – receives the output of the CSS rules applied to the pages added by the instantiated class object.
  • script_ + page slug + _ + tab slug – receives the output of the JavaScript script applied to the tab page of the slug.
  • script_ + page slug – receives the output of the JavaScript script applied to the page of the slug.
  • script_ + extended class name – receives the output of the JavaScript script applied to the pages added by the instantiated class object.
  • export_ + page slug + _ + tab slug – receives the exporting array sent from the tab page.
  • export_ + page slug – receives the exporting array submitted from the page.
  • export_ + extended class name + _ + input id – [2.1.5+] receives the exporting array submitted from the specific export button.
  • export_ + extended class name + _ + field id – [2.1.5+] receives the exporting array submitted from the specific field.
  • export_ + extended class name – receives the exporting array submitted from the plugin.
  • import_ + page slug + _ + tab slug – receives the importing array submitted from the tab page.
  • import_ + page slug – receives the importing array submitted from the page.
  • import_ + extended class name + _ + input id – [2.1.5+] receives the importing array submitted from the specific import button.
  • import_ + extended class name + _ + field id – [2.1.5+] receives the importing array submitted from the specific import field.
  • import_ + extended class name – receives the importing array submitted from the plugin.

Remarks

The slugs must not contain a dot(.) or a hyphen(-) since it is used in the callback method name.

Examples

If the extended class name is Sample_Admin_Pages, defining the following class method will embed a banner image in all pages created by the class.

class Sample_Admin_Pages extends AdminPageFramework { ... function head_Sample_Admin_Pages( $strContent ) { return '<div style="float:right;"><img src="' . plugins_url( 'img/banner468x60.gif', FILE ) . '" /></div>' . $strContent; } ... }

If the created page slug is my_first_setting_page, defining the following class method will filter the middle part of the page output.

class Sample_Admin_Pages extends AdminPageFramework { ... function content_my_first_setting_page( $strContent ) { return $strContent . '<p>Hello world!</p>'; } ... }

Timing of Hooks

------ When the class is instantiated ------ start_ + extended class name load_ + extended class name load_ + page slug load_ + page slug + _ + tab slug ------ Start Rendering HTML ------ <head> <style type="text/css" name="admin-page-framework"> style_ + page slug + _ + tab slug style_ + page slug style_ + extended class name script_ + page slug + _ + tab slug script_ + page slug script_ + extended class name </style> </head> do_before_ + extended class name do_before_ + page slug do_before_ + page slug + _ + tab slug <div class="wrap"> head_ + page slug + _ + tab slug head_ + page slug head_ + extended class name <div class="acmin-page-framework-container"> <form action="options.php" method="post"> do_form_ + page slug + _ + tab slug do_form_ + page slug do_form_ + extended class name extended class name + _ + section_ + section ID extended class name + _ + field_ + field ID content_ + page slug + _ + tab slug content_ + page slug content_ + extended class name do_ + extended class name do_ + page slug do_ + page slug + _ + tab slug </form> </div> foot_ + page slug + _ + tab slug foot_ + page slug foot_ + extended class name </div> do_after_ + extended class name do_after_ + page slug do_after_ + page slug + _ + tab slug ----- After Submitting the Form ------ validation_ + page slug + _ + tab slug validation_ + page slug validation_ + extended class name + _ + submit button input id validation_ + extended class name + _ + submit button field id validation_ + extended class name export_ + page slug + _ + tab slug export_ + page slug export_ + extended class name import_ + page slug + _ + tab slug import_ + page slug import_ + extended class name

Summary

Methods
Properties
Constants
__construct()
__call()
setUp()
checkRedirects()
enqueueStyle()
enqueueScript()
setDisallowedQueryKeys()
registerSettings()
fixPageTitleForHiddenPages()
buildMenus()
finalizeInPageTabs()
No public properties found
No constants found
addSubMenuItems()
addSubMenuLink()
addLinkToPluginDescription()
addLinkToPluginTitle()
setCapability()
setFooterInfoLeft()
setFooterInfoRight()
setAdminNotice()
setSettingNotice()
addSettingSections()
addSettingSection()
removeSettingSections()
addSettingFields()
addSettingField()
removeSettingFields()
getFieldErrors()
setFieldErrors()
getFieldValue()
setRootMenuPage()
setRootMenuPageBySlug()
addSubMenuPage()
showPageTitle()
showPageHeadingTabs()
showInPageTabs()
setInPageTabTag()
setPageHeadingTabTag()
addInPageTab()
addInPageTabs()
addHelpTab()
setHelpTab()
$oProps
$oDebug
$oMsg
$oLink
$oUtil
$oHeadTag
$oScreen
N/A
isFrameworkCallbackMethod()
addSubMenuItem()
askResetOptions()
resetOptions()
setRedirectTransients()
getPressedCustomSubmitButtonSiblingValue()
importOptions()
exportOptions()
getFilteredOptions()
getPageOptions()
getOtherTabOptions()
getOtherPageOptions()
getPageSlugBySectionID()
setFieldHeadTagElements()
formatSectionArrays()
isSettingSectionOfCurrentTab()
formatFieldArrays()
registerRootMenuPage()
registerSubMenuPage()
getScreenIcon()
getScreenIDAttribute()
getPageHeadingTabs()
getInPageTabs()
getParentTabSlug()
No private properties found
N/A

Properties

$oProps

$oProps : object

The common properties shared among sub-classes.

Type

object — an instance of AdminPageFramework_Properties will be assigned in the constructor.

$oDebug

$oDebug : object

The object that provides the debug methods.

Type

object — an instance of AdminPageFramework_Debug will be assigned in the constructor.

$oMsg

$oMsg : object

Provides the methods for text messages of the framework.

Type

object — an instance of AdminPageFramework_Messages will be assigned in the constructor.

$oLink

$oLink : object

Provides the methods for creating HTML link elements.

Type

object — an instance of AdminPageFramework_Link will be assigned in the constructor.

$oUtil

$oUtil : object

Provides the utility methods.

Type

object — an instance of AdminPageFramework_Utilities will be assigned in the constructor.

$oHeadTag

$oHeadTag : object

Provides the methods to insert head tag elements.

Type

object — an instance of AdminPageFramework_HeadTag_Pages will be assigne in the constructor.

$oScreen

$oScreen : object

Stores the screen object.

Type

object

Methods

__construct()

__construct(string $strOptionKey, string $strCallerPath, string $strCapability, string $strTextDomain) : void

The constructor of the main class.

Example

if ( is_admin() ) new MyAdminPageClass( 'my_custom_option_key', FILE );

Parameters

string $strOptionKey

( optional ) specifies the option key name to store in the options table. If this is not set, the extended class name will be used.

string $strCallerPath

( optional ) used to retrieve the plugin/theme details to auto-insert the information into the page footer.

string $strCapability

( optional ) sets the overall access level to the admin pages created by the framework. The used capabilities are listed here( http://codex.wordpress.org/Roles_and_Capabilities ). If not set, manage_options will be assigned by default. The capability can be set per page, tab, setting section, setting field.

string $strTextDomain

( optional ) the text domain( http://codex.wordpress.org/I18n_for_WordPress_Developers#Text_Domains ) used for the framework's text strings. Default: admin-page-framework.

__call()

__call(string $strMethodName, array $arrArgs) : mixed

The magic method which redirects callback-function calls with the pre-defined prefixes for hooks to the appropriate methods.

Parameters

string $strMethodName

the called method name.

array $arrArgs

the argument array. The first element holds the parameters passed to the called method.

Returns

mixed —

depends on the called method. If the method name matches one of the hook prefixes, the redirected methods return value will be returned. Otherwise, none.

setUp()

setUp() : void

The method for all the necessary set-ups.

The users should override this method to set-up necessary settings. To perform certain tasks prior to this method, use the start_ + extended class name hook that is triggered at the end of the class constructor.

Example

public function setUp() { $this->setRootMenuPage( 'APF Form' ); $this->addSubMenuItems( array( 'strPageTitle' => 'Form Fields', 'strPageSlug' => 'apf_form_fields', ) ); $this->addSettingSections( array( 'strSectionID' => 'text_fields', 'strPageSlug' => 'apf_form_fields', 'strTitle' => 'Text Fields', 'strDescription' => 'These are text type fields.', ) ); $this->addSettingFields( array( 'strFieldID' => 'text', 'strSectionID' => 'text_fields', 'strTitle' => 'Text', 'strType' => 'text', ) ); }

checkRedirects()

checkRedirects()

enqueueStyle()

enqueueStyle(string $strSRC, string $strPageSlug, string $strTabSlug, array $arrCustomArgs) : string

Enqueues a style by page slug and tab slug.

Custom Argument Array for the Fourth Parameter

  • strHandleID - ( optional, string ) The handle ID of the stylesheet.
  • arrDependencies - ( optional, array ) The dependency array. For more information, see codex.
  • strVersion - ( optional, string ) The stylesheet version number.
  • strMedia - ( optional, string ) the description of the field which is inserted into the after the input field tag.

Parameters

string $strSRC

The URL of the stylesheet to enqueue, the absolute file path, or the relative path to the root directory of WordPress. Example: '/css/mystyle.css'.

string $strPageSlug

(optional) The page slug that the stylesheet should be added to. If not set, it applies to all the pages created by the framework.

string $strTabSlug

(optional) The tab slug that the stylesheet should be added to. If not set, it applies to all the in-page tabs in the page.

array $arrCustomArgs

(optional) The argument array for more advanced parameters.

Returns

string —

The script handle ID. If the passed url is not a valid url string, an empty string will be returned.

enqueueScript()

enqueueScript(string $strSRC, string $strPageSlug, string $strTabSlug, array $arrCustomArgs) : string

Enqueues a script by page slug and tab slug.

Custom Argument Array for the Fourth Parameter

  • strHandleID - ( optional, string ) The handle ID of the script.
  • arrDependencies - ( optional, array ) The dependency array. For more information, see codex.
  • strVersion - ( optional, string ) The stylesheet version number.
  • arrTranslation - ( optional, array ) The translation array. The handle ID will be used for the object name.
  • fInFooter - ( optional, boolean ) Whether to enqueue the script before < / head > or before < / body > Default: false.

Example

$this->enqueueScript( plugins_url( 'asset/js/test.js' , FILE ), // source url or path 'apf_read_me', // page slug '', // tab slug array( 'strHandleID' => 'my_script', // this handle ID also is used as the object name for the translation array below. 'arrTranslation' => array( 'a' => 'hello world!', 'style_handle_id' => $strStyleHandle, // check the enqueued style handle ID here. ), ) );

Parameters

string $strSRC

The URL of the stylesheet to enqueue, the absolute file path, or the relative path to the root directory of WordPress. Example: '/js/myscript.js'.

string $strPageSlug

(optional) The page slug that the script should be added to. If not set, it applies to all the pages created by the framework.

string $strTabSlug

(optional) The tab slug that the script should be added to. If not set, it applies to all the in-page tabs in the page.

array $arrCustomArgs

(optional) The argument array for more advanced parameters.

Returns

string —

The script handle ID. If the passed url is not a valid url string, an empty string will be returned.

setDisallowedQueryKeys()

setDisallowedQueryKeys( $arrQueryKeys,  $fAppend)

Sets the disallowed query keys in the links that the framework generates.

Example

$this->setDisallowedQueryKeys( array( 'my-custom-admin-notice' ) );

Parameters

$arrQueryKeys
$fAppend

registerSettings()

registerSettings() : void

Registers the setting sections and fields.

This methods passes the stored section and field array contents to the add_settings_section() and add_settings_fields() functions. Then perform register_setting().

The filters will be applied to the section and field arrays; that means that third-party scripts can modify the arrays. Also they get sorted before being registered based on the set order.

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.

addSubMenuItems()

addSubMenuItems(array $arrSubMenuItem1, array $arrSubMenuItem2, array $_and_more) : void

Adds sub-menu items on the left sidebar of the administration panel.

It supports pages and links. Each of them has the specific array structure.

Sub-menu Page Array

  • strPageTitle - ( string ) the page title of the page.
  • strPageSlug - ( string ) the page slug of the page. Non-alphabetical characters should not be used including dots(.) and hyphens(-).
  • strScreenIcon - ( optional, string ) either the ID selector name from the following list or the icon URL. The size of the icon should be 32 by 32 in pixel.
    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

    Notes: the generic icon is available WordPress version 3.5 or above.

  • strCapability - ( optional, string ) the access level to the created admin pages defined [here](http://codex.wordpress.org/Roles_and_Capabilities). If not set, the overall capability assigned in the class constructor, which is *manage_options* by default, will be used.
  • numOrder - ( optional, integer ) the order number of the page. The lager the number is, the lower the position it is placed in the menu.
  • fShowPageHeadingTab - ( optional, boolean ) if this is set to false, the page title won't be displayed in the page heading tab. Default: true.

Sub-menu Link Array

  • strMenuTitle - ( string ) the link title.
  • strURL - ( string ) the URL of the target link.
  • strCapability - ( optional, string ) the access level to show the item, defined [here](http://codex.wordpress.org/Roles_and_Capabilities). If not set, the overall capability assigned in the class constructor, which is *manage_options* by default, will be used.
  • numOrder - ( optional, integer ) the order number of the page. The lager the number is, the lower the position it is placed in the menu.
  • fShowPageHeadingTab - ( optional, boolean ) if this is set to false, the page title won't be displayed in the page heading tab. Default: true.

Example

$this->addSubMenuItems( array( 'strPageTitle' => 'Various Form Fields', 'strPageSlug' => 'first_page', 'strScreenIcon' => 'options-general', ), array( 'strPageTitle' => 'Manage Options', 'strPageSlug' => 'second_page', 'strScreenIcon' => 'link-manager', ), array( 'strMenuTitle' => 'Google', 'strURL' => 'http://www.google.com', 'fShowPageHeadingTab' => false, // this removes the title from the page heading tabs. ), );

Parameters

array $arrSubMenuItem1

a first sub-menu array.

array $arrSubMenuItem2

( optional ) a second sub-menu array.

array $_and_more

( optional ) third and add items as many as necessary with next parameters.

addLinkToPluginDescription()

addLinkToPluginDescription(string $strTaggedLinkHTML1, string $strTaggedLinkHTML2, string $_and_more) : void

Adds the given link(s) into the description cell of the plugin listing table.

Example

$this->addLinkToPluginDescription( "<a href='http://www.google.com'>Google</a>", "<a href='http://www.yahoo.com'>Yahoo!</a>" );

Parameters

string $strTaggedLinkHTML1

the tagged HTML link text.

string $strTaggedLinkHTML2

( optional ) another tagged HTML link text.

string $_and_more

( optional ) add more as many as want by adding items to the next parameters.

addLinkToPluginTitle()

addLinkToPluginTitle(string $strTaggedLinkHTML1, string $strTaggedLinkHTML2, string $_and_more) : void

Adds the given link(s) into the title cell of the plugin listing table.

Example

$this->addLinkToPluginTitle( "<a href='http://www.wordpress.org'>WordPress</a>" );

Parameters

string $strTaggedLinkHTML1

the tagged HTML link text.

string $strTaggedLinkHTML2

( optional ) another tagged HTML link text.

string $_and_more

( optional ) add more as many as want by adding items to the next parameters.

setCapability()

setCapability(string $strCapability) : void

Sets the overall capability.

Example

$this->setCpability( 'read' ); // let subscribers access the pages.

Parameters

string $strCapability

The access level for the created pages.

setFooterInfoLeft()

setFooterInfoLeft(string $strHTML, boolean $fAppend) : void

Sets the given HTML text into the footer on the left hand side.

Example

$this->setFooterInfoLeft( '<br />Custom Text on the left hand side.' );

Parameters

string $strHTML

The HTML code to insert.

boolean $fAppend

If true, the text will be appended; otherwise, it will replace the default text.

setFooterInfoRight()

setFooterInfoRight(string $strHTML, boolean $fAppend) : void

Sets the given HTML text into the footer on the right hand side.

Example

$this->setFooterInfoRight( '<br />Custom Text on the right hand side.' );

Parameters

string $strHTML

The HTML code to insert.

boolean $fAppend

If true, the text will be appended; otherwise, it will replace the default text.

setAdminNotice()

setAdminNotice(string $strMessage, string $strClassSelector, string $strID)

Sets an admin notice.

Example

$this->setAdminNotice( sprintf( 'Please click here to upgrade the options.', admin_url( 'admin.php?page="my_page"' ) ), 'updated' );

Parameters

string $strMessage

The message to display

string $strClassSelector

( optional ) The class selector used in the message HTML element. 'error' and 'updated' are prepared by WordPress but it's not limited to them and can pass a custom name. Default: 'error'

string $strID

( optional ) The ID of the message. If not set, the hash of the message will be used.

setSettingNotice()

setSettingNotice(string $strMsg, string $strType, string $strID, integer $fOverride) : void

Sets the given message to be displayed in the next page load.

This is used to inform users about the submitted input data, such as "Updated successfully." or "Problem occurred." etc. and normally used in validation callback methods.

Example

if ( ! $fVerified ) { $this->setFieldErrors( $arrErrors ); $this->setSettingNotice( 'There was an error in your input.' ); return $arrOldPageOptions; }

Parameters

string $strMsg

the text message to be displayed.

string $strType

( optional ) the type of the message, either "error" or "updated" is used.

string $strID

( optional ) the ID of the message. This is used in the ID attribute of the message HTML element.

integer $fOverride

( optional ) false: do not override when there is a message of the same id. true: override the previous one.

addSettingSections()

addSettingSections(array $arrSection1, array $arrSection2, array $_and_more) : void

Adds the given form section items into the property.

The passed section array must consist of the following keys.

Section Array

  • strSectionID - ( string ) the section ID. Avoid using non-alphabetic characters exept underscore and numbers.
  • strPageSlug - ( string ) the page slug that the section belongs to.
  • strTabSlug - ( optional, string ) the tab slug that the section belongs to.
  • strTitle - ( optional, string ) the title of the section.
  • strCapability - ( optional, string ) the access level of the section. If the page visitor does not have sufficient capability, the section will be invisible to them.
  • fIf - ( optional, boolean ) if the passed value is false, the section will not be registered.
  • numOrder - ( optional, integer ) the order number of the section. The higher the number is, the lower the position it gets.
  • strHelp - ( optional, string ) the help description added to the contextual help tab.
  • strHelpAside - ( optional, string ) the additional help description for the side bar of the contextual help tab.

Example

$this->addSettingSections( array( 'strSectionID' => 'text_fields', 'strPageSlug' => 'first_page', 'strTabSlug' => 'textfields', 'strTitle' => 'Text Fields', 'strDescription' => 'These are text type fields.', 'numOrder' => 10, ), array( 'strSectionID' => 'selectors', 'strPageSlug' => 'first_page', 'strTabSlug' => 'selectors', 'strTitle' => 'Selectors and Checkboxes', 'strDescription' => 'These are selector type options such as dropdown lists, radio buttons, and checkboxes', )

Parameters

array $arrSection1

the section array.

array $arrSection2

( optional ) another section array.

array $_and_more

( optional ) add more section array to the next parameters as many as necessary.

addSettingSection()

addSettingSection(array $arrSection)

A singular form of the adSettingSections() method which takes only a single parameter.

This is useful when adding section arrays in loops.

Parameters

array $arrSection

the section array.

removeSettingSections()

removeSettingSections(string $strSectionID1, string $strSectionID2, string $_and_more) : void

Removes the given section(s) by section ID.

This accesses the property storing the added section arrays and removes the specified ones.

Example

$this->removeSettingSections( 'text_fields', 'selectors', 'another_section', 'yet_another_section' );

Parameters

string $strSectionID1

the section ID to remove.

string $strSectionID2

( optional ) another section ID to remove.

string $_and_more

( optional ) add more section IDs to the next parameters as many as necessary.

addSettingFields()

addSettingFields(array $arrField1, array $arrField2, array $_and_more) : void

Adds the given field array items into the field array property.

The passed field array must consist of the following keys.

Field Array

  • strFieldID - ( string ) the field ID. Avoid using non-alphabetic characters exept underscore and numbers.
  • strSectionID - ( string ) the section ID that the field belongs to.
  • strType - ( string ) the type of the field. The supported types are listed below.
  • strTitle - ( optional, string ) the title of the section.
  • strDescription - ( optional, string ) the description of the field which is inserted into the after the input field tag.
  • strTip - ( optional, string ) the tip for the field which is displayed when the mouse is hovered over the field title.
  • strCapability - ( optional, string ) the http://codex.wordpress.org/Roles_and_Capabilities">access level of the section. If the page visitor does not have sufficient capability, the section will be invisible to them.
  • strName - ( optional, string ) the name attribute value of the input tag instead of automatically generated one.
  • strError - ( optional, string ) the error message to display above the input field.
  • strBeforeField - ( optional, string ) the HTML string to insert before the input field output.
  • strAfterField - ( optional, string ) the HTML string to insert after the input field output.
  • fIf - ( optional, boolean ) if the passed value is false, the section will not be registered.
  • numOrder - ( optional, integer ) the order number of the section. The higher the number is, the lower the position it gets.
  • vLabel - ( optional|mandatory, string|array ) the text label(s) associated with and displayed along with the input field. Some input types can ignore this key while some require it.
  • vDefault - ( optional, string|array ) the default value(s) assigned to the input tag's value attribute.
  • vValue - ( optional, string|array ) the value(s) assigned to the input tag's value attribute to override the default or stored value.
  • vDelimiter - ( optional, string|array ) the HTML string that delimits multiple elements. This is available if the vLabel key is passed as array. It will be enclosed in inline-block elements so the passed HTML string should not contain block elements.
  • vBeforeInputTag - ( optional, string|array ) the HTML string inserted right before the input tag. It will be enclosed in the label tag so the passed HTML string should not contain block elements.
  • vAfterInputTag - ( optional, string|array ) the HTML string inserted right after the input tag. It will be enclosed in the label tag so the passed HTML string should not contain block elements.
  • vClassAttribute - ( optional, string|array ) the value(s) assigned to the input tag's class.
  • vLabelMinWidth - ( optional, string|array ) the inline style property of the min-width of the label tag for the field in pixel without the unit. Default: 120.
  • vDisable - ( optional, boolean|array ) if this is set to true, the disabled attribute will be inserted into the field input tag.
  • strHelp - ( optional, string ) the help description added to the contextual help tab.
  • strHelpAside - ( optional, string ) the additional help description for the side bar of the contextual help tab.

Field Types

Each field type uses specific array keys.

  • text - a text input field which allows the user to type text.
    • vReadOnly - ( optional, boolean|array ) if this is set to true, the readonly attribute will be inserted into the field input tag.
    • vSize - ( optional, integer|array ) the number that indicates the size of the input field.
    • vMaxLength - ( optional, integer|array ) the number that indicates the maxlength attribute of the input field.
    • fRepeatable - [2.1.3+] ( optional, boolean|array ) whether the fields should be repeatable. If is true, the plus and the minus buttons appear next to each field that lets the user add/remove the fields.
  • password - a password input field which allows the user to type text.
    • vReadOnly - ( optional, boolean|array ) if this is set to true, the readonly attribute will be inserted into the field input tag.
    • vSize - ( optional, integer|array ) the number that indicates the size of the input field.
    • vMaxLength - ( optional, integer|array ) the number that indicates the maxlength attribute of the input field.
    • fRepeatable - [2.1.3+] ( optional, boolean|array ) whether the fields should be repeatable. If is true, the plus and the minus buttons appear next to each field that lets the user add/remove the fields.
    • *
  • datetime, datetime-local, email, month, search, tel, time, url, week - HTML5 input fields types. Some browsers do not support these.
    • vReadOnly - ( optional, boolean|array ) if this is set to true, the readonly attribute will be inserted into the field input tag.
    • vSize - ( optional, integer|array ) the number that indicates the size of the input field.
    • vMaxLength - ( optional, integer|array ) the number that indicates the maxlength attribute of the input field.
  • number, range - HTML5 input field types. Some browsers do not support these.
    • vReadOnly - ( optional, boolean|array ) if this is set to true, the readonly attribute will be inserted into the field input tag.
    • vSize - ( optional, integer|array ) the number that indicates the size attribute of the input field.
    • vMax - ( optional, integer|array ) the number that indicates the max attribute of the input field.
    • vMin - ( optional, integer|array ) the number that indicates the min attribute of the input field.
    • vStep - ( optional, integer|array ) the number that indicates the step attribute of the input field.
    • vMaxLength - ( optional, integer|array ) the number that indicates the maxlength attribute of the input field.
    • fRepeatable - [2.1.3+]( optional, boolean|array ) whether the fields should be repeatable. If is true, the plus and the minus buttons appear next to each field that lets the user add/remove the fields.
  • textarea - a textarea input field. The following array keys are supported.
    • vReadOnly - ( optional, boolean|array ) if this is set to true, the readonly attribute will be inserted into the field input tag.
    • vRows - ( optional, integer|array ) the number of rows of the textarea field.
    • vCols - ( optional, integer|array ) the number of cols of the textarea field.
    • vMaxLength - ( optional, integer|array ) the number that indicates the maxlength attribute of the input field.
    • vRich - [2.1.2+]( optional, array ) to make it a rich text editor pass a non-empty value. It accept a setting array of the _WP_Editors class defined in the core. For more information, see the argument section of this page.
    • fRepeatable - [2.1.3+]( optional, boolean|array ) whether the fields should be repeatable. If is true, the plus and the minus buttons appear next to each field that lets the user add/remove the fields. It's not supported for the rich editor.
  • radio - a radio button input field.
  • checkbox - a check box input field.
  • select - a dropdown input field.
    • vMultiple - ( optional, boolean|array ) if this is set to true, the multiple attribute will be inserted into the field input tag, which enables the multiple selections for the user.
    • vWidth - ( optional, string|array ) the width of the dropdown list including the unit. e.g. 120px
    • vSize - ( optional, integer|array ) the number that indicates the size attribute of the input field.
  • size - a size input field. This is a combination of number and select fields.
    • vSizeUnits - ( optional, array ) defines the units to show. e.g. array( 'px' => 'px', '%' => '%', 'em' => 'em' ) Default: array( 'px' => 'px', '%' => '%', 'em' => 'em', 'ex' => 'ex', 'in' => 'in', 'cm' => 'cm', 'mm' => 'mm', 'pt' => 'pt', 'pc' => 'pc' )
    • vMultiple - ( optional, boolean|array ) if this is set to true, the multiple attribute will be inserted into the field input tag, which enables the multiple selections for the user.
    • vWidth - ( optional, string|array ) the width of the dropdown list including the unit. e.g. 120px
    • vReadOnly - ( optional, boolean|array ) if this is set to true, the readonly attribute will be inserted into the field input tag.
    • vSize - ( optional, integer|array ) the number that indicates the size attribute of the number input field.
    • vUnitSize - [2.1.5+]( optional, integer|array ) the number that indicates the size attribute of the select(unit) input field.
    • vMax - ( optional, integer|array ) the number that indicates the max attribute of the input field.
    • vMin - ( optional, integer|array ) the number that indicates the min attribute of the input field.
    • vStep - ( optional, integer|array ) the number that indicates the step attribute of the input field.
    • vMaxLength - ( optional, integer|array ) the number that indicates the maxlength attribute of the input field.
    • vSize - ( optional, integer|array ) the number that indicates the size attribute of the input field.
  • hidden - a hidden input field.
  • file - a file upload input field.
    • vAcceptAttribute - ( optional, string|array ) the accept attribute value. Default: audio/*|video/*|image/*|MIME_type
  • submit - a submit button input field.
    • vLink - ( optional, string|array ) the url(s) linked to the submit button.
    • vRedirect - ( optional, string|array ) the url(s) redirected to after submitting the input form.
    • vReset - [2.1.2+] ( optional, string|array ) the option key to delete. Set 1 for the entire option.
  • import - an inport input field. This is a custom file and submit field.
    • vAcceptAttribute - ( optional, string|array ) the accept attribute value. Default: audio/*|video/*|image/*|MIME_type
    • vClassAttributeUpload - ( optional, string|array ) [2.1.5+] the class attribute for the file upload field. Default: import
    • vImportOptionKey - ( optional, string|array ) the option table key to save the importing data.
    • vImportFormat - ( optional, string|array ) the import format. json, or array is supported. Default: array
    • vMerge - ( optional, boolean|array ) [2.0.5+] determines whether the imported data should be merged with the existing options.
  • export - an export input field. This is a custom submit field.
    • vExportFileName - ( optional, string|array ) the file name to download.
    • vExportFormat - ( optional, string|array ) the format type. array, json, or text is supported. Default: array.
    • vExportData - ( optional, string|array|object ) the data to export.
  • image - an image input field. This is a custom text field with an attached JavaScript script.
    • vReadOnly - ( optional, boolean|array ) if this is set to true, the readonly attribute will be inserted into the field input tag.
    • vSize - ( optional, integer|array ) the number that indicates the size of the input field.
    • vMaxLength - ( optional, integer|array ) the number that indicates the maxlength attribute of the input field.
    • vImagePreview - ( optional, boolean|array ) if this is set to false, the image preview will be disabled.
    • strTickBoxTitle - ( optional, string ) the text label displayed in the media uploader box's title.
    • strLabelUseThis - ( optional, string ) the text label displayed in the button of the media uploader to set the image.
    • fRepeatable - [2.1.3+] ( optional, boolean|array ) whether the fields should be repeatable. If is true, the plus and the minus buttons appear next to each field that lets the user add/remove the fields.
    • arrCaptureAttributes - [2.1.3+] ( optional, array ) the array of the attribute names of the image to save. If this is set, the field will be an array with the specified attributes. The supported attributes are, 'title', 'alt', 'width', 'height', 'caption', 'id', 'align', and 'link'. Note that for external URLs, ID will not be captured. e.g. 'arrCaptureAttributes' => array( 'id', 'caption', 'description' )
    • fAllowExternalSource - [2.1.3+] ( optional, boolean ) whether external URL can be set via the uploader.
  • media - [2.1.3+] a media input field. This is a custom text field with an attached JavaScript script.
    • vReadOnly - ( optional, boolean|array ) if this is set to true, the readonly attribute will be inserted into the field input tag.
    • vSize - ( optional, integer|array ) the number that indicates the size of the input field.
    • vMaxLength - ( optional, integer|array ) the number that indicates the maxlength attribute of the input field.
    • strTickBoxTitle - ( optional, string ) the text label displayed in the media uploader box's title.
    • strLabelUseThis - ( optional, string ) the text label displayed in the button of the media uploader to set the image.
    • fRepeatable - [2.1.3+] ( optional, boolean|array ) whether the fields should be repeatable. If is true, the plus and the minus buttons appear next to each field that lets the user add/remove the fields.
    • arrCaptureAttributes - [2.1.3+] ( optional, array ) the array of the attribute names of the image to save. If this is set, the field will be an array with the specified attributes. The supported attributes are, 'id', 'caption', and 'description'. Note that for external URLs, ID will not be captured. e.g. 'arrCaptureAttributes' => array( 'id', 'caption', 'description' )
    • fAllowExternalSource - [2.1.3+] ( optional, boolean ) whether external URL can be set via the uploader.
  • color - a color picker input field. This is a custom text field with a JavaScript script.
    • vReadOnly - ( optional, boolean|array ) if this is set to true, the readonly attribute will be inserted into the field input tag.
    • vSize - ( optional, integer|array ) the number that indicates the size of the input field.
    • vMaxLength - ( optional, integer|array ) the number that indicates the maxlength attribute of the input field.
    • fRepeatable - [2.1.3+] ( optional, boolean|array ) whether the fields should be repeatable. If is true, the plus and the minus buttons appear next to each field that lets the user add/remove the fields.
  • taxonomy - a taxonomy check list. This is a set of check boxes listing a specified taxonomy. This does not accept to create multiple fields by passing an array of labels.
    • vTaxonomySlug - ( optional, string|array ) the taxonomy slug to list.
    • strWidth - ( optional, string ) the inline style property value of max-width of this element. Include the unit such as px, %. Default: 100%
    • strHeight - ( optional, string ) the inline style property value of height of this element. Include the unit such as px, %. Default: 250px
  • posttype - a posttype check list. This is a set of check boxes listing post type slugs.
    • arrRemove - ( optional, array ) the post type slugs not to be listed. e.g.array( 'revision', 'attachment', 'nav_menu_item' )

Example

$this->addSettingFields( array( // Single text field 'strFieldID' => 'text', 'strSectionID' => 'text_fields', 'strTitle' => __( 'Text', 'admin-page-framework-demo' ), 'strDescription' => __( 'Type something here.', 'admin-page-framework-demo' ), // additional notes besides the form field 'strType' => 'text', 'numOrder' => 1, 'vDefault' => 123456, 'vSize' => 40, ), array( // Multiple text fields 'strFieldID' => 'text_multiple', 'strSectionID' => 'text_fields', 'strTitle' => 'Multiple Text Fields', 'strDescription' => 'These are multiple text fields.', // additional notes besides the form field 'strType' => 'text', 'numOrder' => 2, 'vDefault' => array( 'Hello World', 'Foo bar', 'Yes, we can.' ), 'vLabel' => array( 'First Item: ', 'Second Item: ', 'Third Item: ' ), 'vSize' => array( 30, 60, 90, ), ) );

Parameters

array $arrField1

the field array.

array $arrField2

( optional ) another field array.

array $_and_more

( optional ) add more field arrays to the next parameters as many as necessary.

addSettingField()

addSettingField( $arrField) : void

Adds the given field array items into the field array property.

Itentical to the addSettingFields() method except that this method does not accept enumerated parameters.

Parameters

$arrField

removeSettingFields()

removeSettingFields(string $strFieldID1, string $strFieldID2, string $_and_more) : void

Removes the given field(s) by field ID.

This accesses the property storing the added field arrays and removes the specified ones.

Example

$this->removeSettingFields( 'fieldID_A', 'fieldID_B', 'fieldID_C', 'fieldID_D' );

Parameters

string $strFieldID1

the field ID to remove.

string $strFieldID2

( optional ) another field ID to remove.

string $_and_more

( optional ) add more field IDs to the next parameters as many as necessary.

getFieldErrors()

getFieldErrors( $strPageSlug,  $fDelete)

Retrieves the settings error array set by the user in the validation callback.

Parameters

$strPageSlug
$fDelete

setFieldErrors()

setFieldErrors(array $arrErrors, string $strID, integer $numSavingDuration)

Sets the field error array.

This is normally used in validation callback methods. when submitted data have an issue. This method saves the given array in a temporary area( transient ) of the options database table.

Example

public function validation_first_page_verification( $arrInput, $arrOldPageOptions ) { // valication_ + page slug + _ + tab slug $fVerified = true; $arrErrors = array(); // Check if the submitted value meets your criteria. As an example, here a numeric value is expected. if ( isset( $arrInput['first_page']['verification']['verify_text_field'] ) && ! is_numeric( $arrInput['first_page']['verification']['verify_text_field'] ) ) { // Start with the section key in $arrErrors, not the key of page slug. $arrErrors['verification']['verify_text_field'] = 'The value must be numeric: ' . $arrInput['first_page']['verification']['verify_text_field']; $fVerified = false; } // An invalid value is found. if ( ! $fVerified ) { // Set the error array for the input fields. $this->setFieldErrors( $arrErrors ); $this->setSettingNotice( 'There was an error in your input.' ); return $arrOldPageOptions; } return $arrInput; }

Parameters

array $arrErrors

the field error array. The structure should follow the one contained in the submitted $_POST array.

string $strID

this should be the page slug of the page that has the dealing form field.

integer $numSavingDuration

the transient's lifetime. 300 seconds means 5 minutes.

getFieldValue()

getFieldValue( $strFieldNameToFind)

Retrieves the specified field value stored in the options.

Useful when you don't know the section name but it's a bit slower than accessing the property value by specifying the section name.

Parameters

$strFieldNameToFind

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

isFrameworkCallbackMethod()

isFrameworkCallbackMethod(string $strMethodName) : boolean

Determines whether the method name matches the pre-defined hook prefixes.

Parameters

string $strMethodName

the called method name

Returns

boolean —

If it is a framework's callback method, returns true; otherwise, false.

addSubMenuItem()

addSubMenuItem(array $arrSubMenuItem) : void

Adds the given sub-menu item on the left sidebar of the administration panel.

This only adds one single item, called by the above addSubMenuItem() method.

The array structure of the parameter is documented in the addSubMenuItem() method section.

Parameters

array $arrSubMenuItem

a first sub-menu array.

askResetOptions()

askResetOptions( $strPressedFieldName,  $strPageSlug)

Displays a confirmation message to the user when a reset button is pressed.

Parameters

$strPressedFieldName
$strPageSlug

resetOptions()

resetOptions( $strKeyToReset,  $arrInput)

Performs reset options.

Parameters

$strKeyToReset
$arrInput

setRedirectTransients()

setRedirectTransients( $strURL)

Parameters

$strURL

getPressedCustomSubmitButtonSiblingValue()

getPressedCustomSubmitButtonSiblingValue( $arrPostElements,  $strTargetKey) : mixed

Retrieves the target key's value associated with the given data to a custom submit button.

This method checks if the associated submit button is pressed with the input fields.

Parameters

$arrPostElements
$strTargetKey

Returns

mixed —

Returns null if no button is found and the associated link url if found. Otherwise, the URL associated with the button.

importOptions()

importOptions( $arrStoredOptions,  $strPageSlug,  $strTabSlug)

Processes the imported data.

Parameters

$arrStoredOptions
$strPageSlug
$strTabSlug

exportOptions()

exportOptions( $vData,  $strPageSlug,  $strTabSlug)

Parameters

$vData
$strPageSlug
$strTabSlug

getFilteredOptions()

getFilteredOptions( $arrInput,  $strPageSlug,  $strTabSlug,  $strPressedFieldID,  $strPressedInputID) : array

Apples validation filters to the submitted input data.

Parameters

$arrInput
$strPageSlug
$strTabSlug
$strPressedFieldID
$strPressedInputID

Returns

array —

The filtered input array.

getPageOptions()

getPageOptions( $strPageSlug) : array

Retrieves the stored options of the given page slug.

Other pages' option data will not be contained in the returning array. This is used to pass the old option array to the validation callback method.

Parameters

$strPageSlug

Returns

array —

the stored options of the given page slug. If not found, an empty array will be returned.

getOtherTabOptions()

getOtherTabOptions( $strPageSlug,  $arrSectionKeysForTheTab) : array

Retrieves the stored options excluding the currently specified tab's sections and their fields.

This is used to merge the submitted form data with the previously stored option data of the form elements that belong to the in-page tab of the given page.

Parameters

$strPageSlug
$arrSectionKeysForTheTab

Returns

array —

the stored options excluding the currently specified tab's sections and their fields. If not found, an empty array will be returned.

getOtherPageOptions()

getOtherPageOptions( $strPageSlug) : array

Retrieves the stored options excluding the key of the given page slug.

This is used to merge the submitted form input data with the previously stored option data except the given page.

Parameters

$strPageSlug

Returns

array —

the array storing the options excluding the key of the given page slug.

getPageSlugBySectionID()

getPageSlugBySectionID( $strSectionID) : string|null

Retrieves the page slug that the settings section belongs to.

Parameters

$strSectionID

Returns

string|null

setFieldHeadTagElements()

setFieldHeadTagElements( $arrField)

Sets the given field type's enqueuing scripts and styles.

A helper function for the above registerSettings() method.

Parameters

$arrField

formatSectionArrays()

formatSectionArrays( $arrSections)

Formats the given section arrays.

Parameters

$arrSections

isSettingSectionOfCurrentTab()

isSettingSectionOfCurrentTab( $arrSection) : boolean

Checks if the given section belongs to the currently loading tab.

Parameters

$arrSection

Returns

boolean —

Returns true if the section belongs to the current tab page. Otherwise, false.

formatFieldArrays()

formatFieldArrays( $arrFields)

Formats the given field arrays.

Parameters

$arrFields

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.