From 16a7cbd7f7b36af468d732b273036e37f06e91d8 Mon Sep 17 00:00:00 2001 From: Hugo Cox Date: Fri, 8 Aug 2025 10:47:29 +0200 Subject: [PATCH 1/2] fix: ensure post types and taxonomies are registered only if required functions exist --- src/Base/PostType/PostTypeServiceProvider.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Base/PostType/PostTypeServiceProvider.php b/src/Base/PostType/PostTypeServiceProvider.php index 43ec494..feac399 100644 --- a/src/Base/PostType/PostTypeServiceProvider.php +++ b/src/Base/PostType/PostTypeServiceProvider.php @@ -45,13 +45,16 @@ public function orderByPublishedDate(WP_Query $query): void */ public function registerPostTypes(): void { - if (function_exists('register_extended_post_type')) { - $this->configPostTypes = apply_filters('owc/openpub-base/before-register-posttypes', $this->plugin->config->get('posttypes')); - foreach ($this->configPostTypes as $postTypeName => $postType) { - // Examples of registering post types: http://johnbillion.com/extended-cpts/ - register_extended_post_type($postTypeName, $postType['args'], $postType['names']); - } - } + if (!function_exists('register_extended_post_type')) { + return; + } + + $this->configPostTypes = apply_filters('owc/openpub-base/before-register-posttypes', $this->plugin->config->get('posttypes')); + + foreach ($this->configPostTypes as $postTypeName => $postType) { + // Examples of registering post types: http://johnbillion.com/extended-cpts/ + register_extended_post_type($postTypeName, $postType['args'], $postType['names']); + } } /** From d04ce36eb8a3d5b72a27dd0d62df6d374a5c8164 Mon Sep 17 00:00:00 2001 From: Hugo Cox Date: Fri, 15 Aug 2025 13:21:20 +0200 Subject: [PATCH 2/2] feat: enhance item query with additional filters for REST API --- src/Base/RestAPI/Controllers/ItemController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Base/RestAPI/Controllers/ItemController.php b/src/Base/RestAPI/Controllers/ItemController.php index aad0828..2d31361 100644 --- a/src/Base/RestAPI/Controllers/ItemController.php +++ b/src/Base/RestAPI/Controllers/ItemController.php @@ -55,7 +55,7 @@ protected function itemQueryBuilder(WP_REST_Request $request = null): Item $items->query(Item::addAudienceParameters($this->getAudienceParam($request))); } - return $items; + return apply_filters('owc/openpub/rest-api/items/query/parameters', $items, $request); } /** @@ -146,6 +146,8 @@ protected function addRelated(array $item, WP_REST_Request $request): array $items->query(Item::addAudienceParameters($this->getAudienceParam($request))); } + $items = apply_filters('owc/openpub/rest-api/items/query/parameters', $items, $request); + $query = new WP_Query($items->getQueryArgs()); return array_map([$this, 'transform'], $query->posts); }