rebase on oct-10-2023
This commit is contained in:
@@ -317,6 +317,10 @@ function create_initial_rest_routes() {
|
||||
$controller = new WP_REST_Block_Types_Controller();
|
||||
$controller->register_routes();
|
||||
|
||||
// Global Styles revisions.
|
||||
$controller = new WP_REST_Global_Styles_Revisions_Controller();
|
||||
$controller->register_routes();
|
||||
|
||||
// Global Styles.
|
||||
$controller = new WP_REST_Global_Styles_Controller();
|
||||
$controller->register_routes();
|
||||
@@ -377,6 +381,10 @@ function create_initial_rest_routes() {
|
||||
// Site Editor Export.
|
||||
$controller = new WP_REST_Edit_Site_Export_Controller();
|
||||
$controller->register_routes();
|
||||
|
||||
// Navigation Fallback.
|
||||
$controller = new WP_REST_Navigation_Fallback_Controller();
|
||||
$controller->register_routes();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -465,9 +473,11 @@ function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) {
|
||||
$url .= $path;
|
||||
} else {
|
||||
$url = trailingslashit( get_home_url( $blog_id, '', $scheme ) );
|
||||
// nginx only allows HTTP/1.0 methods when redirecting from / to /index.php.
|
||||
// To work around this, we manually add index.php to the URL, avoiding the redirect.
|
||||
if ( 'index.php' !== substr( $url, 9 ) ) {
|
||||
/*
|
||||
* nginx only allows HTTP/1.0 methods when redirecting from / to /index.php.
|
||||
* To work around this, we manually add index.php to the URL, avoiding the redirect.
|
||||
*/
|
||||
if ( ! str_ends_with( $url, 'index.php' ) ) {
|
||||
$url .= 'index.php';
|
||||
}
|
||||
|
||||
@@ -624,8 +634,10 @@ function rest_ensure_response( $response ) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
// While WP_HTTP_Response is the base class of WP_REST_Response, it doesn't provide
|
||||
// all the required methods used in WP_REST_Server::dispatch().
|
||||
/*
|
||||
* While WP_HTTP_Response is the base class of WP_REST_Response, it doesn't provide
|
||||
* all the required methods used in WP_REST_Server::dispatch().
|
||||
*/
|
||||
if ( $response instanceof WP_HTTP_Response ) {
|
||||
return new WP_REST_Response(
|
||||
$response->get_data(),
|
||||
@@ -937,14 +949,18 @@ function rest_is_field_included( $field, $fields ) {
|
||||
}
|
||||
|
||||
foreach ( $fields as $accepted_field ) {
|
||||
// Check to see if $field is the parent of any item in $fields.
|
||||
// A field "parent" should be accepted if "parent.child" is accepted.
|
||||
if ( strpos( $accepted_field, "$field." ) === 0 ) {
|
||||
/*
|
||||
* Check to see if $field is the parent of any item in $fields.
|
||||
* A field "parent" should be accepted if "parent.child" is accepted.
|
||||
*/
|
||||
if ( str_starts_with( $accepted_field, "$field." ) ) {
|
||||
return true;
|
||||
}
|
||||
// Conversely, if "parent" is accepted, all "parent.child" fields
|
||||
// should also be accepted.
|
||||
if ( strpos( $field, "$accepted_field." ) === 0 ) {
|
||||
/*
|
||||
* Conversely, if "parent" is accepted, all "parent.child" fields
|
||||
* should also be accepted.
|
||||
*/
|
||||
if ( str_starts_with( $field, "$accepted_field." ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1601,8 +1617,10 @@ function rest_get_best_type_for_value( $value, $types ) {
|
||||
'null' => 'is_null',
|
||||
);
|
||||
|
||||
// Both arrays and objects allow empty strings to be converted to their types.
|
||||
// But the best answer for this type is a string.
|
||||
/*
|
||||
* Both arrays and objects allow empty strings to be converted to their types.
|
||||
* But the best answer for this type is a string.
|
||||
*/
|
||||
if ( '' === $value && in_array( 'string', $types, true ) ) {
|
||||
return 'string';
|
||||
}
|
||||
@@ -2183,8 +2201,10 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) {
|
||||
}
|
||||
}
|
||||
|
||||
// The "format" keyword should only be applied to strings. However, for backward compatibility,
|
||||
// we allow the "format" keyword if the type keyword was not specified, or was set to an invalid value.
|
||||
/*
|
||||
* The "format" keyword should only be applied to strings. However, for backward compatibility,
|
||||
* we allow the "format" keyword if the type keyword was not specified, or was set to an invalid value.
|
||||
*/
|
||||
if ( isset( $args['format'] )
|
||||
&& ( ! isset( $args['type'] ) || 'string' === $args['type'] || ! in_array( $args['type'], $allowed_types, true ) )
|
||||
) {
|
||||
@@ -2850,8 +2870,10 @@ function rest_sanitize_value_from_schema( $value, $args, $param = '' ) {
|
||||
* @return array Modified reduce accumulator.
|
||||
*/
|
||||
function rest_preload_api_request( $memo, $path ) {
|
||||
// array_reduce() doesn't support passing an array in PHP 5.2,
|
||||
// so we need to make sure we start with one.
|
||||
/*
|
||||
* array_reduce() doesn't support passing an array in PHP 5.2,
|
||||
* so we need to make sure we start with one.
|
||||
*/
|
||||
if ( ! is_array( $memo ) ) {
|
||||
$memo = array();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user