Merge pull request #11534 from woothemes/localization-tweaks
Localization tweaks
This commit is contained in:
commit
4775cec578
|
@ -152,7 +152,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
|
||||||
$post = get_post( $id );
|
$post = get_post( $id );
|
||||||
|
|
||||||
if ( empty( $id ) || empty( $post->ID ) || ! in_array( $post->post_type, $this->get_post_types() ) ) {
|
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 );
|
$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',
|
'validate_callback' => 'rest_validate_request_arg',
|
||||||
);
|
);
|
||||||
$params['exclude'] = array(
|
$params['exclude'] = array(
|
||||||
'description' => __( 'Ensure result set excludes specific ids.', 'woocommerce' ),
|
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'default' => array(),
|
'default' => array(),
|
||||||
'sanitize_callback' => 'wp_parse_id_list',
|
'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 );
|
$post_type_obj = get_post_type_object( $this->post_type );
|
||||||
if ( isset( $post_type_obj->hierarchical ) && $post_type_obj->hierarchical ) {
|
if ( isset( $post_type_obj->hierarchical ) && $post_type_obj->hierarchical ) {
|
||||||
$params['parent'] = array(
|
$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',
|
'type' => 'array',
|
||||||
'sanitize_callback' => 'wp_parse_id_list',
|
'sanitize_callback' => 'wp_parse_id_list',
|
||||||
'default' => array(),
|
'default' => array(),
|
||||||
);
|
);
|
||||||
$params['parent_exclude'] = 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',
|
'type' => 'array',
|
||||||
'sanitize_callback' => 'wp_parse_id_list',
|
'sanitize_callback' => 'wp_parse_id_list',
|
||||||
'default' => array(),
|
'default' => array(),
|
||||||
|
|
|
@ -111,7 +111,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Orders', 'woocommerce' ),
|
'title' => __( 'Orders', 'woocommerce' ),
|
||||||
'desc' => __( 'Endpoint for the My Account → Orders page', 'woocommerce' ),
|
'desc' => sprintf( __( 'Endpoint for the My Account → %s page', 'woocommerce' ), __( 'Orders', 'woocommerce' ) ),
|
||||||
'id' => 'woocommerce_myaccount_orders_endpoint',
|
'id' => 'woocommerce_myaccount_orders_endpoint',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => 'orders',
|
'default' => 'orders',
|
||||||
|
@ -120,7 +120,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'View Order', 'woocommerce' ),
|
'title' => __( 'View Order', 'woocommerce' ),
|
||||||
'desc' => __( 'Endpoint for the My Account → View Order page', 'woocommerce' ),
|
'desc' => sprintf( __( 'Endpoint for the My Account → %s page', 'woocommerce' ), __( 'View Order', 'woocommerce' ) ),
|
||||||
'id' => 'woocommerce_myaccount_view_order_endpoint',
|
'id' => 'woocommerce_myaccount_view_order_endpoint',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => 'view-order',
|
'default' => 'view-order',
|
||||||
|
@ -129,7 +129,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Downloads', 'woocommerce' ),
|
'title' => __( 'Downloads', 'woocommerce' ),
|
||||||
'desc' => __( 'Endpoint for the My Account → Downloads page', 'woocommerce' ),
|
'desc' => sprintf( __( 'Endpoint for the My Account → %s page', 'woocommerce' ), __( 'Downloads', 'woocommerce' ) ),
|
||||||
'id' => 'woocommerce_myaccount_downloads_endpoint',
|
'id' => 'woocommerce_myaccount_downloads_endpoint',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => 'downloads',
|
'default' => 'downloads',
|
||||||
|
@ -138,7 +138,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Edit Account', 'woocommerce' ),
|
'title' => __( 'Edit Account', 'woocommerce' ),
|
||||||
'desc' => __( 'Endpoint for the My Account → Edit Account page', 'woocommerce' ),
|
'desc' => sprintf( __( 'Endpoint for the My Account → %s page', 'woocommerce' ), __( 'Edit Account', 'woocommerce' ) ),
|
||||||
'id' => 'woocommerce_myaccount_edit_account_endpoint',
|
'id' => 'woocommerce_myaccount_edit_account_endpoint',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => 'edit-account',
|
'default' => 'edit-account',
|
||||||
|
@ -147,7 +147,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Addresses', 'woocommerce' ),
|
'title' => __( 'Addresses', 'woocommerce' ),
|
||||||
'desc' => __( 'Endpoint for the My Account → Addresses page', 'woocommerce' ),
|
'desc' => sprintf( __( 'Endpoint for the My Account → %s page', 'woocommerce' ), __( 'Addresses', 'woocommerce' ) ),
|
||||||
'id' => 'woocommerce_myaccount_edit_address_endpoint',
|
'id' => 'woocommerce_myaccount_edit_address_endpoint',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => 'edit-address',
|
'default' => 'edit-address',
|
||||||
|
@ -156,7 +156,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Payment Methods', 'woocommerce' ),
|
'title' => __( 'Payment Methods', 'woocommerce' ),
|
||||||
'desc' => __( 'Endpoint for the My Account → Payment Methods page', 'woocommerce' ),
|
'desc' => sprintf( __( 'Endpoint for the My Account → %s page', 'woocommerce' ), __( 'Payment Methods', 'woocommerce' ) ),
|
||||||
'id' => 'woocommerce_myaccount_payment_methods_endpoint',
|
'id' => 'woocommerce_myaccount_payment_methods_endpoint',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => 'payment-methods',
|
'default' => 'payment-methods',
|
||||||
|
@ -165,7 +165,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Lost Password', 'woocommerce' ),
|
'title' => __( 'Lost Password', 'woocommerce' ),
|
||||||
'desc' => __( 'Endpoint for the My Account → Lost Password page', 'woocommerce' ),
|
'desc' => sprintf( __( 'Endpoint for the My Account → %s page', 'woocommerce' ), __( 'Lost Password', 'woocommerce' ) ),
|
||||||
'id' => 'woocommerce_myaccount_lost_password_endpoint',
|
'id' => 'woocommerce_myaccount_lost_password_endpoint',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => 'lost-password',
|
'default' => 'lost-password',
|
||||||
|
|
|
@ -353,7 +353,7 @@ class WC_REST_Customers_Controller extends WC_REST_Controller {
|
||||||
$customer = get_userdata( $id );
|
$customer = get_userdata( $id );
|
||||||
|
|
||||||
if ( empty( $id ) || empty( $customer->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 );
|
$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 );
|
$customer = get_userdata( $id );
|
||||||
|
|
||||||
if ( ! $customer ) {
|
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 ) {
|
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['context']['default'] = 'view';
|
||||||
|
|
||||||
$params['exclude'] = array(
|
$params['exclude'] = array(
|
||||||
'description' => __( 'Ensure result set excludes specific ids.', 'woocommerce' ),
|
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'default' => array(),
|
'default' => array(),
|
||||||
'sanitize_callback' => 'wp_parse_id_list',
|
'sanitize_callback' => 'wp_parse_id_list',
|
||||||
);
|
);
|
||||||
$params['include'] = array(
|
$params['include'] = array(
|
||||||
'description' => __( 'Limit result set to specific ids.', 'woocommerce' ),
|
'description' => __( 'Limit result set to specific IDs.', 'woocommerce' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'default' => array(),
|
'default' => array(),
|
||||||
'sanitize_callback' => 'wp_parse_id_list',
|
'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'] );
|
$order = get_post( (int) $request['order_id'] );
|
||||||
|
|
||||||
if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) {
|
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(
|
$args = array(
|
||||||
|
@ -200,7 +200,7 @@ class WC_REST_Order_Notes_Controller extends WC_REST_Controller {
|
||||||
$order = get_post( (int) $request['order_id'] );
|
$order = get_post( (int) $request['order_id'] );
|
||||||
|
|
||||||
if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) {
|
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 );
|
$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'] );
|
$order = get_post( (int) $request['order_id'] );
|
||||||
|
|
||||||
if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) {
|
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 );
|
$note = get_comment( $id );
|
||||||
|
|
||||||
if ( empty( $id ) || empty( $note ) || intval( $note->comment_post_ID ) !== intval( $order->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 );
|
$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'] );
|
$order = get_post( (int) $request['order_id'] );
|
||||||
|
|
||||||
if ( empty( $order->post_type ) || $this->post_type !== $order->post_type ) {
|
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 );
|
$note = get_comment( $id );
|
||||||
|
|
||||||
if ( empty( $id ) || empty( $note ) || intval( $note->comment_post_ID ) !== intval( $order->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' );
|
$request->set_param( 'context', 'edit' );
|
||||||
|
|
|
@ -182,7 +182,7 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Terms_Controller {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'parent' => array(
|
'parent' => array(
|
||||||
'description' => __( 'The id for the parent of the resource.', 'woocommerce' ),
|
'description' => __( 'The ID for the parent of the resource.', 'woocommerce' ),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'context' => array( 'view', 'edit' ),
|
'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'] );
|
$product = get_post( (int) $request['product_id'] );
|
||||||
|
|
||||||
if ( empty( $product->post_type ) || 'product' !== $product->post_type ) {
|
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 );
|
$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'] );
|
$product = get_post( (int) $request['product_id'] );
|
||||||
|
|
||||||
if ( empty( $product->post_type ) || 'product' !== $product->post_type ) {
|
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 );
|
$review = get_comment( $id );
|
||||||
|
|
||||||
if ( empty( $id ) || empty( $review ) || intval( $review->comment_post_ID ) !== intval( $product->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 );
|
$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 );
|
$post = get_post( $id );
|
||||||
|
|
||||||
if ( empty( $id ) || empty( $post->ID ) || ! in_array( $post->post_type, $this->get_post_types() ) ) {
|
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;
|
$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 );
|
$tax_obj = WC_Tax::_get_tax_rate( $id, OBJECT );
|
||||||
|
|
||||||
if ( empty( $id ) || empty( $tax_obj ) ) {
|
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 );
|
$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 );
|
$tax_obj = WC_Tax::_get_tax_rate( $id, OBJECT );
|
||||||
|
|
||||||
if ( empty( $id ) || empty( $tax_obj ) ) {
|
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 );
|
$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 );
|
$tax = WC_Tax::_get_tax_rate( $id, OBJECT );
|
||||||
|
|
||||||
if ( empty( $id ) || empty( $tax ) ) {
|
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' );
|
$request->set_param( 'context', 'edit' );
|
||||||
|
@ -647,13 +647,13 @@ class WC_REST_Taxes_Controller extends WC_REST_Controller {
|
||||||
$params['context']['default'] = 'view';
|
$params['context']['default'] = 'view';
|
||||||
|
|
||||||
$params['exclude'] = array(
|
$params['exclude'] = array(
|
||||||
'description' => __( 'Ensure result set excludes specific ids.', 'woocommerce' ),
|
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'default' => array(),
|
'default' => array(),
|
||||||
'sanitize_callback' => 'wp_parse_id_list',
|
'sanitize_callback' => 'wp_parse_id_list',
|
||||||
);
|
);
|
||||||
$params['include'] = array(
|
$params['include'] = array(
|
||||||
'description' => __( 'Limit result set to specific ids.', 'woocommerce' ),
|
'description' => __( 'Limit result set to specific IDs.', 'woocommerce' ),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'default' => array(),
|
'default' => array(),
|
||||||
'sanitize_callback' => 'wp_parse_id_list',
|
'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'] );
|
$webhook = new WC_Webhook( (int) $request['webhook_id'] );
|
||||||
|
|
||||||
if ( empty( $webhook->post_data->post_type ) || 'shop_webhook' !== $webhook->post_data->post_type ) {
|
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();
|
$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'] );
|
$webhook = new WC_Webhook( (int) $request['webhook_id'] );
|
||||||
|
|
||||||
if ( empty( $webhook->post_data->post_type ) || 'shop_webhook' !== $webhook->post_data->post_type ) {
|
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 );
|
$log = $webhook->get_delivery_log( $id );
|
||||||
|
|
||||||
if ( empty( $id ) || empty( $log ) ) {
|
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 );
|
$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 );
|
$post = get_post( $id );
|
||||||
|
|
||||||
if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
|
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' );
|
$request->set_param( 'context', 'edit' );
|
||||||
|
|
Loading…
Reference in New Issue