Make WordPress Core

Changeset 53123


Ignore:
Timestamp:
04/11/2022 04:35:37 AM (2 years ago)
Author:
peterwilsoncc
Message:

Administration: Remove term page check from ajax-response.js.

Replace hard coded check for the term creation page in _enqueues/lib/ajax-response.js with a check for a notification to display in the AJAX response data.

Follow up to [52170], [52672].

Props SergeyBiryukov, ryokuhi, johnregan3, sabernhardt, joedolson.
Fixes #55078.
See #54955.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r52672 r53123  
    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 = '', successmsg = '';
     21        var parsed = {}, re = jQuery('#' + r).empty(), err = '', noticeMessage = '';
    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                 if ( jQuery( 'body' ).hasClass( 'edit-tags-php' ) ) {
    31                     successmsg += response.data;
    32                 }
    3330                response.supplemental = {};
    3431                if ( !jQuery( 'supplemental', child ).children().each( function() {
     32
     33                    if ( this.nodeName === 'notice' ) {
     34                        noticeMessage += jQuery(this).text();
     35                        return;
     36                    }
     37
    3538                    response.supplemental[this.nodeName] = jQuery(this).text();
    3639                } ).length ) { response.supplemental = false; }
     
    5356                re.html( '<div class="error">' + err + '</div>' );
    5457                wp.a11y.speak( err );
    55             } else if ( successmsg.length ) {
    56                 re.html( '<div class="updated notice is-dismissible"><p>' + successmsg + '</p></div>');
     58            } else if ( noticeMessage.length ) {
     59                re.html( '<div class="updated notice is-dismissible"><p>' + noticeMessage + '</p></div>');
    5760                jQuery(document).trigger( 'wp-updates-notice-added' );
    58                 wp.a11y.speak( successmsg );
     61                wp.a11y.speak( noticeMessage );
    5962            }
    6063            return parsed;
  • trunk/src/wp-admin/includes/ajax-actions.php

    r53089 r53123  
    11221122            'what'         => 'taxonomy',
    11231123            'data'         => $message,
    1124             'supplemental' => compact( 'parents', 'noparents' ),
     1124            'supplemental' => array(
     1125                'parents'   => $parents,
     1126                'noparents' => $noparents,
     1127                'notice'    => $message,
     1128            ),
    11251129        )
    11261130    );
Note: See TracChangeset for help on using the changeset viewer.