Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Fix saving benchmark configurations #62

Merged
merged 2 commits into from
Aug 28, 2023
Merged
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
23 changes: 17 additions & 6 deletions includes/SimplyStaticDeploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ public function remove_static_pages_for_certain_status_transitions(
return;
}

$publicPostTypes = get_post_types(['public' => true]);
$postTypesToObserve = f\omit(['attachment'], $publicPostTypes);

if (!in_array($post->post_type, $postTypesToObserve)) {
if (!$this->is_post_applicable($post)) {
return;
}

Expand All @@ -106,9 +103,15 @@ public function remove_old_static_page_when_slug_is_changed(
WP_Post $post_after,
WP_Post $post_before
) {
if ($post_after->post_name !== $post_before->post_name) {
$this->remove_static_page($post_before);
if ($post_after->post_name === $post_before->post_name) {
return;
}

if (!$this->is_post_applicable($post_after)) {
return;
}

$this->remove_static_page($post_before);
}

/**
Expand Down Expand Up @@ -185,4 +188,12 @@ protected function get_pretty_permalink(\WP_Post $post): string
$samplePermalink[0] // https://example.com/updates/%postname%/
);
}

private function is_post_applicable(\WP_Post $post): bool
{
$publicPostTypes = get_post_types(['public' => true]);
$postTypesToObserve = f\omit(['attachment'], $publicPostTypes);

return in_array($post->post_type, $postTypesToObserve);
}
}