Admin Page Framework Documentation
  • Package
  • Class
  • Tree

Packages

  • AdminPageFramework
    • FieldType
    • MetaBox
    • Page
    • PostType
    • TaxonomyField

Classes

  • AdminPageFramework
  • AdminPageFramework_Menu
  • AdminPageFramework_Page
  • AdminPageFramework_Setting

Class AdminPageFramework_Menu

Provides methods to manipulate menu items.

AdminPageFramework_Base
Extended by AdminPageFramework_Page_MetaBox
Extended by AdminPageFramework_Page
Extended by AdminPageFramework_Menu

Indirect known subclasses

AdminPageFramework, AdminPageFramework_Setting

Abstract
Package: AdminPageFramework\Page
Since: 2.0.0
Extends: AdminPageFramework_Page
Located at page/AdminPageFramework_Menu.php

Methods summary

public
# setRootMenuPage( string $sRootMenuLabel, string $sIcon16x16 = null, string $iMenuPosition = null )

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

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

$sRootMenuLabel
string
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
$sIcon16x16
string
( optional ) the source of menu icon with either of the following forms:
  • the URL of the menu icon with the size of 16 by 16 in pixel.
  • the file path of the menu icon with the size of 16 by 16 in pixel.
  • the name of a Dashicons helper class to use a font icon, e.g. dashicons-editor-customchar.
  • the string, 'none', to leave div.wp-menu-image empty so an icon can be added via CSS.
  • a base64-encoded SVG using a data URI, which will be colored to match the color scheme. This should begin with 'data:image/svg+xml;base64,'.
$iMenuPosition
string
( optional ) the position number that is passed to the $position parameter of the add_menu_page() function.

Since

2.0.0
2.1.6 The $sIcon16x16 parameter accepts a file path.
3.0.0 The scope was changed to public from protected.

Acecss

public

Remark

Only one root page can be set per one class instance.
public
# setRootMenuPageBySlug( string $sRootMenuSlug )

Sets the top level menu page by page slug.

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

$sRootMenuSlug
string
The page slug of the top-level root page.

Since

2.0.0
3.0.0 The scope was changed to public from protected.
public
# addSubMenuItems( array $aSubMenuItem1, array $aSubMenuItem2 = null, array $_and_more = null )

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

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

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

Example

$this->addSubMenuItems(
        array(
                'title' => 'Various Form Fields',
                'page_slug' => 'first_page',
                'screen_icon' => 'options-general',
        ),
        array(
                'title' => 'Manage Options',
                'page_slug' => 'second_page',
                'screen_icon' => 'link-manager',
        ),
        array(
                'title' => 'Google',
                'href' => 'http://www.google.com',
                'show_page_heading_tab' => false,       // this removes the title from the page heading tabs.
        ),
);

Parameters

$aSubMenuItem1
array
a first sub-menu array. A sub-menu array can be a link or a page. The array structures are as follows:

Sub-menu Page Array

  • title - ( string ) the page title of the page.
  • page_slug - ( string ) the page slug of the page. Non-alphabetical characters should not be used including dots(.) and hyphens(-).
  • screen_icon - ( 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. This is for WordPress 3.7.x or below.
    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.)

  • capability - ( optional, string ) the access level to the created admin pages defined here. If not set, the overall capability assigned in the class constructor, which is manage_options by default, will be used.
  • order - ( optional, integer ) the order number of the page. The lager the number is, the lower the position it is placed in the menu.
  • show_page_heading_tab - ( 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

  • title - ( string ) the link title.
  • href - ( string ) the URL of the target link.
  • capability - ( optional, string ) the access level to show the item, defined here. If not set, the overall capability assigned in the class constructor, which is manage_options by default, will be used.
  • order - ( optional, integer ) the order number of the page. The lager the number is, the lower the position it is placed in the menu.
  • show_page_heading_tab - ( optional, boolean ) if this is set to false, the page title won't be displayed in the page heading tab. Default: true.
$aSubMenuItem2
array
( optional ) a second sub-menu array.
$_and_more
array
( optional ) a third and add items as many as necessary with next parameters.

Since

2.0.0
3.0.0 Changed the scope to public.

Remark

The sub menu page slug should be unique because add_submenu_page() can add one callback per page slug.
Accepts variadic parameters; the number of accepted parameters are not limited to three.
public
# addSubMenuItem( array $aSubMenuItem )

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

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

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

Parameters

$aSubMenuItem
array
a sub-menu array. It can be a page or a link. The array structures are as follows:

Sub-menu Page Array

  • title - ( string ) the page title of the page.
  • page_slug - ( string ) the page slug of the page. Non-alphabetical characters should not be used including dots(.) and hyphens(-).
  • screen_icon - ( 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. This is for WordPress 3.7.x or below.
    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.)

  • capability - ( optional, string ) the access level to the created admin pages defined here. If not set, the overall capability assigned in the class constructor, which is manage_options by default, will be used.
  • order - ( optional, integer ) the order number of the page. The lager the number is, the lower the position it is placed in the menu.
  • show_page_heading_tab - ( 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

  • title - ( string ) the link title.
  • href - ( string ) the URL of the target link.
  • capability - ( optional, string ) the access level to show the item, defined here. If not set, the overall capability assigned in the class constructor, which is manage_options by default, will be used.
  • order - ( optional, integer ) the order number of the page. The lager the number is, the lower the position it is placed in the menu.
  • show_page_heading_tab - ( optional, boolean ) if this is set to false, the page title won't be displayed in the page heading tab. Default: true.

Since

2.0.0
3.0.0 Changed the scope to public.

Remark

The sub menu page slug should be unique because add_submenu_page() can add one callback per page slug.

Methods inherited from AdminPageFramework_Page

_replyToFinalizeInPageTabs(), addInPageTab(), addInPageTabs(), setInPageTabTag(), setInPageTabsVisibility(), setPageHeadingTabTag(), setPageHeadingTabsVisibility(), setPageTitleVisibility()

Methods inherited from AdminPageFramework_Page_MetaBox

__construct(), _getNumberOfColumns(), _printMetaBox(), _replyToAddMetaboxScript(), _replyToEnableMetaBox(), _replyToReturnDefaultNumberOfScreenColumns(), _replyToSetNumberOfScreenLayoutColumns()

Methods inherited from AdminPageFramework_Base

__call(), _doPageLoadCall(), _isInThePage(), _sortByOrder(), addHelpTab(), addLinkToPluginDescription(), addLinkToPluginTitle(), addSettingField(), addSettingFields(), addSettingSection(), addSettingSections(), addSubMenuLink(), addSubMenuPage(), addSubMenuPages(), enqueueScript(), enqueueScripts(), enqueueStyle(), enqueueStyles(), getFieldValue(), removeSettingFields(), removeSettingSections(), setAdminNotice(), setCapability(), setDisallowedQueryKeys(), setFieldErrors(), setFooterInfoLeft(), setFooterInfoRight(), setSettingNotice(), setUp()

Magic methods summary

Properties summary

Properties inherited from AdminPageFramework_Base

$_aHookPrefixes, $oDebug, $oHeadTag, $oHelpPane, $oLink, $oMsg, $oPageLoadInfo, $oProp, $oUtil

Admin Page Framework Documentation API documentation generated by ApiGen 2.8.0