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
This commit is contained in:
audrasjb
2025-03-24 23:59:35 +00:00
parent 94bac1c6b3
commit 46cb039f26
2 changed files with 6 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -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.