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_ajax_referer('updates'); 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 { // 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), )); add_filter('plugin_install_action_links', 'wp_allstars_add_pro_button', 10, 2); ob_start(); $wp_list_table->display(); $html = ob_get_clean(); 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); // Setup the list table $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' )); // Set the items directly $wp_list_table->items = $plugins; $wp_list_table->set_pagination_args(array( 'total_items' => count($plugins), 'per_page' => count($plugins), )); add_filter('plugin_install_action_links', 'wp_allstars_add_pro_button', 10, 2); ob_start(); $wp_list_table->display(); $html = ob_get_clean(); if (empty($html)) { wp_send_json_error('Failed to generate plugin display HTML'); return; } 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'); // Helper function to add pro button to plugin cards function wp_allstars_add_pro_button($action_links, $plugin) { // Get pro plugins configuration $pro_plugins = wp_allstars_get_pro_plugins_config(); // Check if this plugin has a pro version foreach ($pro_plugins as $pro_plugin) { if (isset($pro_plugin['free_slug']) && $pro_plugin['free_slug'] === $plugin['slug']) { $action_links[] = sprintf( '%s', esc_url($pro_plugin['url']), esc_html__('Go Pro', 'wp-allstars') ); break; } } return $action_links; } // Remove the old plugins API filter since we're handling everything in the AJAX endpoint remove_filter('plugins_api_result', 'wp_allstars_plugins_api_result'); // Clear plugin cache when plugins are updated, activated, or deactivated function wp_allstars_clear_plugin_cache() { $recommended_plugins = wp_allstars_get_recommended_plugins(); foreach (array_keys($recommended_plugins) as $category) { delete_transient('wp_allstars_plugins_' . $category); } } add_action('upgrader_process_complete', 'wp_allstars_clear_plugin_cache', 10, 0); add_action('activated_plugin', 'wp_allstars_clear_plugin_cache'); add_action('deactivated_plugin', 'wp_allstars_clear_plugin_cache'); add_action('deleted_plugin', 'wp_allstars_clear_plugin_cache'); add_action('update_option_active_plugins', 'wp_allstars_clear_plugin_cache'); // Add transient caching for theme data function wp_allstars_get_cached_theme() { $cache_key = 'wp_allstars_theme_kadence'; return get_transient($cache_key); } function wp_allstars_set_cached_theme($data) { $cache_key = 'wp_allstars_theme_kadence'; set_transient($cache_key, $data, 12 * HOUR_IN_SECONDS); } // Add AJAX endpoint for theme function wp_allstars_ajax_get_theme() { check_ajax_referer('updates'); if (!current_user_can('install_themes')) { error_log('WP ALLSTARS: User does not have permission to install themes'); wp_send_json_error('Permission denied'); return; } error_log('WP ALLSTARS: Starting theme fetch process'); try { error_log('WP ALLSTARS: Fetching theme data for kadence'); // Get theme data with minimal fields $theme_data = themes_api('theme_information', array( 'slug' => 'kadence', 'fields' => array( 'sections' => false, 'description' => true, 'rating' => true, 'ratings' => false, 'downloaded' => true, 'download_link' => true, 'last_updated' => true, 'homepage' => true, 'tags' => false, 'screenshot_url' => true, 'version' => true, 'requires' => true, 'requires_php' => true, 'active_installs' => true, 'author' => true, 'preview_url' => true, ) )); if (is_wp_error($theme_data)) { error_log('WP ALLSTARS Theme API Error: ' . $theme_data->get_error_message()); wp_send_json_error('Theme API Error: ' . $theme_data->get_error_message()); return; } error_log('WP ALLSTARS: Successfully fetched theme data'); // Format author data $author = ''; if (is_string($theme_data->author)) { $author = $theme_data->author; } elseif (is_array($theme_data->author)) { $author = isset($theme_data->author['display_name']) ? $theme_data->author['display_name'] : ''; } // Generate custom HTML for the theme ob_start(); ?>
getMessage()); error_log('WP ALLSTARS Theme loading exception trace: ' . $e->getTraceAsString()); wp_send_json_error('Theme loading error: ' . $e->getMessage()); } catch (Error $e) { error_log('WP ALLSTARS Theme loading error: ' . $e->getMessage()); error_log('WP ALLSTARS Theme loading error trace: ' . $e->getTraceAsString()); wp_send_json_error('Theme loading error: ' . $e->getMessage()); } } add_action('wp_ajax_wp_allstars_get_theme', 'wp_allstars_ajax_get_theme'); // Clear theme cache when themes are updated function wp_allstars_clear_theme_cache() { delete_transient('wp_allstars_theme_kadence'); } add_action('upgrader_process_complete', 'wp_allstars_clear_theme_cache', 10, 0); add_action('switch_theme', 'wp_allstars_clear_theme_cache'); // Add AJAX handler for theme activation function wp_allstars_activate_theme() { check_ajax_referer('updates'); if (!current_user_can('switch_themes')) { wp_send_json_error('Permission denied'); return; } $theme = isset($_POST['theme']) ? sanitize_text_field($_POST['theme']) : ''; if (empty($theme)) { wp_send_json_error('No theme specified'); return; } // Switch the theme switch_theme($theme); // Check if the switch was successful $active_theme = wp_get_theme(); if ($active_theme->get_stylesheet() === $theme) { wp_send_json_success(array( 'message' => 'Theme activated successfully', 'customize_url' => admin_url('customize.php') )); } else { wp_send_json_error('Failed to activate theme'); } } add_action('wp_ajax_wp_allstars_activate_theme', 'wp_allstars_activate_theme'); // Settings page HTML function wp_allstars_settings_page() { global $tabs; $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'general'; $active_category = isset($_GET['category']) ? $_GET['category'] : 'minimal'; // Clear cache and load required files if ($active_tab === 'recommended') { wp_allstars_clear_plugin_cache(); require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; wp_enqueue_script('plugin-install'); wp_enqueue_script('updates'); add_thickbox(); wp_enqueue_style('wp-allstars-admin', plugins_url('css/wp-allstars-admin.css', __FILE__)); } elseif ($active_tab === 'theme') { wp_allstars_clear_theme_cache(); require_once ABSPATH . 'wp-admin/includes/theme.php'; wp_enqueue_script('theme-install'); wp_enqueue_script('updates'); add_thickbox(); wp_enqueue_style('wp-allstars-admin', plugins_url('css/wp-allstars-admin.css', __FILE__)); } ?>
%filename%, %post_id%, %postname%, %timestamp%, %date%, %year%, %month%, %day%
%filename%, %post_title%, %post_id%, %postname%, %timestamp%