From b778726e7457a5a2a02540752550b3b87174573c Mon Sep 17 00:00:00 2001 From: Aaron Jorbin Date: Sat, 17 Oct 2015 00:44:26 +0000 Subject: [PATCH] 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 Built from https://develop.svn.wordpress.org/trunk@35233 git-svn-id: http://core.svn.wordpress.org/trunk@35199 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/link-template.php | 2 +- wp-includes/post-functions.php | 9 ++++++++- wp-includes/version.php | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index a091853d1c..dfd80f46e6 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -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); diff --git a/wp-includes/post-functions.php b/wp-includes/post-functions.php index e8ac9645cc..d1cdc6927e 100644 --- a/wp-includes/post-functions.php +++ b/wp-includes/post-functions.php @@ -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 ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index d7f54bc0dc..c97104fcbc 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-35232'; +$wp_version = '4.4-alpha-35233'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.