includes/class-freemius.php
private function embed_submenu_items() {
            $item_template = $this->_menu->is_top_level() ?
                '<span class="fs-submenu-item %s %s %s">%s</span>' :
                '<span class="fs-submenu-item fs-sub %s %s %s">%s</span>';

            $top_level_menu_capability = $this->get_top_level_menu_capability();

            ksort( $this->_menu_items );

            $is_first_submenu_item = true;

            foreach ( $this->_menu_items as $priority => $items ) {
                foreach ( $items as $item ) {
                    $capability = ( ! empty( $item['capability'] ) ? $item['capability'] : $top_level_menu_capability );

                    $menu_item = sprintf(
                        $item_template,
                        $this->get_unique_affix(),
                        $item['menu_slug'],
                        ! empty( $item['class'] ) ? $item['class'] : '',
                        $item['menu_title']
                    );

                    $top_level_menu_slug = $this->get_top_level_menu_slug();
                    $menu_slug           = $this->_menu->get_slug( $item['menu_slug'] );

                    if ( ! isset( $item['url'] ) ) {
                        $hook = FS_Admin_Menu_Manager::add_subpage(
                            $item['show_submenu'] ?
                                $top_level_menu_slug :
                                null,
                            $item['page_title'],
                            $menu_item,
                            $capability,
                            $menu_slug,
                            $item['render_function']
                        );

                        if ( false !== $item['before_render_function'] ) {
                            add_action( "load-$hook", $item['before_render_function'] );
                        }
                    } else {
                        FS_Admin_Menu_Manager::add_subpage(
                            $item['show_submenu'] ?
                                $top_level_menu_slug :
                                null,
                            $item['page_title'],
                            $menu_item,
                            $capability,
                            $menu_slug,
                            array( $this, '' )
                        );
                    }

                    if ( $item['show_submenu'] && $is_first_submenu_item ) {
                        if ( $this->_is_network_active && ! empty( $this->_dynamically_added_top_level_page_hook_name ) ) {
                            /**
                             * If the top-level menu has been dynamically created, remove the first submenu item that
                             * WordPress automatically creates when there's no submenu item whose slug matches the
                             * parent's. In the following example, the `Awesome Plugin` submenu item will be removed.
                             *
                             * Awesome Plugin
                             *     - Awesome Plugin <-- we want to remove this since there's no real setting page for the top-level
                             *
                             * @author Leo Fajardo (@leorw)
                             */
                            remove_submenu_page( $top_level_menu_slug, $top_level_menu_slug );
                        }

                        $is_first_submenu_item = false;
                    }
                }
            }
        }
private function embed_submenu_items() {
            $item_template = $this->_menu->is_top_level() ?
                '<span class="fs-submenu-item %s %s %s">%s</span>' :
                '<span class="fs-submenu-item fs-sub %s %s %s">%s</span>';

            $top_level_menu_capability = $this->get_top_level_menu_capability();

            ksort( $this->_menu_items );

            $is_first_submenu_item = true;

            foreach ( $this->_menu_items as $priority => $items ) {
                foreach ( $items as $item ) {
                    $capability = ( ! empty( $item['capability'] ) ? $item['capability'] : $top_level_menu_capability );

                    $menu_item = sprintf(
                        $item_template,
                        $this->get_unique_affix(),
                        $item['menu_slug'],
                        ! empty( $item['class'] ) ? $item['class'] : '',
                        $item['menu_title']
                    );

                    $top_level_menu_slug = $this->get_top_level_menu_slug();
                    $menu_slug           = $this->_menu->get_slug( $item['menu_slug'] );

                    if ( ! isset( $item['url'] ) ) {
                        $hook = FS_Admin_Menu_Manager::add_subpage(
                            $item['show_submenu'] ?
                                $top_level_menu_slug :
                                null,
                            $item['page_title'],
                            $menu_item,
                            $capability,
                            $menu_slug,
                            $item['render_function']
                        );

                        if ( false !== $item['before_render_function'] ) {
                            add_action( "load-$hook", $item['before_render_function'] );
                        }
                    } else {
                        FS_Admin_Menu_Manager::add_subpage(
                            $item['show_submenu'] ?
                                $top_level_menu_slug :
                                null,
                            $item['page_title'],
                            $menu_item,
                            $capability,
                            $menu_slug,
                            array( $this, '' )
                        );
                    }

                    if ( $item['show_submenu'] && $is_first_submenu_item ) {
                        if ( $this->_is_network_active && ! empty( $this->_dynamically_added_top_level_page_hook_name ) ) {
                            /**
                             * If the top-level menu has been dynamically created, remove the first submenu item that
                             * WordPress automatically creates when there's no submenu item whose slug matches the
                             * parent's. In the following example, the `Awesome Plugin` submenu item will be removed.
                             *
                             * Awesome Plugin
                             *     - Awesome Plugin <-- we want to remove this since there's no real setting page for the top-level
                             *
                             * @author Leo Fajardo (@leorw)
                             */
                            remove_submenu_page( $top_level_menu_slug, $top_level_menu_slug );
                        }

                        $is_first_submenu_item = false;
                    }
                }
            }
        }
