WordPress.org

Make WordPress Core

Changeset 14645


Ignore:
Timestamp:
05/14/2010 08:06:50 PM (8 years ago)
Author:
ryan
Message:

Add wp_edit_nav_menu_walker filter for specifying a custom edit nav menu walker. Props filosofo. fixes #13342

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/nav-menu.php

    r14638 r14645  
    963963
    964964/**
    965  * Returns the menu item formatted to edit.
    966  *
    967  * @since 3.0.0
    968  *
    969  * @param string $menu_item_id The ID of the menu item to format.
     965 * Returns the menu formatted to edit.
     966 *
     967 * @since 3.0.0
     968 *
     969 * @param string $menu_id The ID of the menu to format.
    970970 * @return string|WP_Error $output The menu formatted to edit or error object on failure.
    971971 */
    972 function wp_get_nav_menu_to_edit( $menu_item_id = 0 ) {
    973     $menu = wp_get_nav_menu_object( $menu_item_id );
     972function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
     973    $menu = wp_get_nav_menu_object( $menu_id );
    974974
    975975    // If the menu exists, get its items.
     
    977977        $menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') );
    978978
    979         $walker = new Walker_Nav_Menu_Edit;
     979        $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
     980
     981        if ( class_exists( $walker_class_name ) )
     982            $walker = new $walker_class_name;
     983        else
     984            return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) );
    980985
    981986        return walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
Note: See TracChangeset for help on using the changeset viewer.