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.2.1 4.2.2 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.4.10 4.4.11 4.4.12 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 5.10 5.10.1 5.10.2 5.11 5.11.1 5.11.2 5.11.3 5.11.4 5.12 5.12.1 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.6.10 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 5.6.7 5.6.8 5.6.9 5.7.0 5.7.1 5.7.10 5.7.12 5.7.13 5.7.2 5.7.3 5.7.4 5.7.5 5.7.6 5.7.7 5.7.8 5.7.9 5.8.0 5.8.1 5.8.10 5.8.11 5.8.12 5.8.13 5.8.14 5.8.2 5.8.3 5.8.4
advanced-custom-fields / includes / admin / views / global / navigation.php
advanced-custom-fields / includes / admin / views / global Last commit date
form-top.php 6 months ago header.php 6 months ago index.php 2 years ago navigation.php 6 months ago
navigation.php
273 lines
1 <?php
2 /**
3 * @package ACF
4 * @author WP Engine
5 *
6 * © 2026 Advanced Custom Fields (ACF®). All rights reserved.
7 * "ACF" is a trademark of WP Engine.
8 * Licensed under the GNU General Public License v2 or later.
9 * https://www.gnu.org/licenses/gpl-2.0.html
10 */
11
12 //phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- included template file.
13 /**
14 * The template for displaying admin navigation.
15 *
16 * @date 27/3/20
17 * @since 5.9.0
18 */
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit;
22 }
23
24 global $submenu, $submenu_file, $plugin_page, $acf_page_title;
25
26 // Setup default vars and generate array of navigation items.
27 $parent_slug = 'edit.php?post_type=acf-field-group';
28 $core_tabs = array();
29 $acf_more_items = array();
30 $more_items = array();
31 $wpengine_more_items = array();
32
33 // Hardcoded since future ACF post types will likely live in the "More" menu.
34 $core_tabs_classes = array( 'acf-field-group', 'acf-post-type', 'acf-taxonomy' );
35 $acf_more_items_classes = array( 'acf-ui-options-page', 'acf-tools', 'acf-settings-updates' );
36
37 if ( isset( $submenu[ $parent_slug ] ) ) {
38 foreach ( $submenu[ $parent_slug ] as $i => $sub_item ) {
39
40 // Check user can access page.
41 if ( ! current_user_can( $sub_item[1] ) ) {
42 continue;
43 }
44
45 // Define tab.
46 $menu_item = array(
47 'text' => $sub_item[0],
48 'url' => $sub_item[2],
49 );
50
51 // Convert submenu slug "test" to "$parent_slug&page=test".
52 if ( ! strpos( $sub_item[2], '.php' ) ) {
53 $menu_item['url'] = add_query_arg( array( 'page' => $sub_item[2] ), $parent_slug );
54 $menu_item['class'] = $sub_item[2];
55 } else {
56 // Build class from URL.
57 $menu_item['class'] = str_replace( 'edit.php?post_type=', '', $sub_item[2] );
58 }
59
60 // Detect active state.
61 if ( $submenu_file === $sub_item[2] || $plugin_page === $sub_item[2] ) {
62 $menu_item['is_active'] = true;
63 }
64
65 // Handle "Add New" versions of edit page.
66 if ( str_replace( 'edit', 'post-new', $sub_item[2] ) === $submenu_file ) {
67 $menu_item['is_active'] = true;
68 }
69
70 // Organize the menu items.
71 if ( in_array( $menu_item['class'], $core_tabs_classes, true ) ) {
72 // Main ACF tabs.
73 $core_tabs[] = $menu_item;
74
75 // Add post types & taxonomies to the more menu as well so we can show them there on smaller screens.
76 if ( in_array( $menu_item['class'], array( 'acf-post-type', 'acf-taxonomy' ), true ) ) {
77 $acf_more_items[] = $menu_item;
78 }
79 } elseif ( in_array( $menu_item['class'], $acf_more_items_classes, true ) ) {
80 // ACF tabs moved to the "More" menu.
81 $acf_more_items[] = $menu_item;
82 } else {
83 // Third party tabs placed into the "More" menu.
84 if ( 'acf_options_preview' === $menu_item['class'] ) {
85 continue;
86 }
87
88 $more_items[] = $menu_item;
89 }
90 }
91 }
92
93 if ( ! acf_get_setting( 'pro' ) ) {
94 $acf_more_items[] = array(
95 'url' => 'edit.php?post_type=acf-field-group&page=acf_options_preview',
96 'text' => __( 'Options Pages', 'acf' ) . '<span class="acf-requires-pro">' . __( 'PRO', 'acf' ) . '</span>',
97 'target' => '_self',
98 );
99 }
100
101 if ( ! defined( 'PWP_NAME' ) ) {
102 $acf_wpengine_logo = acf_get_url( 'assets/images/wp-engine-horizontal-black.svg' );
103 $acf_wpengine_logo = sprintf( '<span><img class="acf-wp-engine-pro" src="%s" alt="WP Engine" /></span>', $acf_wpengine_logo );
104 $utm_content = acf_is_pro() ? 'acf_pro_plugin_topbar_dropdown_cta' : 'acf_free_plugin_topbar_dropdown_cta';
105 $wpengine_more_items[] = array(
106 'url' => acf_add_url_utm_tags( 'https://wpengine.com/plans/?coupon=freedomtocreate', 'bx_prod_referral', $utm_content, false, 'acf_plugin', 'referral' ),
107 'text' => $acf_wpengine_logo . '<span class="acf-wp-engine-upsell-pill">' . __( '4 Months Free', 'acf' ) . '</span>',
108 'target' => '_blank',
109 'li_class' => 'acf-wp-engine',
110 'aria-label' => __( 'Get 4 months free on any WP Engine plan', 'acf' ),
111 );
112 }
113
114 /**
115 * Filters the admin navigation more items.
116 *
117 * @since 5.9.0
118 *
119 * @param array $more_items The array of navigation tabs.
120 */
121 $more_items = apply_filters( 'acf/admin/toolbar', $more_items );
122
123 // Bail early if set to false.
124 if ( $core_tabs === false ) {
125 return;
126 }
127
128 $acf_wpengine_logo_link = acf_add_url_utm_tags(
129 'https://wpengine.com/',
130 'bx_prod_referral',
131 acf_is_pro() ? 'acf_pro_plugin_topbar_logo' : 'acf_free_plugin_topbar_logo',
132 false,
133 'acf_plugin',
134 'referral'
135 );
136
137 /**
138 * Helper function for looping over the provided menu items
139 * and echoing out the necessary markup.
140 *
141 * @since 6.2
142 *
143 * @param array $menu_items An array of menu items to print.
144 * @param string $section The section being printed.
145 * @return void
146 */
147 function acf_print_menu_section( $menu_items, $section = '' ) {
148 // Bail if no menu items.
149 if ( ! is_array( $menu_items ) || empty( $menu_items ) ) {
150 return;
151 }
152
153 $section_html = '';
154
155 foreach ( $menu_items as $menu_item ) {
156 $class = ! empty( $menu_item['class'] ) ? $menu_item['class'] : $menu_item['text'];
157 $target = ! empty( $menu_item['target'] ) ? ' target="' . esc_attr( $menu_item['target'] ) . '"' : '';
158 $aria_label = ! empty( $menu_item['aria-label'] ) ? ' aria-label="' . esc_attr( $menu_item['aria-label'] ) . '"' : '';
159 $li_class = ! empty( $menu_item['li_class'] ) ? esc_attr( $menu_item['li_class'] ) : '';
160
161 $html = sprintf(
162 '<a class="acf-tab%s %s" href="%s"%s%s><i class="acf-icon"></i>%s</a>',
163 ! empty( $menu_item['is_active'] ) ? ' is-active' : '',
164 'acf-header-tab-' . esc_attr( acf_slugify( $class ) ),
165 esc_url( $menu_item['url'] ),
166 $target,
167 $aria_label,
168 acf_esc_html( $menu_item['text'] )
169 );
170
171 if ( 'core' !== $section ) {
172 if ( $li_class === '' ) {
173 $html = '<li>' . $html . '</li>';
174 } else {
175 $html = sprintf( '<li class="%s">', $li_class ) . $html . '</li>';
176 }
177 }
178
179 $section_html .= $html;
180 }
181
182 echo $section_html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- safely built and escaped HTML above.
183 }
184 ?>
185 <div class="acf-admin-toolbar">
186 <div class="acf-admin-toolbar-inner">
187 <div class="acf-nav-wrap">
188 <?php if ( acf_is_pro() && acf_pro_is_license_active() ) { ?>
189 <a href="<?php echo esc_url( admin_url( 'edit.php?post_type=acf-field-group' ) ); ?>" class="acf-logo pro" aria-label="<?php esc_attr_e( 'Edit ACF Field Groups', 'acf' ); ?>">
190 <img src="<?php echo esc_url( acf_get_url( 'assets/images/acf-pro-logo.svg' ) ); ?>" alt="<?php esc_attr_e( 'Advanced Custom Fields logo', 'acf' ); ?>">
191 </a>
192 <?php } else { ?>
193 <a href="<?php echo esc_url( admin_url( 'edit.php?post_type=acf-field-group' ) ); ?>" class="acf-logo" aria-label="<?php esc_attr_e( 'Edit ACF Field Groups', 'acf' ); ?>">
194 <img src="<?php echo esc_url( acf_get_url( 'assets/images/acf-logo.svg' ) ); ?>" alt="<?php esc_attr_e( 'Advanced Custom Fields logo', 'acf' ); ?>">
195 </a>
196 <?php } ?>
197
198 <h2><?php echo esc_html( acf_get_setting( 'name' ) ); ?></h2>
199 <?php acf_print_menu_section( $core_tabs, 'core' ); ?>
200 <?php if ( $acf_more_items || $more_items ) { ?>
201 <div class="acf-more acf-header-tab-acf-more" tabindex="0">
202 <span class="acf-tab acf-more-tab"><i class="acf-icon acf-icon-more"></i><?php esc_html_e( 'More', 'acf' ); ?> <i class="acf-icon acf-icon-dropdown"></i></span>
203 <ul>
204 <?php
205 if ( $acf_more_items ) {
206 if ( $more_items ) {
207 echo '<li class="acf-more-section-header"><span class="acf-tab acf-tab-header">ACF</span></li>';
208 }
209 acf_print_menu_section( $acf_more_items, 'acf' );
210 }
211 if ( $more_items ) {
212 echo '<li class="acf-more-section-header"><span class="acf-tab acf-tab-header">' . esc_html__( 'Other', 'acf' ) . ' </span></li>';
213 acf_print_menu_section( $more_items );
214 }
215 if ( $wpengine_more_items ) {
216 acf_print_menu_section( $wpengine_more_items );
217 }
218 ?>
219 </ul>
220 </div>
221 <?php } ?>
222 </div>
223 <div class="acf-nav-upgrade-wrap">
224 <?php
225 if ( ! acf_is_pro() || ! acf_pro_is_license_active() ) {
226 $unlock_url = acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/pro/', 'ACF upgrade', 'header' );
227 $unlock_target = '_blank';
228 $unlock_text = __( 'Unlock Extra Features with ACF PRO', 'acf' );
229
230 if ( acf_is_pro() ) {
231 if ( acf_pro_is_updates_page_visible() ) {
232 $unlock_url = admin_url( 'edit.php?post_type=acf-field-group&page=acf-settings-updates#acf_pro_license' );
233 $unlock_target = '';
234 }
235
236 if ( acf_pro_is_license_expired() ) {
237 $unlock_url = acf_add_url_utm_tags( acf_pro_get_manage_license_url(), 'ACF renewal', 'header' );
238 $unlock_target = '_blank';
239 $unlock_text = __( 'Renew ACF PRO License', 'acf' );
240 }
241 }
242 ?>
243 <a target="<?php echo esc_attr( $unlock_target ); ?>" href="<?php echo esc_url( $unlock_url ); ?>" class="btn-upgrade acf-admin-toolbar-upgrade-btn">
244 <i class="acf-icon acf-icon-stars"></i>
245 <p><?php echo esc_html( $unlock_text ); ?></p>
246 </a>
247 <?php
248 }
249 ?>
250 <a href="<?php echo $acf_wpengine_logo_link; ?>" target="_blank" class="acf-nav-wpengine-logo" aria-label="<?php esc_attr_e( 'WP Engine', 'acf' ); ?>"><?php //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped on generation. ?>
251 <img src="<?php echo esc_url( acf_get_url( 'assets/images/wp-engine-horizontal-white.svg' ) ); ?>" alt="<?php esc_html_e( 'WP Engine logo', 'acf' ); ?>" />
252 </a>
253 </div>
254 </div>
255 </div>
256
257 <?php
258
259 global $plugin_page;
260 $screen = get_current_screen();
261
262 if ( ! in_array( $screen->id, acf_get_internal_post_types(), true ) ) {
263 if ( $plugin_page == 'acf-tools' ) {
264 $acf_page_title = __( 'Tools', 'acf' );
265 } elseif ( $plugin_page == 'acf-settings-updates' ) {
266 $acf_page_title = __( 'Updates', 'acf' );
267 } elseif ( $plugin_page == 'acf_options_preview' && ! acf_is_pro() ) {
268 $acf_page_title = __( 'Options Pages', 'acf' );
269 }
270 acf_get_view( 'global/header' );
271 }
272 ?>
273