@@ -1109,11 +1109,46 @@ $( function() {
11091109 $button . find ( '.screen-reader-text' ) . text ( __ ( 'Dismiss this notice.' ) ) ;
11101110 $button . on ( 'click.wp-dismiss-notice' , function ( event ) {
11111111 event . preventDefault ( ) ;
1112- $el . fadeTo ( 100 , 0 , function ( ) {
1113- $el . slideUp ( 100 , function ( ) {
1114- $el . remove ( ) ;
1112+
1113+ var $dismiss_data = { action : 'dismiss-notice' } ,
1114+ $slug = $el . data ( 'slug' ) ,
1115+ $expiration = $el . data ( 'expiration' ) ;
1116+
1117+ if ( ! $slug ) {
1118+ $el . fadeTo ( 100 , 0 , function ( ) {
1119+ $el . slideUp ( 100 , function ( ) {
1120+ $el . remove ( ) ;
1121+ } ) ;
11151122 } ) ;
1116- } ) ;
1123+ } else {
1124+ $dismiss_data . slug = $slug ;
1125+
1126+ if ( $expiration ) {
1127+ $dismiss_data . expiration = $expiration ;
1128+ }
1129+
1130+ $ . post (
1131+ ajaxurl ,
1132+ $dismiss_data
1133+ ) . always ( function ( response ) {
1134+ if ( true === response . success ) {
1135+ $el . fadeTo ( 100 , 0 , function ( ) {
1136+ $el . slideUp ( 100 , function ( ) {
1137+ $el . remove ( ) ;
1138+ } ) ;
1139+ } ) ;
1140+ } else {
1141+ var $noticeDismissalFailed = $ ( '#notice-dismissal-failed' ) ;
1142+
1143+ if ( 0 === $noticeDismissalFailed . length ) {
1144+ $el . after ( '<div id="notice-dismissal-failed" class="notice notice-error"><p>' + response . data + '</p></div>' ) ;
1145+ } else {
1146+ $el . after ( $noticeDismissalFailed ) ;
1147+ $noticeDismissalFailed . find ( 'p' ) . innerHTML = response . data ;
1148+ }
1149+ }
1150+ } ) ;
1151+ }
11171152 } ) ;
11181153
11191154 $el . append ( $button ) ;
@@ -1733,7 +1768,7 @@ $( function() {
17331768 setTimeout ( function ( ) {
17341769 var focusIsInToggle = $ . contains ( toggleButton , focusedElement ) ;
17351770 var focusIsInSidebar = $ . contains ( sidebar , focusedElement ) ;
1736-
1771+
17371772 if ( ! focusIsInToggle && ! focusIsInSidebar ) {
17381773 $ ( toggleButton ) . trigger ( 'click.wp-responsive' ) ;
17391774 }
0 commit comments