diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index a124d084ad..8d7b6c0961 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -147,10 +147,10 @@ case 'add-category' : // On the Fly $x = new WP_Ajax_Response(); foreach ( $names as $cat_name ) { $cat_name = trim($cat_name); - if ( !$category_nicename = sanitize_title($cat_name) ) - die('0'); - if ( !$cat_id = category_exists( $cat_name ) ) - $cat_id = wp_create_category( $cat_name ); + $category_nicename = sanitize_title($cat_name); + if ( '' === $category_nicename ) + continue; + $cat_id = wp_create_category( $cat_name ); $cat_name = wp_specialchars(stripslashes($cat_name)); $x->add( array( 'what' => 'category', @@ -169,8 +169,9 @@ case 'add-link-category' : // On the Fly $x = new WP_Ajax_Response(); foreach ( $names as $cat_name ) { $cat_name = trim($cat_name); - if ( !$slug = sanitize_title($cat_name) ) - die('0'); + $slug = sanitize_title($cat_name); + if ( '' === $slug ) + continue; if ( !$cat_id = is_term( $cat_name, 'link_category' ) ) { $cat_id = wp_insert_term( $cat_name, 'link_category' ); } @@ -189,6 +190,15 @@ case 'add-cat' : // From Manage->Categories check_ajax_referer( 'add-category' ); if ( !current_user_can( 'manage_categories' ) ) die('-1'); + + if ( '' === trim($_POST['cat_name']) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'cat', + 'id' => new WP_Error( 'cat_name', __('You did not enter a category name.') ) + ) ); + $x->send(); + } + if ( !$cat = wp_insert_category( $_POST ) ) die('0'); if ( !$cat = get_category( $cat ) ) @@ -216,6 +226,14 @@ case 'add-link-cat' : // From Blogroll -> Categories if ( !current_user_can( 'manage_categories' ) ) die('-1'); + if ( '' === trim($_POST['name']) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'link-cat', + 'id' => new WP_Error( 'name', __('You did not enter a category name.') ) + ) ); + $x->send(); + } + $r = wp_insert_term($_POST['name'], 'link_category', $_POST ); if ( is_wp_error( $r ) ) { $x = new WP_AJAX_Response( array( @@ -270,6 +288,8 @@ case 'add-meta' : if ( isset($_POST['addmeta']) ) { if ( !current_user_can( 'edit_post', $pid ) ) die('-1'); + if ( '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) ) + die('1'); if ( $pid < 0 ) { $now = current_time('timestamp', 1); if ( $pid = wp_insert_post( array( @@ -334,9 +354,11 @@ case 'add-user' : if ( !$user_id = add_user() ) die('0'); elseif ( is_wp_error( $user_id ) ) { - foreach( $user_id->get_error_messages() as $message ) - echo "

$message

"; - exit; + $x = new WP_Ajax_Response( array( + 'what' => 'user', + 'id' => $user_id + ) ); + $x->send(); } $user_object = new WP_User( $user_id ); diff --git a/wp-admin/edit-category-form.php b/wp-admin/edit-category-form.php index 7e8a8d5ce4..d99044f4d1 100644 --- a/wp-admin/edit-category-form.php +++ b/wp-admin/edit-category-form.php @@ -24,21 +24,21 @@ if ( ! empty($cat_ID) ) { - + - + - + - + diff --git a/wp-admin/edit-link-category-form.php b/wp-admin/edit-link-category-form.php index 4c98152a10..6962dcc889 100644 --- a/wp-admin/edit-link-category-form.php +++ b/wp-admin/edit-link-category-form.php @@ -24,15 +24,15 @@ if ( ! empty($cat_ID) ) {
parent . '&hierarchical=1&show_option_none=' . __('None')); ?>
- + - + - + diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index dd5f49d8f5..519d25eeca 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -82,21 +82,25 @@ function edit_user( $user_id = 0 ) { /* checking the password has been typed twice */ do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 )); - if (!$update ) { - if ( $pass1 == '' || $pass2 == '' ) - $errors->add( 'pass', __( 'ERROR: Please enter your password twice.' )); + if ( $update ) { + if ( empty($pass1) && !empty($pass2) ) + $errors->add( 'pass', __( 'ERROR: You entered your new password only once.' ), array( 'form-field' => 'pass1' ) ); + elseif ( !empty($pass1) && empty($pass2) ) + $errors->add( 'pass', __( 'ERROR: You entered your new password only once.' ), array( 'form-field' => 'pass2' ) ); } else { - if ((empty ( $pass1 ) && !empty ( $pass2 ) ) || (empty ( $pass2 ) && !empty ( $pass1 ) ) ) - $errors->add( 'pass', __( 'ERROR: You entered your new password only once.' )); + if ( empty($pass1) ) + $errors->add( 'pass', __( 'ERROR: Please enter your password.' ), array( 'form-field' => 'pass1' ) ); + elseif ( empty($pass2) ) + $errors->add( 'pass', __( 'ERROR: Please enter your password twice.' ), array( 'form-field' => 'pass2' ) ); } /* Check for "\" in password */ if( strpos( " ".$pass1, "\\" ) ) - $errors->add( 'pass', __( 'ERROR: Passwords may not contain the character "\\".' )); + $errors->add( 'pass', __( 'ERROR: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); /* checking the password has been typed twice the same */ if ( $pass1 != $pass2 ) - $errors->add( 'pass', __( 'ERROR: Please enter the same password in the two password fields.' )); + $errors->add( 'pass', __( 'ERROR: Please enter the same password in the two password fields.' ), array( 'form-field' => 'pass1' ) ); if (!empty ( $pass1 )) $user->user_pass = $pass1; @@ -109,10 +113,10 @@ function edit_user( $user_id = 0 ) { /* checking e-mail address */ if ( empty ( $user->user_email ) ) { - $errors->add( 'user_email', __( 'ERROR: Please enter an e-mail address.' )); + $errors->add( 'user_email', __( 'ERROR: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); } else if (!is_email( $user->user_email ) ) { - $errors->add( 'user_email', __( "ERROR: The e-mail address isn't correct." )); + $errors->add( 'user_email', __( "ERROR: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) ); } if ( $errors->get_error_codes() ) diff --git a/wp-admin/js/cat.js b/wp-admin/js/cat.js index 9cb81cf26b..4a64994adf 100644 --- a/wp-admin/js/cat.js +++ b/wp-admin/js/cat.js @@ -1,4 +1,5 @@ jQuery( function($) { + var myConfirm = function() { return '' !== $('#newcat').val(); }; $('#jaxcat').prepend('' + catL10n.how + '') - var a = $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response' } ); + $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response', confirm: myConfirm } ); } ); diff --git a/wp-admin/users.php b/wp-admin/users.php index 59653068dd..ba604a75b1 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -454,34 +454,34 @@ foreach ( (array) $roleclass as $user_object ) { if ( get_option('users_can_register') ) echo '

' . sprintf(__('Users can register themselves or you can manually create users here.'), get_option('siteurl').'/wp-register.php') . '

'; else - echo '

' . sprintf(__('Users cannot currently register themselves, but you can manually create users here.'), get_option('siteurl').'/wp-admin/options-general.php#users_can_register') . '

'; + echo '

' . sprintf(__('Users cannot currently register themselves, but you can manually create users here.'), get_option('siteurl').'/wp-admin/options-general.php#users_can_register') . '

'; ?>
- + - + - + - + - + - + - +

@@ -489,7 +489,7 @@ foreach ( (array) $roleclass as $user_object ) {