WordPress.org

Make WordPress Core

Ticket #40383: 40383.diff

File 40383.diff, 2.2 KB (added by joehoyle, 3 years ago)
  • src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
    index 117529d..90ca05f 100644
    a b class WP_REST_Comments_Controller extends WP_REST_Controller { 
    15271527         * @return bool Whether post can be read.
    15281528         */
    15291529        protected function check_read_post_permission( $post, $request ) {
    1530                 $posts_controller = new WP_REST_Posts_Controller( $post->post_type );
     1530                $post_type = get_post_type_object( $post->post_type );
     1531                if ( $post_type->rest_controller_class && class_exists( $post_type->rest_controller_class ) ) {
     1532                        $posts_controller_class = $post_type->rest_controller_class;
     1533                } else {
     1534                        $posts_controller_class = 'WP_REST_Posts_Controller';
     1535                }
     1536                $posts_controller = new $posts_controller_class( $post->post_type );
     1537
    15311538                $post_type = get_post_type_object( $post->post_type );
    15321539
    15331540                $has_password_filter = false;
  • src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
    index d3f665d..1c36741 100644
    a b class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    5353         */
    5454        public function __construct( $parent_post_type ) {
    5555                $this->parent_post_type = $parent_post_type;
    56                 $this->parent_controller = new WP_REST_Posts_Controller( $parent_post_type );
     56                $post_type = get_post_type_object( $parent_post_type );
     57                if ( $post_type->rest_controller_class && class_exists( $post_type->rest_controller_class ) ) {
     58                        $parent_controller_class = $post_type->rest_controller_class;
     59                } else {
     60                        $parent_controller_class = 'WP_REST_Posts_Controller';
     61                }
     62                $this->parent_controller = new $parent_controller_class( $parent_post_type );
     63
    5764                $this->namespace = 'wp/v2';
    5865                $this->rest_base = 'revisions';
    5966                $post_type_object = get_post_type_object( $parent_post_type );