Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#60695 new defect (bug)

Links in the admin-menu are generated incorrectly for mu-plugins

Reported by: partiellkorrekt's profile partiellkorrekt Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

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
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
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.

Change History (1)

This ticket was mentioned in PR #6227 on WordPress/wordpress-develop by partiellkorrekt.


3 months ago
#1

  • Keywords has-patch added

Checks the WPMU_PLUGIN_DIR in the same way WP_PLUGIN_DIR is being checked when generating admin-menus. Thus making a plugin in mu-plugins behave in exactly the same way as a plugin in plugins would.

Note: See TracTickets for help on using tickets.