diff --git a/admin/settings.php b/admin/settings.php index 9777f8d..b774b64 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -40,87 +40,57 @@ function wp_allstars_get_recommended_plugins() { 'antispam-bee', 'compressx', 'fluent-smtp', - 'plugin-toggle', + 'kadence-blocks', 'simple-cloudflare-turnstile' ), - 'advanced' => array( - 'acf-better-search', + 'admin' => array( 'admin-bar-dashboard-control', - 'advanced-custom-fields', 'admin-menu-editor', - 'ai-engine', + 'hide-admin-notices', + 'mainwp-child', + 'mainwp-child-reports', + 'magic-login', + 'manage-notification-emails', + 'plugin-toggle' + ), + 'cms' => array( 'auto-post-scheduler', - 'avatar-privacy', + 'block-options', 'bookmark-card', 'browser-shots', 'bulk-actions-select-all', 'bulk-edit-categories-tags', 'bulk-edit-user-profiles-in-spreadsheet', - 'burst-statistics', 'carbon-copy', - 'code-snippets', + 'iframe-block', + 'ics-calendar', + 'mammoth-docx-converter', + 'nav-menu-roles', + 'ninja-tables', + 'post-draft-preview', + 'post-type-switcher', + 'simple-custom-post-order', + 'simple-icons', + 'sticky-posts-switch', + 'term-management-tools', + 'the-paste', + 'ultimate-addons-for-gutenberg', + 'wikipedia-preview', + 'wp-sheet-editor-bulk-spreadsheet-editor-for-posts-and-pages' + ), + 'compliance' => array( + 'avatar-privacy', 'complianz-gdpr', 'complianz-terms-conditions', - 'disable-wordpress-updates', - 'easy-video-reviews', - 'easy-watermark', - 'block-options', - 'enable-media-replace', - 'favorites', + 'really-simple-ssl' + ), + 'crm' => array( 'fluent-boards', 'fluent-booking', 'fluent-crm', 'fluentform', 'fluentforms-pdf', - 'fluent-support', - 'flying-analytics', - 'flying-pages', - 'flying-scripts', - 'freesoul-deactivate-plugins', - 'hide-admin-notices', - 'hreflang-manager-lite', - 'ics-calendar', - 'iframe-block', - 'image-copytrack', - 'imsanity', - 'index-wp-mysql-for-speed', - 'kadence-blocks', - 'litespeed-cache', - 'magic-login', - 'mainwp-child', - 'mainwp-child-reports', - 'mammoth-docx-converter', - 'manage-notification-emails', - 'media-file-renamer', - 'nav-menu-roles', - 'ninja-tables', - 'performant-translations', - 'simple-icons', - 'post-draft-preview', - 'post-type-switcher', - 'pretty-link', - 'seo-by-rank-math', - 'really-simple-ssl', - 'remove-cpt-base', - 'safe-svg', - 'simple-custom-post-order', - 'remove-old-slugspermalinks', - 'social-engine', - 'kadence-starter-templates', - 'ultimate-addons-for-gutenberg', - 'sticky-posts-switch', - 'syndication-links', - 'term-management-tools', - 'the-paste', - 'ultimate-410', - 'webmention', - 'wp-widget-disable', - 'wikipedia-preview', - 'wordpress-importer', - 'wp-social-reviews', - 'wp-optimize', - 'wp-sheet-editor-bulk-spreadsheet-editor-for-posts-and-pages', - 'yellow-pencil-visual-theme-customizer' + 'fluent-support' ), 'ecommerce' => array( 'woocommerce', @@ -134,6 +104,57 @@ function wp_allstars_get_recommended_plugins() { 'lms' => array( 'tutor' ), + 'media' => array( + 'easy-watermark', + 'enable-media-replace', + 'image-copytrack', + 'imsanity', + 'media-file-renamer', + 'safe-svg' + ), + 'seo' => array( + 'burst-statistics', + 'pretty-link', + 'seo-by-rank-math', + 'syndication-links', + 'ultimate-410', + 'webmention' + ), + 'setup' => array( + 'kadence-starter-templates', + 'wordpress-importer' + ), + 'social' => array(), + 'speed' => array( + 'disable-wordpress-updates', + 'flying-analytics', + 'flying-pages', + 'flying-scripts', + 'freesoul-deactivate-plugins', + 'index-wp-mysql-for-speed', + 'litespeed-cache', + 'performant-translations', + 'wp-optimize', + 'wp-widget-disable' + ), + 'translation' => array( + 'hreflang-manager-lite', + 'performant-translations', + 'translatepress-multilingual' + ), + 'advanced' => array( + 'acf-better-search', + 'advanced-custom-fields', + 'ai-engine', + 'code-snippets', + 'easy-video-reviews', + 'favorites', + 'remove-cpt-base', + 'remove-old-slugspermalinks', + 'social-engine', + 'wp-social-reviews', + 'yellow-pencil-visual-theme-customizer' + ), 'debug' => array( 'debug-log-manager', 'gotmls', @@ -172,8 +193,6 @@ function wp_allstars_ajax_get_plugins() { } $category = isset($_GET['category']) ? sanitize_key($_GET['category']) : 'minimal'; - $batch_size = isset($_GET['batch_size']) ? intval($_GET['batch_size']) : 5; - $offset = isset($_GET['offset']) ? intval($_GET['offset']) : 0; require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; @@ -183,17 +202,46 @@ function wp_allstars_ajax_get_plugins() { wp_send_json_error('Invalid category: ' . $category); } - // Get the total number of plugins for this category - $total_plugins = count($recommended_plugins[$category]); + // Try to get cached data first + $cached_data = wp_allstars_get_cached_plugins($category); + if ($cached_data !== false) { + error_log('Using cached data for category: ' . $category); + // Setup the list table with cached data + $GLOBALS['tab'] = 'plugin-install'; + $_REQUEST['tab'] = 'plugin-install'; + $_REQUEST['type'] = 'plugin-install'; + set_current_screen('plugin-install'); + + $wp_list_table = _get_list_table('WP_Plugin_Install_List_Table', array( + 'screen' => 'plugin-install' + )); + + // Override the items with our cached data + $wp_list_table->items = $cached_data->plugins; + $wp_list_table->set_pagination_args(array( + 'total_items' => count($cached_data->plugins), + 'per_page' => count($cached_data->plugins), + )); + + ob_start(); + $wp_list_table->display(); + $html = ob_get_clean(); + + wp_send_json_success($html); + return; + } - // Get the current batch of plugins - $current_batch = array_slice($recommended_plugins[$category], $offset, $batch_size); + error_log('Fetching fresh data for category: ' . $category); + error_log('Plugins to fetch: ' . implode(', ', $recommended_plugins[$category])); + // If no cache, get fresh data try { $plugins = array(); - foreach ($current_batch as $slug) { + // Only fetch plugins that are in our recommended list for this category + foreach ($recommended_plugins[$category] as $slug) { try { + error_log('Fetching plugin data for: ' . $slug); $plugin_data = plugins_api('plugin_information', array( 'slug' => $slug, 'fields' => array( @@ -223,6 +271,7 @@ function wp_allstars_ajax_get_plugins() { error_log('Error fetching plugin data for ' . $slug . ': ' . $plugin_data->get_error_message()); } else { $plugins[] = $plugin_data; + error_log('Successfully fetched data for: ' . $slug); } } catch (Exception $e) { error_log('Exception fetching plugin data for ' . $slug . ': ' . $e->getMessage()); @@ -230,6 +279,21 @@ function wp_allstars_ajax_get_plugins() { } } + error_log('Total plugins fetched: ' . count($plugins)); + + // Create response object + $res = (object) array( + 'info' => array( + 'page' => 1, + 'pages' => 1, + 'results' => count($plugins), + ), + 'plugins' => $plugins + ); + + // Cache the results + wp_allstars_set_cached_plugins($category, $res); + // Setup the list table $GLOBALS['tab'] = 'plugin-install'; $_REQUEST['tab'] = 'plugin-install'; @@ -251,12 +315,7 @@ function wp_allstars_ajax_get_plugins() { $wp_list_table->display(); $html = ob_get_clean(); - wp_send_json_success(array( - 'html' => $html, - 'total' => $total_plugins, - 'remaining' => $total_plugins - ($offset + count($plugins)), - 'offset' => $offset + count($plugins) - )); + wp_send_json_success($html); } catch (Exception $e) { error_log('Failed to fetch plugin data: ' . $e->getMessage()); @@ -801,9 +860,21 @@ function wp_allstars_settings_page() { class="button "> - - + + + + + + + + + + + @@ -813,6 +884,34 @@ function wp_allstars_settings_page() { class="button "> + + + + + + + + + + + + + + + + + + + + + @@ -826,52 +925,15 @@ function wp_allstars_settings_page() {
- -