From 14f6cf230bbb4eb78558a02c43461fc8cb3a52c8 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Tue, 30 Nov 2021 15:54:03 +0000 Subject: [PATCH] REST API: Replace hardcoded `wp/v2/` preloaded paths with `rest_get_route_for_taxonomy_items()` and `rest_get_route_for_post_type_items()` in `wp-admin/site-editor.php`. [51962] and [51964] introduced two new functions: `rest_get_route_for_post_type_items()` and `rest_get_route_for_taxonomy_items()`. These functions replaced hardcoded references in all parts of core that reference taxonomy and post type rest controller endpoints. However, several instances were missed in the `wp-admin/site-editor.php` file. This commit replaces those remaining hardcoded instances. Follow-up to [51962], [51964], [52232]. Props spacedmonkey. Fixes #54536. Built from https://develop.svn.wordpress.org/trunk@52281 git-svn-id: http://core.svn.wordpress.org/trunk@51873 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/site-editor.php | 16 ++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/wp-admin/site-editor.php b/wp-admin/site-editor.php index 91c559a2c2..f8a3375765 100644 --- a/wp-admin/site-editor.php +++ b/wp-admin/site-editor.php @@ -64,7 +64,7 @@ if ( isset( $_GET['postType'] ) && ! isset( $_GET['postId'] ) ) { '/', '/wp/v2/types/' . $post_type->name . '?context=edit', '/wp/v2/types?context=edit', - '/wp/v2/' . $post_type->rest_base . '?context=edit', + add_query_arg( 'context', 'edit', rest_get_route_for_post_type_items( $post_type ) ), ); block_editor_rest_api_preload( $preload_paths, $block_editor_context ); @@ -88,16 +88,16 @@ if ( isset( $_GET['postType'] ) && ! isset( $_GET['postId'] ) ) { $active_global_styles_id = WP_Theme_JSON_Resolver::get_user_custom_post_type_id(); $active_theme = wp_get_theme()->get_stylesheet(); $preload_paths = array( - array( '/wp/v2/media', 'OPTIONS' ), + array( rest_get_route_for_post_type_items( 'attachment' ), 'OPTIONS' ), '/', '/wp/v2/types?context=edit', '/wp/v2/taxonomies?context=edit', - '/wp/v2/pages?context=edit', - '/wp/v2/categories?context=edit', - '/wp/v2/posts?context=edit', - '/wp/v2/tags?context=edit', - '/wp/v2/templates?context=edit', - '/wp/v2/template-parts?context=edit', + add_query_arg( 'context', 'edit', rest_get_route_for_post_type_items( 'page' ) ), + add_query_arg( 'context', 'edit', rest_get_route_for_post_type_items( 'post' ) ), + add_query_arg( 'context', 'edit', rest_get_route_for_taxonomy_items( 'category' ) ), + add_query_arg( 'context', 'edit', rest_get_route_for_taxonomy_items( 'post_tag' ) ), + add_query_arg( 'context', 'edit', rest_get_route_for_post_type_items( 'wp_template' ) ), + add_query_arg( 'context', 'edit', rest_get_route_for_post_type_items( 'wp_template_part' ) ), '/wp/v2/settings', '/wp/v2/themes?context=edit&status=active', '/wp/v2/global-styles/' . $active_global_styles_id . '?context=edit', diff --git a/wp-includes/version.php b/wp-includes/version.php index c2fc0af315..a3f180f48f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-52280'; +$wp_version = '5.9-alpha-52281'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.