diff --git a/CHANGELOG.md b/CHANGELOG.md index 81739e7..6b952a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v3.7.6 + +- Feat: add taxonomies to API added through apply_filter + ## v3.7.5 - Feat: add author id in API response of items endpoint diff --git a/openpub-base.php b/openpub-base.php index cc0d01b..331f94a 100644 --- a/openpub-base.php +++ b/openpub-base.php @@ -4,7 +4,7 @@ * Plugin Name: Yard | OpenPub Base * Plugin URI: https://www.openwebconcept.nl/ * Description: Acts as foundation for other OpenPub related content plugins. This plugin implements actions to allow for other plugins to add and/or change Custom Posttypes, Metaboxes, Taxonomies, en Posts 2 posts relations. - * Version: 3.7.5 + * Version: 3.7.6 * Author: Yard | Digital Agency * Author URI: https://www.yard.nl/ * License: GPL-3.0 diff --git a/src/Base/Foundation/Plugin.php b/src/Base/Foundation/Plugin.php index 6991a9f..dfa9d83 100644 --- a/src/Base/Foundation/Plugin.php +++ b/src/Base/Foundation/Plugin.php @@ -8,7 +8,7 @@ class Plugin { public const NAME = 'openpub-base'; - public const VERSION = '3.7.5'; + public const VERSION = '3.7.6'; protected string $rootPath; public Config $config; diff --git a/src/Base/RestAPI/ItemFields/TaxonomyField.php b/src/Base/RestAPI/ItemFields/TaxonomyField.php index e015668..59dc8c4 100644 --- a/src/Base/RestAPI/ItemFields/TaxonomyField.php +++ b/src/Base/RestAPI/ItemFields/TaxonomyField.php @@ -12,9 +12,17 @@ class TaxonomyField extends CreatesFields */ public function create(WP_Post $post): array { - $result = []; + $result = []; - foreach (array_keys($this->plugin->config->get('taxonomies')) as $taxonomy) { + $taxonomies = apply_filters('owc/openpub-base/before-register-extended-taxonomies', $this->plugin->config->get('taxonomies')); + + if (! is_array($taxonomies) || 1 > count($taxonomies)) { + return $result; + } + + $taxonomiesKeys = array_unique(array_keys($taxonomies)); + + foreach ($taxonomiesKeys as $taxonomy) { $result[$taxonomy] = $this->getTerms($post->ID, $taxonomy); }