From 46cb039f267e0ee09ce8738e33b933ce60243d7b Mon Sep 17 00:00:00 2001 From: audrasjb Date: Mon, 24 Mar 2025 23:59:35 +0000 Subject: [PATCH] REST API: exclude `rest_route` from `get_params()` if pretty permalinks are disabled. This changeset introduces a modification to the `get_params()` method within the WordPress REST API. The change ensures that the `rest_route` parameter is excluded from the parameters returned when pretty permalinks are not enabled. This update enhances the developer experience by ensuring that the parameters returned by `get_params()` are relevant and do not include unnecessary values, thereby reducing potential confusion and errors. Props westonruter, TimothyBlynJacobs, audrasjb, debarghyabanerjee, dilip2615, shanemuir, peterwilsoncc. Fixes #62163. Built from https://develop.svn.wordpress.org/trunk@60073 git-svn-id: http://core.svn.wordpress.org/trunk@59409 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api/class-wp-rest-request.php | 5 +++++ wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/class-wp-rest-request.php b/wp-includes/rest-api/class-wp-rest-request.php index 3257194e54..70328e69e4 100644 --- a/wp-includes/rest-api/class-wp-rest-request.php +++ b/wp-includes/rest-api/class-wp-rest-request.php @@ -494,6 +494,11 @@ class WP_REST_Request implements ArrayAccess { } } + // Exclude rest_route if pretty permalinks are not enabled. + if ( ! get_option( 'permalink_structure' ) ) { + unset( $params['rest_route'] ); + } + return $params; } diff --git a/wp-includes/version.php b/wp-includes/version.php index f36de36031..1a5ca33239 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-beta3-60072'; +$wp_version = '6.8-beta3-60073'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.