diff --git a/admin/js/wp-allstars-admin.js b/admin/js/wp-allstars-admin.js
index 10221c7..f796e28 100644
--- a/admin/js/wp-allstars-admin.js
+++ b/admin/js/wp-allstars-admin.js
@@ -206,6 +206,11 @@ jQuery(document).ready(function($) {
// Initialize plugin action buttons
function initPluginActions() {
+ // Remove any existing event handlers to prevent duplicates
+ $('.plugin-card .install-now').off('click');
+ $('.plugin-card .update-now').off('click');
+ $('.plugin-card .activate-now').off('click');
+
// Install plugin
$('.plugin-card .install-now').on('click', function(e) {
e.preventDefault();
@@ -219,10 +224,13 @@ jQuery(document).ready(function($) {
success: function(response) {
$button.removeClass('updating-message').addClass('updated-message').text('Installed!');
setTimeout(function() {
- $button.removeClass('updated-message install-now')
- .addClass('activate-now')
- .text('Activate')
- .attr('href', response.activateUrl);
+ // Replace the button with an activate button
+ var $parent = $button.parent();
+ $button.remove();
+ $parent.html('Activate');
+
+ // Re-initialize the event handlers
+ initPluginActions();
}, 1000);
},
error: function(response) {
@@ -230,9 +238,7 @@ jQuery(document).ready(function($) {
alert(response.errorMessage);
}
});
-
});
-
// Update plugin
$('.plugin-card .update-now').on('click', function(e) {
@@ -257,15 +263,14 @@ jQuery(document).ready(function($) {
alert(response.errorMessage);
}
});
-
});
-
// Activate plugin
$('.plugin-card .activate-now').on('click', function(e) {
e.preventDefault();
var $button = $(this);
var url = $button.attr('href');
+ var slug = $button.data('slug');
$button.addClass('updating-message').text('Activating...');
@@ -275,9 +280,10 @@ jQuery(document).ready(function($) {
success: function() {
$button.removeClass('updating-message').addClass('updated-message').text('Activated!');
setTimeout(function() {
- $button.removeClass('activate-now updated-message')
- .addClass('button-disabled')
- .text('Active');
+ // Replace the button with an active button
+ var $parent = $button.parent();
+ $button.remove();
+ $parent.html('');
}, 1000);
},
error: function() {
@@ -285,13 +291,15 @@ jQuery(document).ready(function($) {
alert('Failed to activate plugin. Please try again or activate from the Plugins page.');
}
});
-
});
-
}
// Initialize theme handlers
function initThemeHandlers() {
+ // Remove any existing event handlers to prevent duplicates
+ $('.theme-actions .install-now').off('click');
+ $('.theme-actions .activate-now').off('click');
+
// Install theme
$('.theme-actions .install-now').on('click', function(e) {
e.preventDefault();
@@ -306,10 +314,13 @@ jQuery(document).ready(function($) {
success: function(response) {
$button.removeClass('updating-message').addClass('updated-message').text('Installed!');
setTimeout(function() {
- $button.removeClass('updated-message install-now')
- .addClass('activate-now')
- .text('Activate')
- .attr('href', response.activateUrl);
+ // Replace the button with an activate button
+ var $parent = $button.closest('.theme-actions');
+ $button.remove();
+ $parent.prepend('');
+
+ // Re-initialize the event handlers
+ initThemeHandlers();
}, 1000);
},
error: function(response) {
@@ -340,9 +351,10 @@ jQuery(document).ready(function($) {
if (response.success) {
$button.removeClass('updating-message').addClass('updated-message').text('Activated!');
setTimeout(function() {
- $button.removeClass('activate-now updated-message')
- .addClass('button-disabled')
- .text('Active');
+ // Replace the button with an active button
+ var $parent = $button.closest('.theme-actions');
+ $button.remove();
+ $parent.prepend('');
}, 1000);
} else {
$button.removeClass('updating-message').text('Activate');
diff --git a/admin/partials/theme-panel.php b/admin/partials/theme-panel.php
index 1b487cf..67c37c8 100644
--- a/admin/partials/theme-panel.php
+++ b/admin/partials/theme-panel.php
@@ -22,7 +22,14 @@ if (!defined('ABSPATH')) {
exists()): ?>
+ $current_theme = wp_get_theme();
+ $is_active = ($current_theme->get_stylesheet() === 'kadence');
+
+ if ($is_active): ?>
+
+ exists()): ?>
diff --git a/admin/settings.php b/admin/settings.php
index 7d5bb3d..732a562 100644
--- a/admin/settings.php
+++ b/admin/settings.php
@@ -1312,6 +1312,13 @@ function wp_allstars_activate_theme() {
return;
}
+ // Get the theme object
+ $theme_obj = wp_get_theme($theme);
+ if (!$theme_obj->exists() || $theme_obj->errors()) {
+ wp_send_json_error('Theme does not exist');
+ return;
+ }
+
// Switch the theme
switch_theme($theme);