includes/class-freemius.php
private function order_sub_submenu_items() {
            global $submenu;

            $menu_slug = $this->_menu->get_top_level_menu_slug();

            /**
             * Before "admin_menu" fires, WordPress will loop over the default submenus and remove pages for which the user
             * does not have permissions. So in case a plugin does not have top-level menu but does have submenus under any
             * of the default menus, only users that have the right role can access its sub-submenus (Account, Contact Us,
             * Support Forum, etc.) since $submenu[ $menu_slug ] will be empty if the user doesn't have permission.
             *
             * In case a plugin does not have submenus under any of the default menus but does have submenus under the menu
             * of another plugin, only users that have the right role can access its sub-submenus since we will use the
             * capability needed to access the parent menu as the capability for the submenus that we will add.
             */
            if ( empty( $submenu[ $menu_slug ] ) ) {
                return;
            }

            $top_level_menu = &$submenu[ $menu_slug ];

            $all_submenu_items_after = array();

            $found_submenu_item = false;

            foreach ( $top_level_menu as $submenu_id => $meta ) {
                if ( $found_submenu_item ) {
                    // Remove all submenu items after the plugin's submenu item.
                    $all_submenu_items_after[] = $meta;
                    unset( $top_level_menu[ $submenu_id ] );
                }

                if ( $this->_menu->get_raw_slug() === $meta[2] ) {
                    // Found the submenu item, put all below.
                    $found_submenu_item = true;
                    continue;
                }
            }

            // Embed all plugin's new submenu items.
            $this->embed_submenu_items();

            // Start with specially high number to make sure it's appended.
            $i = max( 10000, max( array_keys( $top_level_menu ) ) + 1 );
            foreach ( $all_submenu_items_after as $meta ) {
                $top_level_menu[ $i ] = $meta;
                $i ++;
            }

            // Sort submenu items.
            ksort( $top_level_menu );
        }
private function order_sub_submenu_items() {
            global $submenu;

            $menu_slug = $this->_menu->get_top_level_menu_slug();

            /**
             * Before "admin_menu" fires, WordPress will loop over the default submenus and remove pages for which the user
             * does not have permissions. So in case a plugin does not have top-level menu but does have submenus under any
             * of the default menus, only users that have the right role can access its sub-submenus (Account, Contact Us,
             * Support Forum, etc.) since $submenu[ $menu_slug ] will be empty if the user doesn't have permission.
             *
             * In case a plugin does not have submenus under any of the default menus but does have submenus under the menu
             * of another plugin, only users that have the right role can access its sub-submenus since we will use the
             * capability needed to access the parent menu as the capability for the submenus that we will add.
             */
            if ( empty( $submenu[ $menu_slug ] ) ) {
                return;
            }

            $top_level_menu = &$submenu[ $menu_slug ];

            $all_submenu_items_after = array();

            $found_submenu_item = false;

            foreach ( $top_level_menu as $submenu_id => $meta ) {
                if ( $found_submenu_item ) {
                    // Remove all submenu items after the plugin's submenu item.
                    $all_submenu_items_after[] = $meta;
                    unset( $top_level_menu[ $submenu_id ] );
                }

                if ( $this->_menu->get_raw_slug() === $meta[2] ) {
                    // Found the submenu item, put all below.
                    $found_submenu_item = true;
                    continue;
                }
            }

            // Embed all plugin's new submenu items.
            $this->embed_submenu_items();

            // Start with specially high number to make sure it's appended.
            $i = max( 10000, max( array_keys( $top_level_menu ) ) + 1 );
            foreach ( $all_submenu_items_after as $meta ) {
                $top_level_menu[ $i ] = $meta;
                $i ++;
            }

            // Sort submenu items.
            ksort( $top_level_menu );
        }
private function order_sub_submenu_items ( ) { global $ submenu ; $ menu_slug = $ this -> _menu -> get_top_level_menu_slug ( ) ; /**
             * Before "admin_menu" fires, WordPress will loop over the default submenus and remove pages for which the user
             * does not have permissions. So in case a plugin does not have top-level menu but does have submenus under any
             * of the default menus, only users that have the right role can access its sub-submenus (Account, Contact Us,
             * Support Forum, etc.) since $submenu[ $menu_slug ] will be empty if the user doesn't have permission.
             *
             * In case a plugin does not have submenus under any of the default menus but does have submenus under the menu
             * of another plugin, only users that have the right role can access its sub-submenus since we will use the
             * capability needed to access the parent menu as the capability for the submenus that we will add.
             */ if ( empty ( $ submenu [ $ menu_slug ] ) ) { return ; } $ top_level_menu = & $ submenu [ $ menu_slug ] ; $ all_submenu_items_after = array ( ) ; $ found_submenu_item = false ; foreach ( $ top_level_menu as $ submenu_id => $ meta ) { if ( $ found_submenu_item ) { // Remove all submenu items after the plugin's submenu item.
 $ all_submenu_items_after [ ] = $ meta ; unset ( $ top_level_menu [ $ submenu_id ] ) ; } if ( $ this -> _menu -> get_raw_slug ( ) === $ meta [ 2 ] ) { // Found the submenu item, put all below.
 $ found_submenu_item = true ; continue ; } } // Embed all plugin's new submenu items.
 $ this -> embed_submenu_items ( ) ; // Start with specially high number to make sure it's appended.
 $ i = max ( 10000 , max ( array_keys ( $ top_level_menu ) ) + 1 ) ; foreach ( $ all_submenu_items_after as $ meta ) { $ top_level_menu [ $ i ] = $ meta ; $ i ++ ; } // Sort submenu items.
 ksort ( $ top_level_menu ) ; }
Re-order the submenu items so all Freemius added new submenu items
are added right after the plugin's settings submenu item.

@author Vova Feldman (@svovaf)
@since  1.1.4
Re - order the submenu items so all Freemius added new submenu items are added right after the plugin s settings submenu item .