From 223677bd3005f322ac459bb6ded61a4c52484b60 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Sun, 11 Apr 2010 11:10:54 +0000 Subject: [PATCH] Update get_post_type() to perform on the current global post if none specified. Update PHPDoc to reflect changes. Props rmccue. Fixes #12827 git-svn-id: https://develop.svn.wordpress.org/trunk@14071 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 949d990dd7..5b6398f470 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -687,22 +687,21 @@ function is_post_type_hierarchical( $post = false ) { * * @since 2.1.0 * - * @uses $wpdb - * @uses $posts The Loop post global + * @uses $post The Loop current post global * - * @param mixed $post Optional. Post object or post ID. + * @param mixed $the_post Optional. Post object or post ID. * @return bool|string post type or false on failure. */ -function get_post_type($post = false) { - global $posts; +function get_post_type($the_post = false) { + global $post; - if ( false === $post ) - $post = $posts[0]; - elseif ( (int) $post ) - $post = get_post($post, OBJECT); + if ( false === $the_post ) + $the_post = $post; + elseif ( is_numeric($the_post) ) + $the_post = get_post($the_post); - if ( is_object($post) ) - return $post->post_type; + if ( is_object($the_post) ) + return $the_post->post_type; return false; }