header.php
40 lines
| 1 | <?php |
| 2 | //phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- included template file. |
| 3 | |
| 4 | global $post_type, $post_type_object, $acf_page_title; |
| 5 | $post_new_file = sprintf( |
| 6 | 'post-new.php?post_type=%s', |
| 7 | is_string( $post_type ) ? $post_type : 'acf-field-group' |
| 8 | ); |
| 9 | |
| 10 | $page_title = false; |
| 11 | if ( isset( $acf_page_title ) ) { |
| 12 | $page_title = $acf_page_title; |
| 13 | } elseif ( is_object( $post_type_object ) ) { |
| 14 | $page_title = $post_type_object->labels->name; |
| 15 | } |
| 16 | if ( $page_title ) { |
| 17 | ?> |
| 18 | <div class="acf-headerbar"> |
| 19 | |
| 20 | <h1 class="acf-page-title"> |
| 21 | <?php |
| 22 | echo esc_html( $page_title ); |
| 23 | ?> |
| 24 | </h1> |
| 25 | <?php |
| 26 | if ( ! empty( $post_type_object ) && current_user_can( $post_type_object->cap->create_posts ) ) { |
| 27 | $class = 'acf-btn acf-btn-sm'; |
| 28 | |
| 29 | printf( |
| 30 | '<a href="%1$s" class="%2$s"><i class="acf-icon acf-icon-plus"></i>%3$s</a>', |
| 31 | esc_url( admin_url( $post_new_file ) ), |
| 32 | esc_attr( $class ), |
| 33 | esc_html( $post_type_object->labels->add_new ) |
| 34 | ); |
| 35 | } |
| 36 | ?> |
| 37 | |
| 38 | </div> |
| 39 | <?php } ?> |
| 40 |