window.Defender = window.Defender || {};
//Added extra parameter to allow for some actions to keep modal open
Defender.showNotification = function (type, message, closeModal) {
var jq = jQuery;
var html = '
';
if (jq('body').find('#defender-notification').size() === 0) {
jq('.sui-wrap').prepend(html);
}else{
jq('#defender-notification').closest('.sui-floating-notices').replaceWith(jQuery(html));
}
var options = {
type: 'green',
icon: 'info',
dismiss: {
show: true,
label: 'Click to close',
tooltip: 'Dismiss'
}
}
if (type === 'error') {
options.type = 'red';
} else if (type === 'warning') {
options.type = 'warning';
} else if (type === 'info') {
options.type = 'blue';
}
SUI.openNotice('defender-notification', '' + message + '
', options);
}
/**
* Filter default wp.i18n.__ function
* `wpdef` is our domain
*/
wp.hooks.addFilter( 'i18n.gettext_wpdef', 'defender', function ( translation, text ) {
if ( defenderGetText && defenderGetText[ text ] ) {
return defenderGetText[ text ];
}
return translation;
}, 20 );