From 31ae2c631a157ae439487d106563867a442cf9ed Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 29 Aug 2012 13:42:11 +0000 Subject: [PATCH] Simplify return from WP_Post::__get() now that references are no longer returned. see #21309 git-svn-id: https://develop.svn.wordpress.org/trunk@21655 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 0d60f3daa0..2246005a6e 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -489,39 +489,32 @@ final class WP_Post { public function __get( $key ) { if ( 'page_template' == $key && $this->__isset( $key ) ) { - $_ref = get_post_meta( $this->ID, '_wp_page_template', true ); + return get_post_meta( $this->ID, '_wp_page_template', true ); } if ( 'post_category' == $key ) { - if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) { - $_ref = wp_get_post_categories( $this->ID ); - } else { - $_ref = array(); - } + if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) + return wp_get_post_categories( $this->ID ); + else + return array(); } if ( 'tags_input' == $key ) { - if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) { - $_ref = wp_get_post_tags( $this->ID, array( 'fields' => 'names' ) ); - } else { - $_ref = array(); - } + if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) + return wp_get_post_tags( $this->ID, array( 'fields' => 'names' ) ); + else + return array(); } - if ( isset( $_ref ) ) - return $_ref; - // Rest of the values need filtering - if ( 'ancestors' == $key ) { + if ( 'ancestors' == $key ) $value = get_post_ancestors( $this ); - } else { + else $value = get_post_meta( $this->ID, $key, true ); - } - if ( $this->filter ) { + if ( $this->filter ) $value = sanitize_post_field( $key, $value, $this->ID, $this->filter ); - } return $value; }