mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 06:57:35 +01:00
REST API: Set maximum 'per_page' for embedded REST API requests.
This enhancement refines the REST API server to automatically establish the maximum 'per_page' value for embedded objects, adhering to the endpoint's schema when not explicitly defined in the request. This adjustment elevates the limit from the default of 10 items to 100 items, significantly improving the likelihood of receiving the complete dataset of embedded objects. Props manyourisms, lpawlik, spacedmonkey, kadamwhite, TimothyBlynJacobs. Fixes #43439. Built from https://develop.svn.wordpress.org/trunk@57623 git-svn-id: http://core.svn.wordpress.org/trunk@57124 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0ab75261f4
commit
9b3acbae25
@ -743,6 +743,13 @@ class WP_REST_Server {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( empty( $request['per_page'] ) ) {
|
||||
$matched = $this->match_request_to_handler( $request );
|
||||
if ( ! is_wp_error( $matched ) && isset( $matched[1]['args']['per_page']['maximum'] ) ) {
|
||||
$request['per_page'] = (int) $matched[1]['args']['per_page']['maximum'];
|
||||
}
|
||||
}
|
||||
|
||||
// Embedded resources get passed context=embed.
|
||||
if ( empty( $request['context'] ) ) {
|
||||
$request['context'] = 'embed';
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.5-alpha-57622';
|
||||
$wp_version = '6.5-alpha-57623';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user