Update WP and plugins
This commit is contained in:
parent
10a4713229
commit
1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions
|
@ -56,9 +56,9 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||
* @param string $taxonomy Taxonomy key.
|
||||
*/
|
||||
public function __construct( $taxonomy ) {
|
||||
$this->taxonomy = $taxonomy;
|
||||
$this->taxonomy = $taxonomy;
|
||||
$this->namespace = 'wp/v2';
|
||||
$tax_obj = get_taxonomy( $taxonomy );
|
||||
$tax_obj = get_taxonomy( $taxonomy );
|
||||
$this->rest_base = ! empty( $tax_obj->rest_base ) ? $tax_obj->rest_base : $tax_obj->name;
|
||||
|
||||
$this->meta = new WP_REST_Term_Meta_Fields( $taxonomy );
|
||||
|
@ -73,57 +73,65 @@ class WP_REST_Terms_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' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the term.' ),
|
||||
'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' => array(
|
||||
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
|
||||
),
|
||||
),
|
||||
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' => __( 'Required to be true, as terms do not support trashing.' ),
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the term.' ),
|
||||
'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' => array(
|
||||
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
|
||||
),
|
||||
),
|
||||
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' => __( 'Required to be true, as terms do not support trashing.' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,7 +243,7 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||
*/
|
||||
$prepared_args = apply_filters( "rest_{$this->taxonomy}_query", $prepared_args, $request );
|
||||
|
||||
if ( ! empty( $prepared_args['post'] ) ) {
|
||||
if ( ! empty( $prepared_args['post'] ) ) {
|
||||
$query_result = wp_get_object_terms( $prepared_args['post'], $this->taxonomy, $prepared_args );
|
||||
|
||||
// Used when calling wp_count_terms() below.
|
||||
|
@ -258,7 +266,7 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||
$response = array();
|
||||
|
||||
foreach ( $query_result as $term ) {
|
||||
$data = $this->prepare_item_for_response( $term, $request );
|
||||
$data = $this->prepare_item_for_response( $term, $request );
|
||||
$response[] = $this->prepare_response_for_collection( $data );
|
||||
}
|
||||
|
||||
|
@ -418,7 +426,12 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||
if ( $term_id = $term->get_error_data( 'term_exists' ) ) {
|
||||
$existing_term = get_term( $term_id, $this->taxonomy );
|
||||
$term->add_data( $existing_term->term_id, 'term_exists' );
|
||||
$term->add_data( array( 'status' => 400, 'term_id' => $term_id ) );
|
||||
$term->add_data(
|
||||
array(
|
||||
'status' => 400,
|
||||
'term_id' => $term_id,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $term;
|
||||
|
@ -620,7 +633,12 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||
}
|
||||
|
||||
$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(),
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Fires after a single term is deleted via the REST API.
|
||||
|
@ -773,7 +791,7 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||
* @return array Links for the given term.
|
||||
*/
|
||||
protected function prepare_links( $term ) {
|
||||
$base = $this->namespace . '/' . $this->rest_base;
|
||||
$base = $this->namespace . '/' . $this->rest_base;
|
||||
$links = array(
|
||||
'self' => array(
|
||||
'href' => rest_url( trailingslashit( $base ) . $term->term_id ),
|
||||
|
@ -812,7 +830,7 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||
continue;
|
||||
}
|
||||
|
||||
$rest_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name;
|
||||
$rest_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name;
|
||||
$post_type_links[] = array(
|
||||
'href' => add_query_arg( $this->rest_base, $term->term_id, rest_url( sprintf( 'wp/v2/%s', $rest_base ) ) ),
|
||||
);
|
||||
|
@ -839,52 +857,52 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||
'type' => 'object',
|
||||
'properties' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the term.' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'embed', 'edit' ),
|
||||
'readonly' => true,
|
||||
'description' => __( 'Unique identifier for the term.' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'embed', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'count' => array(
|
||||
'description' => __( 'Number of published posts for the term.' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
'description' => __( 'Number of published posts for the term.' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => __( 'HTML description of the term.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'description' => __( 'HTML description of the term.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
'link' => array(
|
||||
'description' => __( 'URL of the term.' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'embed', 'edit' ),
|
||||
'readonly' => true,
|
||||
'description' => __( 'URL of the term.' ),
|
||||
'type' => 'string',
|
||||
'format' => 'uri',
|
||||
'context' => array( 'view', 'embed', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => __( 'HTML title for the term.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'embed', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'description' => __( 'HTML title for the term.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'embed', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
),
|
||||
'required' => true,
|
||||
'required' => true,
|
||||
),
|
||||
'slug' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the term unique to its type.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'embed', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the term unique to its type.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'embed', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => array( $this, 'sanitize_slug' ),
|
||||
),
|
||||
),
|
||||
'taxonomy' => array(
|
||||
'description' => __( 'Type attribution for the term.' ),
|
||||
'type' => 'string',
|
||||
'enum' => array_keys( get_taxonomies() ),
|
||||
'context' => array( 'view', 'embed', 'edit' ),
|
||||
'readonly' => true,
|
||||
'description' => __( 'Type attribution for the term.' ),
|
||||
'type' => 'string',
|
||||
'enum' => array_keys( get_taxonomies() ),
|
||||
'context' => array( 'view', 'embed', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -893,9 +911,9 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||
|
||||
if ( $taxonomy->hierarchical ) {
|
||||
$schema['properties']['parent'] = array(
|
||||
'description' => __( 'The parent term ID.' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'description' => __( 'The parent term ID.' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -913,50 +931,50 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||
*/
|
||||
public function get_collection_params() {
|
||||
$query_params = parent::get_collection_params();
|
||||
$taxonomy = get_taxonomy( $this->taxonomy );
|
||||
$taxonomy = get_taxonomy( $this->taxonomy );
|
||||
|
||||
$query_params['context']['default'] = 'view';
|
||||
|
||||
$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 ( ! $taxonomy->hierarchical ) {
|
||||
$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' => 'asc',
|
||||
'enum' => array(
|
||||
'description' => __( 'Order sort attribute ascending or descending.' ),
|
||||
'type' => 'string',
|
||||
'default' => 'asc',
|
||||
'enum' => array(
|
||||
'asc',
|
||||
'desc',
|
||||
),
|
||||
);
|
||||
|
||||
$query_params['orderby'] = array(
|
||||
'description' => __( 'Sort collection by term attribute.' ),
|
||||
'type' => 'string',
|
||||
'default' => 'name',
|
||||
'enum' => array(
|
||||
'description' => __( 'Sort collection by term attribute.' ),
|
||||
'type' => 'string',
|
||||
'default' => 'name',
|
||||
'enum' => array(
|
||||
'id',
|
||||
'include',
|
||||
'name',
|
||||
|
@ -969,29 +987,29 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||
);
|
||||
|
||||
$query_params['hide_empty'] = array(
|
||||
'description' => __( 'Whether to hide terms not assigned to any posts.' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'description' => __( 'Whether to hide terms not assigned to any posts.' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
);
|
||||
|
||||
if ( $taxonomy->hierarchical ) {
|
||||
$query_params['parent'] = array(
|
||||
'description' => __( 'Limit result set to terms assigned to a specific parent.' ),
|
||||
'type' => 'integer',
|
||||
'description' => __( 'Limit result set to terms assigned to a specific parent.' ),
|
||||
'type' => 'integer',
|
||||
);
|
||||
}
|
||||
|
||||
$query_params['post'] = array(
|
||||
'description' => __( 'Limit result set to terms assigned to a specific post.' ),
|
||||
'type' => 'integer',
|
||||
'default' => null,
|
||||
'description' => __( 'Limit result set to terms assigned to a specific post.' ),
|
||||
'type' => 'integer',
|
||||
'default' => null,
|
||||
);
|
||||
|
||||
$query_params['slug'] = array(
|
||||
'description' => __( 'Limit result set to terms with one or more specific slugs.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'string'
|
||||
'description' => __( 'Limit result set to terms with one or more specific slugs.' ),
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue