Make WordPress Core

Changeset 59986


Ignore:
Timestamp:
03/16/2025 04:09:13 PM (5 weeks ago)
Author:
joedolson
Message:

Media: Dismiss button not functional on upload errors.

Change the onclick attribute to a separate inlined script in the error message and improve the event attachment behavior.

Props vivekawsm, mijotj, adamsilverstein, parthvataliya, adhun, sarathar, peterwilsoncc, sayedulsayem, chaion07, sppramodh, indirabiswas27, aishwarryapande, dhrumilk, manojmaharrshi, ugyensupport, imranhasanraaz, pkbhatt, shailu25, joedolson.
Fixes #60074.

Location:
trunk
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/async-upload.php

    r59634 r59986  
    113113$id = media_handle_upload( 'async-upload', $post_id );
    114114if ( is_wp_error( $id ) ) {
    115     $message = sprintf(
     115    $button_unique_id = uniqid( 'dismiss-' );
     116    $message          = sprintf(
    116117        '%s <strong>%s</strong><br />%s',
    117118        sprintf(
    118             '<button type="button" class="dismiss button-link" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">%s</button>',
     119            '<button type="button" id="%s" class="dismiss button-link">%s</button>',
     120            esc_attr( $button_unique_id ),
    119121            __( 'Dismiss' )
    120122        ),
     
    133135        )
    134136    );
     137    echo "<script>jQuery( 'button#{$button_unique_id}' ).on( 'click', function() {jQuery(this).parents('div.media-item').slideUp(200, function(){jQuery(this).remove();})});</script>\n";
    135138    exit;
    136139}
Note: See TracChangeset for help on using the changeset viewer.