WordPress.org

Make WordPress Core

Ticket #13342: allow_custom_menu_editing.13342.diff

File allow_custom_menu_editing.13342.diff, 1.5 KB (added by filosofo, 8 years ago)
  • wp-admin/includes/nav-menu.php

     
    925925}
    926926
    927927/**
    928  * Returns the menu item formatted to edit.
     928 * Returns the menu formatted to edit.
    929929 *
    930930 * @since 3.0.0
    931931 *
    932  * @param string $menu_item_id The ID of the menu item to format.
     932 * @param string $menu_id The ID of the menu to format.
    933933 * @return string|WP_Error $output The menu formatted to edit or error object on failure.
    934934 */
    935 function wp_get_nav_menu_to_edit( $menu_item_id = 0 ) {
    936         $menu = wp_get_nav_menu_object( $menu_item_id );
     935function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
     936        $menu = wp_get_nav_menu_object( $menu_id );
    937937
    938938        // If the menu exists, get its items.
    939939        if ( is_nav_menu( $menu ) ) {
    940940                $menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') );
    941941
    942                 $walker = new Walker_Nav_Menu_Edit;
     942                $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
    943943
     944                if ( class_exists( $walker_class_name ) )
     945                        $walker = new $walker_class_name;
     946                else
     947                        return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) );
     948
    944949                return walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
    945950        } elseif ( is_wp_error( $menu ) ) {
    946951                return $menu;