Changeset 6303
- Timestamp:
- 11/01/2007 06:23:16 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r6299 r6303 148 148 foreach ( $names as $cat_name ) { 149 149 $cat_name = trim($cat_name); 150 if ( !$category_nicename = sanitize_title($cat_name) )151 die('0');152 if ( !$cat_id = category_exists( $cat_name ) )153 150 $category_nicename = sanitize_title($cat_name); 151 if ( '' === $category_nicename ) 152 continue; 153 $cat_id = wp_create_category( $cat_name ); 154 154 $cat_name = wp_specialchars(stripslashes($cat_name)); 155 155 $x->add( array( … … 170 170 foreach ( $names as $cat_name ) { 171 171 $cat_name = trim($cat_name); 172 if ( !$slug = sanitize_title($cat_name) ) 173 die('0'); 172 $slug = sanitize_title($cat_name); 173 if ( '' === $slug ) 174 continue; 174 175 if ( !$cat_id = is_term( $cat_name, 'link_category' ) ) { 175 176 $cat_id = wp_insert_term( $cat_name, 'link_category' ); … … 190 191 if ( !current_user_can( 'manage_categories' ) ) 191 192 die('-1'); 193 194 if ( '' === trim($_POST['cat_name']) ) { 195 $x = new WP_Ajax_Response( array( 196 'what' => 'cat', 197 'id' => new WP_Error( 'cat_name', __('You did not enter a category name.') ) 198 ) ); 199 $x->send(); 200 } 201 192 202 if ( !$cat = wp_insert_category( $_POST ) ) 193 203 die('0'); … … 216 226 if ( !current_user_can( 'manage_categories' ) ) 217 227 die('-1'); 228 229 if ( '' === trim($_POST['name']) ) { 230 $x = new WP_Ajax_Response( array( 231 'what' => 'link-cat', 232 'id' => new WP_Error( 'name', __('You did not enter a category name.') ) 233 ) ); 234 $x->send(); 235 } 218 236 219 237 $r = wp_insert_term($_POST['name'], 'link_category', $_POST ); … … 271 289 if ( !current_user_can( 'edit_post', $pid ) ) 272 290 die('-1'); 291 if ( '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) ) 292 die('1'); 273 293 if ( $pid < 0 ) { 274 294 $now = current_time('timestamp', 1); … … 335 355 die('0'); 336 356 elseif ( is_wp_error( $user_id ) ) { 337 foreach( $user_id->get_error_messages() as $message ) 338 echo "<p>$message<p>"; 339 exit; 357 $x = new WP_Ajax_Response( array( 358 'what' => 'user', 359 'id' => $user_id 360 ) ); 361 $x->send(); 340 362 } 341 363 $user_object = new WP_User( $user_id ); -
trunk/wp-admin/edit-category-form.php
r6289 r6303 25 25 <?php wp_nonce_field($nonce_action); ?> 26 26 <table class="editform" width="100%" cellspacing="2" cellpadding="5"> 27 <tr >27 <tr class="form-field form-required"> 28 28 <th width="33%" scope="row" valign="top"><label for="cat_name"><?php _e('Category name:') ?></label></th> 29 29 <td width="67%"><input name="cat_name" id="cat_name" type="text" value="<?php echo attribute_escape($category->name); ?>" size="40" /></td> 30 30 </tr> 31 <tr >31 <tr class="form-field"> 32 32 <th scope="row" valign="top"><label for="category_nicename"><?php _e('Category slug:') ?></label></th> 33 33 <td><input name="category_nicename" id="category_nicename" type="text" value="<?php echo attribute_escape($category->slug); ?>" size="40" /></td> 34 34 </tr> 35 <tr >35 <tr class="form-field"> 36 36 <th scope="row" valign="top"><label for="category_parent"><?php _e('Category parent:') ?></label></th> 37 37 <td> … … 39 39 </td> 40 40 </tr> 41 <tr >41 <tr class="form-field"> 42 42 <th scope="row" valign="top"><label for="category_description"><?php _e('Description: (optional)') ?></label></th> 43 43 <td><textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->description); ?></textarea></td> -
trunk/wp-admin/edit-link-category-form.php
r6299 r6303 25 25 <?php wp_nonce_field($nonce_action); ?> 26 26 <table class="editform" width="100%" cellspacing="2" cellpadding="5"> 27 <tr >27 <tr class="form-field form-required"> 28 28 <th width="33%" scope="row" valign="top"><label for="name"><?php _e('Category name:') ?></label></th> 29 29 <td width="67%"><input name="name" id="name" type="text" value="<?php echo $category->name; ?>" size="40" /></td> 30 30 </tr> 31 <tr >31 <tr class="form-field"> 32 32 <th scope="row" valign="top"><label for="slug"><?php _e('Category slug:') ?></label></th> 33 33 <td><input name="slug" id="slug" type="text" value="<?php echo $category->slug; ?>" size="40" /></td> 34 34 </tr> 35 <tr >35 <tr class="form-field"> 36 36 <th scope="row" valign="top"><label for="description"><?php _e('Description: (optional)') ?></label></th> 37 37 <td><textarea name="description" id="description" rows="5" cols="50" style="width: 97%;"><?php echo $category->description; ?></textarea></td> -
trunk/wp-admin/includes/user.php
r6188 r6303 83 83 do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 )); 84 84 85 if (!$update ) { 86 if ( $pass1 == '' || $pass2 == '' ) 87 $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password twice.' )); 88 } else { 89 if ((empty ( $pass1 ) && !empty ( $pass2 ) ) || (empty ( $pass2 ) && !empty ( $pass1 ) ) ) 90 $errors->add( 'pass', __( '<strong>ERROR</strong>: You entered your new password only once.' )); 85 if ( $update ) { 86 if ( empty($pass1) && !empty($pass2) ) 87 $errors->add( 'pass', __( '<strong>ERROR</strong>: You entered your new password only once.' ), array( 'form-field' => 'pass1' ) ); 88 elseif ( !empty($pass1) && empty($pass2) ) 89 $errors->add( 'pass', __( '<strong>ERROR</strong>: You entered your new password only once.' ), array( 'form-field' => 'pass2' ) ); 90 } else { 91 if ( empty($pass1) ) 92 $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password.' ), array( 'form-field' => 'pass1' ) ); 93 elseif ( empty($pass2) ) 94 $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password twice.' ), array( 'form-field' => 'pass2' ) ); 91 95 } 92 96 93 97 /* Check for "\" in password */ 94 98 if( strpos( " ".$pass1, "\\" ) ) 95 $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ) );99 $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); 96 100 97 101 /* checking the password has been typed twice the same */ 98 102 if ( $pass1 != $pass2 ) 99 $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter the same password in the two password fields.' ) );103 $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter the same password in the two password fields.' ), array( 'form-field' => 'pass1' ) ); 100 104 101 105 if (!empty ( $pass1 )) … … 110 114 /* checking e-mail address */ 111 115 if ( empty ( $user->user_email ) ) { 112 $errors->add( 'user_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.' ) );116 $errors->add( 'user_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); 113 117 } else 114 118 if (!is_email( $user->user_email ) ) { 115 $errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address isn't correct." ) );119 $errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) ); 116 120 } 117 121 -
trunk/wp-admin/js/cat.js
r6213 r6303 1 1 jQuery( function($) { 2 var myConfirm = function() { return '' !== $('#newcat').val(); }; 2 3 $('#jaxcat').prepend('<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" class="add:categorychecklist:jaxcat" id="catadd" value="' + catL10n.add + '"/><input type="hidden"/><input type="hidden"/><span id="howto">' + catL10n.how + '</span></span><span id="cat-ajax-response"></span>') 3 var a = $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response'} );4 $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response', confirm: myConfirm } ); 4 5 } ); -
trunk/wp-admin/users.php
r6213 r6303 455 455 echo '<p>' . sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), get_option('siteurl').'/wp-register.php') . '</p>'; 456 456 else 457 echo '<p>' . sprintf(__('Users cannot currently <a href="%1$s">register themselves</a>, but you can manually create users here.'), get_option('siteurl').'/wp-admin/options-general.php#users_can_register') . '</p>';457 echo '<p>' . sprintf(__('Users cannot currently <a href="%1$s">register themselves</a>, but you can manually create users here.'), get_option('siteurl').'/wp-admin/options-general.php#users_can_register') . '</p>'; 458 458 ?> 459 459 <form action="#add-new-user" method="post" name="adduser" id="adduser" class="add:user-list:"> 460 460 <?php wp_nonce_field('add-user') ?> 461 461 <table class="editform" width="100%" cellspacing="2" cellpadding="5"> 462 <tr >462 <tr class="form-field form-required"> 463 463 <th scope="row" width="33%"><?php _e('Username (required)') ?><input name="action" type="hidden" id="action" value="adduser" /></th> 464 464 <td width="66%"><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" /></td> 465 465 </tr> 466 <tr >466 <tr class="form-field"> 467 467 <th scope="row"><?php _e('First Name') ?> </th> 468 468 <td><input name="first_name" type="text" id="first_name" value="<?php echo $new_user_firstname; ?>" /></td> 469 469 </tr> 470 <tr >470 <tr class="form-field"> 471 471 <th scope="row"><?php _e('Last Name') ?> </th> 472 472 <td><input name="last_name" type="text" id="last_name" value="<?php echo $new_user_lastname; ?>" /></td> 473 473 </tr> 474 <tr >474 <tr class="form-field form-required"> 475 475 <th scope="row"><?php _e('E-mail (required)') ?></th> 476 476 <td><input name="email" type="text" id="email" value="<?php echo $new_user_email; ?>" /></td> 477 477 </tr> 478 <tr >478 <tr class="form-field"> 479 479 <th scope="row"><?php _e('Website') ?></th> 480 480 <td><input name="url" type="text" id="url" value="<?php echo $new_user_uri; ?>" /></td> … … 482 482 483 483 <?php if ( apply_filters('show_password_fields', true) ) : ?> 484 <tr >484 <tr class="form-field form-required"> 485 485 <th scope="row"><?php _e('Password (twice)') ?> </th> 486 486 <td><input name="pass1" type="password" id="pass1" /> … … 490 490 <?php endif; ?> 491 491 492 <tr >492 <tr class="form-field"> 493 493 <th scope="row"><?php _e('Role'); ?></th> 494 494 <td><select name="role" id="role"> -
trunk/wp-admin/wp-admin.css
r6213 r6303 183 183 background: #fff; 184 184 border: 1px solid #686868; 185 } 186 187 .form-invalid { 188 background-color: #FF9999 !important; 185 189 } 186 190 -
trunk/wp-includes/classes.php
r6213 r6303 711 711 712 712 $response = ''; 713 if ( is_wp_error($data) ) 714 foreach ( $data->get_error_codes() as $code ) 713 if ( is_wp_error($data) ) { 714 foreach ( $data->get_error_codes() as $code ) { 715 715 $response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message($code) . "]]></wp_error>"; 716 else 716 if ( !$error_data = $data->get_error_data($code) ) 717 continue; 718 $class = ''; 719 if ( is_object($error_data) ) { 720 $class = ' class="' . get_class($error_data) . '"'; 721 $error_data = get_object_vars($error_data); 722 } 723 724 $response .= "<wp_error_data code='$code'$class>"; 725 726 if ( is_scalar($error_data) ) { 727 $response .= "<![CDATA[$v]]>"; 728 } elseif ( is_array($error_data) ) { 729 foreach ( $error_data as $k => $v ) 730 $response .= "<$k><![CDATA[$v]]></$k>"; 731 } 732 733 $response .= "</wp_error_data>"; 734 } 735 } else { 717 736 $response = "<response_data><![CDATA[$data]]></response_data>"; 737 } 718 738 719 739 $s = ''; -
trunk/wp-includes/js/wp-lists.js
r6287 r6303 14 14 return r; 15 15 }, 16 parseAjaxResponse: function( x, r ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission16 parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission 17 17 var re = $('#' + r).html(''); 18 18 if ( x && typeof x == 'object' && x.getElementsByTagName('wp_ajax') ) { 19 if ( $('wp_error', x).each( function() { re.append('<p>' + this.firstChild.nodeValue + '</p>'); } ).size() ) { 20 return !re.wrap( '<div class="error"></div>' ); 19 var errs = $('wp_error', x); 20 if ( errs.size() ) { 21 var err = ''; 22 errs.each( function() { 23 var code = $(this).attr('code'); 24 if ( formField = $('wp_error_data[@code="' + code + '"] form-field', x).text() ) 25 code = formField; 26 wpAjax.invalidateForm( $('#' + e + ' :input[@name="' + code + '"]' ).parents('.form-field:first') ); 27 err += '<p>' + this.firstChild.nodeValue + '</p>'; 28 } ); 29 return !re.html( '<div class="error">' + err + '</div>' ); 21 30 } 22 31 return true; … … 27 36 else if ( 0 === x ) { return !re.html('<div class="error"><p>AJAX is teh b0rked.</p></div>'); } 28 37 return true; 38 }, 39 invalidateForm: function( jQ ) { 40 jQ.addClass( 'form-invalid' ).change( function() { $(this).removeClass( 'form-invalid' ); } ); 29 41 } 30 42 }; … … 92 104 93 105 var es = $('#' + s.element + ' :input').not('[@name=_ajax_nonce], [@name=_wpnonce], [@name=action]'); 106 var required = $('#' + s.element + ' .form-required:has(:input[@value=""]), #' + s.element + ' .form-required:input[@value=""]'); 107 if ( required.size() ) { 108 wpAjax.invalidateForm( required ); 109 return false; 110 } 111 94 112 s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( cls[4] || '' ) ) ); 95 113 var formData = $.isFunction(es.fieldSerialize) ? es.fieldSerialize() : es.serialize(); … … 103 121 104 122 s.success = function(r) { 105 if ( !wpAjax.parseAjaxResponse(r, s.response ) ) { return false; }123 if ( !wpAjax.parseAjaxResponse(r, s.response, s.element) ) { return false; } 106 124 107 125 $(s.what + ' response_data', r).each( function() { … … 165 183 166 184 s.success = function(r) { 167 if ( !wpAjax.parseAjaxResponse(r, s.response ) ) {185 if ( !wpAjax.parseAjaxResponse(r, s.response, s.element) ) { 168 186 clearTimeout(hideTO); 169 187 func = function() { $('#' + s.element).css( 'background-color', '#FF3333' ).show(); list.wpList.recolor(); }; … … 219 237 220 238 s.success = function(r) { 221 if ( !wpAjax.parseAjaxResponse(r, s.response ) ) {239 if ( !wpAjax.parseAjaxResponse(r, s.response, s.element) ) { 222 240 clearTimeout(dimTO); 223 241 func = function() { $('#' + s.element).css( 'background-color', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass); }; -
trunk/wp-includes/script-loader.php
r6299 r6303 62 62 ) ); 63 63 64 $this->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('jquery'), '20071 023' );64 $this->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('jquery'), '20071101' ); 65 65 $this->localize( 'wp-lists', 'wpListL10n', array( 66 66 'url' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php' … … 111 111 ) ); 112 112 } 113 $this->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '2007 0823' );113 $this->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20071101' ); 114 114 $this->localize( 'ajaxcat', 'catL10n', array( 115 115 'add' => attribute_escape(__('Add')),
Note: See TracChangeset
for help on using the changeset viewer.