Remove references from get_post() and get_page().

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


git-svn-id: https://develop.svn.wordpress.org/trunk@21572 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2012-08-21 15:42:28 +00:00
parent 4803997d35
commit 83ea8767a5
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 ) ) {
@ -398,18 +397,15 @@ function &get_post( &$post, $output = OBJECT, $filter = 'raw' ) {
$_post = WP_Post::get_instance( $post ); $_post = WP_Post::get_instance( $post );
} }
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;
} }
/** /**