From 41a141855f575279d846afc7d9fa0ec9e2dd95cd Mon Sep 17 00:00:00 2001 From: Maarten Bruna <14947039+ictbeheer@users.noreply.github.com> Date: Mon, 2 Feb 2026 16:40:55 +0100 Subject: [PATCH 1/3] fix: don't show url for non-public posts --- src/PostData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PostData.php b/src/PostData.php index 0f045aa..0fdd57e 100644 --- a/src/PostData.php +++ b/src/PostData.php @@ -256,7 +256,7 @@ public function hasThumbnail(): bool public function url(): string { - if (null === $this->id) { + if (null === $this->id || ! is_post_publicly_viewable($this->id)) { return ''; } From 69ead6ce06ad00d99adb2dc8f9c8c237b56381a6 Mon Sep 17 00:00:00 2001 From: Maarten Bruna <14947039+ictbeheer@users.noreply.github.com> Date: Mon, 2 Feb 2026 17:00:15 +0100 Subject: [PATCH 2/3] fix: update tests --- tests/src/PostDataTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/src/PostDataTest.php b/tests/src/PostDataTest.php index e00861b..76c4be1 100644 --- a/tests/src/PostDataTest.php +++ b/tests/src/PostDataTest.php @@ -28,14 +28,33 @@ 'return' => 'https://example.com/hello-world', ]); + \WP_Mock::userFunction('is_post_publicly_viewable', [ + 'args' => [1], + 'return' => true, + ]); + expect($this->postData->url())->toBe('https://example.com/hello-world'); }); +it('returns an empty string when post is not publicly viewable', function () { + \WP_Mock::userFunction('is_post_publicly_viewable', [ + 'args' => [1], + 'return' => false, + ]); + + expect($this->postData->url())->toBe(''); +}); + it('returns an empty string when url does not exist', function () { \WP_Mock::userFunction('get_permalink', [ 'args' => [1], 'return' => false, ]); + \WP_Mock::userFunction('is_post_publicly_viewable', [ + 'args' => [1], + 'return' => true, + ]); + expect($this->postData->url())->toBe(''); }); From 8e77a6e78f931789274ef7d2569bed9d9b1b3e36 Mon Sep 17 00:00:00 2001 From: Maarten Bruna <14947039+ictbeheer@users.noreply.github.com> Date: Tue, 3 Feb 2026 13:38:26 +0100 Subject: [PATCH 3/3] fix: phpstan --- phpstan.neon.dist | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index b50b245..13cbc9f 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -12,3 +12,8 @@ parameters: message: '#Access to an undefined property Corcel\\Model\\Post[a-zA-Z0-9::a-zA-Z]#' - message: '#Function get_field not found.#' + - + identifier: function.impossibleType + path: src/Traits/HasMeta.php + count: 1 +