Make Free Plugins filter menu dynamically generated from data file
This commit is contained in:
@ -43,61 +43,54 @@ class WP_Allstars_Free_Plugins_Manager {
|
|||||||
public static function display_tab_content() {
|
public static function display_tab_content() {
|
||||||
// Get the active category from query params or use default
|
// Get the active category from query params or use default
|
||||||
$active_category = isset($_GET['category']) ? sanitize_text_field($_GET['category']) : 'minimal';
|
$active_category = isset($_GET['category']) ? sanitize_text_field($_GET['category']) : 'minimal';
|
||||||
|
|
||||||
|
// Get all available plugin categories from the data file
|
||||||
|
$plugin_categories = wp_allstars_get_free_plugins();
|
||||||
|
|
||||||
|
// Define priority categories to display first
|
||||||
|
$priority_categories = array('minimal', 'admin');
|
||||||
|
|
||||||
|
// Start HTML output
|
||||||
?>
|
?>
|
||||||
<div class="wp-allstars-settings-content tab-content" id="recommended">
|
<div class="wp-allstars-settings-content tab-content" id="recommended">
|
||||||
<div id="wpa-plugin-filters" class="wp-filter">
|
<div id="wpa-plugin-filters" class="wp-filter">
|
||||||
<ul class="filter-links">
|
<ul class="filter-links">
|
||||||
<li><a href="#" data-category="minimal" class="<?php echo $active_category == 'minimal' ? 'current' : ''; ?>">
|
<?php
|
||||||
<?php esc_html_e('Minimal', 'wp-allstars'); ?>
|
// First output priority categories
|
||||||
</a></li>
|
foreach ($priority_categories as $category) {
|
||||||
<li><a href="#" data-category="admin" class="<?php echo $active_category == 'admin' ? 'current' : ''; ?>">
|
if (isset($plugin_categories[$category])) {
|
||||||
<?php esc_html_e('Admin', 'wp-allstars'); ?>
|
$category_name = ucfirst($category);
|
||||||
</a></li>
|
if ($category == 'cms') $category_name = 'CMS';
|
||||||
<li><a href="#" data-category="affiliates" class="<?php echo $active_category == 'affiliates' ? 'current' : ''; ?>">
|
if ($category == 'crm') $category_name = 'CRM';
|
||||||
<?php esc_html_e('Affiliates', 'wp-allstars'); ?>
|
if ($category == 'ecommerce') $category_name = 'eCommerce';
|
||||||
</a></li>
|
if ($category == 'lms') $category_name = 'LMS';
|
||||||
<li><a href="#" data-category="ai" class="<?php echo $active_category == 'ai' ? 'current' : ''; ?>">
|
if ($category == 'seo') $category_name = 'SEO';
|
||||||
<?php esc_html_e('AI', 'wp-allstars'); ?>
|
?>
|
||||||
</a></li>
|
<li><a href="#" data-category="<?php echo esc_attr($category); ?>" class="<?php echo $active_category == $category ? 'current' : ''; ?>">
|
||||||
<li><a href="#" data-category="cms" class="<?php echo $active_category == 'cms' ? 'current' : ''; ?>">
|
<?php echo esc_html($category_name); ?>
|
||||||
<?php esc_html_e('CMS', 'wp-allstars'); ?>
|
</a></li>
|
||||||
</a></li>
|
<?php
|
||||||
<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' : ''; ?>">
|
// Then output all other categories alphabetically
|
||||||
<?php esc_html_e('CRM', 'wp-allstars'); ?>
|
$remaining_categories = array_diff(array_keys($plugin_categories), $priority_categories);
|
||||||
</a></li>
|
sort($remaining_categories);
|
||||||
<li><a href="#" data-category="ecommerce" class="<?php echo $active_category == 'ecommerce' ? 'current' : ''; ?>">
|
|
||||||
<?php esc_html_e('eCommerce', 'wp-allstars'); ?>
|
foreach ($remaining_categories as $category) {
|
||||||
</a></li>
|
$category_name = ucfirst($category);
|
||||||
<li><a href="#" data-category="lms" class="<?php echo $active_category == 'lms' ? 'current' : ''; ?>">
|
if ($category == 'cms') $category_name = 'CMS';
|
||||||
<?php esc_html_e('LMS', 'wp-allstars'); ?>
|
if ($category == 'crm') $category_name = 'CRM';
|
||||||
</a></li>
|
if ($category == 'ecommerce') $category_name = 'eCommerce';
|
||||||
<li><a href="#" data-category="media" class="<?php echo $active_category == 'media' ? 'current' : ''; ?>">
|
if ($category == 'lms') $category_name = 'LMS';
|
||||||
<?php esc_html_e('Media', 'wp-allstars'); ?>
|
if ($category == 'seo') $category_name = 'SEO';
|
||||||
</a></li>
|
?>
|
||||||
<li><a href="#" data-category="seo" class="<?php echo $active_category == 'seo' ? 'current' : ''; ?>">
|
<li><a href="#" data-category="<?php echo esc_attr($category); ?>" class="<?php echo $active_category == $category ? 'current' : ''; ?>">
|
||||||
<?php esc_html_e('SEO', 'wp-allstars'); ?>
|
<?php echo esc_html($category_name); ?>
|
||||||
</a></li>
|
</a></li>
|
||||||
<li><a href="#" data-category="setup" class="<?php echo $active_category == 'setup' ? 'current' : ''; ?>">
|
<?php
|
||||||
<?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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user