Update WP and plugins
This commit is contained in:
parent
10a4713229
commit
1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions
|
@ -42,7 +42,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
public function __construct( $post_type ) {
|
||||
$this->post_type = $post_type;
|
||||
$this->namespace = 'wp/v2';
|
||||
$obj = get_post_type_object( $post_type );
|
||||
$obj = get_post_type_object( $post_type );
|
||||
$this->rest_base = ! empty( $obj->rest_base ) ? $obj->rest_base : $obj->name;
|
||||
|
||||
$this->meta = new WP_REST_Post_Meta_Fields( $this->post_type );
|
||||
|
@ -57,25 +57,29 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
*/
|
||||
public function register_routes() {
|
||||
|
||||
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
|
||||
register_rest_route(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
'permission_callback' => array( $this, 'get_items_permissions_check' ),
|
||||
'args' => $this->get_collection_params(),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'callback' => array( $this, 'create_item' ),
|
||||
'permission_callback' => array( $this, 'create_item_permissions_check' ),
|
||||
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
|
||||
),
|
||||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
) );
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
'permission_callback' => array( $this, 'get_items_permissions_check' ),
|
||||
'args' => $this->get_collection_params(),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'callback' => array( $this, 'create_item' ),
|
||||
'permission_callback' => array( $this, 'create_item_permissions_check' ),
|
||||
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
|
||||
),
|
||||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
)
|
||||
);
|
||||
|
||||
$schema = $this->get_item_schema();
|
||||
$schema = $this->get_item_schema();
|
||||
$get_item_args = array(
|
||||
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
|
||||
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
|
||||
);
|
||||
if ( isset( $schema['properties']['password'] ) ) {
|
||||
$get_item_args['password'] = array(
|
||||
|
@ -83,39 +87,43 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'type' => 'string',
|
||||
);
|
||||
}
|
||||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the object.' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
register_rest_route(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<id>[\d]+)',
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_item' ),
|
||||
'permission_callback' => array( $this, 'get_item_permissions_check' ),
|
||||
'args' => $get_item_args,
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'update_item' ),
|
||||
'permission_callback' => array( $this, 'update_item_permissions_check' ),
|
||||
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::DELETABLE,
|
||||
'callback' => array( $this, 'delete_item' ),
|
||||
'permission_callback' => array( $this, 'delete_item_permissions_check' ),
|
||||
'args' => array(
|
||||
'force' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'description' => __( 'Whether to bypass trash and force deletion.' ),
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the object.' ),
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
),
|
||||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
) );
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_item' ),
|
||||
'permission_callback' => array( $this, 'get_item_permissions_check' ),
|
||||
'args' => $get_item_args,
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'update_item' ),
|
||||
'permission_callback' => array( $this, 'update_item_permissions_check' ),
|
||||
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::DELETABLE,
|
||||
'callback' => array( $this, 'delete_item' ),
|
||||
'permission_callback' => array( $this, 'delete_item_permissions_check' ),
|
||||
'args' => array(
|
||||
'force' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'description' => __( 'Whether to bypass trash and force deletion.' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,7 +167,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
|
||||
// Retrieve the list of registered collection query parameters.
|
||||
$registered = $this->get_collection_params();
|
||||
$args = array();
|
||||
$args = array();
|
||||
|
||||
/*
|
||||
* This array defines mappings between public API query parameters whose
|
||||
|
@ -258,13 +266,13 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
* @param array $args Key value array of query var to query value.
|
||||
* @param WP_REST_Request $request The request used.
|
||||
*/
|
||||
$args = apply_filters( "rest_{$this->post_type}_query", $args, $request );
|
||||
$args = apply_filters( "rest_{$this->post_type}_query", $args, $request );
|
||||
$query_args = $this->prepare_items_query( $args, $request );
|
||||
|
||||
$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
|
||||
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
|
||||
$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
|
||||
$tax_exclude = $base . '_exclude';
|
||||
|
||||
if ( ! empty( $request[ $base ] ) ) {
|
||||
|
@ -311,7 +319,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
remove_filter( 'post_password_required', '__return_false' );
|
||||
}
|
||||
|
||||
$page = (int) $query_args['paged'];
|
||||
$page = (int) $query_args['paged'];
|
||||
$total_posts = $posts_query->found_posts;
|
||||
|
||||
if ( $total_posts < 1 ) {
|
||||
|
@ -329,13 +337,13 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
return new WP_Error( 'rest_post_invalid_page_number', __( 'The page number requested is larger than the number of pages available.' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$response = rest_ensure_response( $posts );
|
||||
$response = rest_ensure_response( $posts );
|
||||
|
||||
$response->header( 'X-WP-Total', (int) $total_posts );
|
||||
$response->header( 'X-WP-TotalPages', (int) $max_pages );
|
||||
|
||||
$request_params = $request->get_query_params();
|
||||
$base = add_query_arg( $request_params, rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
|
||||
$base = add_query_arg( $request_params, rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
|
||||
|
||||
if ( $page > 1 ) {
|
||||
$prev_page = $page - 1;
|
||||
|
@ -466,7 +474,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
$response = rest_ensure_response( $data );
|
||||
|
||||
if ( is_post_type_viewable( get_post_type_object( $post->post_type ) ) ) {
|
||||
$response->link_header( 'alternate', get_permalink( $post->ID ), array( 'type' => 'text/html' ) );
|
||||
$response->link_header( 'alternate', get_permalink( $post->ID ), array( 'type' => 'text/html' ) );
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
@ -591,7 +599,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
}
|
||||
}
|
||||
|
||||
$post = get_post( $post_id );
|
||||
$post = get_post( $post_id );
|
||||
$fields_update = $this->update_additional_fields_for_object( $post, $request );
|
||||
|
||||
if ( is_wp_error( $fields_update ) ) {
|
||||
|
@ -730,7 +738,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
}
|
||||
}
|
||||
|
||||
$post = get_post( $post_id );
|
||||
$post = get_post( $post_id );
|
||||
$fields_update = $this->update_additional_fields_for_object( $post, $request );
|
||||
|
||||
if ( is_wp_error( $fields_update ) ) {
|
||||
|
@ -817,13 +825,17 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
|
||||
|
||||
// If we're forcing, then delete permanently.
|
||||
if ( $force ) {
|
||||
$previous = $this->prepare_item_for_response( $post, $request );
|
||||
$result = wp_delete_post( $id, true );
|
||||
$result = wp_delete_post( $id, true );
|
||||
$response = new WP_REST_Response();
|
||||
$response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data() ) );
|
||||
$response->set_data(
|
||||
array(
|
||||
'deleted' => true,
|
||||
'previous' => $previous->get_data(),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// If we don't support trashing for this type, error out.
|
||||
if ( ! $supports_trash ) {
|
||||
|
@ -838,8 +850,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
|
||||
// (Note that internally this falls through to `wp_delete_post` if
|
||||
// the trash is disabled.)
|
||||
$result = wp_trash_post( $id );
|
||||
$post = get_post( $id );
|
||||
$result = wp_trash_post( $id );
|
||||
$post = get_post( $id );
|
||||
$response = $this->prepare_item_for_response( $post, $request );
|
||||
}
|
||||
|
||||
|
@ -1013,14 +1025,14 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
|
||||
if ( ! empty( $date_data ) ) {
|
||||
list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
|
||||
$prepared_post->edit_date = true;
|
||||
$prepared_post->edit_date = true;
|
||||
}
|
||||
} elseif ( ! empty( $schema['properties']['date_gmt'] ) && ! empty( $request['date_gmt'] ) ) {
|
||||
$date_data = rest_get_date_with_gmt( $request['date_gmt'], true );
|
||||
|
||||
if ( ! empty( $date_data ) ) {
|
||||
list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
|
||||
$prepared_post->edit_date = true;
|
||||
$prepared_post->edit_date = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1215,7 +1227,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
* Sets the template for a post.
|
||||
*
|
||||
* @since 4.7.0
|
||||
* @since 4.9.0 Introduced the $validate parameter.
|
||||
* @since 4.9.0 Added the `$validate` parameter.
|
||||
*
|
||||
* @param string $template Page template filename.
|
||||
* @param integer $post_id Post ID.
|
||||
|
@ -1525,7 +1537,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
|
||||
if ( in_array( 'excerpt', $fields, true ) ) {
|
||||
/** This filter is documented in wp-includes/post-template.php */
|
||||
$excerpt = apply_filters( 'the_excerpt', apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ) );
|
||||
$excerpt = apply_filters( 'the_excerpt', apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ) );
|
||||
$data['excerpt'] = array(
|
||||
'raw' => $post->post_excerpt,
|
||||
'rendered' => post_password_required( $post ) ? '' : $excerpt,
|
||||
|
@ -1593,13 +1605,13 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
|
||||
|
||||
if ( in_array( $base, $fields, true ) ) {
|
||||
$terms = get_the_terms( $post, $taxonomy->name );
|
||||
$terms = get_the_terms( $post, $taxonomy->name );
|
||||
$data[ $base ] = $terms ? array_values( wp_list_pluck( $terms, 'term_id' ) ) : array();
|
||||
}
|
||||
}
|
||||
|
||||
$post_type_obj = get_post_type_object( $post->post_type );
|
||||
if ( is_post_type_viewable( $post_type_obj ) && $post_type_obj->public ) {
|
||||
if ( is_post_type_viewable( $post_type_obj ) && $post_type_obj->public ) {
|
||||
|
||||
if ( ! function_exists( 'get_sample_permalink' ) ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/post.php';
|
||||
|
@ -1677,14 +1689,14 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
|
||||
// Entity meta.
|
||||
$links = array(
|
||||
'self' => array(
|
||||
'href' => rest_url( trailingslashit( $base ) . $post->ID ),
|
||||
'self' => array(
|
||||
'href' => rest_url( trailingslashit( $base ) . $post->ID ),
|
||||
),
|
||||
'collection' => array(
|
||||
'href' => rest_url( $base ),
|
||||
'href' => rest_url( $base ),
|
||||
),
|
||||
'about' => array(
|
||||
'href' => rest_url( 'wp/v2/types/' . $this->post_type ),
|
||||
'href' => rest_url( 'wp/v2/types/' . $this->post_type ),
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -1723,7 +1735,6 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'id' => $last_revision,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$post_type_obj = get_post_type_object( $post->post_type );
|
||||
|
@ -1859,19 +1870,19 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'type' => 'object',
|
||||
// Base properties for every Post.
|
||||
'properties' => array(
|
||||
'date' => array(
|
||||
'date' => array(
|
||||
'description' => __( "The date the object was published, in the site's timezone." ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
),
|
||||
'date_gmt' => array(
|
||||
'date_gmt' => array(
|
||||
'description' => __( 'The date the object was published, as GMT.' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'guid' => array(
|
||||
'guid' => array(
|
||||
'description' => __( 'The globally unique identifier for the object.' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
|
@ -1891,34 +1902,34 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
),
|
||||
),
|
||||
),
|
||||
'id' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the object.' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'link' => array(
|
||||
'link' => array(
|
||||
'description' => __( 'URL to the object.' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'modified' => array(
|
||||
'modified' => array(
|
||||
'description' => __( "The date the object was last modified, in the site's timezone." ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'modified_gmt' => array(
|
||||
'modified_gmt' => array(
|
||||
'description' => __( 'The date the object was last modified, as GMT.' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'slug' => array(
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the object unique to its type.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
|
@ -1926,19 +1937,19 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'sanitize_callback' => array( $this, 'sanitize_slug' ),
|
||||
),
|
||||
),
|
||||
'status' => array(
|
||||
'status' => array(
|
||||
'description' => __( 'A named status for the object.' ),
|
||||
'type' => 'string',
|
||||
'enum' => array_keys( get_post_stati( array( 'internal' => false ) ) ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'type' => array(
|
||||
'type' => array(
|
||||
'description' => __( 'Type of Post for the object.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'password' => array(
|
||||
'password' => array(
|
||||
'description' => __( 'A password to protect access to the content and excerpt.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'edit' ),
|
||||
|
@ -1983,8 +1994,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'post-formats',
|
||||
'custom-fields',
|
||||
);
|
||||
$fixed_schemas = array(
|
||||
'post' => array(
|
||||
$fixed_schemas = array(
|
||||
'post' => array(
|
||||
'title',
|
||||
'editor',
|
||||
'author',
|
||||
|
@ -1995,7 +2006,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'post-formats',
|
||||
'custom-fields',
|
||||
),
|
||||
'page' => array(
|
||||
'page' => array(
|
||||
'title',
|
||||
'editor',
|
||||
'author',
|
||||
|
@ -2033,7 +2044,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database()
|
||||
),
|
||||
'properties' => array(
|
||||
'raw' => array(
|
||||
'raw' => array(
|
||||
'description' => __( 'Title for the object, as it exists in the database.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'edit' ),
|
||||
|
@ -2058,12 +2069,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database()
|
||||
),
|
||||
'properties' => array(
|
||||
'raw' => array(
|
||||
'raw' => array(
|
||||
'description' => __( 'Content for the object, as it exists in the database.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'edit' ),
|
||||
),
|
||||
'rendered' => array(
|
||||
'rendered' => array(
|
||||
'description' => __( 'HTML content for the object, transformed for display.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
|
@ -2075,7 +2086,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'context' => array( 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'protected' => array(
|
||||
'protected' => array(
|
||||
'description' => __( 'Whether the content is protected with a password.' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
|
@ -2103,18 +2114,18 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database()
|
||||
),
|
||||
'properties' => array(
|
||||
'raw' => array(
|
||||
'raw' => array(
|
||||
'description' => __( 'Excerpt for the object, as it exists in the database.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'edit' ),
|
||||
),
|
||||
'rendered' => array(
|
||||
'rendered' => array(
|
||||
'description' => __( 'HTML excerpt for the object, transformed for display.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'protected' => array(
|
||||
'protected' => array(
|
||||
'description' => __( 'Whether the excerpt is protected with a password.' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
|
@ -2139,7 +2150,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'enum' => array( 'open', 'closed' ),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
);
|
||||
$schema['properties']['ping_status'] = array(
|
||||
$schema['properties']['ping_status'] = array(
|
||||
'description' => __( 'Whether or not the object can be pinged.' ),
|
||||
'type' => 'string',
|
||||
'enum' => array( 'open', 'closed' ),
|
||||
|
@ -2193,13 +2204,13 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
|
||||
$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
|
||||
$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
|
||||
$schema['properties'][ $base ] = array(
|
||||
/* translators: %s: taxonomy name */
|
||||
'description' => sprintf( __( 'The terms assigned to the object in the %s taxonomy.' ), $taxonomy->name ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
'type' => 'integer',
|
||||
),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
);
|
||||
|
@ -2249,8 +2260,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'title' => __( 'The current user can post unfiltered HTML markup and JavaScript.' ),
|
||||
'href' => $href,
|
||||
'targetSchema' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'content' => array(
|
||||
'raw' => array(
|
||||
'type' => 'string',
|
||||
|
@ -2353,78 +2364,78 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
$query_params['context']['default'] = 'view';
|
||||
|
||||
$query_params['after'] = array(
|
||||
'description' => __( 'Limit response to posts published after a given ISO8601 compliant date.' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
'description' => __( 'Limit response to posts published after a given ISO8601 compliant date.' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
);
|
||||
|
||||
if ( post_type_supports( $this->post_type, 'author' ) ) {
|
||||
$query_params['author'] = array(
|
||||
'description' => __( 'Limit result set to posts assigned to specific authors.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
$query_params['author'] = array(
|
||||
'description' => __( 'Limit result set to posts assigned to specific authors.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
'default' => array(),
|
||||
'default' => array(),
|
||||
);
|
||||
$query_params['author_exclude'] = array(
|
||||
'description' => __( 'Ensure result set excludes posts assigned to specific authors.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
'description' => __( 'Ensure result set excludes posts assigned to specific authors.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
'default' => array(),
|
||||
'default' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
$query_params['before'] = array(
|
||||
'description' => __( 'Limit response to posts published before a given ISO8601 compliant date.' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
'description' => __( 'Limit response to posts published before a given ISO8601 compliant date.' ),
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
);
|
||||
|
||||
$query_params['exclude'] = array(
|
||||
'description' => __( 'Ensure result set excludes specific IDs.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
'description' => __( 'Ensure result set excludes specific IDs.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
'default' => array(),
|
||||
'default' => array(),
|
||||
);
|
||||
|
||||
$query_params['include'] = array(
|
||||
'description' => __( 'Limit result set to specific IDs.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
'description' => __( 'Limit result set to specific IDs.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
'default' => array(),
|
||||
'default' => array(),
|
||||
);
|
||||
|
||||
if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) {
|
||||
$query_params['menu_order'] = array(
|
||||
'description' => __( 'Limit result set to posts with a specific menu_order value.' ),
|
||||
'type' => 'integer',
|
||||
'description' => __( 'Limit result set to posts with a specific menu_order value.' ),
|
||||
'type' => 'integer',
|
||||
);
|
||||
}
|
||||
|
||||
$query_params['offset'] = array(
|
||||
'description' => __( 'Offset the result set by a specific number of items.' ),
|
||||
'type' => 'integer',
|
||||
'description' => __( 'Offset the result set by a specific number of items.' ),
|
||||
'type' => 'integer',
|
||||
);
|
||||
|
||||
$query_params['order'] = array(
|
||||
'description' => __( 'Order sort attribute ascending or descending.' ),
|
||||
'type' => 'string',
|
||||
'default' => 'desc',
|
||||
'enum' => array( 'asc', 'desc' ),
|
||||
'description' => __( 'Order sort attribute ascending or descending.' ),
|
||||
'type' => 'string',
|
||||
'default' => 'desc',
|
||||
'enum' => array( 'asc', 'desc' ),
|
||||
);
|
||||
|
||||
$query_params['orderby'] = array(
|
||||
'description' => __( 'Sort collection by object attribute.' ),
|
||||
'type' => 'string',
|
||||
'default' => 'date',
|
||||
'enum' => array(
|
||||
'description' => __( 'Sort collection by object attribute.' ),
|
||||
'type' => 'string',
|
||||
'default' => 'date',
|
||||
'enum' => array(
|
||||
'author',
|
||||
'date',
|
||||
'id',
|
||||
|
@ -2445,21 +2456,21 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
$post_type = get_post_type_object( $this->post_type );
|
||||
|
||||
if ( $post_type->hierarchical || 'attachment' === $this->post_type ) {
|
||||
$query_params['parent'] = array(
|
||||
'description' => __( 'Limit result set to items with particular parent IDs.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
$query_params['parent'] = array(
|
||||
'description' => __( 'Limit result set to items with particular parent IDs.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
'default' => array(),
|
||||
'default' => array(),
|
||||
);
|
||||
$query_params['parent_exclude'] = array(
|
||||
'description' => __( 'Limit result set to all items except those of a particular parent ID.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
'description' => __( 'Limit result set to all items except those of a particular parent ID.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
'default' => array(),
|
||||
'default' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2467,7 +2478,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'description' => __( 'Limit result set to posts with one or more specific slugs.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'string',
|
||||
'type' => 'string',
|
||||
),
|
||||
'sanitize_callback' => 'wp_parse_slug_list',
|
||||
);
|
||||
|
@ -2477,8 +2488,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'description' => __( 'Limit result set to posts assigned one or more statuses.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'enum' => array_merge( array_keys( get_post_stati() ), array( 'any' ) ),
|
||||
'type' => 'string',
|
||||
'enum' => array_merge( array_keys( get_post_stati() ), array( 'any' ) ),
|
||||
'type' => 'string',
|
||||
),
|
||||
'sanitize_callback' => array( $this, 'sanitize_post_statuses' ),
|
||||
);
|
||||
|
@ -2490,12 +2501,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
|
||||
$query_params[ $base ] = array(
|
||||
/* translators: %s: taxonomy name */
|
||||
'description' => sprintf( __( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
'description' => sprintf( __( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
'default' => array(),
|
||||
'default' => array(),
|
||||
);
|
||||
|
||||
$query_params[ $base . '_exclude' ] = array(
|
||||
|
@ -2503,16 +2514,16 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
'description' => sprintf( __( 'Limit result set to all items except those that have the specified term assigned in the %s taxonomy.' ), $base ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
'type' => 'integer',
|
||||
),
|
||||
'default' => array(),
|
||||
'default' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'post' === $this->post_type ) {
|
||||
$query_params['sticky'] = array(
|
||||
'description' => __( 'Limit result set to items that are sticky.' ),
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'Limit result set to items that are sticky.' ),
|
||||
'type' => 'boolean',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2549,7 +2560,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
$statuses = wp_parse_slug_list( $statuses );
|
||||
|
||||
// The default status is different in WP_REST_Attachments_Controller
|
||||
$attributes = $request->get_attributes();
|
||||
$attributes = $request->get_attributes();
|
||||
$default_status = $attributes['args']['status']['default'];
|
||||
|
||||
foreach ( $statuses as $status ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue