[wp-trac] [WordPress Trac] #60695: Links in the admin-menu are generated incorrectly for mu-plugins

WordPress Trac noreply at wordpress.org
Tue Mar 5 15:27:57 UTC 2024


#60695: Links in the admin-menu are generated incorrectly for mu-plugins
-----------------------------+-----------------------------
 Reporter:  partiellkorrekt  |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Administration   |    Version:
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 The function _wp_menu_output in wp-admin/menu-header.php checks if a file
 exists in the WordPress plugin directory. But it never checks if the file
 exists in the mu-plugins directory.

 The result of this is that some plugins behave in an unexpected way when
 moved to mu-plugins. Especially their admin-menus stop working. One
 example of such a plugin is WPML.

 E.g. lines 165-175:
 {{{#!php
 <?php
 if (
   !empty($menu_hook)
   || (('index.php' !== $submenu_items[0][2])
     && file_exists(WP_PLUGIN_DIR . "/$menu_file")
     && !file_exists(ABSPATH . "/wp-admin/$menu_file"))
 ) {
   $admin_is_parent = true;
   echo "<a href='admin.php?page={$submenu_items[0][2]}'$class
 $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style
 aria-hidden='true'>$img</div><div class='wp-menu-name'>$title</div></a>";
 } else {
   echo "\n\t<a href='{$submenu_items[0][2]}'$class
 $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style
 aria-hidden='true'>$img</div><div class='wp-menu-name'>$title</div></a>";
 }
 }}}

 Better would be:
 {{{#!php
 <?php
 if (
   !empty($menu_hook)
   || (('index.php' !== $submenu_items[0][2])
     && (file_exists(WP_PLUGIN_DIR . "/$menu_file") ||
 file_exists(WPMU_PLUGIN_DIR . "/$menu_file"))
     && !file_exists(ABSPATH . "/wp-admin/$menu_file"))
 ) {
   $admin_is_parent = true;
   echo "<a href='admin.php?page={$submenu_items[0][2]}'$class
 $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style
 aria-hidden='true'>$img</div><div class='wp-menu-name'>$title</div></a>";
 } else {
   echo "\n\t<a href='{$submenu_items[0][2]}'$class
 $aria_attributes>$arrow<div class='wp-menu-image$img_class'$img_style
 aria-hidden='true'>$img</div><div class='wp-menu-name'>$title</div></a>";
 }
 }}}

 Not how the code in the 5th line only checks for WP_PLUGIN_DIR and not for
 WPMU_PLUGIN_DIR. This happens a few more times in this function.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60695>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list