From 408ca17d0b33810c306bf84b506be23e5daf849a Mon Sep 17 00:00:00 2001 From: Marcus Quinn Date: Fri, 14 Mar 2025 04:33:23 +0000 Subject: [PATCH] Fix theme loading: - Remove list table implementation - Add direct theme data handling - Fix JSON response encoding - Improve escaping and security - Add better error handling --- admin/settings.php | 68 ++++++++++------------------------------------ 1 file changed, 15 insertions(+), 53 deletions(-) diff --git a/admin/settings.php b/admin/settings.php index 88e3bcc..67f1ee4 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -253,51 +253,13 @@ function wpa_superstar_ajax_get_theme() { if (!current_user_can('install_themes')) { error_log('WPA Superstar: User does not have permission to install themes'); - wp_die(-1); + wp_send_json_error('Permission denied'); + return; } error_log('WPA Superstar: Starting theme fetch process'); try { - // Make sure required files are loaded in the correct order - if (!class_exists('WP_List_Table')) { - error_log('WPA Superstar: Loading list table base class'); - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; - } - - if (!class_exists('WP_Themes_List_Table')) { - error_log('WPA Superstar: Loading themes list table class'); - require_once ABSPATH . 'wp-admin/includes/class-wp-themes-list-table.php'; - } - - if (!class_exists('WP_Theme_Install_List_Table')) { - error_log('WPA Superstar: Loading theme install list table class'); - require_once ABSPATH . 'wp-admin/includes/class-wp-theme-install-list-table.php'; - } - - if (!function_exists('themes_api')) { - error_log('WPA Superstar: Loading theme.php'); - require_once ABSPATH . 'wp-admin/includes/theme.php'; - } - - // Set up the necessary globals and requests - $GLOBALS['tab'] = 'theme-install'; - $_REQUEST['tab'] = 'theme-install'; - $_REQUEST['type'] = 'theme-install'; - - // Set up the screen - if (!function_exists('get_current_screen')) { - error_log('WPA Superstar: Loading admin screen functions'); - require_once ABSPATH . 'wp-admin/includes/screen.php'; - } - - if (!function_exists('set_current_screen')) { - error_log('WPA Superstar: Loading admin functions'); - require_once ABSPATH . 'wp-admin/includes/admin.php'; - } - - set_current_screen('theme-install'); - error_log('WPA Superstar: Fetching theme data for kadence'); // Get theme data with minimal fields @@ -338,24 +300,24 @@ function wpa_superstar_ajax_get_theme() {
-
author)); ?>
+
author))); ?>

name); ?>

slug); + $installed_theme = wp_get_theme('kadence'); if ($installed_theme->exists()): ?> - - - +
@@ -365,7 +327,7 @@ function wpa_superstar_ajax_get_theme() {
- +
@@ -373,12 +335,12 @@ function wpa_superstar_ajax_get_theme() {

name); ?>

-

author)); ?>

-

description); ?>

+

author))); ?>

+

description); ?>

- version)); ?> - active_installs)); ?> - last_updated)); ?> + version)); ?> + active_installs))); ?> + last_updated)); ?>