Class AdminPageFramework
The main class of the framework to create admin pages and forms.
This class should be extended and the setUp() method should be overridden to
define how pages are composed. Most of the internal methods are prefixed with
the underscore like _getSomething()
and callback methods are
prefixed with _reply
. The methods for the users are public and do
not have those prefixes.
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 the actions.
Methods and Action Hooks
- start_{instantiated class name} – triggered at the end of the class constructor. This will be triggered in any admin page.
- load_{instantiated 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_{instantiated class name} – triggered before rendering the page. It applies to all the 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_{instantiated class name} – triggered in the middle of rendering the page. It applies to all the 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_{instantiated class name} – triggered after rendering the page. It applies to all the 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.
- submit_{instantiated class name}_{submit input id} – [3.0.0+] triggered after the form is submitted with the submit button of the specified input id.
- submit_{instantiated class name}_{submit field id} – [3.0.0+] triggered after the form is submitted with the submit button of the specified field that does not hava section is submitted.
- submit_{instantiated class name}_{submit section id}_{submit field id} – [3.0.0+] triggered after the form is submitted with the submit button of the specified section and field is submitted.
- submit_{instantiated class name}_{submit section id} – [3.0.0+] triggered after the form is submitted with the submit button of the specified section.
- submit_{instantiated class name} – [3.0.0+] triggered after the form is submitted.
Methods and Filter Hooks
- content_foot_{page slug}_{tab slug} – receives the output of the top part of the page. [3.0.0+] Changed the name from head_{...}.
- content_foot_{page slug} – receives the output of the top part of the page. [3.0.0+] Changed the name from head_{...}.
- content_foot_{instantiated class name} – receives the output of the top part of the page, applied to all pages created by the instantiated class object. [3.0.0+] Changed the name from head_{...}.
- content_{page slug}_{tab slug} – receives the output of the middle part of the page including form input fields.
- content_{page slug} – receives the output of the middle part of the page including form input fields.
- content_{instantiated class name} – receives the output of the middle part of the page, applied to all pages created by the instantiated class object.
- content_bottom_{page slug}_{tab slug} – receives the output of the bottom part of the page. [3.0.0+] Changed the name from foot_{...}.
- content_bottom_{page slug} – receives the output of the bottom part of the page. [3.0.0+] Changed the name from foot_{...}.
- content_bottom_{instantiated class name} – receives the output of the bottom part of the page, applied to all pages created by the instantiated class object. [3.0.0+] Changed the name from foot_{...}.
- section_head_{instantiated class name}_{section ID} – receives the title and the description output of the given form section ID. The first parameter: the output string.
- field_{instantiated class name}_{field ID} – receives the form input field output of the given input field ID that does not have a section. The first parameter: output string. The second parameter: the array of option.
- field_{instantiated class name}_{section id}_{field ID} – [3.0.0+] receives the form input field output of the given input field ID that has a section. The first parameter: output string. The second parameter: the array of option.
- sections_{instantiated class name} – receives the registered section arrays. The first parameter: sections container array.
- fields_{instantiated class name} – receives the registered field arrays. The first parameter: fields container array.
- fields_{instantiated class name}_{section id} – [3.0.0+] receives the registered field arrays which belong to the specified section. The first parameter: fields container array.
- field_definition_{instantiated class name}_{field ID} – [3.0.2+] receives the form field definition array of the given input field ID that does not have a section. The first parameter: the field definition array.
- field_definition_{instantiated class name}_{section id}_{field ID} – [3.0.2+] receives the form field definition array of the given input field ID that has a section. The first parameter: the field definition array. The second parameter: the integer representing sub-section index if the field belongs to a sub-section.
- pages_{instantiated class name} – receives the registered page arrays. The first parameter: pages container array.
- tabs_{instantiated class name}_{page slug} – receives the registered in-page tab arrays. The first parameter: tabs container array.
- validation_{instantiated class name}_{field id} – [3.0.0+] receives the form submission value of the field that does not have a section. The first parameter: ( string|array ) submitted input value. The second parameter: ( string|array ) the old value stored in the database.
- validation_{instantiated class name}_{section_id}_{field id} – [3.0.0+] receives the form submission value of the field that has a section. The first parameter: ( string|array ) submitted input value. The second parameter: ( string|array ) the old value stored in the database.
- validation_{instantiated class name}_{section id} – [3.0.0+] receives the form submission values that belongs to the section.. The first parameter: ( array ) the array of submitted input values that belong to the section. The second parameter: ( array ) the array of the old values stored in the database.
- 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_{instantiated 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_{instantiated 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_{instantiated class name} – receives the output of the JavaScript script applied to the pages added by the instantiated class object.
- export_{instantiated class name}_{input id} – [2.1.5+] receives the exporting array submitted from the specific export button.
- export_{instantiated class name}_{field id} – [2.1.5+] receives the exporting array submitted from the specific field that does not have a section.
- export_{instantiated class name}_{section id}_{field id} – [3.0.0+] receives the exporting array submitted from the specific field that has a section.
- 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_{instantiated class name} – receives the exporting array submitted from the plugin.
- export_name_{instantiated class name}_{input id} – receives the exporting file name submitted the specified input id.
- export_name_{instantiated class name}_{field id} – receives the exporting file name submitted from the specific field that does not have a section.
- export_name_{instantiated class name}_{section id}_{field id} – [3.0.0+] receives the exporting file name submitted from the specific field that has a section.
- export_name_{page slug}_{tab slug} – receives the exporting file name submitted from the tab page.
- export_name_{page slug} – receives the exporting file name submitted from the page.
- export_name_{instantiated class name} – receives the exporting file name submitted from the script.
- export_format_{instantiated class name}_{input id} – receives the exporting file format submitted from the specific export button.
- export_format_{instantiated class name}_{field id} – receives the exporting file format submitted from the specific field that does not have a section.
- export_format_{instantiated class name}_{section id}_{field id} – [3.0.0+] receives the exporting file format submitted from the specific field that has a section.
- export_format_{page slug}_{tab slug} – receives the exporting file format sent from the tab page.
- export_format_{page slug} – receives the exporting file format submitted from the page.
- export_format_{instantiated class name} – receives the exporting file format submitted from the plugin.
- import_{instantiated class name}_{input id} – [2.1.5+] receives the importing array submitted from the specific import button.
- import_{instantiated class name}_{field id} – [2.1.5+] receives the importing array submitted from the specific import field that does not have a section.
- import_{instantiated class name}_{section id}_{field id} – [3.0.0+] receives the importing array submitted from the specific import field that has a section.
- 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_{instantiated class name} – receives the importing array submitted from the plugin.
- import_mime_types_{instantiated class name}_{input id} – [2.1.5+] receives the mime types of the import data submitted from the specific import button.
- import_mime_types_{instantiated class name}_{field id} – [2.1.5+] receives the mime types of the import data submitted from the specific import field that does not have a section.
- import_mime_types_{instantiated class name}_{section id}_{field id} – [3.0.0+] receives the mime types of the import data submitted from the specific import field that has a section.
- import_mime_types_{page slug}_{tab slug} – receives the mime types of the import data submitted from the tab page.
- import_mime_types_{page slug} – receives the mime types of the import data submitted from the page.
- import_mime_types_{instantiated class name} – receives the mime types of the import data submitted from the plugin.
- import_format_{instantiated class name}_{input id} – [2.1.5+] receives the import data format submitted from the specific import button.
- import_format_{instantiated class name}_{field id} – [2.1.5+] receives the import data format submitted from the specific import field that does not have a section.
- import_format_{instantiated class name}_{section id}_{field id} – [3.0.0+] receives the import data format submitted from the specific import field that has a section.
- import_format_{page slug}_{tab slug} – receives the import data format submitted from the tab page.
- import_format_{page slug} – receives the import data format submitted from the page.
- import_format_{instantiated class name} – receives the import data format submitted from the plugin.
- import_option_key_{instantiated class name}_{input id} – [2.1.5+] receives the option array key of the importing array submitted from the specific import button.
- import_option_key_{instantiated class name}_{field id} – [2.1.5+] receives the option array key of the importing array submitted from the specific import field that does not have a section.
- import_option_key_{instantiated class name}_{section id}_{field id} – [3.0.0+] receives the option array key of the importing array submitted from the specific import field that has a section.
- import_option_key_{page slug}_{tab slug} – receives the option array key of the importing array submitted from the tab page.
- import_option_key_{page slug} – receives the option array key of the importing array submitted from the page.
- import_option_key_{instantiated class name} – receives the option array key of 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 instantiated 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 content_foot_Sample_Admin_Pages( $sContent ) { return '<div style="float:right;"><img src="' . plugins_url( 'img/banner468x60.gif', __FILE__ ) . '" /></div>' . $sContent; } ... }
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( $sContent ) { return $sContent . '<p>Hello world!</p>'; } ... }
Timing of Hooks
------ When the class is instantiated ------ start_{instantiated class name} load_{instantiated class name} load_{page slug} load_{page slug}_{tab slug} sections_{instantiated class name} fields_{instantiated class name} pages_{instantiated class name} tabs_{instantiated class name}_{page slug} ------ Start Rendering HTML ------ <head> <style type="text/css" name="admin-page-framework"> style_{page slug}_{tab slug} style_{page slug} style_{instantiated class name} script_{page slug}_{tab slug} script_{page slug} script_{instantiated class name} </style> <head/> do_before_{instantiated class name} do_before_{page slug} do_before_{page slug}_{tab slug} <div class="wrap"> content_foot_{page slug}_{tab slug} content_foot_{page slug} content_foot_{instantiated 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_{instantiated class name} section_head_{instantiated class name}_{section ID} field_{instantiated class name}_{field ID} content_{page slug}_{tab slug} content_{page slug} content_{instantiated class name} do_{instantiated class name} do_{page slug} do_{page slug}_{tab slug} </form> </div> content_bottom_{page slug}_{tab slug} content_bottom_{page slug} content_bottom_{instantiated class name} </div> do_after_{instantiated class name} do_after_{page slug} do_after_{page slug}_{tab slug} ----- After Submitting the Form ------ validation_{instantiated class name}_{submit button input id} validation_{instantiated class name}_{submit button field id} validation_{page slug}_{tab slug } validation_{page slug } validation_{instantiated class name } export_{page slug}_{tab slug} export_{page slug} export_{instantiated class name} import_{page slug}_{tab slug} import_{page slug} import_{instantiated class name}
- AdminPageFramework_Base
-
AdminPageFramework_Page_MetaBox
-
AdminPageFramework_Page
-
AdminPageFramework_Menu
-
AdminPageFramework_Setting_Base
-
AdminPageFramework_Setting
-
AdminPageFramework_Setting_Port
-
AdminPageFramework_Setting_Validation
-
AdminPageFramework
Package: AdminPageFramework\Page
Since: 2.0.0
Extends: AdminPageFramework_Setting
Remark: This class stems from several abstract classes.
Use: AdminPageFramework_Property_Page
Use: AdminPageFramework_Debug
Use: AdminPageFramework_Property_Page
Use: AdminPageFramework_Message
Use: AdminPageFramework_Link_Page
Use: AdminPageFramework_Utility
Located at page/AdminPageFramework.php
Methods summary
public
|
#
__construct( string $sOptionKey = null, string $sCallerPath = null, string $sCapability = null, string $sTextDomain = 'admin-page-framework' )
|
public
|
|
public
|
#
addHelpTab( array $aHelpTab )
|
public
array
|
#
enqueueStyles( array $aSRCs, string $sPageSlug = '', string $sTabSlug = '', array $aCustomArgs = array() )
|
public
string
|
#
enqueueStyle( string $sSRC, string $sPageSlug = '', string $sTabSlug = '', array $aCustomArgs = array() )
|
public
array
|
#
enqueueScripts( array $aSRCs, string $sPageSlug = '', string $sTabSlug = '', array $aCustomArgs = array() )
|
public
string
|
#
enqueueScript( string $sSRC, string $sPageSlug = '', string $sTabSlug = '', array $aCustomArgs = array() )
|
public
|
#
addLinkToPluginDescription( string $sTaggedLinkHTML1, string $sTaggedLinkHTML2 = null, string $_and_more = null )
|
public
|
#
addLinkToPluginTitle( string $sTaggedLinkHTML1, string $sTaggedLinkHTML2 = null, string $_and_more = null )
|
public
|
#
setCapability( string $sCapability )
|
public
|
#
setFooterInfoLeft( string $sHTML, boolean $bAppend = true )
|
public
|
#
setFooterInfoRight( string $sHTML, boolean $bAppend = true )
|
public
|
#
setAdminNotice( string $sMessage, string $sClassSelector = 'error', string $sID = '' )
|
public
|
#
setDisallowedQueryKeys( array|string $asQueryKeys, boolean $bAppend = true )
|
public static
mixed
|
Methods inherited from AdminPageFramework_Setting_Validation
_doValidationCall()
Methods inherited from AdminPageFramework_Setting_Port
_exportOptions()
,
_importOptions()
Methods inherited from AdminPageFramework_Setting
addSettingField()
,
addSettingFields()
,
addSettingSection()
,
addSettingSections()
,
getFieldValue()
,
removeSettingFields()
,
removeSettingSections()
,
setFieldErrors()
,
setSettingNotice()
Methods inherited from AdminPageFramework_Setting_Base
_replyToCheckRedirects()
,
_replyToGetFieldOutput()
,
_replyToGetSectionHeaderOutput()
,
_replyToRegisterSettings()
Methods inherited from AdminPageFramework_Menu
addSubMenuItem()
,
addSubMenuItems()
,
setRootMenuPage()
,
setRootMenuPageBySlug()
Methods inherited from AdminPageFramework_Page
_replyToFinalizeInPageTabs()
,
addInPageTab()
,
addInPageTabs()
,
setInPageTabTag()
,
setInPageTabsVisibility()
,
setPageHeadingTabTag()
,
setPageHeadingTabsVisibility()
,
setPageTitleVisibility()
Methods inherited from AdminPageFramework_Page_MetaBox
_getNumberOfColumns()
,
_printMetaBox()
,
_replyToAddMetaboxScript()
,
_replyToEnableMetaBox()
,
_replyToReturnDefaultNumberOfScreenColumns()
,
_replyToSetNumberOfScreenLayoutColumns()
Methods inherited from AdminPageFramework_Base
__call()
,
_doPageLoadCall()
,
_isInThePage()
,
_sortByOrder()
,
addSubMenuLink()
,
addSubMenuPage()
,
addSubMenuPages()
Magic methods summary
Properties summary
Properties inherited from AdminPageFramework_Setting_Base
$_sFieldsType
,
$_sTargetPageSlug
,
$_sTargetSectionTabSlug
,
$_sTargetTabSlug
,
$aFieldErrors
Properties inherited from AdminPageFramework_Base
$_aHookPrefixes
,
$oDebug
,
$oHeadTag
,
$oHelpPane
,
$oLink
,
$oMsg
,
$oPageLoadInfo
,
$oProp
,
$oUtil