Changeset 42343 for trunk/src/wp-includes/class-wp-post.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-post.php
r42228 r42343 18 18 * @property-read int $post_category 19 19 * @property-read string $tag_input 20 *21 20 */ 22 21 final class WP_Post { … … 244 243 $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id ) ); 245 244 246 if ( ! $_post ) 245 if ( ! $_post ) { 247 246 return false; 247 } 248 248 249 249 $_post = sanitize_post( $_post, 'raw' ); … … 264 264 */ 265 265 public function __construct( $post ) { 266 foreach ( get_object_vars( $post ) as $key => $value ) 266 foreach ( get_object_vars( $post ) as $key => $value ) { 267 267 $this->$key = $value; 268 } 268 269 } 269 270 … … 277 278 */ 278 279 public function __isset( $key ) { 279 if ( 'ancestors' == $key ) 280 if ( 'ancestors' == $key ) { 280 281 return true; 281 282 if ( 'page_template' == $key ) 282 } 283 284 if ( 'page_template' == $key ) { 283 285 return true; 284 285 if ( 'post_category' == $key ) 286 } 287 288 if ( 'post_category' == $key ) { 286 289 return true; 287 288 if ( 'tags_input' == $key ) 290 } 291 292 if ( 'tags_input' == $key ) { 289 293 return true; 294 } 290 295 291 296 return metadata_exists( 'post', $this->ID, $key ); … … 306 311 307 312 if ( 'post_category' == $key ) { 308 if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) 313 if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) { 309 314 $terms = get_the_terms( $this, 'category' ); 310 311 if ( empty( $terms ) ) 315 } 316 317 if ( empty( $terms ) ) { 312 318 return array(); 319 } 313 320 314 321 return wp_list_pluck( $terms, 'term_id' ); … … 316 323 317 324 if ( 'tags_input' == $key ) { 318 if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) 325 if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) { 319 326 $terms = get_the_terms( $this, 'post_tag' ); 320 321 if ( empty( $terms ) ) 327 } 328 329 if ( empty( $terms ) ) { 322 330 return array(); 331 } 323 332 324 333 return wp_list_pluck( $terms, 'name' ); … … 326 335 327 336 // Rest of the values need filtering. 328 if ( 'ancestors' == $key ) 337 if ( 'ancestors' == $key ) { 329 338 $value = get_post_ancestors( $this ); 330 else339 } else { 331 340 $value = get_post_meta( $this->ID, $key, true ); 332 333 if ( $this->filter ) 341 } 342 343 if ( $this->filter ) { 334 344 $value = sanitize_post_field( $key, $value, $this->ID, $this->filter ); 345 } 335 346 336 347 return $value; … … 346 357 */ 347 358 public function filter( $filter ) { 348 if ( $this->filter == $filter ) 359 if ( $this->filter == $filter ) { 349 360 return $this; 350 351 if ( $filter == 'raw' ) 361 } 362 363 if ( $filter == 'raw' ) { 352 364 return self::get_instance( $this->ID ); 365 } 353 366 354 367 return sanitize_post( $this, $filter ); … … 366 379 367 380 foreach ( array( 'ancestors', 'page_template', 'post_category', 'tags_input' ) as $key ) { 368 if ( $this->__isset( $key ) ) 381 if ( $this->__isset( $key ) ) { 369 382 $post[ $key ] = $this->__get( $key ); 383 } 370 384 } 371 385
Note: See TracChangeset
for help on using the changeset viewer.