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