PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.2.7
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.2.7
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / assets / js / admin / plugin-installer.js

plugin-installer.js in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.2.7, at assets/js/admin/plugin-installer.js

51 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2
3 (function ($) {
4 'use strict';
5
6 var merchantPluginInstaller = window.merchantPluginInstaller || {};
7 merchantPluginInstaller = {
8 installButtonSelector: '.merchant-install-plugin',
9 init: function init() {
10 this.events();
11 },
12 events: function events() {
13 var self = this;
14 $(document).on('click', self.installButtonSelector, function (e) {
15 e.preventDefault();
16 var type = $(this).data('type') === 'external' ? 'external' : 'wporg';
17 var plugin_name = $(this).data('plugin-name');
18 var redirect_to = $(this).data('redirect-to');
19 if (type === 'external') {
20 var url = $(this).data('plugin-url');
21 self.installExternalPlugin($(this), url, plugin_name, redirect_to);
22 } else {
23 // self.installPlugin(plugin_name); - TODO: We don't need it yet, but we should rely on the WP API to install plugins from wp.org.
24 }
25 });
26 },
27 installExternalPlugin: function installExternalPlugin(button, url, plugin_name, redirect_to) {
28 var data = {
29 action: 'merchant_install_external_plugin',
30 url: url,
31 plugin_name: plugin_name,
32 nonce: merchantPluginInstallerConfig.nonce
33 };
34 button.text(merchantPluginInstallerConfig.i18n.installingText);
35 $.post(ajaxurl, data, function (response) {
36 if (!response.success) {
37 button.text(merchantPluginInstallerConfig.i18n.defaultText);
38 alert(response.data.message);
39 return;
40 }
41 button.text(merchantPluginInstallerConfig.i18n.activatingText);
42 setTimeout(function () {
43 window.location.href = redirect_to;
44 }, 1000);
45 });
46 }
47 };
48 $(document).ready(function () {
49 merchantPluginInstaller.init();
50 });
51 })(jQuery);