REST API: Add some missing documentation.
Props swissspidy. Fixes #34215. git-svn-id: https://develop.svn.wordpress.org/trunk@34949 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
df1b726ed0
commit
ab296be565
@ -4,6 +4,7 @@
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage REST_API
|
||||
* @since 4.4.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -11,6 +12,8 @@
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server).
|
||||
*
|
||||
* @param string $namespace The first URL segment after core prefix. Should be unique to your package/plugin.
|
||||
* @param string $route The base URL for route you are adding.
|
||||
* @param array $args Optional. Either an array of options for the endpoint, or an array of arrays for
|
||||
@ -19,7 +22,6 @@
|
||||
* false merges (with newer overriding if duplicate keys exist). Default false.
|
||||
*/
|
||||
function register_rest_route( $namespace, $route, $args = array(), $override = false ) {
|
||||
|
||||
/** @var WP_REST_Server $wp_rest_server */
|
||||
global $wp_rest_server;
|
||||
|
||||
@ -67,7 +69,7 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
|
||||
* by object type.
|
||||
*
|
||||
* @param string|array $object_type Object(s) the field is being registered
|
||||
* to, "post"|"term"|"comment" etc.
|
||||
* to, "post"|"term"|"comment" etc.
|
||||
* @param string $attribute The attribute name.
|
||||
* @param array $args {
|
||||
* Optional. An array of arguments used to handle the registered field.
|
||||
@ -78,12 +80,11 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
|
||||
* @type string|array|null $update_callback Optional. The callback function used to set and update the
|
||||
* field value. Default is 'null', the value cannot be set or
|
||||
* updated.
|
||||
* @type string|array|null schema Optional. The callback function used to create the schema for
|
||||
* @type string|array|null $schema Optional. The callback function used to create the schema for
|
||||
* this field. Default is 'null', no schema entry will be returned.
|
||||
* }
|
||||
*/
|
||||
function register_api_field( $object_type, $attribute, $args = array() ) {
|
||||
|
||||
$defaults = array(
|
||||
'get_callback' => null,
|
||||
'update_callback' => null,
|
||||
@ -153,6 +154,9 @@ function rest_api_default_filters() {
|
||||
* Loads the REST API.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @global WP $wp Current WordPress environment instance.
|
||||
* @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server).
|
||||
*/
|
||||
function rest_api_loaded() {
|
||||
if ( empty( $GLOBALS['wp']->query_vars['rest_route'] ) ) {
|
||||
@ -162,6 +166,7 @@ function rest_api_loaded() {
|
||||
/**
|
||||
* Whether this is a REST Request.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @var bool
|
||||
*/
|
||||
define( 'REST_REQUEST', true );
|
||||
@ -286,7 +291,7 @@ function rest_url( $path = '', $scheme = 'json' ) {
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @global WP_REST_Server $wp_rest_server
|
||||
* @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server).
|
||||
*
|
||||
* @param WP_REST_Request|string $request Request.
|
||||
* @return WP_REST_Response REST response.
|
||||
@ -447,7 +452,6 @@ function rest_handle_options_request( $response, $handler, $request ) {
|
||||
* @return WP_REST_Response Current response being served.
|
||||
*/
|
||||
function rest_send_allow_header( $response, $server, $request ) {
|
||||
|
||||
$matched_route = $response->get_matched_route();
|
||||
|
||||
if ( ! $matched_route ) {
|
||||
|
Loading…
Reference in New Issue
Block a user