Include modified in orderby filter

This commit is contained in:
Stamoulis Zamanis 2019-10-19 02:10:40 +03:00 committed by vedanshujain
parent fdcb116b4f
commit a37628e94b
3 changed files with 14 additions and 0 deletions

View File

@ -584,6 +584,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
'include',
'title',
'slug',
'modified',
),
'validate_callback' => 'rest_validate_request_arg',
);

View File

@ -304,4 +304,16 @@ class WC_REST_Customers_Controller extends WC_REST_Customers_V2_Controller {
return $this->add_additional_fields_schema( $schema );
}
/**
* Add new options for 'orderby' to the collection params.
*
* @return array
*/
public function get_collection_params() {
$params = parent::get_collection_params();
$params['orderby']['enum'] = array_merge( $params['orderby']['enum'], array( 'modified' ) );
return $params;
}
}

View File

@ -673,6 +673,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
'include',
'title',
'slug',
'modified',
),
'validate_callback' => 'rest_validate_request_arg',
);