Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions source/php/AcfFields/json/mod-posts-taxonomydisplay.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"label": "Taxonomies to display",
"name": "taxonomy_display",
"aria-label": "",
"type": "acfe_taxonomies",
"type": "checkbox",
"instructions": "",
"required": 0,
"conditional_logic": 0,
Expand All @@ -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": [
Expand Down Expand Up @@ -64,4 +58,4 @@
"acfe_meta": "",
"acfe_note": ""
}]

32 changes: 14 additions & 18 deletions source/php/AcfFields/php/mod-posts-taxonomydisplay.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

if (function_exists('acf_add_local_field_group')) {
acf_add_local_field_group(array(


if (function_exists('acf_add_local_field_group')) {

acf_add_local_field_group(array(
'key' => 'group_630645d822841',
'title' => __('Taxonomies to display', 'modularity'),
'fields' => array(
Expand All @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -69,4 +64,5 @@
'acfe_meta' => '',
'acfe_note' => '',
));
}

}
30 changes: 29 additions & 1 deletion source/php/Module/Posts/Posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down