diff --git a/admin/settings.php b/admin/settings.php index 01ed13e..77f2bf7 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -63,47 +63,35 @@ function wpa_superstar_get_recommended_plugins() { ); } -// Filter the plugins API results -function wpa_superstar_filter_plugins_api($result, $action, $args) { - if ($action !== 'query_plugins') { - return $result; +// Filter plugins API to show only our recommended plugins +function wpa_superstar_plugins_api_filter($args) { + if (!empty($_GET['page']) && $_GET['page'] === 'wpa-superstar') { + $category = isset($_GET['category']) ? sanitize_key($_GET['category']) : 'recommended'; + $recommended_plugins = wpa_superstar_get_recommended_plugins(); + + if (isset($recommended_plugins[$category])) { + $args->per_page = 100; + $args->plugins = $recommended_plugins[$category]; + } } - - // Only filter on our page - if (!isset($_GET['page']) || $_GET['page'] !== 'wpa-superstar') { - return $result; - } - - $category = isset($_GET['category']) ? sanitize_key($_GET['category']) : 'recommended'; - $recommended_plugins = wpa_superstar_get_recommended_plugins(); - - if (!isset($recommended_plugins[$category])) { - return $result; - } - - // Get the full plugin data for our recommended plugins - $args = array( - 'per_page' => 100, - 'fields' => array( - 'last_updated' => true, - 'active_installs' => true, - 'downloaded' => true, - 'icons' => true, - ), - 'slug' => $recommended_plugins[$category] - ); - - $query = new WP_Plugin_Install_List_Table(); - $query->prepare_items(); - - return plugins_api('query_plugins', $args); + return $args; } -add_filter('plugins_api_result', 'wpa_superstar_filter_plugins_api', 10, 3); +add_filter('plugins_api_args', 'wpa_superstar_plugins_api_filter'); // Settings page HTML function wpa_superstar_settings_page() { + global $tabs; + $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'recommended'; $active_category = isset($_GET['category']) ? $_GET['category'] : 'recommended'; + + // Ensure required files are loaded + if ($active_tab === 'recommended') { + require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; + wp_enqueue_script('plugin-install'); + wp_enqueue_script('updates'); + add_thickbox(); + } ?>
@@ -152,19 +140,13 @@ function wpa_superstar_settings_page() {
- prepare_items(); - - // Display the plugin browser - echo '
'; - $plugin_table->display(); - echo '
'; - ?> +
+ prepare_items(); + $wp_list_table->display(); + ?> +