Make WordPress Core

Ticket #45677: 45677.diff

File 45677.diff, 2.5 KB (added by TimothyBlynJacobs, 6 years ago)
  • src/wp-includes/rest-api.php

    diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
    index 1c73b97824..947ebf08f2 100644
    a b function create_initial_rest_routes() { 
    210210                }
    211211
    212212                if ( 'attachment' !== $post_type->name ) {
    213                         $autosaves_controller = new WP_REST_Autosaves_Controller( $post_type->name );
     213                        $autosaves_controller = new WP_REST_Autosaves_Controller( $post_type->name, $controller );
    214214                        $autosaves_controller->register_routes();
    215215                }
    216216        }
  • src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php
    index bf5b180df8..4562fc5ebd 100644
    a b class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { 
    5252         * Constructor.
    5353         *
    5454         * @since 5.0.0
     55     * @since 5.3.0 Added $parent_controller parameter.
    5556         *
    56          * @param string $parent_post_type Post type of the parent.
    57          */
    58         public function __construct( $parent_post_type ) {
     57     * @param string                  $parent_post_type  Post type of the parent.
     58     * @param WP_REST_Controller|null $parent_controller Controller for the Posts endpoint.
     59     */
     60        public function __construct( $parent_post_type, $parent_controller = null ) {
    5961                $this->parent_post_type = $parent_post_type;
    6062                $post_type_object       = get_post_type_object( $parent_post_type );
    6163
    62                 // Ensure that post type-specific controller logic is available.
    63                 $parent_controller_class = ! empty( $post_type_object->rest_controller_class ) ? $post_type_object->rest_controller_class : 'WP_REST_Posts_Controller';
     64                if ( ! $parent_controller instanceof WP_REST_Controller ) {
     65                        // Ensure that post type-specific controller logic is available.
     66                        $parent_controller_class = ! empty( $post_type_object->rest_controller_class ) ? $post_type_object->rest_controller_class : 'WP_REST_Posts_Controller';
     67                        $parent_controller       = new $parent_controller_class( $post_type_object->name );
     68                }
    6469
    65                 $this->parent_controller    = new $parent_controller_class( $post_type_object->name );
     70                $this->parent_controller    = $parent_controller;
    6671                $this->revisions_controller = new WP_REST_Revisions_Controller( $parent_post_type );
    6772                $this->rest_namespace       = 'wp/v2';
    6873                $this->rest_base            = 'autosaves';