Make WordPress Core

Ticket #12955: 12955.5.diff

File 12955.5.diff, 4.8 KB (added by MikeSchinkel, 9 years ago)

Added in correct first parameter for 'get_virtual_post_instance' hook

  • wp-admin/includes/post.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    618618                $post->page_template = 'default';
    619619                $post->post_parent = 0;
    620620                $post->menu_order = 0;
    621                 $post = new WP_Post( $post );
     621                $post = WP_Post::make_instance( $post );
    622622        }
    623623
    624624        /**
     
    18441844         */
    18451845        wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );
    18461846        exit;
    1847 }
    1848  No newline at end of file
     1847}
  • wp-includes/class-wp-post.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    197197        public $filter;
    198198
    199199        /**
     200         * Flag to disallow "new WP_Post()" to be called w/o deprecation warning.
     201         *
     202         * @var bool
     203         */
     204        private static $_allow__construct = false;
     205
     206        /**
     207         * Retrieve virtual WP_Post instance.
     208         *
     209         * @static
     210         * @access public
     211         *
     212         * @param WP_Post|object|array $post Post value.
     213         * @return WP_Post|object Post object.
     214         */
     215        public static function make_instance( $post ) {
     216
     217                if ( is_array( $post ) || 'stdClass' === get_class( $post ) ) {
     218                        self::$_allow__construct = true;
     219                        $post = new WP_Post( (object) $post );
     220                        self::$_allow__construct = false;
     221                }
     222
     223                /**
     224                 * Filter post object to be sanitized, virtualized and/or have properties annotated.
     225                 *
     226                 * @since 4.4.0
     227                 *
     228                 * @param WP_Post $post Post object to sanitize/virtualize/annotate/etc.
     229                 */
     230                return apply_filters( 'make_post_instance', $post );
     231
     232        }
     233
     234        /**
    200235         * Retrieve WP_Post instance.
    201236         *
    202237         * @static
     
    219254                if ( ! $_post ) {
    220255                        $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id ) );
    221256
    222                         if ( ! $_post )
    223                                 return false;
     257                        if ( ! $_post ) {
     258
     259                                /**
     260                                 * Retrieve a virtual post instance based on its post_id
     261                                 *
     262                                 * @since 4.4.0
     263                                 *
     264                                 * @param null  $_post   Null value returned by failed $wpdb->get_row()
     265                                 * @param int   $post_id Virtual post object to retrieve
     266                                 */
     267                                $_post = apply_filters( 'get_virtual_post_instance', $_post, $post_id );
     268
     269                                if ( ! $_post ) {
     270                                        return false;
     271                                }
     272                        }
    224273
    225274                        $_post = sanitize_post( $_post, 'raw' );
    226275                        wp_cache_add( $_post->ID, $_post, 'posts' );
     
    228277                        $_post = sanitize_post( $_post, 'raw' );
    229278                }
    230279
    231                 return new WP_Post( $_post );
     280                return self::make_instance( $_post );
    232281        }
    233282
    234283        /**
     
    237286         * @param WP_Post|object $post Post object.
    238287         */
    239288        public function __construct( $post ) {
     289
     290                if ( ! self::$_allow__construct ) {
     291                        _deprecated_function( 'new ' . __CLASS__ . '()', '4.4', 'WP_Post::make_instance()' );
     292                }
     293
    240294                foreach ( get_object_vars( $post ) as $key => $value )
    241295                        $this->$key = $value;
    242296        }
  • wp-includes/post-functions.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    433433        } elseif ( is_object( $post ) ) {
    434434                if ( empty( $post->filter ) ) {
    435435                        $_post = sanitize_post( $post, 'raw' );
    436                         $_post = new WP_Post( $_post );
     436                        $_post = WP_Post::make_instance( $_post );
    437437                } elseif ( 'raw' == $post->filter ) {
    438                         $_post = new WP_Post( $post );
     438                        $_post = WP_Post::make_instance( $post );
    439439                } else {
    440440                        $_post = WP_Post::get_instance( $post->ID );
    441441                }
  • wp-admin/includes/media.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    11871187        if ( is_int($post) )
    11881188                $post = get_post($post);
    11891189        if ( is_array($post) )
    1190                 $post = new WP_Post( (object) $post );
     1190                $post = WP_Post::make_instance( $post );
    11911191
    11921192        $image_url = wp_get_attachment_url($post->ID);
    11931193
  • wp-includes/class-wp-customize-setting.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    13481348
    13491349                $item->ID = $this->post_id;
    13501350                $item->db_id = $this->post_id;
    1351                 $post = new WP_Post( (object) $item );
     1351                $post = WP_Post::make_instance( $item );
    13521352
    13531353                if ( empty( $post->post_author ) ) {
    13541354                        $post->post_author = get_current_user_id();