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