From 84c41080f59549271fd04c42f585d952329006f1 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 22 Apr 2013 20:41:16 +0000 Subject: [PATCH] Return false in get_post_format() if the post does not exist. props adamsilverstein, ericlewis. fixes #23255. git-svn-id: http://core.svn.wordpress.org/trunk@24057 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-formats.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wp-includes/post-formats.php b/wp-includes/post-formats.php index 4896e7a40e..0d80a3833a 100644 --- a/wp-includes/post-formats.php +++ b/wp-includes/post-formats.php @@ -11,12 +11,12 @@ * * @since 3.1.0 * - * @param int|object $post A post. - * - * @return mixed The format if successful. False if no format is set. WP_Error if errors. + * @param int|object $post Post ID or post object. Optional, default is the current post from the loop. + * @return mixed The format if successful. False otherwise. */ function get_post_format( $post = null ) { - $post = get_post($post); + if ( ! $post = get_post( $post ) ) + return false; if ( ! post_type_supports( $post->post_type, 'post-formats' ) ) return false; @@ -28,7 +28,7 @@ function get_post_format( $post = null ) { $format = array_shift( $_format ); - return ( str_replace('post-format-', '', $format->slug ) ); + return str_replace('post-format-', '', $format->slug ); } /**