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']); + } } /** 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); }