$oProps
$oProps : object
The common properties shared among sub-classes.
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.
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.
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.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.The slugs must not contain a dot(.) or a hyphen(-) since it is used in the callback method name.
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>';
}
...
}
------ 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
__construct(string $strOptionKey, string $strCallerPath, string $strCapability, string $strTextDomain) : void
The constructor of the main class.
if ( is_admin() )
new MyAdminPageClass( 'my_custom_option_key', FILE );
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(string $strMethodName, array $arrArgs) : mixed
The magic method which redirects callback-function calls with the pre-defined prefixes for hooks to the appropriate methods.
string | $strMethodName | the called method name. |
array | $arrArgs | the argument array. The first element holds the parameters passed to the called method. |
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() : 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.
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',
)
);
}
enqueueStyle(string $strSRC, string $strPageSlug, string $strTabSlug, array $arrCustomArgs) : string
Enqueues a style by page slug and tab slug.
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. |
The script handle ID. If the passed url is not a valid url string, an empty string will be returned.
enqueueScript(string $strSRC, string $strPageSlug, string $strTabSlug, array $arrCustomArgs) : string
Enqueues a script by page slug and tab slug.
false
.$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.
),
)
);
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. |
The script handle ID. If the passed url is not a valid url string, an empty string will be returned.
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.
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(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.
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.
$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.
),
);
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. |
addSubMenuLink(string $strMenuTitle, string $strURL, string $strCapability, string $numOrder, string $fShowPageHeadingTab, $fShowInMenu) : void
Adds the given link into the menu on the left sidebar of the administration panel.
string | $strMenuTitle | the menu title. |
string | $strURL | the URL linked to the menu. |
string | $strCapability | ( optional ) the access level. ( http://codex.wordpress.org/Roles_and_Capabilities) |
string | $numOrder | ( optional ) the order number. The larger it is, the lower the position it gets. |
string | $fShowPageHeadingTab | ( optional ) if set to false, the menu title will not be listed in the tab navigation menu at the top of the page. |
$fShowInMenu |
addLinkToPluginDescription(string $strTaggedLinkHTML1, string $strTaggedLinkHTML2, string $_and_more) : void
Adds the given link(s) into the description cell of the plugin listing table.
$this->addLinkToPluginDescription(
"<a href='http://www.google.com'>Google</a>",
"<a href='http://www.yahoo.com'>Yahoo!</a>"
);
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(string $strTaggedLinkHTML1, string $strTaggedLinkHTML2, string $_and_more) : void
Adds the given link(s) into the title cell of the plugin listing table.
$this->addLinkToPluginTitle(
"<a href='http://www.wordpress.org'>WordPress</a>"
);
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(string $strCapability) : void
Sets the overall capability.
$this->setCpability( 'read' ); // let subscribers access the pages.
string | $strCapability | The access level for the created pages. |
setAdminNotice(string $strMessage, string $strClassSelector, string $strID)
Sets an admin notice.
$this->setAdminNotice( sprintf( 'Please click here to upgrade the options.', admin_url( 'admin.php?page="my_page"' ) ), 'updated' );
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(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.
if ( ! $fVerified ) {
$this->setFieldErrors( $arrErrors );
$this->setSettingNotice( 'There was an error in your input.' );
return $arrOldPageOptions;
}
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(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
$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',
)
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. |
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.
$this->removeSettingSections( 'text_fields', 'selectors', 'another_section', 'yet_another_section' );
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(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.
label
tag so the passed HTML string should not contain block elements.label
tag so the passed HTML string should not contain block elements.120
.Each field type uses specific array keys.
_WP_Editors
class defined in the core.
For more information, see the argument section of this page.
array( 'px' => 'px', '%' => '%', 'em' => 'em' )
Default: array( 'px' => 'px', '%' => '%', 'em' => 'em', 'ex' => 'ex', 'in' => 'in', 'cm' => 'cm', 'mm' => 'mm', 'pt' => 'pt', 'pc' => 'pc' )
audio/*|video/*|image/*|MIME_type
audio/*|video/*|image/*|MIME_type
import
'arrCaptureAttributes' => array( 'id', 'caption', 'description' )
'arrCaptureAttributes' => array( 'id', 'caption', 'description' )
array( 'revision', 'attachment', 'nav_menu_item' )
$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,
),
)
);
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. |
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.
$this->removeSettingFields( 'fieldID_A', 'fieldID_B', 'fieldID_C', 'fieldID_D' );
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. |
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.
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;
}
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. |
setRootMenuPage(string $strRootMenuLabel, string $strURLIcon16x16, string $intMenuPosition) : void
Sets to which top level page is going to be adding sub-pages.
$this->setRootMenuPage( 'Settings' );
$this->setRootMenuPage(
'APF Form',
plugins_url( 'image/screen_icon32x32.jpg', FILE )
);
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(string $strRootMenuSlug) : void
Sets the top level menu page by page slug.
The page should be already created or scheduled to be created separately.
$this->setRootMenuPageBySlug( 'edit.php?post_type=apf_posts' );
string | $strRootMenuSlug | The page slug of the top-level root page. |
addSubMenuPage(string $strPageTitle, string $strPageSlug, string $strScreenIcon, string $strCapability, integer $numOrder, boolean $fShowPageHeadingTab, boolean $fShowInMenu) : void
Adds a single sub-menu page.
$this->addSubMenuPage( 'My Page', 'my_page', 'edit-pages' );
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. |
showPageHeadingTabs(boolean $fShow, string $strPageSlug)
Sets whether page-heading tabs are displayed or not.
$this->showPageHeadingTabs( false ); // disables the page heading tabs by passing false.
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(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.
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. |
setPageHeadingTabTag(string $strTag, string $strPageSlug)
Sets page-heading tab's HTML tag.
$this->setPageHeadingTabTag( 'h2' );
string | $strTag | The HTML tag that encloses the page-heading tab title. Default: h2. |
string | $strPageSlug | The page slug that applies the setting. |
addInPageTab(string $strPageSlug, string $strTabTitle, string $strTabSlug, integer $numOrder, boolean $fHide, string $strParentTabSlug) : void
Adds an in-page tab.
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(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.
$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'
)
);
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(array $arrHelpTab) : void
Adds the given contextual help tab contents into the property.
$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' ),
)
);
array | $arrHelpTab | The help tab array. The key structure is explained in the description part. |
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.
$strID | ||
$strTitle | ||
$arrContents | ||
$arrSideBarContents |
isFrameworkCallbackMethod(string $strMethodName) : boolean
Determines whether the method name matches the pre-defined hook prefixes.
string | $strMethodName | the called method name |
If it is a framework's callback method, returns true; otherwise, false.
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.
array | $arrSubMenuItem | a first sub-menu array. |
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.
$arrPostElements | ||
$strTargetKey |
Returns null if no button is found and the associated link url if found. Otherwise, the URL associated with the button.
getFilteredOptions( $arrInput, $strPageSlug, $strTabSlug, $strPressedFieldID, $strPressedInputID) : array
Apples validation filters to the submitted input data.
$arrInput | ||
$strPageSlug | ||
$strTabSlug | ||
$strPressedFieldID | ||
$strPressedInputID |
The filtered input array.
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.
$strPageSlug |
the stored options of the given page slug. If not found, an empty array will be returned.
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.
$strPageSlug | ||
$arrSectionKeysForTheTab |
the stored options excluding the currently specified tab's sections and their fields. If not found, an empty array will be returned.
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.
$strPageSlug |
the array storing the options excluding the key of the given page slug.