diff --git a/source/php/AcfFields/json/mod-posts-taxonomydisplay.json b/source/php/AcfFields/json/mod-posts-taxonomydisplay.json index 2c8e1e0db..408f44c7e 100644 --- a/source/php/AcfFields/json/mod-posts-taxonomydisplay.json +++ b/source/php/AcfFields/json/mod-posts-taxonomydisplay.json @@ -7,7 +7,7 @@ "label": "Taxonomies to display", "name": "taxonomy_display", "aria-label": "", - "type": "acfe_taxonomies", + "type": "checkbox", "instructions": "", "required": 0, "conditional_logic": 0, @@ -16,21 +16,15 @@ "class": "", "id": "" }, - "taxonomy": "", - "field_type": "checkbox", + "choices": {}, "default_value": [], - "return_format": "name", + "return_format": "value", + "allow_custom": 0, + "allow_in_bindings": 0, "layout": "horizontal", "toggle": 0, - "allow_custom": 0, - "multiple": 0, - "allow_null": 0, - "choices": [], - "ui": 0, - "ajax": 0, - "placeholder": "", - "search_placeholder": "", - "other_choice": 0 + "save_custom": 0, + "custom_choice_button_text": "Add new choice" } ], "location": [ @@ -64,4 +58,4 @@ "acfe_meta": "", "acfe_note": "" }] - \ No newline at end of file + diff --git a/source/php/AcfFields/php/mod-posts-taxonomydisplay.php b/source/php/AcfFields/php/mod-posts-taxonomydisplay.php index d288c5119..ed7eb0977 100644 --- a/source/php/AcfFields/php/mod-posts-taxonomydisplay.php +++ b/source/php/AcfFields/php/mod-posts-taxonomydisplay.php @@ -1,7 +1,9 @@ 'group_630645d822841', 'title' => __('Taxonomies to display', 'modularity'), 'fields' => array( @@ -10,7 +12,7 @@ 'label' => __('Taxonomies to display', 'modularity'), 'name' => 'taxonomy_display', 'aria-label' => '', - 'type' => 'acfe_taxonomies', + 'type' => 'checkbox', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, @@ -19,23 +21,16 @@ 'class' => '', 'id' => '', ), - 'taxonomy' => '', - 'field_type' => 'checkbox', + 'choices' => array(), 'default_value' => array( ), - 'return_format' => 'name', + 'return_format' => 'value', + 'allow_custom' => 0, + 'allow_in_bindings' => 0, 'layout' => 'horizontal', 'toggle' => 0, - 'allow_custom' => 0, - 'multiple' => 0, - 'allow_null' => 0, - 'choices' => array( - ), - 'ui' => 0, - 'ajax' => 0, - 'placeholder' => '', - 'search_placeholder' => '', - 'other_choice' => 0, + 'save_custom' => 0, + 'custom_choice_button_text' => 'Add new choice', ), ), 'location' => array( @@ -69,4 +64,5 @@ 'acfe_meta' => '', 'acfe_note' => '', )); - } \ No newline at end of file + +} \ No newline at end of file diff --git a/source/php/Module/Posts/Posts.php b/source/php/Module/Posts/Posts.php index 5074bbf9b..5eac375d9 100644 --- a/source/php/Module/Posts/Posts.php +++ b/source/php/Module/Posts/Posts.php @@ -60,6 +60,11 @@ public function init() 'acf/fields/post_object/query/name=posts_data_posts', array($this, 'removeUnwantedPostTypesFromManuallyPicked'), 10, 3 ); + + add_filter( + 'acf/load_field/name=taxonomy_display', + array($this, 'loadTaxonomyDisplayField') + ); // Helpers $this->archiveUrlHelper = new GetArchiveUrl(); @@ -85,7 +90,30 @@ public function loadSchemaTypesField(array $field = []):array { return $field; } - public function loadNetworkSourcesField(array $field = []):array { + /** + * Load taxonomy display field + * + * @param array $field + * @return array + */ + public function loadTaxonomyDisplayField(array $field = []): array + { + $taxonomies = get_taxonomies([ + 'public' => true + ], 'objects'); + + $choices = []; + foreach ($taxonomies as $taxonomyName => $taxonomyObj) { + $choices[$taxonomyName] = $taxonomyObj->labels->singular_name; + } + + $field['choices'] = $choices; + + return $field; + } + + public function loadNetworkSourcesField(array $field = []) :array + { if(!is_multisite() || get_post_type() === 'acf-field-group') { return $field;