WordPress.org

Make WordPress Core

Changeset 52170


Ignore:
Timestamp:
11/15/2021 10:23:01 PM (2 weeks ago)
Author:
joedolson
Message:

Taxonomy: Display update notices when adding terms.

Display notice and announce to screen readers when a new term is added.

Props manishamakhija, birgire, dilipbheda, afercia, hellofromTonya.
Fixes #42937.

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/lib/ajax-response.js

    r52169 r52170  
    1919    },
    2020    parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission.
    21         var parsed = {}, re = jQuery('#' + r).empty(), err = '';
     21        var parsed = {}, re = jQuery('#' + r).empty(), err = '', successmsg = '';
    2222
    2323        if ( x && typeof x === 'object' && x.getElementsByTagName('wp_ajax') ) {
     
    2828                response = { action: th.attr('action'), what: child.get(0).nodeName, id: child.attr('id'), oldId: child.attr('old_id'), position: child.attr('position') };
    2929                response.data = jQuery( 'response_data', child ).text();
     30                successmsg += response.data;
    3031                response.supplemental = {};
    3132                if ( !jQuery( 'supplemental', child ).children().each( function() {
     
    4748                parsed.responses.push( response );
    4849            } );
    49             if ( err.length ) { re.html( '<div class="error">' + err + '</div>' ); }
     50            if ( err.length ) {
     51                re.html( '<div class="error">' + err + '</div>' );
     52                wp.a11y.speak( err );
     53            } else {
     54                re.html( '<div class="updated notice is-dismissible"><p>' + successmsg + '</p></div>');
     55                jQuery(document).trigger( 'wp-updates-notice-added' );
     56                wp.a11y.speak( successmsg );
     57            }
    5058            return parsed;
    5159        }
  • trunk/src/wp-admin/includes/ajax-actions.php

    r52169 r52170  
    11031103    $parents = ob_get_clean();
    11041104
     1105    require ABSPATH . 'wp-admin/includes/edit-tag-messages.php';
     1106
     1107    $message = '';
     1108    if ( isset( $messages[ $tax->name ][1] ) ) {
     1109        $message = $messages[ $tax->name ][1];
     1110    } elseif ( isset( $messages['_item'][1] ) ) {
     1111        $message = $messages['_item'][1];
     1112    }
     1113
    11051114    $x->add(
    11061115        array(
    11071116            'what'         => 'taxonomy',
     1117            'data'         => $message,
    11081118            'supplemental' => compact( 'parents', 'noparents' ),
    11091119        )
Note: See TracChangeset for help on using the changeset viewer.