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
*
* @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;
}