PluginProbe
Filter Everything — WordPress & WooCommerce Filters / 1.9.7
Filter Everything — WordPress & WooCommerce Filters v1.9.7
1.9.7 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 All 52 releases
filter-everything / views / admin / header-navigation.php

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

139 lines 5.0 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 $this_page_has_import_export_tab = false;
16 if (isset($submenu[$parent_slug])) {
17 foreach ($submenu[$parent_slug] as $sub_item) {
18 if (isset($sub_item[2]) && strpos($sub_item[2], 'tab=import_export') !== false) {
19 $this_page_has_import_export_tab = true;
20 }
21 }
22 }
23
24 // Submenu entries that must NOT become toolbar tabs (the toolbar mirrors the
25 // sidebar). Empty by default: since 1.9.7 «What's new» is a Settings tab, not
26 // a submenu entry, and Import/Export is back in both.
27 $hidden_in_toolbar = apply_filters('wpc_header_nav_hidden_slugs', array());
28
29 if (isset($submenu[$parent_slug])) {
30 foreach ($submenu[$parent_slug] as $i => $sub_item) {
31
32 if (!current_user_can($sub_item[1])) {
33 continue;
34 }
35
36 if ($i === 1) {
37 continue;
38 }
39
40 if (in_array($sub_item[2], $hidden_in_toolbar, true)) {
41 continue;
42 }
43
44 $tab = array(
45 // The sidebar's unread badge (WhatsNew) belongs to the sidebar; the
46 // toolbar shows the plain label
47 'text' => preg_replace('#\s*<span class="update-plugins[^"]*">.*?</span></span>#s', '', $sub_item[0]),
48 'url' => $sub_item[2]
49 );
50
51 if (!strpos($sub_item[2], '.php')) {
52 $tab['url'] = add_query_arg(array('page' => $sub_item[2]), $parent_slug);
53 }
54
55 $tab_tab = '';
56 $tab_url_parts = wp_parse_url($tab['url']);
57 if (isset($tab_url_parts['query'])) {
58 parse_str($tab_url_parts['query'], $tab_qs);
59 if (isset($tab_qs['tab'])) {
60 $tab_tab = sanitize_key($tab_qs['tab']);
61 }
62 }
63
64 $tab['is_active'] = false;
65
66 $tab_matches = false;
67 if (strpos($sub_item[2], '.php') === false) {
68 $current_page = isset($_GET['page']) ? sanitize_key($_GET['page']) : '';
69 $tab_matches = ($current_page === sanitize_key($sub_item[2]));
70 } else {
71 $tab_matches = ($submenu_file === $sub_item[2] || $plugin_page === $sub_item[2]);
72 }
73 $is_same_submenu = $tab_matches;
74
75 if ($is_same_submenu) {
76 // Settings tabs: Import/Export has a toolbar tab of its own (PRO deep
77 // link), every other tab keeps «Settings» active
78 if($current_page == 'filters-settings'){
79 if ($tab_tab) {
80 $tab['is_active'] = ($tab_tab === $current_tab);
81 } else {
82 $tab['is_active'] = ($current_tab !== 'import_export') || ! $this_page_has_import_export_tab;
83 }
84 }elseif ($current_tab) {
85 if ($tab_tab && $tab_tab === $current_tab) {
86 $tab['is_active'] = true;
87 }
88 } else {
89 if (empty($tab_tab)) {
90 $tab['is_active'] = true;
91 }
92 }
93 }
94
95 if ($i === 0 && $submenu_file === 'post-new.php?post_type=' . FLRT_FILTERS_SET_POST_TYPE) {
96 $tab['is_active'] = true;
97 }
98 $tabs[] = $tab;
99 }
100 }
101
102 $tabs = apply_filters('wpc_header_nav_tabs', $tabs);
103
104 if ($tabs === false) {
105 return;
106 }
107 ?>
108 <div class="wpc-admin-toolbar">
109 <h2><a class="wpc-toolbar-brand" href="<?php echo esc_url( admin_url( 'edit.php?post_type=' . FLRT_FILTERS_SET_POST_TYPE ) ); ?>"><img src="<?php
110 echo esc_attr(flrt_get_icon_svg('#333333'));
111 ?>" alt="" width="24"/> <?php
112 echo esc_html(flrt_get_plugin_name());
113 // The running version, always visible on every plugin screen in both builds
114 // (PRO used to print it on the right next to the licence status); the
115 // logo + name link back to the Filter Sets list
116 echo ' <span class="wpc-plugin-version">' . esc_html( FLRT_PLUGIN_VER ) . '</span>';
117 ?></a></h2>
118 <?php foreach ($tabs as $tab) {
119 $is_active = !empty($tab['is_active']) ? ' is-active' : '';
120 $is_pro = str_contains($tab['text'], 'wpc-pro-badge') ? ' wpc-pro-badge-text' : '';
121 $tab_text = str_replace('wpc-pro-badge', 'wpc-pro-badge-transparent', $tab['text']);
122 $extra_class = preg_replace( '/[^a-z]/', '', strtolower( wp_kses($tab_text, [] ) ) );
123 printf(
124 '<a class="wpc-tab%s%s wpc-%s" href="%s">%s</a>',
125 $is_active,
126 $is_pro,
127 $extra_class,
128 esc_url($tab['url']),
129 wp_kses($tab_text, array(
130 'span' => array(
131 'class' => array(),
132 ),
133 ))
134 );
135 } ?>
136 <div class="wpc-admin-right">
137 <?php do_action('wpc_admin_toolbar_right'); ?>
138 </div>
139 </div>