PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.4.2
Secure Custom Fields v6.4.2
6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / includes / admin / views / global / navigation.php
secure-custom-fields / includes / admin / views / global Last commit date
form-top.php 1 year ago header.php 1 year ago index.php 1 year ago navigation.php 1 year ago
navigation.php
182 lines
1 <?php
2 //phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- included template file.
3 /**
4 * The template for displaying admin navigation.
5 *
6 * @date 27/3/20
7 * @since ACF 5.9.0
8 */
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 global $submenu, $submenu_file, $plugin_page, $acf_page_title;
15
16 // Setup default vars and generate array of navigation items.
17 $parent_slug = 'edit.php?post_type=acf-field-group';
18 $core_tabs = array();
19 $acf_more_items = array();
20 $more_items = array();
21
22 // Hardcoded since future ACF post types will likely live in the "More" menu.
23 $core_tabs_classes = array( 'acf-field-group', 'acf-post-type', 'acf-taxonomy' );
24 $acf_more_items_classes = array( 'acf-ui-options-page', 'acf-tools', 'acf-settings-updates' );
25
26 if ( isset( $submenu[ $parent_slug ] ) ) {
27 foreach ( $submenu[ $parent_slug ] as $i => $sub_item ) {
28
29 // Check user can access page.
30 if ( ! current_user_can( $sub_item[1] ) ) {
31 continue;
32 }
33
34 // Define tab.
35 $menu_item = array(
36 'text' => $sub_item[0],
37 'url' => $sub_item[2],
38 );
39
40 // Convert submenu slug "test" to "$parent_slug&page=test".
41 if ( ! strpos( $sub_item[2], '.php' ) ) {
42 $menu_item['url'] = add_query_arg( array( 'page' => $sub_item[2] ), $parent_slug );
43 $menu_item['class'] = $sub_item[2];
44 } else {
45 // Build class from URL.
46 $menu_item['class'] = str_replace( 'edit.php?post_type=', '', $sub_item[2] );
47 }
48
49 // Detect active state.
50 if ( $submenu_file === $sub_item[2] || $plugin_page === $sub_item[2] ) {
51 $menu_item['is_active'] = true;
52 }
53
54 // Handle "Add New" versions of edit page.
55 if ( str_replace( 'edit', 'post-new', $sub_item[2] ) === $submenu_file ) {
56 $menu_item['is_active'] = true;
57 }
58
59 // Organize the menu items.
60 if ( in_array( $menu_item['class'], $core_tabs_classes, true ) ) {
61 // Main ACF tabs.
62 $core_tabs[] = $menu_item;
63
64 // Add post types & taxonomies to the more menu as well so we can show them there on smaller screens.
65 if ( in_array( $menu_item['class'], array( 'acf-post-type', 'acf-taxonomy' ), true ) ) {
66 $acf_more_items[] = $menu_item;
67 }
68 } elseif ( in_array( $menu_item['class'], $acf_more_items_classes, true ) ) {
69 // ACF tabs moved to the "More" menu.
70 $acf_more_items[] = $menu_item;
71 } else {
72 // Third party tabs placed into the "More" menu.
73 $more_items[] = $menu_item;
74 }
75 }
76 }
77
78 /**
79 * Filters the admin navigation more items.
80 *
81 * @since ACF 5.9.0
82 *
83 * @param array $more_items The array of navigation tabs.
84 */
85 $more_items = apply_filters( 'acf/admin/toolbar', $more_items );
86
87 // Bail early if set to false.
88 if ( $core_tabs === false ) {
89 return;
90 }
91
92 /**
93 * Helper function for looping over the provided menu items
94 * and echoing out the necessary markup.
95 *
96 * @since ACF 6.2
97 *
98 * @param array $menu_items An array of menu items to print.
99 * @param string $section The section being printed.
100 * @return void
101 */
102 function acf_print_menu_section( $menu_items, $section = '' ) {
103 // Bail if no menu items.
104 if ( ! is_array( $menu_items ) || empty( $menu_items ) ) {
105 return;
106 }
107
108 $section_html = '';
109
110 foreach ( $menu_items as $menu_item ) {
111 $class = ! empty( $menu_item['class'] ) ? $menu_item['class'] : $menu_item['text'];
112 $target = ! empty( $menu_item['target'] ) ? ' target="' . esc_attr( $menu_item['target'] ) . '"' : '';
113 $li_class = ! empty( $menu_item['li_class'] ) ? esc_attr( $menu_item['li_class'] ) : '';
114
115 $html = sprintf(
116 '<a class="acf-tab%s %s" href="%s"%s><i class="acf-icon"></i>%s</a>',
117 ! empty( $menu_item['is_active'] ) ? ' is-active' : '',
118 'acf-header-tab-' . esc_attr( acf_slugify( $class ) ),
119 esc_url( $menu_item['url'] ),
120 $target,
121 acf_esc_html( $menu_item['text'] )
122 );
123
124 if ( 'core' !== $section ) {
125 if ( $li_class === '' ) {
126 $html = '<li>' . $html . '</li>';
127 } else {
128 $html = sprintf( '<li class="%s">', $li_class ) . $html . '</li>';
129 }
130 }
131
132 $section_html .= $html;
133 }
134
135 echo $section_html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- safely built and escaped HTML above.
136 }
137 ?>
138 <div class="acf-admin-toolbar">
139 <div class="acf-admin-toolbar-inner">
140 <div class="acf-nav-wrap">
141 <a href="<?php echo esc_url( admin_url( 'edit.php?post_type=acf-field-group' ) ); ?>" class="acf-logo">
142 <img src="<?php echo esc_url( acf_get_url( 'assets/images/scf-logo.svg' ) ); ?>" alt="<?php esc_attr_e( 'Seecure Custom Fields logo', 'secure-custom-fields' ); ?>">
143 </a>
144
145 <h2><?php echo esc_html( acf_get_setting( 'name' ) ); ?></h2>
146 <?php acf_print_menu_section( $core_tabs, 'core' ); ?>
147 <?php if ( $acf_more_items || $more_items ) { ?>
148 <div class="acf-more acf-header-tab-acf-more" tabindex="0">
149 <span class="acf-tab acf-more-tab"><i class="acf-icon acf-icon-more"></i><?php esc_html_e( 'More', 'secure-custom-fields' ); ?> <i class="acf-icon acf-icon-dropdown"></i></span>
150 <ul>
151 <?php
152 if ( $acf_more_items ) {
153 if ( $more_items ) {
154 echo '<li class="acf-more-section-header"><span class="acf-tab acf-tab-header">ACF</span></li>';
155 }
156 acf_print_menu_section( $acf_more_items, 'acf' );
157 }
158 if ( $more_items ) {
159 echo '<li class="acf-more-section-header"><span class="acf-tab acf-tab-header">' . esc_html__( 'Other', 'secure-custom-fields' ) . ' </span></li>';
160 acf_print_menu_section( $more_items );
161 }
162 ?>
163 </ul>
164 </div>
165 <?php } ?>
166 </div>
167 </div>
168 </div>
169
170 <?php
171
172 global $plugin_page;
173 $screen = get_current_screen();
174
175 if ( ! in_array( $screen->id, acf_get_internal_post_types(), true ) ) {
176 if ( $plugin_page == 'acf-tools' ) {
177 $acf_page_title = __( 'Tools', 'secure-custom-fields' );
178 }
179 acf_get_view( 'global/header' );
180 }
181 ?>
182