From c771c5bb0f42acf8589c1a5a959eb68c1749fe0d Mon Sep 17 00:00:00 2001 From: Marcus Quinn Date: Fri, 14 Mar 2025 03:46:51 +0000 Subject: [PATCH] Improve plugin browser: - Add Tutor LMS to LMS category - Move Free Plugins tab after Advanced - Fix loading overlay coverage - Add immediate tab loading with loading state - Implement plugin list caching (12 hours) - Add minimum loading time for better UX --- admin/css/wpa-superstar-admin.css | 17 ++++--- admin/settings.php | 74 +++++++++++++++++++++++++++---- 2 files changed, 77 insertions(+), 14 deletions(-) diff --git a/admin/css/wpa-superstar-admin.css b/admin/css/wpa-superstar-admin.css index 87ec8d0..4270571 100644 --- a/admin/css/wpa-superstar-admin.css +++ b/admin/css/wpa-superstar-admin.css @@ -197,13 +197,13 @@ /* Loading overlay */ .wpa-loading-overlay { - position: absolute; - top: 0; - left: 0; + position: fixed; + top: 32px; + left: 160px; right: 0; bottom: 0; - background: rgba(255, 255, 255, 0.8); - z-index: 100; + background: rgba(255, 255, 255, 0.9); + z-index: 100000; display: flex; align-items: center; justify-content: center; @@ -211,5 +211,10 @@ .wp-list-table-container { position: relative; - min-height: 200px; + min-height: 400px; +} + +.wp-list-table-container .spinner { + float: none; + margin: 0; } \ No newline at end of file diff --git a/admin/settings.php b/admin/settings.php index a55e0d3..a44db7b 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -58,11 +58,28 @@ function wpa_superstar_get_recommended_plugins() { 'client-booking' ), 'lms' => array( - // Add LMS plugins when needed + 'tutor' ) ); } +// Add transient caching for plugin data +function wpa_superstar_get_cached_plugins($category) { + $cache_key = 'wpa_superstar_plugins_' . $category; + $cached_data = get_transient($cache_key); + + if ($cached_data !== false) { + return $cached_data; + } + + return false; +} + +function wpa_superstar_set_cached_plugins($category, $data) { + $cache_key = 'wpa_superstar_plugins_' . $category; + set_transient($cache_key, $data, 12 * HOUR_IN_SECONDS); +} + // Filter plugins API to show only our recommended plugins function wpa_superstar_plugins_api_result($res, $action, $args) { // Only filter if we're on our plugin page and it's a plugin query @@ -75,6 +92,13 @@ function wpa_superstar_plugins_api_result($res, $action, $args) { // Get the current category $category = isset($_GET['category']) ? sanitize_key($_GET['category']) : 'minimal'; + + // Try to get cached data first + $cached_data = wpa_superstar_get_cached_plugins($category); + if ($cached_data !== false) { + return $cached_data; + } + $recommended_plugins = wpa_superstar_get_recommended_plugins(); // Check if category exists and has plugins @@ -126,9 +150,11 @@ function wpa_superstar_plugins_api_result($res, $action, $args) { 'plugins' => $plugins ); + // Cache the results + wpa_superstar_set_cached_plugins($category, $res); + return $res; } catch (Exception $e) { - // If something goes wrong, return original results return $res; } } @@ -163,15 +189,15 @@ function wpa_superstar_settings_page() {
@@ -197,7 +223,7 @@ function wpa_superstar_settings_page() {
-