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
This commit is contained in:
Dion Hulse 2010-04-11 11:10:54 +00:00
parent 491063c698
commit 223677bd30
1 changed files with 10 additions and 11 deletions

View File

@ -687,22 +687,21 @@ function is_post_type_hierarchical( $post = false ) {
* *
* @since 2.1.0 * @since 2.1.0
* *
* @uses $wpdb * @uses $post The Loop current post global
* @uses $posts The Loop 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. * @return bool|string post type or false on failure.
*/ */
function get_post_type($post = false) { function get_post_type($the_post = false) {
global $posts; global $post;
if ( false === $post ) if ( false === $the_post )
$post = $posts[0]; $the_post = $post;
elseif ( (int) $post ) elseif ( is_numeric($the_post) )
$post = get_post($post, OBJECT); $the_post = get_post($the_post);
if ( is_object($post) ) if ( is_object($the_post) )
return $post->post_type; return $the_post->post_type;
return false; return false;
} }