Make WordPress Core

Changeset 14071


Ignore:
Timestamp:
04/11/2010 11:10:54 AM (15 years ago)
Author:
dd32
Message:

Update get_post_type() to perform on the current global post if none specified. Update PHPDoc to reflect changes. Props rmccue. Fixes #12827

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r14062 r14071  
    688688 * @since 2.1.0
    689689 *
    690  * @uses $wpdb
    691  * @uses $posts The Loop post global
    692  *
    693  * @param mixed $post Optional. Post object or post ID.
     690 * @uses $post The Loop current post global
     691 *
     692 * @param mixed $the_post Optional. Post object or post ID.
    694693 * @return bool|string post type or false on failure.
    695694 */
    696 function get_post_type($post = false) {
    697     global $posts;
    698 
    699     if ( false === $post )
    700         $post = $posts[0];
    701     elseif ( (int) $post )
    702         $post = get_post($post, OBJECT);
    703 
    704     if ( is_object($post) )
    705         return $post->post_type;
     695function get_post_type($the_post = false) {
     696    global $post;
     697
     698    if ( false === $the_post )
     699        $the_post = $post;
     700    elseif ( is_numeric($the_post) )
     701        $the_post = get_post($the_post);
     702
     703    if ( is_object($the_post) )
     704        return $the_post->post_type;
    706705
    707706    return false;
Note: See TracChangeset for help on using the changeset viewer.