Capitalise all the things
This commit is contained in:
parent
e799b1e234
commit
5613985882
|
@ -152,7 +152,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
$post = get_post( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $post->ID ) || ! in_array( $post->post_type, $this->get_post_types() ) ) {
|
||||
return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'Invalid id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$data = $this->prepare_item_for_response( $post, $request );
|
||||
|
@ -622,7 +622,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
$params['exclude'] = array(
|
||||
'description' => __( 'Ensure result set excludes specific ids.', 'woocommerce' ),
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'default' => array(),
|
||||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
|
@ -663,13 +663,13 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
|||
$post_type_obj = get_post_type_object( $this->post_type );
|
||||
if ( isset( $post_type_obj->hierarchical ) && $post_type_obj->hierarchical ) {
|
||||
$params['parent'] = array(
|
||||
'description' => __( 'Limit result set to those of particular parent ids.', 'woocommerce' ),
|
||||
'description' => __( 'Limit result set to those of particular parent IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
'default' => array(),
|
||||
);
|
||||
$params['parent_exclude'] = array(
|
||||
'description' => __( 'Limit result set to all items except those of a particular parent id.', 'woocommerce' ),
|
||||
'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
'default' => array(),
|
||||
|
|
|
@ -353,7 +353,7 @@ class WC_REST_Customers_Controller extends WC_REST_Controller {
|
|||
$customer = get_userdata( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $customer->ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$customer = $this->prepare_item_for_response( $customer, $request );
|
||||
|
@ -373,7 +373,7 @@ class WC_REST_Customers_Controller extends WC_REST_Controller {
|
|||
$customer = get_userdata( $id );
|
||||
|
||||
if ( ! $customer ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $request['email'] ) && email_exists( $request['email'] ) && $request['email'] !== $customer->user_email ) {
|
||||
|
@ -837,13 +837,13 @@ class WC_REST_Customers_Controller extends WC_REST_Controller {
|
|||
$params['context']['default'] = 'view';
|
||||
|
||||
$params['exclude'] = array(
|
||||
'description' => __( 'Ensure result set excludes specific ids.', 'woocommerce' ),
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'default' => array(),
|
||||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
);
|
||||
$params['include'] = array(
|
||||
'description' => __( 'Limit result set to specific ids.', 'woocommerce' ),
|
||||
'description' => __( 'Limit result set to specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'default' => array(),
|
||||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
|
|
|
@ -161,7 +161,7 @@ class WC_REST_Order_Notes_Controller extends WC_REST_Controller {
|
|||
$order = get_post( (int) $request['order_id'] );
|
||||
|
||||
if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) {
|
||||
return new WP_Error( 'woocommerce_rest_{$this->post_type}_invalid_id', __( 'Invalid order id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_{$this->post_type}_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$args = array(
|
||||
|
@ -200,7 +200,7 @@ class WC_REST_Order_Notes_Controller extends WC_REST_Controller {
|
|||
$order = get_post( (int) $request['order_id'] );
|
||||
|
||||
if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) {
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$order = wc_get_order( $order );
|
||||
|
@ -244,13 +244,13 @@ class WC_REST_Order_Notes_Controller extends WC_REST_Controller {
|
|||
$order = get_post( (int) $request['order_id'] );
|
||||
|
||||
if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) {
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$note = get_comment( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $note ) || intval( $note->comment_post_ID ) !== intval( $order->ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$order_note = $this->prepare_item_for_response( $note, $request );
|
||||
|
@ -277,13 +277,13 @@ class WC_REST_Order_Notes_Controller extends WC_REST_Controller {
|
|||
$order = get_post( (int) $request['order_id'] );
|
||||
|
||||
if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) {
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$note = get_comment( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $note ) || intval( $note->comment_post_ID ) !== intval( $order->ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
|
|
|
@ -182,7 +182,7 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Terms_Controller {
|
|||
),
|
||||
),
|
||||
'parent' => array(
|
||||
'description' => __( 'The id for the parent of the resource.', 'woocommerce' ),
|
||||
'description' => __( 'The ID for the parent of the resource.', 'woocommerce' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
|
|
@ -103,7 +103,7 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$product = get_post( (int) $request['product_id'] );
|
||||
|
||||
if ( empty( $product->post_type ) || 'product' !== $product->post_type ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$reviews = get_approved_comments( $product->ID );
|
||||
|
@ -128,13 +128,13 @@ class WC_REST_Product_Reviews_Controller extends WC_REST_Controller {
|
|||
$product = get_post( (int) $request['product_id'] );
|
||||
|
||||
if ( empty( $product->post_type ) || 'product' !== $product->post_type ) {
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$review = get_comment( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $review ) || intval( $review->comment_post_ID ) !== intval( $product->ID ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$delivery = $this->prepare_item_for_response( $review, $request );
|
||||
|
|
|
@ -1732,7 +1732,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
|
|||
$post = get_post( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $post->ID ) || ! in_array( $post->post_type, $this->get_post_types() ) ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid post id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid post ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$supports_trash = EMPTY_TRASH_DAYS > 0;
|
||||
|
|
|
@ -389,7 +389,7 @@ class WC_REST_Taxes_Controller extends WC_REST_Controller {
|
|||
$tax_obj = WC_Tax::_get_tax_rate( $id, OBJECT );
|
||||
|
||||
if ( empty( $id ) || empty( $tax_obj ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$tax = $this->prepare_item_for_response( $tax_obj, $request );
|
||||
|
@ -409,7 +409,7 @@ class WC_REST_Taxes_Controller extends WC_REST_Controller {
|
|||
$tax_obj = WC_Tax::_get_tax_rate( $id, OBJECT );
|
||||
|
||||
if ( empty( $id ) || empty( $tax_obj ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$tax = $this->create_or_update_tax( $request, $tax_obj );
|
||||
|
@ -452,7 +452,7 @@ class WC_REST_Taxes_Controller extends WC_REST_Controller {
|
|||
$tax = WC_Tax::_get_tax_rate( $id, OBJECT );
|
||||
|
||||
if ( empty( $id ) || empty( $tax ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
|
@ -647,13 +647,13 @@ class WC_REST_Taxes_Controller extends WC_REST_Controller {
|
|||
$params['context']['default'] = 'view';
|
||||
|
||||
$params['exclude'] = array(
|
||||
'description' => __( 'Ensure result set excludes specific ids.', 'woocommerce' ),
|
||||
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'default' => array(),
|
||||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
);
|
||||
$params['include'] = array(
|
||||
'description' => __( 'Limit result set to specific ids.', 'woocommerce' ),
|
||||
'description' => __( 'Limit result set to specific IDs.', 'woocommerce' ),
|
||||
'type' => 'array',
|
||||
'default' => array(),
|
||||
'sanitize_callback' => 'wp_parse_id_list',
|
||||
|
|
|
@ -103,7 +103,7 @@ class WC_REST_Webhook_Deliveries_Controller extends WC_REST_Controller {
|
|||
$webhook = new WC_Webhook( (int) $request['webhook_id'] );
|
||||
|
||||
if ( empty( $webhook->post_data->post_type ) || 'shop_webhook' !== $webhook->post_data->post_type ) {
|
||||
return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$logs = $webhook->get_delivery_logs();
|
||||
|
@ -129,13 +129,13 @@ class WC_REST_Webhook_Deliveries_Controller extends WC_REST_Controller {
|
|||
$webhook = new WC_Webhook( (int) $request['webhook_id'] );
|
||||
|
||||
if ( empty( $webhook->post_data->post_type ) || 'shop_webhook' !== $webhook->post_data->post_type ) {
|
||||
return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$log = $webhook->get_delivery_log( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $log ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$delivery = $this->prepare_item_for_response( (object) $log, $request );
|
||||
|
|
|
@ -302,7 +302,7 @@ class WC_REST_Webhooks_Controller extends WC_REST_Posts_Controller {
|
|||
$post = get_post( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid post id.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid post ID.', 'woocommerce' ), array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
|
|
Loading…
Reference in New Issue