@@ -1109,11 +1109,46 @@ $( function() {
1109
1109
$button . find ( '.screen-reader-text' ) . text ( __ ( 'Dismiss this notice.' ) ) ;
1110
1110
$button . on ( 'click.wp-dismiss-notice' , function ( event ) {
1111
1111
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
+ } ) ;
1115
1122
} ) ;
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
+ }
1117
1152
} ) ;
1118
1153
1119
1154
$el . append ( $button ) ;
@@ -1733,7 +1768,7 @@ $( function() {
1733
1768
setTimeout ( function ( ) {
1734
1769
var focusIsInToggle = $ . contains ( toggleButton , focusedElement ) ;
1735
1770
var focusIsInSidebar = $ . contains ( sidebar , focusedElement ) ;
1736
-
1771
+
1737
1772
if ( ! focusIsInToggle && ! focusIsInSidebar ) {
1738
1773
$ ( toggleButton ) . trigger ( 'click.wp-responsive' ) ;
1739
1774
}
0 commit comments