Fix theme loading class dependencies: - Add proper class loading order - Load WP_List_Table base class first - Load WP_Themes_List_Table before install table - Add admin.php for screen functions

This commit is contained in:
Marcus Quinn
2025-03-14 04:30:45 +00:00
parent f4d9f69a98
commit 411ee6ffa9

View File

@ -252,19 +252,50 @@ function wpa_superstar_ajax_get_theme() {
check_ajax_referer('updates'); check_ajax_referer('updates');
if (!current_user_can('install_themes')) { if (!current_user_can('install_themes')) {
error_log('WPA Superstar: User does not have permission to install themes');
wp_die(-1); wp_die(-1);
} }
error_log('WPA Superstar: Starting theme fetch process'); error_log('WPA Superstar: Starting theme fetch process');
try { try {
// Make sure required files are loaded // Make sure required files are loaded in the correct order
require_once ABSPATH . 'wp-admin/includes/theme.php'; if (!class_exists('WP_List_Table')) {
require_once ABSPATH . 'wp-admin/includes/class-wp-theme-install-list-table.php'; 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 // Set up the necessary globals and requests
$GLOBALS['tab'] = 'theme-install'; $GLOBALS['tab'] = 'theme-install';
$_REQUEST['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'); set_current_screen('theme-install');
error_log('WPA Superstar: Fetching theme data for kadence'); error_log('WPA Superstar: Fetching theme data for kadence');