menu_page = new AMP_Options_Menu_Page(); $this->menu_slug = 'amp-plugin-options'; } public function init() { add_action( 'admin_post_amp_analytics_options', 'AMP_Options_Manager::handle_analytics_submit' ); add_action( 'admin_menu', array( $this, 'add_menu_items' ) ); } public function add_menu_items() { add_menu_page( __( 'AMP Options', 'amp' ), __( 'AMP', 'amp' ), 'manage_options', $this->menu_slug, array( $this->menu_page, 'render' ), self::ICON_BASE64_SVG ); $submenus = array( new AMP_Analytics_Options_Submenu( $this->menu_slug ), ); // Create submenu items and calls on the Submenu Page object to render the actual contents of the page. foreach ( $submenus as $submenu ) { $submenu->init( $this->menu_slug ); } $this->remove_toplevel_menu_item(); } // Helper function to avoid having the top-level menu as // the first menu item function remove_toplevel_menu_item() { global $submenu; if ( isset( $submenu['amp-plugin-options'][0] ) ) { unset( $submenu['amp-plugin-options'][0] ); } } }