From 92cdb9500313823bd3ae79f63637212bbc2135e7 Mon Sep 17 00:00:00 2001 From: Marcus Quinn Date: Fri, 14 Mar 2025 03:53:24 +0000 Subject: [PATCH] Optimize plugin browser and update categories: - Make General tab default - Update plugin categories - Move plugins from Minimal to Advanced - Add AJAX loading for faster initial page load - Add request cancellation for better performance - Improve category switching UX --- admin/settings.php | 109 +++++++++++++++++++++++++++++++++------------ 1 file changed, 80 insertions(+), 29 deletions(-) diff --git a/admin/settings.php b/admin/settings.php index a44db7b..652e3d3 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -37,17 +37,17 @@ add_action('wp_ajax_wpa_superstar_update_option', 'wpa_superstar_update_option') function wpa_superstar_get_recommended_plugins() { return array( 'minimal' => array( + 'antispam-bee', + 'turnstile' + ), + 'advanced' => array( 'advanced-custom-fields', 'admin-menu-editor', - 'antispam-bee', 'burst-statistics', 'freesoul-deactivate-plugins', 'plugin-toggle', 'pretty-links', 'seo-by-rank-math', - 'turnstile' - ), - 'advanced' => array( 'fluent-crm', 'fluentform', 'fluent-smtp', @@ -160,11 +160,35 @@ function wpa_superstar_plugins_api_result($res, $action, $args) { } add_filter('plugins_api_result', 'wpa_superstar_plugins_api_result', 10, 3); +// Add AJAX endpoint for plugin list +function wpa_superstar_ajax_get_plugins() { + check_ajax_referer('updates'); + + if (!current_user_can('install_plugins')) { + wp_die(-1); + } + + $category = isset($_GET['category']) ? sanitize_key($_GET['category']) : 'minimal'; + + require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; + + // Setup the list table + $wp_list_table = _get_list_table('WP_Plugin_Install_List_Table', array('screen' => 'plugin-install')); + $wp_list_table->prepare_items(); + + ob_start(); + $wp_list_table->display(); + $html = ob_get_clean(); + + wp_send_json_success($html); +} +add_action('wp_ajax_wpa_get_plugins', 'wpa_superstar_ajax_get_plugins'); + // Settings page HTML function wpa_superstar_settings_page() { global $tabs; - $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'recommended'; + $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'general'; $active_category = isset($_GET['category']) ? $_GET['category'] : 'minimal'; // Ensure required files are loaded @@ -226,50 +250,77 @@ function wpa_superstar_settings_page() {
- prepare_items(); - $wp_list_table->display(); - ?> +