Update WP and plugins
This commit is contained in:
parent
10a4713229
commit
1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions
|
@ -88,8 +88,8 @@ class WP_REST_Server {
|
|||
// Meta endpoints.
|
||||
'/' => array(
|
||||
'callback' => array( $this, 'get_index' ),
|
||||
'methods' => 'GET',
|
||||
'args' => array(
|
||||
'methods' => 'GET',
|
||||
'args' => array(
|
||||
'context' => array(
|
||||
'default' => 'view',
|
||||
),
|
||||
|
@ -160,7 +160,11 @@ class WP_REST_Server {
|
|||
|
||||
foreach ( (array) $error->errors as $code => $messages ) {
|
||||
foreach ( (array) $messages as $message ) {
|
||||
$errors[] = array( 'code' => $code, 'message' => $message, 'data' => $error->get_error_data( $code ) );
|
||||
$errors[] = array(
|
||||
'code' => $code,
|
||||
'message' => $message,
|
||||
'data' => $error->get_error_data( $code ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,7 +264,11 @@ class WP_REST_Server {
|
|||
*
|
||||
* @param bool $rest_enabled Whether the REST API is enabled. Default true.
|
||||
*/
|
||||
apply_filters_deprecated( 'rest_enabled', array( true ), '4.7.0', 'rest_authentication_errors',
|
||||
apply_filters_deprecated(
|
||||
'rest_enabled',
|
||||
array( true ),
|
||||
'4.7.0',
|
||||
'rest_authentication_errors',
|
||||
__( 'The REST API can no longer be completely disabled, the rest_authentication_errors filter can be used to restrict access to the API, instead.' )
|
||||
);
|
||||
|
||||
|
@ -398,8 +406,8 @@ class WP_REST_Server {
|
|||
$json_error_message = $this->get_json_last_error();
|
||||
if ( $json_error_message ) {
|
||||
$json_error_obj = new WP_Error( 'rest_encode_error', $json_error_message, array( 'status' => 500 ) );
|
||||
$result = $this->error_to_response( $json_error_obj );
|
||||
$result = wp_json_encode( $result->data[0] );
|
||||
$result = $this->error_to_response( $json_error_obj );
|
||||
$result = wp_json_encode( $result->data[0] );
|
||||
}
|
||||
|
||||
if ( $jsonp_callback ) {
|
||||
|
@ -454,7 +462,6 @@ class WP_REST_Server {
|
|||
* direct output.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @static
|
||||
*
|
||||
* @param WP_REST_Response $response Response to extract links from.
|
||||
* @return array Map of link relation to list of link hashes.
|
||||
|
@ -471,9 +478,9 @@ class WP_REST_Server {
|
|||
$data[ $rel ] = array();
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
$attributes = $item['attributes'];
|
||||
$attributes = $item['attributes'];
|
||||
$attributes['href'] = $item['href'];
|
||||
$data[ $rel ][] = $attributes;
|
||||
$data[ $rel ][] = $attributes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -487,7 +494,6 @@ class WP_REST_Server {
|
|||
* direct output.
|
||||
*
|
||||
* @since 4.5.0
|
||||
* @static
|
||||
*
|
||||
* @param WP_REST_Response $response Response to extract links from.
|
||||
* @return array Map of link relation to list of link hashes.
|
||||
|
@ -499,7 +505,7 @@ class WP_REST_Server {
|
|||
return array();
|
||||
}
|
||||
|
||||
$curies = $response->get_curies();
|
||||
$curies = $response->get_curies();
|
||||
$used_curies = array();
|
||||
|
||||
foreach ( $links as $rel => $items ) {
|
||||
|
@ -515,9 +521,9 @@ class WP_REST_Server {
|
|||
$rel_regex = str_replace( '\{rel\}', '(.+)', preg_quote( $curie['href'], '!' ) );
|
||||
preg_match( '!' . $rel_regex . '!', $rel, $matches );
|
||||
if ( $matches ) {
|
||||
$new_rel = $curie['name'] . ':' . $matches[1];
|
||||
$new_rel = $curie['name'] . ':' . $matches[1];
|
||||
$used_curies[ $curie['name'] ] = $curie;
|
||||
$links[ $new_rel ] = $items;
|
||||
$links[ $new_rel ] = $items;
|
||||
unset( $links[ $rel ] );
|
||||
break;
|
||||
}
|
||||
|
@ -652,25 +658,29 @@ class WP_REST_Server {
|
|||
if ( ! isset( $this->namespaces[ $namespace ] ) ) {
|
||||
$this->namespaces[ $namespace ] = array();
|
||||
|
||||
$this->register_route( $namespace, '/' . $namespace, array(
|
||||
$this->register_route(
|
||||
$namespace,
|
||||
'/' . $namespace,
|
||||
array(
|
||||
'methods' => self::READABLE,
|
||||
'callback' => array( $this, 'get_namespace_index' ),
|
||||
'args' => array(
|
||||
'namespace' => array(
|
||||
'default' => $namespace,
|
||||
),
|
||||
'context' => array(
|
||||
'default' => 'view',
|
||||
array(
|
||||
'methods' => self::READABLE,
|
||||
'callback' => array( $this, 'get_namespace_index' ),
|
||||
'args' => array(
|
||||
'namespace' => array(
|
||||
'default' => $namespace,
|
||||
),
|
||||
'context' => array(
|
||||
'default' => 'view',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
) );
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Associative to avoid double-registration.
|
||||
$this->namespaces[ $namespace ][ $route ] = true;
|
||||
$route_args['namespace'] = $namespace;
|
||||
$route_args['namespace'] = $namespace;
|
||||
|
||||
if ( $override || empty( $this->endpoints[ $route ] ) ) {
|
||||
$this->endpoints[ $route ] = $route_args;
|
||||
|
@ -756,7 +766,7 @@ class WP_REST_Server {
|
|||
$handler['methods'] = array();
|
||||
|
||||
foreach ( $methods as $method ) {
|
||||
$method = strtoupper( trim( $method ) );
|
||||
$method = strtoupper( trim( $method ) );
|
||||
$handler['methods'][ $method ] = true;
|
||||
}
|
||||
}
|
||||
|
@ -838,7 +848,7 @@ class WP_REST_Server {
|
|||
}
|
||||
|
||||
foreach ( $handlers as $handler ) {
|
||||
$callback = $handler['callback'];
|
||||
$callback = $handler['callback'];
|
||||
$response = null;
|
||||
|
||||
// Fallback to GET method if no HEAD method is registered.
|
||||
|
@ -894,9 +904,9 @@ class WP_REST_Server {
|
|||
*
|
||||
* @since 4.7.0
|
||||
*
|
||||
* @param WP_HTTP_Response $response Result to send to the client. Usually a WP_REST_Response.
|
||||
* @param WP_REST_Server $handler ResponseHandler instance (usually WP_REST_Server).
|
||||
* @param WP_REST_Request $request Request used to generate the response.
|
||||
* @param WP_HTTP_Response|WP_Error $response Result to send to the client. Usually a WP_REST_Response or WP_Error.
|
||||
* @param array $handler Route handler used for the request.
|
||||
* @param WP_REST_Request $request Request used to generate the response.
|
||||
*/
|
||||
$response = apply_filters( 'rest_request_before_callbacks', $response, $handler, $request );
|
||||
|
||||
|
@ -922,7 +932,7 @@ class WP_REST_Server {
|
|||
* @since 4.4.0
|
||||
* @since 4.5.0 Added `$route` and `$handler` parameters.
|
||||
*
|
||||
* @param bool $dispatch_result Dispatch result, will be used if not empty.
|
||||
* @param mixed $dispatch_result Dispatch result, will be used if not empty.
|
||||
* @param WP_REST_Request $request Request used to generate the response.
|
||||
* @param string $route Route matched for the request.
|
||||
* @param array $handler Route handler used for the request.
|
||||
|
@ -953,9 +963,9 @@ class WP_REST_Server {
|
|||
*
|
||||
* @since 4.7.0
|
||||
*
|
||||
* @param WP_HTTP_Response $response Result to send to the client. Usually a WP_REST_Response.
|
||||
* @param WP_REST_Server $handler ResponseHandler instance (usually WP_REST_Server).
|
||||
* @param WP_REST_Request $request Request used to generate the response.
|
||||
* @param WP_HTTP_Response|WP_Error $response Result to send to the client. Usually a WP_REST_Response or WP_Error.
|
||||
* @param array $handler Route handler used for the request.
|
||||
* @param WP_REST_Request $request Request used to generate the response.
|
||||
*/
|
||||
$response = apply_filters( 'rest_request_after_callbacks', $response, $handler, $request );
|
||||
|
||||
|
@ -1062,12 +1072,12 @@ class WP_REST_Server {
|
|||
return new WP_Error( 'rest_invalid_namespace', __( 'The specified namespace could not be found.' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$routes = $this->namespaces[ $namespace ];
|
||||
$routes = $this->namespaces[ $namespace ];
|
||||
$endpoints = array_intersect_key( $this->get_routes(), $routes );
|
||||
|
||||
$data = array(
|
||||
$data = array(
|
||||
'namespace' => $namespace,
|
||||
'routes' => $this->get_data_for_routes( $endpoints, $request['context'] ),
|
||||
'routes' => $this->get_data_for_routes( $endpoints, $request['context'] ),
|
||||
);
|
||||
$response = rest_ensure_response( $data );
|
||||
|
||||
|
@ -1145,7 +1155,7 @@ class WP_REST_Server {
|
|||
public function get_data_for_route( $route, $callbacks, $context = 'view' ) {
|
||||
$data = array(
|
||||
'namespace' => '',
|
||||
'methods' => array(),
|
||||
'methods' => array(),
|
||||
'endpoints' => array(),
|
||||
);
|
||||
|
||||
|
@ -1170,7 +1180,7 @@ class WP_REST_Server {
|
|||
}
|
||||
|
||||
$data['methods'] = array_merge( $data['methods'], array_keys( $callback['methods'] ) );
|
||||
$endpoint_data = array(
|
||||
$endpoint_data = array(
|
||||
'methods' => array_keys( $callback['methods'] ),
|
||||
);
|
||||
|
||||
|
@ -1319,7 +1329,11 @@ class WP_REST_Server {
|
|||
$headers = array();
|
||||
|
||||
// CONTENT_* headers are not prefixed with HTTP_.
|
||||
$additional = array( 'CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true );
|
||||
$additional = array(
|
||||
'CONTENT_LENGTH' => true,
|
||||
'CONTENT_MD5' => true,
|
||||
'CONTENT_TYPE' => true,
|
||||
);
|
||||
|
||||
foreach ( $server as $key => $value ) {
|
||||
if ( strpos( $key, 'HTTP_' ) === 0 ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue