REST API: Introduce `modified_before` and `modified_after` query parameters for the posts endpoints.
These parameters work just the same as `before` and `after` except they operate on the post modified date instead of the post published date. Props claytoncollie, TimothyBlynJacobs, hellofromTonya Fixes #50617 Built from https://develop.svn.wordpress.org/trunk@50024 git-svn-id: http://core.svn.wordpress.org/trunk@49725 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4ad17435f9
commit
3670cc0b36
|
@ -216,14 +216,32 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||||
// Check for & assign any parameters which require special handling or setting.
|
// Check for & assign any parameters which require special handling or setting.
|
||||||
$args['date_query'] = array();
|
$args['date_query'] = array();
|
||||||
|
|
||||||
// Set before into date query. Date query must be specified as an array of an array.
|
|
||||||
if ( isset( $registered['before'], $request['before'] ) ) {
|
if ( isset( $registered['before'], $request['before'] ) ) {
|
||||||
$args['date_query'][0]['before'] = $request['before'];
|
$args['date_query'][] = array(
|
||||||
|
'before' => $request['before'],
|
||||||
|
'column' => 'post_date',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset( $registered['modified_before'], $request['modified_before'] ) ) {
|
||||||
|
$args['date_query'][] = array(
|
||||||
|
'before' => $request['modified_before'],
|
||||||
|
'column' => 'post_modified',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set after into date query. Date query must be specified as an array of an array.
|
|
||||||
if ( isset( $registered['after'], $request['after'] ) ) {
|
if ( isset( $registered['after'], $request['after'] ) ) {
|
||||||
$args['date_query'][0]['after'] = $request['after'];
|
$args['date_query'][] = array(
|
||||||
|
'after' => $request['after'],
|
||||||
|
'column' => 'post_date',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset( $registered['modified_after'], $request['modified_after'] ) ) {
|
||||||
|
$args['date_query'][] = array(
|
||||||
|
'after' => $request['modified_after'],
|
||||||
|
'column' => 'post_modified',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure our per_page parameter overrides any provided posts_per_page filter.
|
// Ensure our per_page parameter overrides any provided posts_per_page filter.
|
||||||
|
@ -2628,6 +2646,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||||
* Retrieves the query params for the posts collection.
|
* Retrieves the query params for the posts collection.
|
||||||
*
|
*
|
||||||
* @since 4.7.0
|
* @since 4.7.0
|
||||||
|
* @since 5.4.0 The `tax_relation` query parameter was added.
|
||||||
|
* @since 5.7.0 The `modified_after` and `modified_before` query parameters were added.
|
||||||
*
|
*
|
||||||
* @return array Collection parameters.
|
* @return array Collection parameters.
|
||||||
*/
|
*/
|
||||||
|
@ -2642,6 +2662,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||||
'format' => 'date-time',
|
'format' => 'date-time',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$query_params['modified_after'] = array(
|
||||||
|
'description' => __( 'Limit response to posts modified after a given ISO8601 compliant date.' ),
|
||||||
|
'type' => 'string',
|
||||||
|
'format' => 'date-time',
|
||||||
|
);
|
||||||
|
|
||||||
if ( post_type_supports( $this->post_type, 'author' ) ) {
|
if ( post_type_supports( $this->post_type, 'author' ) ) {
|
||||||
$query_params['author'] = array(
|
$query_params['author'] = array(
|
||||||
'description' => __( 'Limit result set to posts assigned to specific authors.' ),
|
'description' => __( 'Limit result set to posts assigned to specific authors.' ),
|
||||||
|
@ -2667,6 +2693,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||||
'format' => 'date-time',
|
'format' => 'date-time',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$query_params['modified_before'] = array(
|
||||||
|
'description' => __( 'Limit response to posts modified before a given ISO8601 compliant date.' ),
|
||||||
|
'type' => 'string',
|
||||||
|
'format' => 'date-time',
|
||||||
|
);
|
||||||
|
|
||||||
$query_params['exclude'] = array(
|
$query_params['exclude'] = array(
|
||||||
'description' => __( 'Ensure result set excludes specific IDs.' ),
|
'description' => __( 'Ensure result set excludes specific IDs.' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.7-alpha-50022';
|
$wp_version = '5.7-alpha-50024';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue