Fix plugin filtering to match defined lists: - Ensure only recommended plugins are displayed - Add better error handling - Fix table initialization - Improve API error handling
This commit is contained in:
@ -104,6 +104,7 @@ function wpa_superstar_ajax_get_plugins() {
|
|||||||
// Setup the list table with cached data
|
// Setup the list table with cached data
|
||||||
$GLOBALS['tab'] = 'plugin-install';
|
$GLOBALS['tab'] = 'plugin-install';
|
||||||
$_REQUEST['tab'] = 'plugin-install';
|
$_REQUEST['tab'] = 'plugin-install';
|
||||||
|
$_REQUEST['type'] = 'plugin-install';
|
||||||
set_current_screen('plugin-install');
|
set_current_screen('plugin-install');
|
||||||
|
|
||||||
$wp_list_table = _get_list_table('WP_Plugin_Install_List_Table', array(
|
$wp_list_table = _get_list_table('WP_Plugin_Install_List_Table', array(
|
||||||
@ -128,7 +129,10 @@ function wpa_superstar_ajax_get_plugins() {
|
|||||||
// If no cache, get fresh data
|
// If no cache, get fresh data
|
||||||
try {
|
try {
|
||||||
$plugins = array();
|
$plugins = array();
|
||||||
|
|
||||||
|
// Only fetch plugins that are in our recommended list for this category
|
||||||
foreach ($recommended_plugins[$category] as $slug) {
|
foreach ($recommended_plugins[$category] as $slug) {
|
||||||
|
try {
|
||||||
$plugin_data = plugins_api('plugin_information', array(
|
$plugin_data = plugins_api('plugin_information', array(
|
||||||
'slug' => $slug,
|
'slug' => $slug,
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
@ -157,6 +161,10 @@ function wpa_superstar_ajax_get_plugins() {
|
|||||||
if (!is_wp_error($plugin_data)) {
|
if (!is_wp_error($plugin_data)) {
|
||||||
$plugins[] = $plugin_data;
|
$plugins[] = $plugin_data;
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// Skip this plugin if there's an error
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create response object
|
// Create response object
|
||||||
@ -175,6 +183,7 @@ function wpa_superstar_ajax_get_plugins() {
|
|||||||
// Setup the list table
|
// Setup the list table
|
||||||
$GLOBALS['tab'] = 'plugin-install';
|
$GLOBALS['tab'] = 'plugin-install';
|
||||||
$_REQUEST['tab'] = 'plugin-install';
|
$_REQUEST['tab'] = 'plugin-install';
|
||||||
|
$_REQUEST['type'] = 'plugin-install';
|
||||||
set_current_screen('plugin-install');
|
set_current_screen('plugin-install');
|
||||||
|
|
||||||
$wp_list_table = _get_list_table('WP_Plugin_Install_List_Table', array(
|
$wp_list_table = _get_list_table('WP_Plugin_Install_List_Table', array(
|
||||||
@ -195,7 +204,7 @@ function wpa_superstar_ajax_get_plugins() {
|
|||||||
wp_send_json_success($html);
|
wp_send_json_success($html);
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
wp_send_json_error('Failed to fetch plugin data');
|
wp_send_json_error('Failed to fetch plugin data: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('wp_ajax_wpa_get_plugins', 'wpa_superstar_ajax_get_plugins');
|
add_action('wp_ajax_wpa_get_plugins', 'wpa_superstar_ajax_get_plugins');
|
||||||
|
Reference in New Issue
Block a user