| @@ -11,9 +11,23 @@ | ||
| 11 | 11 | |
| 12 | 12 | $current_tab = isset($_GET['tab']) ? sanitize_key($_GET['tab']) : ''; |
| 13 | 13 | $current_page = isset($_GET['page']) ? sanitize_key($_GET['page']) : ''; |
| 14 | 14 | $tabs = array(); |
| 15 | +$this_page_has_import_export_tab = false; | |
| 15 | 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])) { | |
| 16 | 30 | foreach ($submenu[$parent_slug] as $i => $sub_item) { |
| 17 | 31 | |
| 18 | 32 | if (!current_user_can($sub_item[1])) { |
| 19 | 33 | continue; |
| @@ -22,10 +36,16 @@ | ||
| 22 | 36 | if ($i === 1) { |
| 23 | 37 | continue; |
| 24 | 38 | } |
| 25 | 39 | |
| 40 | + if (in_array($sub_item[2], $hidden_in_toolbar, true)) { | |
| 41 | + continue; | |
| 42 | + } | |
| 43 | + | |
| 26 | 44 | $tab = array( |
| 27 | - 'text' => $sub_item[0], | |
| 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]), | |
| 28 | 48 | 'url' => $sub_item[2] |
| 29 | 49 | ); |
| 30 | 50 | |
| 31 | 51 | if (!strpos($sub_item[2], '.php')) { |
| @@ -52,10 +72,16 @@ | ||
| 52 | 72 | } |
| 53 | 73 | $is_same_submenu = $tab_matches; |
| 54 | 74 | |
| 55 | 75 | if ($is_same_submenu) { |
| 56 | - if($current_tab !== 'import_export' && $current_page == 'filters-settings'){ | |
| 57 | - $tab['is_active'] = true; | |
| 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 | + } | |
| 58 | 84 | }elseif ($current_tab) { |
| 59 | 85 | if ($tab_tab && $tab_tab === $current_tab) { |
| 60 | 86 | $tab['is_active'] = true; |
| 61 | 87 | } |
| @@ -79,13 +105,17 @@ | ||
| 79 | 105 | return; |
| 80 | 106 | } |
| 81 | 107 | ?> |
| 82 | 108 | <div class="wpc-admin-toolbar"> |
| 83 | - <h2><img src="<?php | |
| 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 | |
| 84 | 110 | echo esc_attr(flrt_get_icon_svg('#333333')); |
| 85 | 111 | ?>" alt="" width="24"/> <?php |
| 86 | 112 | echo esc_html(flrt_get_plugin_name()); |
| 87 | - ?></h2> | |
| 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> | |
| 88 | 118 | <?php foreach ($tabs as $tab) { |
| 89 | 119 | $is_active = !empty($tab['is_active']) ? ' is-active' : ''; |
| 90 | 120 | $is_pro = str_contains($tab['text'], 'wpc-pro-badge') ? ' wpc-pro-badge-text' : ''; |
| 91 | 121 | $tab_text = str_replace('wpc-pro-badge', 'wpc-pro-badge-transparent', $tab['text']); |