From 5b98ed821a9985094a7953d7e7975f7fb7e89482 Mon Sep 17 00:00:00 2001 From: olatechpro Date: Thu, 16 Jan 2025 14:14:59 +0100 Subject: [PATCH] Sidebar tabs for Admin Features #1126 --- includes/features/admin-features.php | 477 ++++++++++-------- includes/features/restrict-admin-features.php | 48 ++ 2 files changed, 316 insertions(+), 209 deletions(-) diff --git a/includes/features/admin-features.php b/includes/features/admin-features.php index 3053a65c..5ce63c01 100644 --- a/includes/features/admin-features.php +++ b/includes/features/admin-features.php @@ -29,7 +29,12 @@ $disabled_admin_items = !empty(get_option('capsman_disabled_admin_features')) ? (array)get_option('capsman_disabled_admin_features') : []; $disabled_admin_items = array_key_exists($default_role, $disabled_admin_items) ? (array)$disabled_admin_items[$default_role] : []; -$admin_features_elements = PP_Capabilities_Admin_Features::elementsLayout(); +$admin_features_elements = PP_Capabilities_Admin_Features::elementsLayout(); +$icon_list = (array)PP_Capabilities_Admin_Features::elementLayoutItemIcons(); +$title_lists = (array)PP_Capabilities_Admin_Features::elementLayoutItemTitles(); +$section_actions = (array)PP_Capabilities_Admin_Features::elementLayoutItemActions(); + +$active_tab_slug = (!empty($_REQUEST['pp_caps_tab'])) ? sanitize_key($_REQUEST['pp_caps_tab']) : 'headerandfooter'; ?>
@@ -38,6 +43,7 @@
+
@@ -78,219 +84,219 @@ class="button-primary ppc-admin-features-submit" />
- - - - - - - - - - - - - - - - - - - - - - $section_elements) : - $sn++; - if (is_array($title_lists) && isset($title_lists[$section_title])) { - $translated_title = $title_lists[$section_title]; - } else { - $translated_title = $section_title; - } - - $section_slug = strtolower(ppc_remove_non_alphanumeric_space_characters($section_title)); - $icon_name = 'open-folder';//isset($icon_list[$section_slug]) ? $icon_list[$section_slug] : ''; - ?> - - - - - - - - - +
+
+
    + $section_elements) { + $sn++; + if (is_array($title_lists) && isset($title_lists[$section_title])) { + $translated_title = $title_lists[$section_title]; + } else { + $translated_title = $section_title; + } + + $feature_action = is_array($section_actions) && isset($section_actions[$section_title]) ? $section_actions[$section_title] : ''; + + $section_slug = strtolower(ppc_remove_non_alphanumeric_space_characters($section_title)); + + $active_class = ($section_slug === $active_tab_slug) ? 'ppc-capabilities-tab-active' : ''; + + $disabled_count = count(PP_Capabilities_Admin_Features::adminFeaturesRestrictedElements($disabled_admin_items, $feature_action)); + + $count_html = ($disabled_count > 0) ? '('. $disabled_count .')' : ''; + ?> +
  • +
    + +
    +
    + +
    +
  • + +
+
+ +
$section_array) : + foreach ($admin_features_elements as $section_title => $section_elements) : $sn++; - if (!$section_id) { - continue; - } - $item_name = $section_array['label']; - $item_action = $section_array['action']; - $restrict_value = $item_action.'||'.$section_id; - if($item_action === 'ppc_dashboard_widget'){ - $restrict_value .= '||'.$section_array['context']; - } - - if (isset($section_array['custom_element']) && ($section_array['custom_element'] === true)) { - $additional_class = 'custom-item-' . $section_array['button_data_id']; + if (is_array($title_lists) && isset($title_lists[$section_title])) { + $translated_title = $title_lists[$section_title]; } else { - $additional_class = ''; + $translated_title = $section_title; } - ?> -
- - - - - - - - - + $section_slug = strtolower(ppc_remove_non_alphanumeric_space_characters($section_title)); - - - -
- -
- -
- /> - - - - -
- /> -
+ $active_style = ($section_slug === $active_tab_slug) ? '' : 'display:none;'; + ?> +
+ +

+ +

+ + + + <> + + + + + > + + + + + $section_array) : + $sn++; + if (!$section_id) { + continue; + } + $item_name = $section_array['label']; + $item_action = $section_array['action']; + $restrict_value = $item_action.'||'.$section_id; + if($item_action === 'ppc_dashboard_widget'){ + $restrict_value .= '||'.$section_array['context']; + } + + if (isset($section_array['custom_element']) && ($section_array['custom_element'] === true)) { + $additional_class = 'custom-item-' . $section_array['button_data_id']; + } else { + $additional_class = ''; + } + ?> + + + + + + + + + + + +
+ + + +
+ /> +
+
+ +
+
-
+ class="button-primary ppc-admin-features-submit" style="float:right"/> @@ -315,14 +321,67 @@ class="button-primary ppc-admin-features-submit"/> + +