WordPress.org

Make WordPress Core

Ticket #26877: 26877.patch

File 26877.patch, 1.2 KB (added by MikeSchinkel, 6 years ago)

Patch adds a 'get_post' filter to get_post()

  • wp-includes/post-functions.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    425425 *                            When $output is OBJECT, a `WP_Post` instance is returned.
    426426 */
    427427function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
     428
     429        /**
     430         * Filter that allows a custom post to be provided when appropriate
     431         *
     432         * @since 4.4.0
     433         *
     434         * @param object|null   null    Value to return if no custom post it to be provided
     435         * @param string        $output Optional, default is Object. Accepts OBJECT, ARRAY_A, or ARRAY_N.
     436         *                              Default OBJECT.
     437         * @param string        $filter Optional. Type of filter to apply. Accepts 'raw', 'edit', 'db',
     438         *                              or 'display'. Default 'raw'.
     439         */
     440        if ( $custom_post = apply_filters( 'get_post', null, $output, $filter ) ) {
     441                return $custom_post;
     442        }
     443
    428444        if ( empty( $post ) && isset( $GLOBALS['post'] ) )
    429445                $post = $GLOBALS['post'];
    430446