wp-seo-admin-global.js
2.29 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* global ajaxurl */
/* jshint -W097 */
/* jshint unused:false */
'use strict';
/**
* Used to dismiss the after-update admin notice for a specific user until the next update.
*
* @param {string} nonce
*/
function wpseoDismissAbout( nonce ) {
jQuery.post( ajaxurl, {
action: 'wpseo_dismiss_about',
_wpnonce: nonce
}
);
}
/**
* Used to dismiss the tagline notice for a specific user.
*
* @param {string} nonce
*/
function wpseoDismissTaglineNotice( nonce ) {
jQuery.post( ajaxurl, {
action: 'wpseo_dismiss_tagline_notice',
_wpnonce: nonce
}
);
}
/**
* Used to remove the admin notices for several purposes, dies on exit.
*
* @param {string} option
* @param {string} hide
* @param {string} nonce
*/
function wpseoSetIgnore( option, hide, nonce ) {
jQuery.post( ajaxurl, {
action: 'wpseo_set_ignore',
option: option,
_wpnonce: nonce
}, function( data ) {
if ( data ) {
jQuery( '#' + hide ).hide();
jQuery( '#hidden_ignore_' + option ).val( 'ignore' );
}
}
);
}
/**
* Make the notices dismissible (again)
*/
function wpseoMakeDismissible() {
jQuery( '.notice.is-dismissible' ).each( function() {
var $notice = jQuery( this );
if ( $notice.find( '.notice-dismiss').empty() ) {
var $button = jQuery( '<button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>' );
$notice.append( $button );
$button.on( 'click.wp-dismiss-notice', function( event ) {
event.preventDefault();
$notice.fadeTo( 100 , 0, function() {
jQuery(this).slideUp( 100, function() {
jQuery(this).remove();
});
});
});
}
});
}
jQuery( document ).ready( function() {
jQuery( '#wpseo-dismiss-about > .notice-dismiss' ).click( function() {
wpseoDismissAbout( jQuery( '#wpseo-dismiss-about' ).data( 'nonce' ) );
});
jQuery( '#wpseo-dismiss-tagline-notice > .notice-dismiss').click( function() {
wpseoDismissTaglineNotice( jQuery( '#wpseo-dismiss-tagline-notice').data( 'nonce' ) );
});
jQuery( '.yoast-dismissible > .notice-dismiss').click( function() {
var parent_div = jQuery( this ).parent('.yoast-dismissible');
jQuery.post(
ajaxurl,
{
action: parent_div.attr( 'id').replace( /-/g, '_' ),
_wpnonce: parent_div.data( 'nonce' ),
data: parent_div.data( 'json' )
}
);
});
});