private function embed_submenu_items ( ) { $ item_template = $ this -> _menu -> is_top_level ( ) ? '<span class="fs-submenu-item %s %s %s">%s</span>' : '<span class="fs-submenu-item fs-sub %s %s %s">%s</span>' ; $ top_level_menu_capability = $ this -> get_top_level_menu_capability ( ) ; ksort ( $ this -> _menu_items ) ; $ is_first_submenu_item = true ; foreach ( $ this -> _menu_items as $ priority => $ items ) { foreach ( $ items as $ item ) { $ capability = ( ! empty ( $ item [ 'capability' ] ) ? $ item [ 'capability' ] : $ top_level_menu_capability ) ; $ menu_item = sprintf ( $ item_template , $ this -> get_unique_affix ( ) , $ item [ 'menu_slug' ] , ! empty ( $ item [ 'class' ] ) ? $ item [ 'class' ] : '' , $ item [ 'menu_title' ] ) ; $ top_level_menu_slug = $ this -> get_top_level_menu_slug ( ) ; $ menu_slug = $ this -> _menu -> get_slug ( $ item [ 'menu_slug' ] ) ; if ( ! isset ( $ item [ 'url' ] ) ) { $ hook = FS_Admin_Menu_Manager :: add_subpage ( $ item [ 'show_submenu' ] ? $ top_level_menu_slug : null , $ item [ 'page_title' ] , $ menu_item , $ capability , $ menu_slug , $ item [ 'render_function' ] ) ; if ( false !== $ item [ 'before_render_function' ] ) { add_action ( "load-$hook" , $ item [ 'before_render_function' ] ) ; } } else { FS_Admin_Menu_Manager :: add_subpage ( $ item [ 'show_submenu' ] ? $ top_level_menu_slug : null , $ item [ 'page_title' ] , $ menu_item , $ capability , $ menu_slug , array ( $ this , '' ) ) ; } if ( $ item [ 'show_submenu' ] && $ is_first_submenu_item ) { if ( $ this -> _is_network_active && ! empty ( $ this -> _dynamically_added_top_level_page_hook_name ) ) { /**
                             * If the top-level menu has been dynamically created, remove the first submenu item that
                             * WordPress automatically creates when there's no submenu item whose slug matches the
                             * parent's. In the following example, the `Awesome Plugin` submenu item will be removed.
                             *
                             * Awesome Plugin
                             *     - Awesome Plugin <-- we want to remove this since there's no real setting page for the top-level
                             *
                             * @author Leo Fajardo (@leorw)
                             */ remove_submenu_page ( $ top_level_menu_slug , $ top_level_menu_slug ) ; } $ is_first_submenu_item = false ; } } } }
Moved the actual submenu item additions to a separated function,
in order to support sub-submenu items when the plugin's settings
only have a submenu and not top-level menu item.

@author Vova Feldman (@svovaf)
@since  1.1.4
Moved the actual submenu item additions to a separated function in order to support sub - submenu items when the plugin s settings only have a submenu and not top - level menu item .