From 25dcb020af652efa2d1a0f0cf3f1e3d566dd2be8 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 14 May 2010 20:06:50 +0000 Subject: [PATCH] Add wp_edit_nav_menu_walker filter for specifying a custom edit nav menu walker. Props filosofo. fixes #13342 git-svn-id: http://svn.automattic.com/wordpress/trunk@14645 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/nav-menu.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-menu.php index 3893438a9a..0dbba3e213 100644 --- a/wp-admin/includes/nav-menu.php +++ b/wp-admin/includes/nav-menu.php @@ -962,21 +962,26 @@ function _wp_nav_menu_meta_box_object( $object = null ) { } /** - * Returns the menu item formatted to edit. + * Returns the menu formatted to edit. * * @since 3.0.0 * - * @param string $menu_item_id The ID of the menu item to format. + * @param string $menu_id The ID of the menu to format. * @return string|WP_Error $output The menu formatted to edit or error object on failure. */ -function wp_get_nav_menu_to_edit( $menu_item_id = 0 ) { - $menu = wp_get_nav_menu_object( $menu_item_id ); +function wp_get_nav_menu_to_edit( $menu_id = 0 ) { + $menu = wp_get_nav_menu_object( $menu_id ); // If the menu exists, get its items. if ( is_nav_menu( $menu ) ) { $menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') ); - $walker = new Walker_Nav_Menu_Edit; + $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id ); + + if ( class_exists( $walker_class_name ) ) + $walker = new $walker_class_name; + else + return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named %s does not exist.'), $walker_class_name ) ); return walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) ); } elseif ( is_wp_error( $menu ) ) {