芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/public_html/wp-content/plugins/elementor/core/admin/menu/admin-menu-manager.php
items[ $item_slug ] = $item; } public function unregister( $item_slug ) { unset( $this->items[ $item_slug ] ); } public function get( $item_slug ) { if ( empty( $this->items[ $item_slug ] ) ) { return null; } return $this->items[ $item_slug ]; } public function get_all() { return $this->items; } public function register_actions() { add_action( 'admin_menu', function () { $this->register_wp_menus(); }, 20 ); add_action( 'admin_head', function () { $this->hide_invisible_menus(); } ); } private function register_wp_menus() { do_action( 'elementor/admin/menu/register', $this ); $hooks = []; foreach ( $this->get_all() as $item_slug => $item ) { $is_top_level = empty( $item->get_parent_slug() ); if ( $is_top_level ) { $hooks[ $item_slug ] = $this->register_top_level_menu( $item_slug, $item ); } else { $hooks[ $item_slug ] = $this->register_sub_menu( $item_slug, $item ); } } do_action( 'elementor/admin/menu/after_register', $this, $hooks ); } private function register_top_level_menu( $item_slug, Admin_Menu_Item $item ) { $has_page = ( $item instanceof Admin_Menu_Item_With_Page ); $has_position = ( $item instanceof Admin_Menu_Item_Has_Position ); $page_title = $has_page ? $item->get_page_title() : ''; $callback = $has_page ? [ $item, 'render' ] : ''; $position = $has_position ? $item->get_position() : null; return add_menu_page( $page_title, $item->get_label(), $item->get_capability(), $item_slug, $callback, '', $position ); } private function register_sub_menu( $item_slug, Admin_Menu_Item $item ) { $has_page = ( $item instanceof Admin_Menu_Item_With_Page ); $page_title = $has_page ? $item->get_page_title() : ''; $callback = $has_page ? [ $item, 'render' ] : ''; return add_submenu_page( $item->get_parent_slug(), $page_title, $item->get_label(), $item->get_capability(), $item_slug, $callback ); } private function hide_invisible_menus() { foreach ( $this->get_all() as $item_slug => $item ) { if ( $item->is_visible() ) { continue; } $is_top_level = empty( $item->get_parent_slug() ); if ( $is_top_level ) { remove_menu_page( $item_slug ); } else { remove_submenu_page( $item->get_parent_slug(), $item_slug ); } } } }