PluginProbe
Filter Everything — WordPress & WooCommerce Filters / 1.9.5
Filter Everything — WordPress & WooCommerce Filters v1.9.5
1.9.6 1.9.5 1.9.4 1.9.3 1.9.2.2 1.9.2.1 trunk 1.2.1 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.1 1.4.4 1.4.5 1.4.8 1.4.9 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 All 51 releases
filter-everything / views / admin / header-navigation.php

header-navigation.php in Filter Everything — WordPress & WooCommerce Filters 1.9.5, at views/admin/header-navigation.php

109 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) {
4 exit;
5 }
6
7 global $submenu, $parent_file, $submenu_file, $plugin_page, $pagenow;
8
9 $parent_slug = 'edit.php?post_type=' . FLRT_FILTERS_SET_POST_TYPE;
10
11
12 $current_tab = isset($_GET['tab']) ? sanitize_key($_GET['tab']) : '';
13 $current_page = isset($_GET['page']) ? sanitize_key($_GET['page']) : '';
14 $tabs = array();
15 if (isset($submenu[$parent_slug])) {
16 foreach ($submenu[$parent_slug] as $i => $sub_item) {
17
18 if (!current_user_can($sub_item[1])) {
19 continue;
20 }
21
22 if ($i === 1) {
23 continue;
24 }
25
26 $tab = array(
27 'text' => $sub_item[0],
28 'url' => $sub_item[2]
29 );
30
31 if (!strpos($sub_item[2], '.php')) {
32 $tab['url'] = add_query_arg(array('page' => $sub_item[2]), $parent_slug);
33 }
34
35 $tab_tab = '';
36 $tab_url_parts = wp_parse_url($tab['url']);
37 if (isset($tab_url_parts['query'])) {
38 parse_str($tab_url_parts['query'], $tab_qs);
39 if (isset($tab_qs['tab'])) {
40 $tab_tab = sanitize_key($tab_qs['tab']);
41 }
42 }
43
44 $tab['is_active'] = false;
45
46 $tab_matches = false;
47 if (strpos($sub_item[2], '.php') === false) {
48 $current_page = isset($_GET['page']) ? sanitize_key($_GET['page']) : '';
49 $tab_matches = ($current_page === sanitize_key($sub_item[2]));
50 } else {
51 $tab_matches = ($submenu_file === $sub_item[2] || $plugin_page === $sub_item[2]);
52 }
53 $is_same_submenu = $tab_matches;
54
55 if ($is_same_submenu) {
56 if($current_tab !== 'import_export' && $current_page == 'filters-settings'){
57 $tab['is_active'] = true;
58 }elseif ($current_tab) {
59 if ($tab_tab && $tab_tab === $current_tab) {
60 $tab['is_active'] = true;
61 }
62 } else {
63 if (empty($tab_tab)) {
64 $tab['is_active'] = true;
65 }
66 }
67 }
68
69 if ($i === 0 && $submenu_file === 'post-new.php?post_type=' . FLRT_FILTERS_SET_POST_TYPE) {
70 $tab['is_active'] = true;
71 }
72 $tabs[] = $tab;
73 }
74 }
75
76 $tabs = apply_filters('wpc_header_nav_tabs', $tabs);
77
78 if ($tabs === false) {
79 return;
80 }
81 ?>
82 <div class="wpc-admin-toolbar">
83 <h2><img src="<?php
84 echo esc_attr(flrt_get_icon_svg('#333333'));
85 ?>" alt="" width="24"/> <?php
86 echo esc_html(flrt_get_plugin_name());
87 ?></h2>
88 <?php foreach ($tabs as $tab) {
89 $is_active = !empty($tab['is_active']) ? ' is-active' : '';
90 $is_pro = str_contains($tab['text'], 'wpc-pro-badge') ? ' wpc-pro-badge-text' : '';
91 $tab_text = str_replace('wpc-pro-badge', 'wpc-pro-badge-transparent', $tab['text']);
92 $extra_class = preg_replace( '/[^a-z]/', '', strtolower( wp_kses($tab_text, [] ) ) );
93 printf(
94 '<a class="wpc-tab%s%s wpc-%s" href="%s">%s</a>',
95 $is_active,
96 $is_pro,
97 $extra_class,
98 esc_url($tab['url']),
99 wp_kses($tab_text, array(
100 'span' => array(
101 'class' => array(),
102 ),
103 ))
104 );
105 } ?>
106 <div class="wpc-admin-right">
107 <?php do_action('wpc_admin_toolbar_right'); ?>
108 </div>
109 </div>