-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from awesomemotive/20241002-Cross-promotion-du…
…plicator Added cross promotion to duplicator
- Loading branch information
Showing
6 changed files
with
2,263 additions
and
1,632 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/** | ||
* Transients Manager Extra Plugins | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var AmTmExtraPlugins = window.AmTmExtraPlugins || (function (document, window, $) { | ||
|
||
/** | ||
* Public functions and properties. | ||
*/ | ||
var app = { | ||
|
||
/** | ||
* Start the engine. | ||
*/ | ||
init: function () { | ||
$(app.ready); | ||
}, | ||
|
||
/** | ||
* Document ready. | ||
*/ | ||
ready: function () { | ||
app.events(); | ||
}, | ||
|
||
/** | ||
* Dismissible notices events. | ||
*/ | ||
events: function () { | ||
$(document).on( | ||
'click', | ||
'button.am-tm-extra-plugin-item[data-plugin]', | ||
function (e) { | ||
e.preventDefault(); | ||
|
||
if ($(this).hasClass('disabled')) { | ||
return; | ||
} | ||
|
||
let button = $(this); | ||
let buttonText = $(this).html(); | ||
|
||
$(this).addClass('disabled'); | ||
$(this).html(l10nAmTmExtraPlugins.loading); | ||
|
||
$.post( | ||
am_tm_extra_plugins.ajax_url, | ||
{ | ||
action: 'transients_manager_extra_plugin', | ||
nonce: am_tm_extra_plugins.extra_plugin_install_nonce, | ||
plugin: $(this).data('plugin'), | ||
} | ||
).done(function (response) { | ||
console.log(response); | ||
if (response.success !== true) { | ||
console.log("Plugin installed failed with message: " + response.data.message); | ||
button.fadeOut(300); | ||
|
||
setTimeout(function () { | ||
button.html(buttonText); | ||
button.removeClass('disabled'); | ||
button.fadeIn(100); | ||
}, 3000); | ||
return; | ||
} | ||
|
||
button.fadeOut(500); | ||
button.html(l10nAmTmExtraPlugins.activated); | ||
button.prepend('<span class="dashicons dashicons-yes"></span>'); | ||
button.fadeIn(300); | ||
}); | ||
} | ||
); | ||
|
||
$(document).on( | ||
'click', | ||
'.notice.cross-promotion .notice-dismiss', | ||
function (e) { | ||
e.preventDefault(); | ||
|
||
$.post( | ||
am_tm_extra_plugins.ajax_url, | ||
{ | ||
action: 'transients_manager_cross_promo_dismiss', | ||
nonce: am_tm_extra_plugins.cross_promo_dismiss_nonce, | ||
} | ||
).done(function (response) { | ||
if (response.success !== true) { | ||
console.log("Error dismissing notice"); | ||
return; | ||
} | ||
}); | ||
} | ||
); | ||
}, | ||
|
||
|
||
}; | ||
|
||
return app; | ||
|
||
}(document, window, jQuery)); | ||
|
||
// Initialize. | ||
AmTmExtraPlugins.init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.