@@ -30,7 +30,9 @@ public static function getUpdatedCpNavItems(array $cpNavItems): array
3030 // get the nav items of the plugins with cp sections from the $cpNavItems based on the $pluginsWithCpSections matching the url to the plugin handle
3131 $ cpNavOldPluginNavItems = array_filter ($ cpNavItems , static function ($ navItem ) use ($ pluginsWithCpSections ) {
3232 foreach ($ pluginsWithCpSections as $ plugin ) {
33- if ($ navItem ['url ' ] === $ plugin ->handle ) {
33+ $ cpNavItem = $ plugin ->getCpNavItem ();
34+ $ pluginNavItemUrl = $ cpNavItem ['url ' ] ?? null ;
35+ if ($ navItem ['url ' ] === $ pluginNavItemUrl ) {
3436 return true ;
3537 }
3638 }
@@ -110,7 +112,9 @@ public static function getUpdatedCpNavItems(array $cpNavItems): array
110112 // Remove all the Sprout Plugin hasCpSection nav items
111113 $ newCpNavItems = array_filter ($ cpNavItems , static function ($ navItem ) use ($ pluginsWithCpSections ) {
112114 foreach ($ pluginsWithCpSections as $ plugin ) {
113- if ($ navItem ['url ' ] === $ plugin ->handle ) {
115+ $ cpNavItem = $ plugin ->getCpNavItem ();
116+ $ pluginNavItemUrl = $ cpNavItem ['url ' ] ?? null ;
117+ if ($ navItem ['url ' ] === $ pluginNavItemUrl ) {
114118 return false ;
115119 }
116120 }
@@ -119,8 +123,10 @@ public static function getUpdatedCpNavItems(array $cpNavItems): array
119123 });
120124
121125 // If no other plugins are installed and no modules are enabled, this will be the Sprout plugin and just get removed later
122- $ cpNavFirstPluginItemKey = array_key_first ($ pluginsWithCpSections );
123- $ cpNavFirstPluginItemIndex = Collection::make ($ cpNavItems )->search (fn (array $ item ) => $ item ['url ' ] === $ cpNavFirstPluginItemKey );
126+ $ firstPlugin = reset ($ pluginsWithCpSections );
127+ $ firstCpNavItem = $ firstPlugin ->getCpNavItem ();
128+ $ firstPluginNavItemUrl = $ firstCpNavItem ['url ' ] ?? null ;
129+ $ cpNavFirstPluginItemIndex = Collection::make ($ cpNavItems )->search (fn (array $ item ) => $ item ['url ' ] === $ firstPluginNavItemUrl );
124130
125131 // If we don't find any plugins with CP sections (a Sprout Plugin should always be there), we'll just add the Sprout Modules to the end of the nav
126132 if ($ cpNavFirstPluginItemIndex === false ) {
0 commit comments