WordPress.org

Make WordPress Core

Changeset 21572


Ignore:
Timestamp:
08/21/12 15:42:28 (3 years ago)
Author:
ryan
Message:

Remove references from get_post() and get_page().
Handle $GLOBALSpost? containing stdClass instead of WP_Post.
Props nacin
see #21309

File:
1 edited

Legend:

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

    r21567 r21572  
    378378 * @return mixed Post data or null on failure 
    379379 */ 
    380 function &get_post( &$post, $output = OBJECT, $filter = 'raw' ) { 
    381     $null = null; 
    382  
    383     if ( empty( $post ) && isset( $GLOBALS['post'] ) ) { 
    384         $_post = & $GLOBALS['post']; 
    385     } elseif ( is_a( $post, 'WP_Post' ) ) { 
     380function get_post( $post, $output = OBJECT, $filter = 'raw' ) { 
     381    if ( empty( $post ) && isset( $GLOBALS['post'] ) ) 
     382        $post = $GLOBALS['post']; 
     383 
     384    if ( is_a( $post, 'WP_Post' ) ) { 
    386385        $_post = $post; 
    387386    } elseif ( is_object( $post ) ) { 
     
    399398    } 
    400399 
    401     if ( !$_post ) 
    402         return $null; 
     400    if ( ! $_post ) 
     401        return null; 
    403402 
    404403    $_post = $_post->filter( $filter ); 
    405404 
    406     if ( $output == ARRAY_A ) { 
    407         $__post = $_post->to_array(); 
    408         return $__post; 
    409     } elseif ( $output == ARRAY_N ) { 
    410         $__post = array_values( $_post->to_array() ); 
    411         return $__post; 
    412     } 
     405    if ( $output == ARRAY_A ) 
     406        return $_post->to_array(); 
     407    elseif ( $output == ARRAY_N ) 
     408        return array_values( $_post->to_array() ); 
    413409 
    414410    return $_post; 
     
    33003296 * @return mixed Page data. 
    33013297 */ 
    3302 function &get_page(&$page, $output = OBJECT, $filter = 'raw') { 
    3303     $p = get_post($page, $output, $filter); 
    3304     return $p; 
     3298function get_page( $page, $output = OBJECT, $filter = 'raw') { 
     3299    return get_post( $page, $output, $filter ); 
    33053300} 
    33063301 
Note: See TracChangeset for help on using the changeset viewer.