Skip to content

Commit

Permalink
Refactor workflow_is_published into workflow_is_publish_blocked
Browse files Browse the repository at this point in the history
  • Loading branch information
alecgeatches committed Jul 8, 2024
1 parent 888b125 commit 8c37c02
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions modules/custom-status/custom-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -1674,12 +1674,12 @@ public function fix_post_row_actions( $actions, $post ) {
}

/**
* Given a post ID, return true if the extended post status allows for publishing.
* Given a post ID, return true if the custom post status indicates the post should be blocked from publishing, or false otherwise.
*
* @param int $post_id The post ID being queried.
* @return bool True if the post is publishable based on the extended post status, or false otherwise.
* @return bool True if the post should not be published based on the extended post status, false otherwise.
*/
public function workflow_is_publishable( $post_id ) {
public function workflow_is_publish_blocked( $post_id ) {
$post = get_post( $post_id );

if ( null === $post ) {
Expand All @@ -1694,14 +1694,10 @@ public function workflow_is_publishable( $post_id ) {
return false;
}

$status_before_publish = $custom_statuses[ array_key_last( $custom_statuses ) ];
$status_before_publish = $custom_statuses[ array_key_last( $custom_statuses ) ];
$is_in_final_custom_status = $status_before_publish->slug === $post->post_status;

if ( $status_before_publish->slug == $post->post_status ) {
// Post is in the last status, so it can be published
return true;
} else {
return false;
}
return ! $is_in_final_custom_status;
}
}
}
Expand Down

0 comments on commit 8c37c02

Please sign in to comment.