$sub_item) { if (!current_user_can($sub_item[1])) { continue; } if ($i === 1) { continue; } if (in_array($sub_item[2], $hidden_in_toolbar, true)) { continue; } $tab = array( 'text' => $sub_item[0], 'url' => $sub_item[2] ); if (!strpos($sub_item[2], '.php')) { $tab['url'] = add_query_arg(array('page' => $sub_item[2]), $parent_slug); } $tab_tab = ''; $tab_url_parts = wp_parse_url($tab['url']); if (isset($tab_url_parts['query'])) { parse_str($tab_url_parts['query'], $tab_qs); if (isset($tab_qs['tab'])) { $tab_tab = sanitize_key($tab_qs['tab']); } } $tab['is_active'] = false; $tab_matches = false; if (strpos($sub_item[2], '.php') === false) { $current_page = isset($_GET['page']) ? sanitize_key($_GET['page']) : ''; $tab_matches = ($current_page === sanitize_key($sub_item[2])); } else { $tab_matches = ($submenu_file === $sub_item[2] || $plugin_page === $sub_item[2]); } $is_same_submenu = $tab_matches; if ($is_same_submenu) { // Any Settings tab (Import/Export included — it has no toolbar tab of // its own any more) keeps the «Settings» tab active if($current_page == 'filters-settings'){ $tab['is_active'] = true; }elseif ($current_tab) { if ($tab_tab && $tab_tab === $current_tab) { $tab['is_active'] = true; } } else { if (empty($tab_tab)) { $tab['is_active'] = true; } } } if ($i === 0 && $submenu_file === 'post-new.php?post_type=' . FLRT_FILTERS_SET_POST_TYPE) { $tab['is_active'] = true; } $tabs[] = $tab; } } $tabs = apply_filters('wpc_header_nav_tabs', $tabs); if ($tabs === false) { return; } ?>