From 7311d4eb5953e3080df124a007939d642895115a Mon Sep 17 00:00:00 2001
From: Ian Dunn <iandunn@git.wordpress.org>
Date: Tue, 22 Jun 2021 21:20:44 +0000
Subject: [PATCH] Block Editor: Send locale, version with remote pattern
 requests.

This information is needed by the w.org API for translation and caching.

Props dd32, ryelle, tellyworth
See #53435


git-svn-id: https://develop.svn.wordpress.org/trunk@51206 602fd350-edb4-49c9-b593-d223f7449a82
---
 .../class-wp-rest-pattern-directory-controller.php  | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php
index 8edf4a80ba..d758b1346d 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php
@@ -83,7 +83,18 @@ class WP_REST_Pattern_Directory_Controller extends WP_REST_Controller {
 	 * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
 	 */
 	public function get_items( $request ) {
-		$query_args  = array();
+		/*
+		 * Include an unmodified `$wp_version`, so the API can craft a response that's tailored to
+		 * it. Some plugins modify the version in a misguided attempt to improve security by
+		 * obscuring the version, which can cause invalid requests.
+		 */
+		require ABSPATH . WPINC . '/version.php';
+
+		$query_args = array(
+			'locale'     => get_user_locale(),
+			'wp-version' => $wp_version,
+		);
+
 		$category_id = $request['category'];
 		$keyword_id  = $request['keyword'];
 		$search_term = $request['search'];