| Server IP : 77.50.203.18 / Your IP : 192.168.0.10 Web Server : Apache/2.4.62 (CentOS Stream) OpenSSL/3.5.7 mpm-itk/2.4.7-04 PHP/8.4.23 System : Linux web2 5.14.0-722.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 6 09:07:51 UTC 2026 x86_64 User : warsnews.ru ( 1001) PHP Version : 8.4.23 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/ifwar.ru/www/wp-content/themes/newsup/js/ |
Upload File : |
jQuery(function ($) {
$(document).on("click", ".btn-install, .btn-activate", function (e) {
e.preventDefault();
let btn = $(this);
let box = btn.closest(".bottom-item");
let slug = box.data("slug"); // plugin slug
let plugin = box.data("plugin"); // plugin main file path
// Redirect URLs
let redirectURL = "";
if (slug === "ansar-import") {
redirectURL = "admin.php?page=ansar-demo-import";
}
if (slug === "blognews-for-elementor") {
redirectURL = "admin.php?page=blognews_admin_menu";
}
/* -----------------------------------------------------------
* CASE 1: PLUGIN ALREADY INSTALLED → ONLY ACTIVATE
* ----------------------------------------------------------- */
if (btn.hasClass("btn-activate")) {
btn.html("Activating…").prop("disabled", true);
$.ajax({
url: newsup_ajax_obj.ajax_url,
type: "POST",
data: {
action: "newsup_activate_plugin",
nonce: newsup_ajax_obj.nonce,
plugin_file: plugin
},
success: function (response) {
if (!response.success) {
btn.text("Failed").prop("disabled", false);
return;
}
btn.removeClass("btn-activate")
.addClass("btn-disabled")
.text("Activated");
// Redirect after activation
if (redirectURL !== "") {
setTimeout(() => window.location.href = redirectURL, 800);
}
},
error: function () {
btn.text("Error").prop("disabled", false);
}
});
return; // Stop here (no install)
}
/* -----------------------------------------------------------
* CASE 2: PLUGIN NOT INSTALLED → INSTALL + ACTIVATE
* ----------------------------------------------------------- */
if (btn.hasClass("btn-install")) {
btn.html("Installing…").prop("disabled", true);
// STEP 1 → INSTALL
$.ajax({
url: newsup_ajax_obj.ajax_url,
type: "POST",
data: {
action: "newsup_install_plugin",
nonce: newsup_ajax_obj.nonce,
slug: slug
},
success: function (response) {
if (!response.success) {
btn.text("Install Failed").prop("disabled", false);
return;
}
// STEP 2 → ACTIVATE
btn.html("Activating…");
$.ajax({
url: newsup_ajax_obj.ajax_url,
type: "POST",
data: {
action: "newsup_activate_plugin",
nonce: newsup_ajax_obj.nonce,
plugin_file: plugin
},
success: function (result) {
if (!result.success) {
btn.text("Activation Failed").prop("disabled", false);
return;
}
btn.removeClass("btn-install")
.addClass("btn-disabled")
.text("Activated");
// Redirect
if (redirectURL !== "") {
setTimeout(() => window.location.href = redirectURL, 800);
}
},
error: function () {
btn.text("Error").prop("disabled", false);
}
});
},
error: function () {
btn.text("Error").prop("disabled", false);
}
});
}
});
$('#newsup-upgrade-menu-item').parent().attr('target', '_blank');
});