form-top.php
97 lines
| 1 | <?php |
| 2 | global $title, $post_new_file, $post_type_object, $post; |
| 3 | $acf_title_placeholder = apply_filters( 'enter_title_here', __( 'Add title', 'secure-custom-fields' ), $post ); |
| 4 | $acf_title = $post->post_title; |
| 5 | $acf_post_type = is_object( $post_type_object ) ? $post_type_object->name : ''; |
| 6 | $acf_publish_btn_name = 'save'; |
| 7 | $acf_duplicated_from = ''; |
| 8 | |
| 9 | if ( 'publish' !== $post->post_status ) { |
| 10 | $acf_publish_btn_name = 'publish'; |
| 11 | } |
| 12 | |
| 13 | if ( 'acf-field-group' === $acf_post_type ) { |
| 14 | $acf_use_post_type = acf_get_post_type_from_request_args( 'add-fields' ); |
| 15 | $acf_use_taxonomy = acf_get_taxonomy_from_request_args( 'add-fields' ); |
| 16 | $acf_use_options_page = acf_get_ui_options_page_from_request_args( 'add-fields' ); |
| 17 | |
| 18 | /* translators: %s - singular label of post type/taxonomy, i.e. "Movie"/"Genre" */ |
| 19 | $acf_prefilled_title = __( '%s fields', 'secure-custom-fields' ); |
| 20 | |
| 21 | /** |
| 22 | * Sets a default title to be prefilled (e.g. "Movies Fields") for a post type or taxonomy. |
| 23 | * |
| 24 | * @since ACF 6.1.5 |
| 25 | * |
| 26 | * @param string $acf_prefilled_title A string to define the prefilled title for a post type or taxonomy. |
| 27 | */ |
| 28 | $acf_prefilled_title = (string) apply_filters( 'acf/field_group/prefill_title', $acf_prefilled_title ); |
| 29 | |
| 30 | if ( $acf_use_post_type && ! empty( $acf_use_post_type['labels']['singular_name'] ) ) { |
| 31 | $acf_prefilled_title = sprintf( $acf_prefilled_title, $acf_use_post_type['labels']['singular_name'] ); |
| 32 | } elseif ( $acf_use_taxonomy && ! empty( $acf_use_taxonomy['labels']['singular_name'] ) ) { |
| 33 | $acf_prefilled_title = sprintf( $acf_prefilled_title, $acf_use_taxonomy['labels']['singular_name'] ); |
| 34 | } elseif ( $acf_use_options_page && ! empty( $acf_use_options_page['page_title'] ) ) { |
| 35 | $acf_prefilled_title = sprintf( $acf_prefilled_title, $acf_use_options_page['page_title'] ); |
| 36 | } else { |
| 37 | $acf_prefilled_title = false; |
| 38 | } |
| 39 | |
| 40 | if ( empty( $acf_title ) && $acf_prefilled_title ) { |
| 41 | $acf_title = $acf_prefilled_title; |
| 42 | } |
| 43 | } elseif ( in_array( $acf_post_type, array( 'acf-post-type', 'acf-taxonomy', 'acf-ui-options-page' ), true ) ) { |
| 44 | $acf_duplicate_post_type = acf_get_post_type_from_request_args( 'acfduplicate' ); |
| 45 | $acf_duplicate_taxonomy = acf_get_taxonomy_from_request_args( 'acfduplicate' ); |
| 46 | $acf_duplicate_ui_options_page = acf_get_ui_options_page_from_request_args( 'acfduplicate' ); |
| 47 | $acf_duplicated_from_label = ''; |
| 48 | |
| 49 | if ( $acf_duplicate_post_type && ! empty( $acf_duplicate_post_type['labels']['singular_name'] ) ) { |
| 50 | $acf_duplicated_from_label = $acf_duplicate_post_type['labels']['singular_name']; |
| 51 | } elseif ( $acf_duplicate_taxonomy && ! empty( $acf_duplicate_taxonomy['labels']['singular_name'] ) ) { |
| 52 | $acf_duplicated_from_label = $acf_duplicate_taxonomy['labels']['singular_name']; |
| 53 | } elseif ( $acf_duplicate_ui_options_page && ! empty( $acf_duplicate_ui_options_page['page_title'] ) ) { |
| 54 | $acf_duplicated_from_label = $acf_duplicate_ui_options_page['page_title']; |
| 55 | } |
| 56 | |
| 57 | if ( ! empty( $acf_duplicated_from_label ) ) { |
| 58 | /* translators: %s - A singular label for a post type or taxonomy. */ |
| 59 | $acf_duplicated_from = ' ' . sprintf( __( '(Duplicated from %s)', 'secure-custom-fields' ), $acf_duplicated_from_label ); |
| 60 | } |
| 61 | } |
| 62 | ?> |
| 63 | <div class="acf-headerbar acf-headerbar-field-editor"> |
| 64 | <div class="acf-headerbar-inner"> |
| 65 | |
| 66 | <div class="acf-headerbar-content"> |
| 67 | <h1 class="acf-page-title"> |
| 68 | <?php |
| 69 | echo esc_html( $title ); |
| 70 | |
| 71 | if ( ! empty( $acf_duplicated_from ) ) { |
| 72 | echo '<span class="acf-duplicated-from">' . esc_html( $acf_duplicated_from ) . '</span>'; |
| 73 | } |
| 74 | ?> |
| 75 | </h1> |
| 76 | <?php if ( 'acf-field-group' === $acf_post_type ) : ?> |
| 77 | <div class="acf-title-wrap"> |
| 78 | <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo esc_html( $acf_title_placeholder ); ?></label> |
| 79 | <input form="post" type="text" name="post_title" size="30" value="<?php echo esc_attr( $acf_title ); ?>" id="title" class="acf-headerbar-title-field" spellcheck="true" autocomplete="off" placeholder="<?php esc_attr_e( 'Field Group Title', 'secure-custom-fields' ); ?>" /> |
| 80 | </div> |
| 81 | <?php endif; ?> |
| 82 | </div> |
| 83 | |
| 84 | <div class="acf-headerbar-actions" id="submitpost"> |
| 85 | <?php if ( 'acf-field-group' === $acf_post_type ) : ?> |
| 86 | <a href="#" class="acf-btn acf-btn-secondary add-field"> |
| 87 | <i class="acf-icon acf-icon-plus"></i> |
| 88 | <?php esc_html_e( 'Add Field', 'secure-custom-fields' ); ?> |
| 89 | </a> |
| 90 | <?php endif; ?> |
| 91 | <button form="post" class="acf-btn acf-publish" name="<?php echo esc_attr( $acf_publish_btn_name ); ?>" type="submit"> |
| 92 | <?php esc_html_e( 'Save Changes', 'secure-custom-fields' ); ?> |
| 93 | </button> |
| 94 | </div> |
| 95 | |
| 96 | </div> |
| 97 | </div> |