PHP 클래스 WPDKMenu

## Overview $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(); ## WPDK Sample * https://github.com/wpXtreme/wpdk-sample-menu
저자: =undo= ([email protected])
파일 보기 프로젝트 열기: wpxtreme/wpdk 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$capability string Minumun capabilty require to display this menu
$hookName string WorkPress hook name - returned from add_menu_page()
$icon string The url to the icon to be used for this menu.
$id string Unique menu ID
$menuTitle string The top level menu title
$position integer The position in the menu order this one should appear
$subMenus array An array with the sub menus list

공개 메소드들

메소드 설명
__construct ( string $id, string $menu_title, string $capability = self::DEFAULT_CAPABILITY, string $icon = '', integer $position = null ) : WPDKMenu Create an instance of WPDKMenu class
addDivider ( string $title = '' ) : WPDKSubMenu Add a special submenu as separator
addSubMenu ( string $menu_title, string $view_controller, string $capability = WPDKMenu::DEFAULT_CAPABILITY ) : WPDKSubMenu Return an instance of WPDKSubMenu after add a sub menu to this main menu
addSubMenuAt ( array &$menus, array $menu_item, integer $index ) : array Add a submenu item at index position into the $menus array,
addSubMenusAt ( array &$menus, array $submenus, integer $index ) : mixed Recursive version of self::addSubMenuAt()
hook ( string $view_controller ) : string Return the hook id for a view controller
isPageWithMenu ( string $id ) : boolean Return TRUE if the displayed page is the view controller
menu ( string | array $view_controller ) : array Return the WPDK menu info by name of view controller of submenu item
page ( string $view_controller ) : string Return the page id for a view controller
render ( ) Register this menu tree to WordPress menu
renderByArray ( array $menus ) : array Return an array with WPDKMenu instance as render a menu from an array
sanitizeViewController ( string | array $view_controller ) : string Return a sanitize view controller for a callable
url ( string $view_controller ) : string Return the compute URL of menu item from view controller name

메소드 상세

__construct() 공개 메소드

Create an instance of WPDKMenu class
public __construct ( string $id, string $menu_title, string $capability = self::DEFAULT_CAPABILITY, string $icon = '', integer $position = null ) : WPDKMenu
$id string menu unique string id
$menu_title string The menu title
$capability string Optional. Minimun capabilties to show this item. Default WPDKMenu::DEFAULT_CAPABILITY
$icon string 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.
$position integer Optional. The position in the menu order this one should appear
리턴 WPDKMenu

addDivider() 공개 메소드

Add a special submenu as separator
public addDivider ( string $title = '' ) : WPDKSubMenu
$title string
리턴 WPDKSubMenu

addSubMenu() 공개 메소드

Return an instance of WPDKSubMenu after add a sub menu to this main menu
public addSubMenu ( string $menu_title, string $view_controller, string $capability = WPDKMenu::DEFAULT_CAPABILITY ) : WPDKSubMenu
$menu_title string Menu title
$view_controller string Name of view controller
$capability string Optional. Minimun capabilties to show this item. Default WPDKMenu::DEFAULT_CAPABILITY
리턴 WPDKSubMenu

addSubMenuAt() 공개 정적인 메소드

### Sample $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 );
public static addSubMenuAt ( array &$menus, array $menu_item, integer $index ) : array
$menus array Array menu used in WPDKMenu::renderByArray() method
$menu_item array Single new array to add
$index integer Start position from the first menu item (zero base).
리턴 array

addSubMenusAt() 공개 정적인 메소드

$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 );
부터: 1.3.1
public static addSubMenusAt ( array &$menus, array $submenus, integer $index ) : mixed
$menus array Array menu used in WPDKMenu::renderByArray() method
$submenus array Array of new menu
$index integer Start position from the first menu item (zero base).
리턴 mixed

hook() 공개 정적인 메소드

Return the hook id for a view controller
부터: 1.2.0
public static hook ( string $view_controller ) : string
$view_controller string Class name of view controller
리턴 string

isPageWithMenu() 공개 정적인 메소드

Return TRUE if the displayed page is the view controller
부터: 1.2.0
public static isPageWithMenu ( string $id ) : boolean
$id string The menu id
리턴 boolean

menu() 공개 정적인 메소드

Return the WPDK menu info by name of view controller of submenu item
public static menu ( string | array $view_controller ) : array
$view_controller string | array Any callable or view controller class name
리턴 array

page() 공개 정적인 메소드

Return the page id for a view controller
부터: 1.2.0
public static page ( string $view_controller ) : string
$view_controller string Class name of view controller
리턴 string

render() 공개 메소드

Register this menu tree to WordPress menu
public render ( )

renderByArray() 공개 정적인 메소드

$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', ), ) ) );
public static renderByArray ( array $menus ) : array
$menus array A key value pairs array with the list of menu
리턴 array

sanitizeViewController() 공개 정적인 메소드

Return a sanitize view controller for a callable
public static sanitizeViewController ( string | array $view_controller ) : string
$view_controller string | array Callable
리턴 string

url() 공개 정적인 메소드

Return the compute URL of menu item from view controller name
public static url ( string $view_controller ) : string
$view_controller string Class name of view controller
리턴 string

프로퍼티 상세

$capability 공개적으로 프로퍼티

Minumun capabilty require to display this menu
public string $capability
리턴 string

$hookName 공개적으로 프로퍼티

WorkPress hook name - returned from add_menu_page()
public string $hookName
리턴 string

$icon 공개적으로 프로퍼티

The url to the icon to be used for this menu.
public string $icon
리턴 string

$id 공개적으로 프로퍼티

Unique menu ID
public string $id
리턴 string

$menuTitle 공개적으로 프로퍼티

The top level menu title
public string $menuTitle
리턴 string

$position 공개적으로 프로퍼티

The position in the menu order this one should appear
public int $position
리턴 integer

$subMenus 공개적으로 프로퍼티

An array with the sub menus list
public array $subMenus
리턴 array