-
Notifications
You must be signed in to change notification settings - Fork 22
/
dismiss-notice.js
34 lines (27 loc) · 987 Bytes
/
dismiss-notice.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(function ($) {
//shorthand for ready event.
$(
function () {
$( 'div[data-dismissible] button.notice-dismiss, div[data-dismissible] .dismiss-this' ).on("click",
function (event) {
event.preventDefault();
var $this = $( this );
var attr_value, option_name, dismissible_length, data;
attr_value = $this.closest("div[data-dismissible]").attr( 'data-dismissible' ).split( '-' );
// remove the dismissible length from the attribute value and rejoin the array.
dismissible_length = attr_value.pop();
option_name = attr_value.join( '-' );
data = {
'action': 'dismiss_admin_notice',
'option_name': option_name,
'dismissible_length': dismissible_length,
'nonce': dismissible_notice.nonce
};
// We can also pass the url value separately from ajaxurl for front end AJAX implementations
$.post( ajaxurl, data );
$this.closest("div[data-dismissible]").hide('slow');
}
);
}
)
}(jQuery));