PluginProbe
Filter Everything — WordPress & WooCommerce Filters / 1.2.4
Filter Everything — WordPress & WooCommerce Filters v1.2.4
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.2.4, at views/admin/header-navigation.php

71 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined('WPINC') ) {
4 wp_die();
5 }
6
7 global $submenu, $parent_file, $submenu_file, $plugin_page, $pagenow;
8
9 // Vars.
10 $parent_slug = 'edit.php?post_type=' . FLRT_FILTERS_SET_POST_TYPE;
11
12 // Generate array of navigation items.
13 $tabs = array();
14 if( isset($submenu[ $parent_slug ]) ) {
15 foreach( $submenu[ $parent_slug ] as $i => $sub_item ) {
16
17 // Check user can access page.
18 if ( !current_user_can( $sub_item[1] ) ) {
19 continue;
20 }
21
22 // Ignore "Add New".
23 if( $i === 1 ) {
24 continue;
25 }
26
27 // Define tab.
28 $tab = array(
29 'text' => $sub_item[0],
30 'url' => $sub_item[2]
31 );
32
33 // Convert submenu slug "test" to "$parent_slug&page=test".
34 if( !strpos($sub_item[2], '.php') ) {
35 $tab['url'] = add_query_arg( array( 'page' => $sub_item[2] ), $parent_slug );
36 }
37
38 // Detect active state.
39 if( $submenu_file === $sub_item[2] || $plugin_page === $sub_item[2] ) {
40 $tab['is_active'] = true;
41 }
42
43 // Special case for "Add New" page.
44 if( $i === 0 && $submenu_file === 'post-new.php?post_type=' . FLRT_FILTERS_SET_POST_TYPE ) {
45 $tab['is_active'] = true;
46 }
47 $tabs[] = $tab;
48 }
49 }
50
51 $tabs = apply_filters( 'wpc_header_nav_tabs', $tabs );
52
53 // Bail early if set to false.
54 if( $tabs === false ) {
55 return;
56 }
57 ?>
58 <div class="wpc-admin-toolbar">
59 <h2><img src="<?php echo esc_attr( flrt_get_icon_svg('#333333') ); ?>" alt="" width="20" /> <?php echo esc_html( flrt_get_plugin_name() ); ?></h2>
60 <?php foreach( $tabs as $tab ) {
61 $is_active = !empty( $tab['is_active'] ) ? ' is-active' : '';
62
63 printf(
64 '<a class="wpc-tab%s" href="%s">%s</a>', $is_active, esc_url( $tab['url'] ), esc_html( $tab['text'] )
65 );
66 } ?>
67
68 <div class="wpc-admin-right">
69 <?php do_action('wpc_admin_toolbar_right'); ?>
70 </div>
71 </div>