array( 'antispam-bee', 'compressx', 'fluent-smtp', 'kadence-blocks', 'simple-cloudflare-turnstile' ), 'admin' => array( 'admin-bar-dashboard-control', 'codepress-admin-columns', 'admin-menu-editor', 'hide-admin-notices', 'mainwp-child', 'mainwp-child-reports', 'magic-login', 'manage-notification-emails', 'plugin-groups', 'plugin-toggle' ), 'ai' => array( 'ai-engine', ), 'cms' => array( 'auto-post-scheduler', 'block-options', 'bookmark-card', 'browser-shots', 'bulk-actions-select-all', 'bulk-edit-categories-tags', 'bulk-edit-user-profiles-in-spreadsheet', 'carbon-copy', 'code-block-pro', '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', 'really-simple-ssl' ), 'crm' => array( 'fluent-boards', 'fluent-booking', 'fluent-crm', 'fluentform', 'fluentforms-pdf', 'fluent-support' ), 'ecommerce' => array( 'woocommerce', 'woo-bulk-edit-products', 'woo-coupons-bulk-editor', 'woocommerce-gateway-gocardless', 'kadence-woocommerce-email-designer', 'pymntpl-paypal-woocommerce', 'woo-stripe-payment' ), '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( 'easy-video-reviews', 'social-engine', 'wp-social-reviews' ), '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', 'code-snippets', 'favorites', 'remove-cpt-base', 'remove-old-slugspermalinks', 'yellow-pencil-visual-theme-customizer' ), 'debug' => array( 'debug-log-manager', 'gotmls', 'query-monitor', 'string-locator', 'user-switching', 'wp-crontrol' ) ); } // Add transient caching for plugin data function wp_allstars_get_cached_plugins($category) { $cache_key = 'wp_allstars_plugins_' . $category; $cached_data = get_transient($cache_key); if ($cached_data !== false) { return $cached_data; } return false; } function wp_allstars_set_cached_plugins($category, $data) { $cache_key = 'wp_allstars_plugins_' . $category; set_transient($cache_key, $data, 12 * HOUR_IN_SECONDS); } // Add AJAX endpoint for plugin list function wp_allstars_ajax_get_plugins() { // Check nonce with the correct action name if (!check_ajax_referer('wp-allstars-nonce', '_wpnonce', false)) { wp_send_json_error('Invalid security token sent.'); return; } 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'; // Get our recommended plugins for this category $recommended_plugins = wp_allstars_get_recommended_plugins(); if (!isset($recommended_plugins[$category])) { wp_send_json_error('Invalid category: ' . $category); return; } // 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); try { // Generate plugin cards HTML $html = wp_allstars_generate_plugin_cards($cached_data->plugins); wp_send_json_success($html); return; } catch (Exception $e) { error_log('Error displaying cached plugins: ' . $e->getMessage()); // Fall through to fetch fresh data } } error_log('Fetching fresh data for category: ' . $category); error_log('Plugins to fetch: ' . implode(', ', $recommended_plugins[$category])); try { $plugins = array(); // 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( 'short_description' => true, 'sections' => false, 'requires' => true, 'rating' => true, 'ratings' => false, 'downloaded' => true, 'last_updated' => true, 'added' => false, 'tags' => false, 'compatibility' => false, 'homepage' => true, 'versions' => false, 'donate_link' => false, 'reviews' => false, 'banners' => false, 'icons' => true, 'active_installs' => true, 'group' => false, 'contributors' => false, ) )); if (is_wp_error($plugin_data)) { 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()); continue; } } if (empty($plugins)) { wp_send_json_error('No plugin data could be retrieved for category: ' . $category); return; } 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); // Generate plugin cards HTML $html = wp_allstars_generate_plugin_cards($plugins); wp_send_json_success($html); } catch (Exception $e) { error_log('Failed to fetch plugin data: ' . $e->getMessage()); wp_send_json_error('Failed to fetch plugin data: ' . $e->getMessage()); } } add_action('wp_ajax_wp_allstars_get_plugins', 'wp_allstars_ajax_get_plugins'); // Function to generate plugin cards HTML function wp_allstars_generate_plugin_cards($plugins) { if (empty($plugins)) { return '
No plugins found.