fix: add unsupported function `is_post_status_viewable` on previous WP version
This commit is contained in:
parent
e683bb09d5
commit
7d17c2174c
|
@ -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 );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue