Improve `get_post_permalink` compatibility with non standard post status
This adds a new filter named `get_post_status` to the function named `get_post_status` which can be used to make additional post types behave like unpublished post status in `get_post_permalink`. Props misterbisson, antpb, iamfriendly Fixes #23458 git-svn-id: https://develop.svn.wordpress.org/trunk@35233 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fe72320f33
commit
7db19dcda2
|
@ -259,7 +259,7 @@ function get_post_permalink( $id = 0, $leavename = false, $sample = false ) {
|
|||
|
||||
$slug = $post->post_name;
|
||||
|
||||
$draft_or_pending = isset( $post->post_status ) && in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) );
|
||||
$draft_or_pending = get_post_status( $id ) && in_array( get_post_status( $id ), array( 'draft', 'pending', 'auto-draft', 'future' ) );
|
||||
|
||||
$post_type = get_post_type_object($post->post_type);
|
||||
|
||||
|
|
|
@ -573,7 +573,14 @@ function get_post_status( $ID = '' ) {
|
|||
|
||||
}
|
||||
|
||||
return $post->post_status;
|
||||
/**
|
||||
* Filters the post status.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param string $post->post_status The status of the post.
|
||||
*/
|
||||
return apply_filters( 'get_post_status', $post->post_status, $post );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue