From 5f4f0112a8bc52e14cf2a2bc71561ebec018e65e Mon Sep 17 00:00:00 2001 From: nacin Date: Thu, 10 Jun 2010 15:28:39 +0000 Subject: [PATCH] Server-side check for an empty menu name on save. props ocean90, fixes #13703. git-svn-id: http://svn.automattic.com/wordpress/trunk@15189 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/nav-menus.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wp-admin/nav-menus.php b/wp-admin/nav-menus.php index 9eb00c5849..6e34070706 100644 --- a/wp-admin/nav-menus.php +++ b/wp-admin/nav-menus.php @@ -282,7 +282,7 @@ switch ( $action ) { // Add Menu if ( 0 == $nav_menu_selected_id ) { - $new_menu_title = esc_html( $_POST['menu-name'] ); + $new_menu_title = trim( esc_html( $_POST['menu-name'] ) ); if ( $new_menu_title ) { $_nav_menu_selected_id = wp_update_nav_menu_object( 0, array('menu-name' => $new_menu_title) ); @@ -307,8 +307,14 @@ switch ( $action ) { $_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id ); + $menu_title = trim( esc_html( $_POST['menu-name'] ) ); + if ( ! $menu_title ) { + $messages[] = '

' . __('Please enter a valid menu name.') . '

'; + $menu_title = $_menu_object->name; + } + if ( ! is_wp_error( $_menu_object ) ) { - $_nav_menu_selected_id = wp_update_nav_menu_object( $nav_menu_selected_id, array( 'menu-name' => $_POST['menu-name'] ) ); + $_nav_menu_selected_id = wp_update_nav_menu_object( $nav_menu_selected_id, array( 'menu-name' => $menu_title ) ); if ( is_wp_error( $_nav_menu_selected_id ) ) { $_menu_object = $_nav_menu_selected_id; $messages[] = '

' . $_nav_menu_selected_id->get_error_message() . '

';