WordPress.org

Make WordPress Core

Ticket #12827: 12827-corrected.diff

File 12827-corrected.diff, 786 bytes (added by rmccue, 8 years ago)

Corrected version of the original function, so it matches the phpDoc

  • post.php

     
    671671 * @param mixed $post Optional. Post object or post ID.
    672672 * @return bool|string post type or false on failure.
    673673 */
    674 function get_post_type($post = false) {
    675         global $posts;
     674function get_post_type($the_post = false) {
     675        global $posts, $post;
    676676
    677         if ( false === $post )
    678                 $post = $posts[0];
    679         elseif ( (int) $post )
    680                 $post = get_post($post, OBJECT);
     677        if ( false === $the_post )
     678                $the_post = $post;
     679        elseif ( (int) $the_post )
     680                $the_post = get_post($the_post, OBJECT);
    681681
    682         if ( is_object($post) )
    683                 return $post->post_type;
     682        if ( is_object($the_post) )
     683                return $the_post->post_type;
    684684
    685685        return false;
    686686}