You appear to be a bot. Output may be restricted
Description
Callback to the admin_menu hook that will register the enqueued menu items
Usage
$void = Admin_Menu::admin_menu_hook_callback();
Parameters
Returns
void
Source
File name: jetpack/jetpack_vendor/automattic/jetpack-admin-ui/src/class-admin-menu.php
Lines:
1 to 62 of 62
public static function admin_menu_hook_callback() { $can_see_toplevel_menu = true; $jetpack_plugin_present = class_exists( 'Jetpack_React_Page' ); if ( ! $jetpack_plugin_present ) { add_action( 'admin_print_scripts', array( __CLASS__, 'enqueue_style' ) ); add_menu_page( 'Jetpack', 'Jetpack', 'read', 'jetpack', '__return_null', 'div', 3 ); // If Jetpack plugin is not present, user will only be able to see this menu if they have enough capability to at least one of the sub menus being added. $can_see_toplevel_menu = false; } /** * The add_sub_menu function has a bug and will not keep the right order of menu items. * * @see https://core.trac.wordpress.org/ticket/52035 * Let's order the items before registering them. * Since this all happens after the Jetpack plugin menu items were added, all items will be added after Jetpack plugin items - unless position is very low number (smaller than the number of menu items present in Jetpack plugin). */ usort( self::$menu_items, function ( $a, $b ) { $position_a = empty( $a['position'] ) ? 0 : $a['position']; $position_b = empty( $b['position'] ) ? 0 : $b['position']; return $position_a - $position_b; } ); foreach ( self::$menu_items as $menu_item ) { if ( ! current_user_can( $menu_item['capability'] ) ) { continue; } $can_see_toplevel_menu = true; add_submenu_page( 'jetpack', $menu_item['page_title'], $menu_item['menu_title'], $menu_item['capability'], $menu_item['menu_slug'], $menu_item['function'], $menu_item['position'] ); } if ( ! $jetpack_plugin_present ) { remove_submenu_page( 'jetpack', 'jetpack' ); } if ( ! $can_see_toplevel_menu ) { remove_menu_page( 'jetpack' ); } }