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
5 changes: 5 additions & 0 deletions .changeset/olive-queens-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wpengine/hwp-previews-wordpress-plugin": patch
---

bug: Fixed issue with retrieving post types before ACF hook initialisation.
28 changes: 16 additions & 12 deletions plugins/hwp-previews/src/Preview/Post/Post_Preview_Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,11 @@ class Post_Preview_Service {
*/
protected $parent_post_statuses = [];

/**
* Constructor for the Post_Preview_Service class.
*
* Initializes the allowed post-types and statuses for previews.
*/
public function __construct() {
$this->set_post_types();
$this->set_post_statuses();
$this->set_post_parent_statuses();
}

/**
* @return array<string>
*/
public function get_allowed_post_types(): array {
return $this->post_types;
return $this->get_post_types();
}

/**
Expand All @@ -59,6 +48,11 @@ public function get_allowed_post_types(): array {
* @return array<string>
*/
public function get_post_statuses(): array {
$post_statuses = $this->post_statuses;
if ([] !== $post_statuses) {
return $post_statuses;
}
$this->set_post_statuses();
return $this->post_statuses;
}

Expand All @@ -68,6 +62,11 @@ public function get_post_statuses(): array {
* @return array<string>
*/
public function get_post_types(): array {
$post_types = $this->post_types;
if ([] !== $post_types) {
return $post_types;
}
$this->set_post_types();
return $this->post_types;
}

Expand All @@ -77,6 +76,11 @@ public function get_post_types(): array {
* @return array<string>
*/
public function get_parent_post_statuses(): array {
$parent_post_statuses = $this->parent_post_statuses;
if ([] !== $parent_post_statuses) {
return $parent_post_statuses;
}
$this->set_post_parent_statuses();
return $this->parent_post_statuses;
}

Expand Down
43 changes: 32 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading