Make WordPress Core

Ticket #47018: 47018.3.diff

File 47018.3.diff, 3.4 KB (added by afercia, 4 years ago)
  • src/js/_enqueues/admin/common.js

     
    497497window.validateForm = function( form ) {
    498498        return !$( form )
    499499                .find( '.form-required' )
    500                 .filter( function() { return $( ':input:visible', this ).val() === ''; } )
     500                .filter( function() { return $( ':input:visible', this ).val().trim() === ''; } )
    501501                .addClass( 'form-invalid' )
    502502                .find( ':input:visible' )
    503503                .on( 'change', function() { $( this ).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } )
  • src/js/_enqueues/admin/tags.js

     
    101101        $('#submit').on( 'click', function(){
    102102                var form = $(this).parents('form');
    103103
    104                 if ( ! validateForm( form ) )
    105                         return false;
    106 
    107104                if ( addingTerm ) {
    108105                        // If we're adding a term, noop the button to avoid duplicate requests.
    109106                        return false;
     
    127124
    128125                        $('#ajax-response').empty();
    129126                        res = wpAjax.parseAjaxResponse( r, 'ajax-response' );
    130                         if ( ! res || res.errors )
     127
     128                        if ( res.errors && res.responses[0].errors[0].code === 'empty_term_name' ) {
     129                                validateForm( form );
     130                        }
     131
     132                        if ( ! res || res.errors ) {
    131133                                return;
     134                        }
    132135
    133136                        parent = form.find( 'select#parent' ).val();
    134137
  • src/wp-admin/css/forms.css

     
    245245.form-invalid.form-required select,
    246246.form-invalid.form-required select:focus {
    247247        border-color: #d63638 !important;
    248         box-shadow: 0 0 2px rgba(214, 54, 56, 0.8);
     248        box-shadow: 0 0 0 1px #d63638;
    249249}
    250250
    251251.form-table .form-required.form-invalid td:after {
  • src/wp-admin/includes/ajax-actions.php

     
    10711071        }
    10721072
    10731073        if ( ! $tag || is_wp_error( $tag ) ) {
    1074                 $message = __( 'An error has occurred. Please reload the page and try again.' );
     1074                $message    = __( 'An error has occurred. Please reload the page and try again.' );
     1075                $error_code = 'error';
    10751076
    10761077                if ( is_wp_error( $tag ) && $tag->get_error_message() ) {
    10771078                        $message = $tag->get_error_message();
    10781079                }
    10791080
     1081                if ( is_wp_error( $tag ) && $tag->get_error_code() ) {
     1082                        $error_code = $tag->get_error_code();
     1083                }
     1084
    10801085                $x->add(
    10811086                        array(
    10821087                                'what' => 'taxonomy',
    1083                                 'data' => new WP_Error( 'error', $message ),
     1088                                'data' => new WP_Error( $error_code, $message ),
    10841089                        )
    10851090                );
    10861091                $x->send();
  • src/wp-includes/script-loader.php

     
    694694
    695695        $scripts->add( 'clipboard', "/wp-includes/js/clipboard$suffix.js", array(), false, 1 );
    696696
    697         $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array( 'jquery' ), false, 1 );
     697        $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
    698698        did_action( 'init' ) && $scripts->localize(
    699699                'wp-ajax-response',
    700700                'wpAjax',