WPDK
1.5.0
WordPress Development Kit
|
Public Member Functions | |
__construct ($id, $menu_title, $capability=self::DEFAULT_CAPABILITY, $icon= '', $position=null) | |
Construct. More... | |
addDivider ($title= '') | |
Divider. More... | |
addSubMenu ($menu_title, $view_controller, $capability=WPDKMenu::DEFAULT_CAPABILITY) | |
Add sub menus. More... | |
render () | |
Render. More... | |
Static Public Member Functions | |
static | sanitizeViewController ($view_controller) |
Sanitize. More... | |
static | menu ($view_controller) |
static | url ($view_controller) |
static | hook ($view_controller) |
Hook id. More... | |
static | page ($view_controller) |
Page id. More... | |
static | renderByArray ($menus) |
Render by array. More... | |
static | addSubMenuAt (&$menus, $menu_item, $index) |
Add submenu. More... | |
static | addSubMenusAt (&$menus, $submenus, $index) |
Brief. More... | |
static | isPageWithMenu ($id) |
Check displayed page. More... | |
Data Fields | |
const | DEFAULT_CAPABILITY = 'read' |
Capability. More... | |
const | GLOBAL_MENU = 'wpdk_menus' |
Global key. More... | |
$capability | |
Capability. More... | |
$hookName | |
Hook name. More... | |
$icon | |
Icon. More... | |
$id | |
Menu ID. More... | |
$menuTitle | |
Menu title. More... | |
$position | |
Position. More... | |
$subMenus | |
Sub menus. More... | |
This class is the top level menu model
$menu = new WPDKMenu( 'wpdk-sample-menu', __( 'WPDK Sample', WPXWPDKSAMPLEMENU_TEXTDOMAIN ), self::MENU_CAPABILITY, $icon_menu ); $menu->addSubMenu( __( 'First item' ), 'WPXWPDKSamplemenuViewController' ); $menu->addDivider(); $menu->addSubMenu( __( 'Second item' ), 'WPXWPDKSamplemenuViewController' ); $menu->addSubMenu( __( 'Options' ), 'WPXWPDKSamplemenuViewController' ); $menu->addDivider( 'More' ); $menu->addSubMenu( __( 'About' ), 'WPXWPDKSamplemenuViewController' ); $menu->render();
Definition at line 28 of file wpdk-menu.php.
__construct | ( | $id, | |
$menu_title, | |||
$capability = self::DEFAULT_CAPABILITY , |
|||
$icon = '' , |
|||
$position = null |
|||
) |
Construct.
Create an instance of WPDKMenu class
string | $id | menu unique string id |
string | $menu_title | The menu title |
string | $capability | Optional. Minimun capabilties to show this item. Default WPDKMenu::DEFAULT_CAPABILITY |
string | $icon | Optional. The url to the icon to be used for this menu. Using 'none' would leave div.wp-menu-image empty so an icon can be added as background with CSS. |
int | $position | Optional. The position in the menu order this one should appear |
Definition at line 113 of file wpdk-menu.php.
addDivider | ( | $title = '' | ) |
Divider.
Add a special submenu as separator
string | $title |
Definition at line 320 of file wpdk-menu.php.
addSubMenu | ( | $menu_title, | |
$view_controller, | |||
$capability = WPDKMenu::DEFAULT_CAPABILITY |
|||
) |
Add sub menus.
Return an instance of WPDKSubMenu after add a sub menu to this main menu
string | $menu_title | Menu title |
string | $view_controller | Name of view controller |
string | $capability | Optional. Minimun capabilties to show this item. Default WPDKMenu::DEFAULT_CAPABILITY |
Definition at line 341 of file wpdk-menu.php.
|
static |
Add submenu.
Add a submenu item at index position into the $menus
array,
$menus = array( 'wpx_ras_main' => array( 'menuTitle' => __( 'REST API Server', WPXRESTAPISERVER_TEXTDOMAIN ), 'capability' => self::MENU_CAPABILITY, 'icon' => $icon_menu, 'subMenus' => array( array( 'menuTitle' => __( 'Servers', WPXRESTAPISERVER_TEXTDOMAIN ), 'viewController' => 'WPXRESTAPIServerServersListTableViewController', 'capability' => self::MENU_CAPABILITY, ), WPDKSubMenuDivider::DIVIDER, array( 'menuTitle' => __( 'Preferences' ), 'viewController' => 'WPXRESTAPIServerConfigurationCoreViewController', 'capability' => self::MENU_CAPABILITY, ), array( 'menuTitle' => __( 'About' ), 'capability' => self::MENU_CAPABILITY, 'viewController' => 'WPXRESTAPIServerAboutViewController', ), ) ) ); $new = array( 'menuTitle' => __( 'New Menu' ), 'viewController' => 'WPXRESTAPIServerConfigurationCoreViewController', 'capability' => self::MENU_CAPABILITY, ); WPDKMenu::addSubMenuAt( $menus, $new, 2 ); WPDKMenu::renderByArray( $menus );
array | $menus | Array menu used in WPDKMenu::renderByArray() method |
array | $menu_item | Single new array to add |
int | $index | Start position from the first menu item (zero base). |
Definition at line 426 of file wpdk-menu.php.
|
static |
Brief.
Recursive version of self::addSubMenuAt()
$submenus = array( WPDKSubMenuDivider::DIVIDER, array( 'menuTitle' => __( 'Extensions', WPXTREME_TEXTDOMAIN ), 'capability' => self::MENU_CAPABILITY, 'viewController' => array( $this, 'about' ), ), array( 'menuTitle' => __( 'About', WPXTREME_TEXTDOMAIN ), 'capability' => self::MENU_CAPABILITY, 'viewController' => array( $this, 'about' ), ) ); WPDKMenu::addSubMenusAt( $this->menus, $submenus, -1 );
array | $menus | Array menu used in WPDKMenu::renderByArray() method |
array | $submenus | Array of new menu |
int | $index | Start position from the first menu item (zero base). |
Definition at line 467 of file wpdk-menu.php.
|
static |
Hook id.
Return the hook id for a view controller
string | $view_controller | Class name of view controller |
Definition at line 201 of file wpdk-menu.php.
|
static |
Check displayed page.
Return TRUE if the displayed page is the view controller
string | $id | The menu id |
Definition at line 495 of file wpdk-menu.php.
|
static |
Return the WPDK menu info by name of view controller of submenu item
string | array | $view_controller | Any callable or view controller class name |
Definition at line 152 of file wpdk-menu.php.
|
static |
Page id.
Return the page id for a view controller
string | $view_controller | Class name of view controller |
Definition at line 221 of file wpdk-menu.php.
render | ( | ) |
|
static |
Render by array.
Return an array with WPDKMenu instance as render a menu from an array
$menus = array( 'wpdk-sample-menu' => array( 'menuTitle' => __( 'WPDK Sample', WPXWPDKSAMPLEMENU_TEXTDOMAIN ), 'capability' => self::MENU_CAPABILITY, 'icon' => $icon_menu, 'subMenus' => array( array( 'menuTitle' => __( 'First item' ), 'viewController' => 'WPXWPDKSamplemenuViewController', ), WPDKSubMenuDivider::DIVIDER, array( 'menuTitle' => __( 'Second item' ), 'viewController' => 'WPXWPDKSamplemenuViewController', ), array( 'menuTitle' => __( 'Options' ), 'viewController' => 'WPXWPDKSamplemenuViewController', ), array( WPDKSubMenuDivider::DIVIDER => 'More' ), array( 'menuTitle' => __( 'About' ), 'viewController' => 'WPXWPDKSamplemenuViewController', ), ) ) );
array | $menus | A key value pairs array with the list of menu |
Definition at line 268 of file wpdk-menu.php.
|
static |
Sanitize.
Return a sanitize view controller for a callable
string | array | $view_controller | Callable |
Definition at line 132 of file wpdk-menu.php.
|
static |
Return the compute URL of menu item from view controller name
string | $view_controller | Class name of view controller |
Definition at line 174 of file wpdk-menu.php.
string $capability |
Capability.
Minumun capabilty require to display this menu
Definition at line 49 of file wpdk-menu.php.
string $hookName |
Hook name.
WorkPress hook name - returned from add_menu_page()
Definition at line 57 of file wpdk-menu.php.
string $icon |
string $id |
string $menuTitle |
int $position |
Position.
The position in the menu order this one should appear
Definition at line 89 of file wpdk-menu.php.
array $subMenus |
const DEFAULT_CAPABILITY = 'read' |
const GLOBAL_MENU = 'wpdk_menus' |
Global key.
The global key for access to the wpdk menu list
Definition at line 41 of file wpdk-menu.php.