Ticket #47690: 47690.diff
File 47690.diff, 2.3 KB (added by , 5 years ago) |
---|
-
src/wp-admin/includes/plugin.php
diff --git src/wp-admin/includes/plugin.php src/wp-admin/includes/plugin.php index a01e104757..365ad547d6 100644
function remove_menu_page( $menu_slug ) { 1670 1670 * 1671 1671 * @global array $submenu 1672 1672 * 1673 * @param string $ menu_slug The slug for the parent menu.1674 * @param string $ submenu_slug The slug of the submenu.1673 * @param string $parent_slug The slug for the parent menu. 1674 * @param string $menu_slug The slug of the submenu. 1675 1675 * @return array|bool The removed submenu on success, false if not found. 1676 1676 */ 1677 function remove_submenu_page( $menu_slug, $submenu_slug ) { 1678 global $submenu; 1677 function remove_submenu_page( $parent_slug, $menu_slug ) { 1678 1679 global $submenu, $_wp_real_parent_file; 1679 1680 1680 if ( ! isset( $submenu[ $menu_slug ] ) ) { 1681 $menu_slug = plugin_basename( $menu_slug ); 1682 $parent_slug = plugin_basename( $parent_slug ); 1683 1684 if ( ! isset( $submenu[ $parent_slug ] ) ) { 1681 1685 return false; 1682 1686 } 1683 1687 1684 foreach ( $submenu[ $menu_slug ] as $i => $item ) { 1685 if ( $submenu_slug == $item[2] ) { 1686 unset( $submenu[ $menu_slug ][ $i ] ); 1687 return $item; 1688 $removed_submenu = null; 1689 1690 foreach ( $submenu[ $parent_slug ] as $i => $item ) { 1691 if ( $menu_slug == $item[2] ) { 1692 1693 unset( $submenu[ $parent_slug ][ $i ] ); 1694 $removed_submenu = $item; 1695 break; 1696 1697 } 1698 } 1699 1700 if ( is_null( $removed_submenu ) ) { 1701 return false; 1702 } 1703 1704 if ( isset( $_wp_real_parent_file[ $parent_slug ] ) ) { 1705 $parent_slug = $_wp_real_parent_file[ $parent_slug ]; 1706 } 1707 1708 if ( isset( $_wp_submenu_nopriv[ $parent_slug ][ $menu_slug ] ) ) { 1709 unset( $_wp_submenu_nopriv[ $parent_slug ][ $menu_slug ] ); 1710 } 1711 1712 $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug ); 1713 1714 // Remove the callback function attached to the submenu. 1715 remove_all_actions( $hookname ); 1716 1717 if ( isset( $_registered_pages[ $hookname ] ) ) { 1718 unset( $_registered_pages[ $hookname ] ); 1719 } 1720 1721 if ( 'tools.php' == $parent_slug ) { 1722 1723 $edit_plugin_page_hook_name = get_plugin_page_hookname( $menu_slug, 'edit.php' ); 1724 1725 if ( isset( $_registered_pages[ $edit_plugin_page_hook_name ] ) ) { 1726 1727 unset( $_registered_pages[ $edit_plugin_page_hook_name ] ); 1728 1688 1729 } 1730 1731 } 1732 1733 if ( isset( $_parent_pages[ $menu_slug ] ) ) { 1734 1735 unset( $_parent_pages[ $menu_slug ] ); 1736 1689 1737 } 1690 1738 1691 1739 return false;