fix: add unsupported function `is_post_status_viewable` on previous WP version

This commit is contained in:
vnmedeiros 2021-06-29 15:11:58 -03:00
parent e683bb09d5
commit 7d17c2174c
1 changed files with 25 additions and 0 deletions

View File

@ -13,3 +13,28 @@ function tainacan_get_api_postdata() {
$post = json_decode($postdata); $post = json_decode($postdata);
return $post; return $post;
} }
/**
* Retrieve if the post status is viewable
* @return boollean
*/
if(!function_exists("is_post_status_viewable")) {
function is_post_status_viewable( $post_status ) {
if ( is_scalar( $post_status ) ) {
$post_status = \get_post_status_object( $post_status );
if ( ! $post_status ) {
return false;
}
}
if (
! \is_object( $post_status ) ||
$post_status->internal ||
$post_status->protected
) {
return false;
}
return $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public );
}
}