advanced-settings.php
6 months ago
basic-settings.php
6 months ago
index.php
2 years ago
list-empty.php
6 months ago
basic-settings.php
162 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 | global $acf_taxonomy; |
| 13 | |
| 14 | $acf_duplicate_taxonomy = acf_get_taxonomy_from_request_args( 'acfduplicate' ); |
| 15 | |
| 16 | if ( acf_is_taxonomy( $acf_duplicate_taxonomy ) ) { |
| 17 | // Reset vars that likely have to be changed. |
| 18 | $acf_duplicate_taxonomy['key'] = uniqid( 'taxonomy_' ); |
| 19 | $acf_duplicate_taxonomy['title'] = ''; |
| 20 | $acf_duplicate_taxonomy['labels'] = array_map( '__return_empty_string', $acf_duplicate_taxonomy['labels'] ); |
| 21 | $acf_duplicate_taxonomy['taxonomy'] = ''; |
| 22 | $acf_duplicate_taxonomy['rewrite']['slug'] = ''; |
| 23 | $acf_duplicate_taxonomy['query_var_name'] = ''; |
| 24 | $acf_duplicate_taxonomy['rest_base'] = ''; |
| 25 | |
| 26 | // Rest of the vars can be reused. |
| 27 | $acf_taxonomy = $acf_duplicate_taxonomy; |
| 28 | } |
| 29 | |
| 30 | acf_render_field_wrap( |
| 31 | array( |
| 32 | 'label' => __( 'Plural Label', 'acf' ), |
| 33 | /* translators: example taxonomy */ |
| 34 | 'placeholder' => __( 'Genres', 'acf' ), |
| 35 | 'type' => 'text', |
| 36 | 'key' => 'name', |
| 37 | 'name' => 'name', |
| 38 | 'class' => 'acf_plural_label', |
| 39 | 'prefix' => 'acf_taxonomy[labels]', |
| 40 | 'value' => $acf_taxonomy['labels']['name'], |
| 41 | 'required' => 1, |
| 42 | ), |
| 43 | 'div', |
| 44 | 'field' |
| 45 | ); |
| 46 | |
| 47 | acf_render_field_wrap( |
| 48 | array( |
| 49 | 'label' => __( 'Singular Label', 'acf' ), |
| 50 | /* translators: example taxonomy */ |
| 51 | 'placeholder' => __( 'Genre', 'acf' ), |
| 52 | 'type' => 'text', |
| 53 | 'key' => 'singular_name', |
| 54 | 'name' => 'singular_name', |
| 55 | 'class' => 'acf_slugify_to_key acf_singular_label', |
| 56 | 'prefix' => 'acf_taxonomy[labels]', |
| 57 | 'value' => $acf_taxonomy['labels']['singular_name'], |
| 58 | 'required' => 1, |
| 59 | ), |
| 60 | 'div', |
| 61 | 'field' |
| 62 | ); |
| 63 | |
| 64 | acf_render_field_wrap( |
| 65 | array( |
| 66 | 'label' => __( 'Taxonomy Key', 'acf' ), |
| 67 | 'instructions' => __( 'Lower case letters, underscores and dashes only, Max 32 characters.', 'acf' ), |
| 68 | /* translators: example taxonomy */ |
| 69 | 'placeholder' => __( 'genre', 'acf' ), |
| 70 | 'type' => 'text', |
| 71 | 'key' => 'taxonomy', |
| 72 | 'name' => 'taxonomy', |
| 73 | 'maxlength' => 32, |
| 74 | 'class' => 'acf_slugified_key', |
| 75 | 'prefix' => 'acf_taxonomy', |
| 76 | 'value' => $acf_taxonomy['taxonomy'], |
| 77 | 'required' => 1, |
| 78 | ), |
| 79 | 'div', |
| 80 | 'field' |
| 81 | ); |
| 82 | |
| 83 | // Allow preselecting the linked post types based on previously created post type. |
| 84 | $acf_use_post_type = acf_get_post_type_from_request_args( 'create-taxonomy' ); |
| 85 | if ( $acf_use_post_type && ! empty( $acf_use_post_type['post_type'] ) ) { |
| 86 | $acf_taxonomy['object_type'] = array( $acf_use_post_type['post_type'] ); |
| 87 | } |
| 88 | |
| 89 | acf_render_field_wrap( |
| 90 | array( |
| 91 | 'label' => __( 'Post Types', 'acf' ), |
| 92 | 'type' => 'select', |
| 93 | 'name' => 'object_type', |
| 94 | 'prefix' => 'acf_taxonomy', |
| 95 | 'value' => $acf_taxonomy['object_type'], |
| 96 | 'choices' => acf_get_pretty_post_types(), |
| 97 | 'multiple' => 1, |
| 98 | 'ui' => 1, |
| 99 | 'allow_null' => 1, |
| 100 | 'instructions' => __( 'One or many post types that can be classified with this taxonomy.', 'acf' ), |
| 101 | ), |
| 102 | 'div', |
| 103 | 'field' |
| 104 | ); |
| 105 | |
| 106 | acf_render_field_wrap( array( 'type' => 'seperator' ) ); |
| 107 | |
| 108 | acf_render_field_wrap( |
| 109 | array( |
| 110 | 'type' => 'true_false', |
| 111 | 'key' => 'public', |
| 112 | 'name' => 'public', |
| 113 | 'prefix' => 'acf_taxonomy', |
| 114 | 'value' => $acf_taxonomy['public'], |
| 115 | 'label' => __( 'Public', 'acf' ), |
| 116 | 'instructions' => __( 'Makes a taxonomy visible on the frontend and in the admin dashboard.', 'acf' ), |
| 117 | 'ui' => true, |
| 118 | 'default' => 1, |
| 119 | ) |
| 120 | ); |
| 121 | |
| 122 | acf_render_field_wrap( |
| 123 | array( |
| 124 | 'type' => 'true_false', |
| 125 | 'key' => 'hierarchical', |
| 126 | 'name' => 'hierarchical', |
| 127 | 'class' => 'acf_hierarchical_switch', |
| 128 | 'prefix' => 'acf_taxonomy', |
| 129 | 'value' => $acf_taxonomy['hierarchical'], |
| 130 | 'label' => __( 'Hierarchical', 'acf' ), |
| 131 | 'instructions' => __( 'Hierarchical taxonomies can have descendants (like categories).', 'acf' ), |
| 132 | 'ui' => true, |
| 133 | ), |
| 134 | 'div' |
| 135 | ); |
| 136 | |
| 137 | do_action( 'acf/taxonomy/basic_settings', $acf_taxonomy ); |
| 138 | |
| 139 | acf_render_field_wrap( array( 'type' => 'seperator' ) ); |
| 140 | |
| 141 | acf_render_field_wrap( |
| 142 | array( |
| 143 | 'label' => __( 'Advanced Configuration', 'acf' ), |
| 144 | 'instructions' => __( 'I know what I\'m doing, show me all the options.', 'acf' ), |
| 145 | 'type' => 'true_false', |
| 146 | 'key' => 'advanced_configuration', |
| 147 | 'name' => 'advanced_configuration', |
| 148 | 'prefix' => 'acf_taxonomy', |
| 149 | 'value' => $acf_taxonomy['advanced_configuration'], |
| 150 | 'ui' => 1, |
| 151 | 'class' => 'acf-advanced-settings-toggle', |
| 152 | ) |
| 153 | ); |
| 154 | |
| 155 | ?> |
| 156 | <div class="acf-hidden"> |
| 157 | <input type="hidden" name="acf_taxonomy[key]" value="<?php echo esc_attr( $acf_taxonomy['key'] ); ?>" /> |
| 158 | <input type="hidden" name="acf_taxonomy[import_source]" value="<?php echo esc_attr( $acf_taxonomy['import_source'] ); ?>" /> |
| 159 | <input type="hidden" name="acf_taxonomy[import_date]" value="<?php echo esc_attr( $acf_taxonomy['import_date'] ); ?>" /> |
| 160 | </div> |
| 161 | <?php |
| 162 |