Files
wpa-superstar-plugin/admin/includes/class-recommended-plugins-manager.php

122 lines
5.5 KiB
PHP

<?php
/**
* WP ALLSTARS Recommended Plugins Manager
*
* Manages the Recommended Plugins tab including:
* - Category filtering system
* - Plugin recommendations by use case
* - Plugin installation functionality
*
* @package WP_ALLSTARS
* @since 0.2.0
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}
/**
* WP_Allstars_Recommended_Plugins_Manager class
*
* Provides categorized plugin recommendations based on website needs
*/
class WP_Allstars_Recommended_Plugins_Manager {
/**
* Initialize the class and register hooks if needed
*
* @return void
*/
public static function init() {
// We'll implement AJAX handlers in a future update if needed
// add_action('wp_ajax_wp_allstars_load_recommended_plugins', array(self::class, 'ajax_load_recommended_plugins'));
}
/**
* Display the recommended plugins tab content
*
* Renders the category filter bar and plugin list container.
* Initial view shows 'minimal' category plugins by default.
*
* @return void
*/
public static function display_tab_content() {
// Get the active category from query params or use default
$active_category = isset($_GET['category']) ? sanitize_text_field($_GET['category']) : 'minimal';
?>
<div class="wp-allstars-settings-content tab-content" id="recommended">
<div id="wpa-plugin-filters" class="wp-filter">
<ul class="filter-links">
<li><a href="#" data-category="minimal" class="<?php echo $active_category == 'minimal' ? 'current' : ''; ?>">
<?php esc_html_e('Minimal', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="admin" class="<?php echo $active_category == 'admin' ? 'current' : ''; ?>">
<?php esc_html_e('Admin', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="ai" class="<?php echo $active_category == 'ai' ? 'current' : ''; ?>">
<?php esc_html_e('AI', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="cms" class="<?php echo $active_category == 'cms' ? 'current' : ''; ?>">
<?php esc_html_e('CMS', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="compliance" class="<?php echo $active_category == 'compliance' ? 'current' : ''; ?>">
<?php esc_html_e('Compliance', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="crm" class="<?php echo $active_category == 'crm' ? 'current' : ''; ?>">
<?php esc_html_e('CRM', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="ecommerce" class="<?php echo $active_category == 'ecommerce' ? 'current' : ''; ?>">
<?php esc_html_e('Ecommerce', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="lms" class="<?php echo $active_category == 'lms' ? 'current' : ''; ?>">
<?php esc_html_e('LMS', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="media" class="<?php echo $active_category == 'media' ? 'current' : ''; ?>">
<?php esc_html_e('Media', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="seo" class="<?php echo $active_category == 'seo' ? 'current' : ''; ?>">
<?php esc_html_e('SEO', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="setup" class="<?php echo $active_category == 'setup' ? 'current' : ''; ?>">
<?php esc_html_e('Setup', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="social" class="<?php echo $active_category == 'social' ? 'current' : ''; ?>">
<?php esc_html_e('Social', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="speed" class="<?php echo $active_category == 'speed' ? 'current' : ''; ?>">
<?php esc_html_e('Speed', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="translation" class="<?php echo $active_category == 'translation' ? 'current' : ''; ?>">
<?php esc_html_e('Translation', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="advanced" class="<?php echo $active_category == 'advanced' ? 'current' : ''; ?>">
<?php esc_html_e('Advanced', 'wp-allstars'); ?>
</a></li>
<li><a href="#" data-category="debug" class="<?php echo $active_category == 'debug' ? 'current' : ''; ?>">
<?php esc_html_e('Debug', 'wp-allstars'); ?>
</a></li>
</ul>
</div>
<div class="wp-allstars-plugin-browser">
<div id="wpa-plugin-list"></div>
</div>
</div>
<?php
}
/**
* Get the list of recommended plugins
*
* @return array Array of recommended plugins
*/
public static function get_recommended_plugins() {
// Define the plugins data if it hasn't been included yet
if (!function_exists('wp_allstars_get_recommended_plugins')) {
require_once dirname(dirname(__FILE__)) . '/data/recommended-plugins.php';
}
return wp_allstars_get_recommended_plugins();
}
}