WPSEO_Base_Menu::register_submenu_page()
Registers a submenu page.
This method will override the capability of the page to automatically use the general manage capability. Use the register_menu_page() method if the submenu page should actually use a different capability.
Метод класса: WPSEO_Base_Menu{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->register_submenu_page( $submenu_page );
- $submenu_page(массив) (обязательный)
Submenu page definition.
-
0(строка)
Parent menu page slug. -
1(строка)
Page title, currently unused. -
2(строка)
Title to display in the menu. -
3(строка)
Required capability to access the page. -
4(строка)
Page slug. -
5(callable)
Callback to run when the page is rendered. - 6(массив)
Optional. List of callbacks to run when the page is loaded.
-
Код WPSEO_Base_Menu::register_submenu_page() WPSEO Base Menu::register submenu page Yoast 22.3
protected function register_submenu_page( $submenu_page ) { $page_title = $submenu_page[2]; // We cannot use $submenu_page[1] because add-ons define that, so hard-code this value. if ( $submenu_page[4] === 'wpseo_licenses' ) { $page_title = $this->get_license_page_title(); } /* * Handle the Google Search Console special case by passing a fake parent * page slug. This way, the sub-page is stil registered and can be accessed * directly. Its menu item won't be displayed. */ if ( $submenu_page[4] === 'wpseo_search_console' ) { // Set the parent page slug to a non-existing one. $submenu_page[0] = 'wpseo_fake_menu_parent_page_slug'; } $page_title .= ' - Yoast SEO'; // Register submenu page. $hook_suffix = add_submenu_page( $submenu_page[0], $page_title, $submenu_page[2], $submenu_page[3], $submenu_page[4], $submenu_page[5] ); // If necessary, add hooks for the submenu page. if ( isset( $submenu_page[6] ) && ( is_array( $submenu_page[6] ) ) ) { $this->add_page_hooks( $hook_suffix, $submenu_page[6] ); } }