Fix theme tab loading by using the same inline script approach as the plugins tab

This commit is contained in:
Marcus Quinn
2025-03-16 19:08:13 +00:00
parent f848160158
commit 479934b6c3
2 changed files with 35 additions and 65 deletions

View File

@ -201,61 +201,8 @@ jQuery(document).ready(function($) {
}
// Function to load themes - global function
window.loadTheme = function() {
console.log('Starting theme loading process');
var $container = $('#wpa-theme-list');
// Clear existing content
$container.empty();
console.log('Container emptied');
// Show loading overlay
$container.css('position', 'relative');
var $loadingOverlay = $('<div class="wp-allstars-loading-overlay"><span class="spinner is-active"></span></div>');
$container.append($loadingOverlay);
console.log('Loading overlay added');
// AJAX request to get themes
console.log('Sending AJAX request with nonce:', wpAllstars.nonce);
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: 'wp_allstars_get_themes',
_wpnonce: wpAllstars.nonce
},
success: function(response) {
console.log('AJAX success response:', response);
// Remove loading overlay
$loadingOverlay.remove();
if (response.success) {
console.log('Response success, updating container HTML');
// Replace all content with new HTML
$container.html(response.data);
// Initialize theme action buttons
console.log('Initializing theme handlers');
initThemeHandlers();
} else {
console.error('Response indicates error:', response.data);
// Show error message
$container.html('<div class="notice notice-error"><p>' + response.data + '</p></div>');
}
},
error: function(xhr, status, error) {
console.error('AJAX error:', { xhr: xhr, status: status, error: error });
// Remove loading overlay
$loadingOverlay.remove();
// Show error message
$container.html('<div class="notice notice-error"><p>Failed to load themes. Please try again. Error: ' + error + '</p></div>');
console.error('AJAX Error Response Text:', xhr.responseText);
}
});
}
// Theme handlers are initialized directly from the inline script
// We don't need a separate loadTheme function anymore
// Initialize plugin action buttons
function initPluginActions() {