Fixed coding standards

This commit is contained in:
Claudio Sanches 2017-10-17 14:22:30 -02:00
parent 0284bf61f0
commit 4bec8f9df5
1 changed files with 25 additions and 9 deletions

View File

@ -23,7 +23,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller {
/**
* Endpoint namespace.
* Endpoint namespace.
*
* @var string
*/
@ -92,7 +92,9 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
'callback' => array( $this, 'get_item' ),
'permission_callback' => array( $this, 'get_item_permissions_check' ),
'args' => array(
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
'context' => $this->get_context_param( array(
'default' => 'view',
) ),
),
),
array(
@ -396,7 +398,9 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) {
// If dealing with a taxonomy, we need to get the slug from the name posted to the API.
// @codingStandardsIgnoreStart
$term = get_term_by( 'name', $attribute_value, $attribute_name );
// @codingStandardsIgnoreEnd
if ( $term && ! is_wp_error( $term ) ) {
$attribute_value = $term->slug;
@ -449,7 +453,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
/**
* Delete a variation.
*
* @param WP_REST_Request $request Full details about the request
* @param WP_REST_Request $request Full details about the request.
*
* @return bool|WP_Error|WP_REST_Response
*/
@ -459,7 +463,9 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
$result = false;
if ( ! $object || 0 === $object->get_id() ) {
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array(
'status' => 404,
) );
}
$supports_trash = EMPTY_TRASH_DAYS > 0 && is_callable( array( $object, 'get_status' ) );
@ -476,7 +482,9 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $object->get_id() ) ) {
/* translators: %s: post type */
return new WP_Error( "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array(
'status' => rest_authorization_required_code(),
) );
}
$request->set_param( 'context', 'edit' );
@ -490,14 +498,18 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
// If we don't support trashing for this type, error out.
if ( ! $supports_trash ) {
/* translators: %s: post type */
return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( 'status' => 501 ) );
return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array(
'status' => 501,
) );
}
// Otherwise, only trash if we haven't already.
if ( is_callable( array( $object, 'get_status' ) ) ) {
if ( 'trash' === $object->get_status() ) {
/* translators: %s: post type */
return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 410 ) );
return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array(
'status' => 410,
) );
}
$object->delete();
@ -507,7 +519,9 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
if ( ! $result ) {
/* translators: %s: post type */
return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 500 ) );
return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array(
'status' => 500,
) );
}
// Delete parent product transients.
@ -544,7 +558,9 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
if ( ! empty( $items[ $batch_type ] ) ) {
$injected_items = array();
foreach ( $items[ $batch_type ] as $item ) {
$injected_items[] = is_array( $item ) ? array_merge( array( 'product_id' => $product_id ), $item ) : $item;
$injected_items[] = is_array( $item ) ? array_merge( array(
'product_id' => $product_id,
), $item ) : $item;
}
$body_params[ $batch_type ] = $injected_items;
}