header.php
66 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 | global $post_type, $post_type_object, $acf_page_title; |
| 15 | $post_new_file = sprintf( |
| 16 | 'post-new.php?post_type=%s', |
| 17 | is_string( $post_type ) ? $post_type : 'acf-field-group' |
| 18 | ); |
| 19 | |
| 20 | $acf_is_options_page_preview = acf_request_arg( 'page' ) === 'acf_options_preview'; |
| 21 | |
| 22 | $page_title = false; |
| 23 | if ( isset( $acf_page_title ) ) { |
| 24 | $page_title = $acf_page_title; |
| 25 | } elseif ( is_object( $post_type_object ) ) { |
| 26 | $page_title = $post_type_object->labels->name; |
| 27 | } |
| 28 | if ( $page_title ) { |
| 29 | ?> |
| 30 | <div class="acf-headerbar"> |
| 31 | |
| 32 | <h1 class="acf-page-title"> |
| 33 | <?php |
| 34 | echo esc_html( $page_title ); |
| 35 | ?> |
| 36 | <?php if ( $acf_is_options_page_preview ) { ?> |
| 37 | <div class="acf-pro-label"><img src="<?php echo esc_url( acf_get_url( 'assets/images/pro-chip.svg' ) ); ?>" alt="<?php esc_attr_e( 'ACF PRO logo', 'acf' ); ?>"></div> |
| 38 | <?php |
| 39 | } |
| 40 | ?> |
| 41 | </h1> |
| 42 | <?php if ( $acf_is_options_page_preview ) { ?> |
| 43 | <a href="#" class="acf-btn acf-btn-sm disabled"> |
| 44 | <i class="acf-icon acf-icon-plus"></i> |
| 45 | <?php esc_html_e( 'Add Options Page', 'acf' ); ?> |
| 46 | </a> |
| 47 | <?php } ?> |
| 48 | <?php |
| 49 | if ( ! empty( $post_type_object ) && current_user_can( $post_type_object->cap->create_posts ) ) { |
| 50 | $class = 'acf-btn acf-btn-sm'; |
| 51 | if ( 'acf-ui-options-page' === $post_type && acf_is_pro() && ! acf_pro_is_license_active() ) { |
| 52 | $class .= ' disabled'; |
| 53 | } |
| 54 | |
| 55 | printf( |
| 56 | '<a href="%1$s" class="%2$s"><i class="acf-icon acf-icon-plus"></i>%3$s</a>', |
| 57 | esc_url( admin_url( $post_new_file ) ), |
| 58 | esc_attr( $class ), |
| 59 | esc_html( $post_type_object->labels->add_new ) |
| 60 | ); |
| 61 | } |
| 62 | ?> |
| 63 | |
| 64 | </div> |
| 65 | <?php } ?> |
| 66 |