diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 06db540af2..e4a8bcba86 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -1344,8 +1344,10 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { } if ( $request['id'] ) { + $post = get_post( $request['id'] ); $current_template = get_page_template_slug( $request['id'] ); } else { + $post = null; $current_template = ''; } @@ -1355,7 +1357,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { } // If this is a create request, get_post() will return null and wp theme will fallback to the passed post type. - $allowed_templates = wp_get_theme()->get_page_templates( get_post( $request['id'] ), $this->post_type ); + $allowed_templates = wp_get_theme()->get_page_templates( $post, $this->post_type ); if ( isset( $allowed_templates[ $template ] ) ) { return true; diff --git a/wp-includes/version.php b/wp-includes/version.php index e096c3a327..1e1aa02e41 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-beta1-49300'; +$wp_version = '5.6-beta1-49301'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.