IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
425 | 425 | * When $output is OBJECT, a `WP_Post` instance is returned. |
426 | 426 | */ |
427 | 427 | function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) { |
428 | | if ( empty( $post ) && isset( $GLOBALS['post'] ) ) |
429 | | $post = $GLOBALS['post']; |
| 428 | |
| 429 | /** |
| 430 | * Filter that allows a custom object to be provided for post when appropriate. |
| 431 | * |
| 432 | * Allows a developer to substitute an object that contains a WP_Post or that simulates a WP_Post. |
| 433 | * |
| 434 | * @since 4.4.0 |
| 435 | * |
| 436 | * @param object|null null Value to return if no custom post it to be provided |
| 437 | * @param string $output Optional, default is Object. Accepts OBJECT, ARRAY_A, or ARRAY_N. |
| 438 | * Default OBJECT. |
| 439 | * @param string $filter Optional. Type of filter to apply. Accepts 'raw', 'edit', 'db', |
| 440 | * or 'display'. Default 'raw'. |
| 441 | */ |
| 442 | $_post = apply_filters( 'do_get_post', null, $output, $filter ); |
| 443 | |
| 444 | if ( is_null( $_post ) ) { |
| 445 | |
| 446 | if ( empty( $post ) && isset( $GLOBALS['post'] ) ) { |
| 447 | $post = $GLOBALS['post']; |
| 448 | } |
430 | 449 | |
431 | | if ( $post instanceof WP_Post ) { |
432 | | $_post = $post; |
433 | | } elseif ( is_object( $post ) ) { |
434 | | if ( empty( $post->filter ) ) { |
435 | | $_post = sanitize_post( $post, 'raw' ); |
436 | | $_post = new WP_Post( $_post ); |
437 | | } elseif ( 'raw' == $post->filter ) { |
438 | | $_post = new WP_Post( $post ); |
439 | | } else { |
440 | | $_post = WP_Post::get_instance( $post->ID ); |
441 | | } |
442 | | } else { |
443 | | $_post = WP_Post::get_instance( $post ); |
444 | | } |
| 450 | if ( $post instanceof WP_Post ) { |
| 451 | $_post = $post; |
| 452 | } elseif ( is_object( $post ) ) { |
| 453 | if ( empty( $post->filter ) ) { |
| 454 | $_post = sanitize_post( $post, 'raw' ); |
| 455 | $_post = new WP_Post( $_post ); |
| 456 | } elseif ( 'raw' == $post->filter ) { |
| 457 | $_post = new WP_Post( $post ); |
| 458 | } else { |
| 459 | $_post = WP_Post::get_instance( $post->ID ); |
| 460 | } |
| 461 | } else { |
| 462 | $_post = WP_Post::get_instance( $post ); |
| 463 | } |
445 | 464 | |
446 | | if ( ! $_post ) |
447 | | return null; |
| 465 | if ( ! $_post ) { |
| 466 | return null; |
| 467 | } |
448 | 468 | |
| 469 | } |
| 470 | |
449 | 471 | $_post = $_post->filter( $filter ); |
450 | 472 | |
451 | | if ( $output == ARRAY_A ) |
| 473 | if ( $output == ARRAY_A ) { |
452 | 474 | return $_post->to_array(); |
453 | | elseif ( $output == ARRAY_N ) |
| 475 | } elseif ( $output == ARRAY_N ) { |
454 | 476 | return array_values( $_post->to_array() ); |
| 477 | } |
455 | 478 | |
456 | 479 | return $_post; |
| 480 | |
457 | 481 | } |
458 | 482 | |
459 | 483 | /** |