Automattic\WooCommerce\Admin\Features\Navigation
Menu::migrate_menu_items() public WC 1.0
Hides all WP admin menus items and adds screen IDs to check for new items.
{} Это метод класса: Menu{}
Хуков нет.
Возвращает
Массив.
Использование
$result = Menu::migrate_menu_items( $menu );
- $menu(массив) (обязательный)
- Menu items.
Код Menu::migrate_menu_items() Menu::migrate menu items WC 5.0.0
public static function migrate_menu_items( $menu ) {
global $submenu;
foreach ( $menu as $key => $menu_item ) {
if ( self::has_callback( $menu_item ) ) {
$menu[ $key ][ self::CSS_CLASSES ] .= ' hide-if-js';
continue;
}
// WordPress core menus make the parent item the same URL as the first child.
$has_children = isset( $submenu[ $menu_item[ self::CALLBACK ] ] ) && isset( $submenu[ $menu_item[ self::CALLBACK ] ][0] );
$first_child = $has_children ? $submenu[ $menu_item[ self::CALLBACK ] ][0] : null;
if ( self::has_callback( $first_child ) ) {
$menu[ $key ][ self::CSS_CLASSES ] .= ' hide-if-js';
}
}
foreach ( $submenu as $parent_key => $parent ) {
foreach ( $parent as $key => $menu_item ) {
if ( self::has_callback( $menu_item ) ) {
// Disable phpcs since we need to override submenu classes.
// Note that `phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited` does not work to disable this check.
// phpcs:disable
if ( ! isset( $menu_item[ self::SLUG ] ) ) {
$submenu[ $parent_key ][ $key ][] = '';
}
if ( ! isset( $menu_item[ self::CSS_CLASSES ] ) ) {
$submenu[ $parent_key ][ $key ][] .= ' hide-if-js';
} else {
$submenu[ $parent_key ][ $key ][ self::CSS_CLASSES ] .= ' hide-if-js';
}
// phps:enable
}
}
}
foreach ( array_keys( self::$callbacks ) as $callback ) {
Screen::add_screen( $callback );
}
return $menu;
}