- // Move .updated and .error alert boxes. Don't move boxes designed to be inline.
- $('div.wrap h2:first').nextAll('div.updated, div.error').addClass('below-h2');
- $('div.updated, div.error').not('.below-h2, .inline').insertAfter( $('div.wrap h2:first') );
+ /*
+ * The `.below-h2` class is here just for backwards compatibility with plugins
+ * that are (incorrectly) using it. Do not use. Use `.inline` instead. See #34570.
+ */
+ $( 'div.updated, div.error, div.notice' ).not( '.inline, .below-h2' ).insertAfter( $( '.wrap h1, .wrap h2' ).first() );
+
+ // Make notices dismissible
+ function makeNoticesDismissible() {
+ $( '.notice.is-dismissible' ).each( function() {
+ var $el = $( this ),
+ $button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ),
+ btnText = commonL10n.dismiss || '';
+
+ // Ensure plain text
+ $button.find( '.screen-reader-text' ).text( btnText );
+ $button.on( 'click.wp-dismiss-notice', function( event ) {
+ event.preventDefault();
+ $el.fadeTo( 100, 0, function() {
+ $el.slideUp( 100, function() {
+ $el.remove();
+ });
+ });
+ });
+
+ $el.append( $button );
+ });
+ }
+
+ $document.on( 'wp-plugin-update-error', function() {
+ makeNoticesDismissible();
+ });