WordPress.org

Make WordPress Core

Ticket #3799: 3799.diff

File 3799.diff, 2.3 KB (added by mdawaffe, 10 years ago)
  • wp-includes/js/wp-ajax-response.js

     
    5050                else if ( 0 === x ) { return !re.html('<div class="error"><p>' + this.broken  + '</p></div>'); }
    5151                return true;
    5252        },
     53        invalidateForm: function ( selector ) {
     54                return jQuery( selector ).addClass( 'form-invalid' ).change( function() { jQuery(this).removeClass( 'form-invalid' ); } );
     55        },
    5356        validateForm: function( selector ) {
    5457                selector = jQuery( selector );
    55                 return !selector.find('.form-required').andSelf().filter('.form-required:has(:input[value=""]), .form-required:input[value=""]').addClass( 'form-invalid' ).change( function() { jQuery(this).removeClass( 'form-invalid' ); } ).size();
     58                return !wpAjax.invalidateForm( selector.find('.form-required').andSelf().filter('.form-required:has(:input[value=""]), .form-required:input[value=""]') ).size();
    5659        }
    5760}, wpAjax || { noPerm: 'You do not have permission to do that.', broken: 'AJAX is teh b0rked.' } );
  • wp-includes/script-loader.php

     
    4141
    4242                $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
    4343
    44                 $this->add( 'wp-ajax-response', '/wp-includes/js/wp-ajax-response.js', array('jquery'), '20080312' );
     44                $this->add( 'wp-ajax-response', '/wp-includes/js/wp-ajax-response.js', array('jquery'), '20080316' );
    4545                $this->localize( 'wp-ajax-response', 'wpAjax', array(
    4646                        'noPerm' => 'You do not have permission to do that.',
    4747                        'broken' => 'AJAX is teh b0rked.'
  • wp-admin/admin-ajax.php

     
    246246                $x->send();
    247247        }
    248248
     249        if ( category_exists( trim( $_POST['cat_name'] ) ) ) {
     250                $x = new WP_Ajax_Response( array(
     251                        'what' => 'cat',
     252                        'id' => new WP_Error( 'cat_exists', __('The category you are trying to create already exists.'), array( 'form-field' => 'cat_name' ) ),
     253                ) );
     254                $x->send();
     255        }
     256       
    249257        $cat = wp_insert_category( $_POST, true );
    250258
    251259        if ( is_wp_error($cat) ) {