Remove references from get_post() and get_page().

Handle $GLOBALS['post'] containing stdClass instead of WP_Post.
Props nacin
see #21309


git-svn-id: http://core.svn.wordpress.org/trunk@21572 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-08-21 15:42:28 +00:00
parent 791eda2594
commit d2ecd62b7f
1 changed files with 12 additions and 17 deletions

View File

@ -377,12 +377,11 @@ function get_extended($post) {
* @param string $filter Optional, default is raw. * @param string $filter Optional, default is raw.
* @return mixed Post data or null on failure * @return mixed Post data or null on failure
*/ */
function &get_post( &$post, $output = OBJECT, $filter = 'raw' ) { function get_post( $post, $output = OBJECT, $filter = 'raw' ) {
$null = null; if ( empty( $post ) && isset( $GLOBALS['post'] ) )
$post = $GLOBALS['post'];
if ( empty( $post ) && isset( $GLOBALS['post'] ) ) { if ( is_a( $post, 'WP_Post' ) ) {
$_post = & $GLOBALS['post'];
} elseif ( is_a( $post, 'WP_Post' ) ) {
$_post = $post; $_post = $post;
} elseif ( is_object( $post ) ) { } elseif ( is_object( $post ) ) {
if ( empty( $post->filter ) ) { if ( empty( $post->filter ) ) {
@ -399,17 +398,14 @@ function &get_post( &$post, $output = OBJECT, $filter = 'raw' ) {
} }
if ( ! $_post ) if ( ! $_post )
return $null; return null;
$_post = $_post->filter( $filter ); $_post = $_post->filter( $filter );
if ( $output == ARRAY_A ) { if ( $output == ARRAY_A )
$__post = $_post->to_array(); return $_post->to_array();
return $__post; elseif ( $output == ARRAY_N )
} elseif ( $output == ARRAY_N ) { return array_values( $_post->to_array() );
$__post = array_values( $_post->to_array() );
return $__post;
}
return $_post; return $_post;
} }
@ -3299,9 +3295,8 @@ function get_all_page_ids() {
* @param string $filter How the return value should be filtered. * @param string $filter How the return value should be filtered.
* @return mixed Page data. * @return mixed Page data.
*/ */
function &get_page(&$page, $output = OBJECT, $filter = 'raw') { function get_page( $page, $output = OBJECT, $filter = 'raw') {
$p = get_post($page, $output, $filter); return get_post( $page, $output, $filter );
return $p;
} }
/** /**