diff --git a/admin/settings.php b/admin/settings.php index 77f2bf7..7d6d074 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -36,7 +36,7 @@ add_action('wp_ajax_wpa_superstar_update_option', 'wpa_superstar_update_option') // Define recommended plugins function wpa_superstar_get_recommended_plugins() { return array( - 'recommended' => array( + 'minimal' => array( 'advanced-custom-fields', 'admin-menu-editor', 'antispam-bee', @@ -64,26 +64,47 @@ function wpa_superstar_get_recommended_plugins() { } // Filter plugins API to show only our recommended plugins -function wpa_superstar_plugins_api_filter($args) { +function wpa_superstar_plugins_api_result($res, $action, $args) { + if ($action !== 'query_plugins') { + return $res; + } + if (!empty($_GET['page']) && $_GET['page'] === 'wpa-superstar') { - $category = isset($_GET['category']) ? sanitize_key($_GET['category']) : 'recommended'; + $category = isset($_GET['category']) ? sanitize_key($_GET['category']) : 'minimal'; $recommended_plugins = wpa_superstar_get_recommended_plugins(); if (isset($recommended_plugins[$category])) { - $args->per_page = 100; - $args->plugins = $recommended_plugins[$category]; + // Get plugin data for our recommended plugins + $args = (object) array( + 'per_page' => 100, + 'fields' => array( + 'last_updated' => true, + 'active_installs' => true, + 'downloaded' => true, + 'icons' => true, + ), + 'locale' => get_user_locale(), + 'slugs' => $recommended_plugins[$category] + ); + + $query = plugins_api('query_plugins', $args); + + if (!is_wp_error($query)) { + return $query; + } } } - return $args; + + return $res; } -add_filter('plugins_api_args', 'wpa_superstar_plugins_api_filter'); +add_filter('plugins_api_result', 'wpa_superstar_plugins_api_result', 10, 3); // 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'; + $active_category = isset($_GET['category']) ? $_GET['category'] : 'minimal'; // Ensure required files are loaded if ($active_tab === 'recommended') { @@ -108,7 +129,7 @@ function wpa_superstar_settings_page() {