Align variables
This commit is contained in:
parent
8df7723895
commit
bf64942b28
|
@ -393,7 +393,6 @@ abstract class WC_REST_Posts_Controller extends WP_REST_Controller {
|
|||
public function delete_item( $request ) {
|
||||
$id = (int) $request['id'];
|
||||
$force = (bool) $request['force'];
|
||||
|
||||
$post = get_post( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
|
||||
|
@ -473,7 +472,6 @@ abstract class WC_REST_Posts_Controller extends WP_REST_Controller {
|
|||
return $links;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine the allowed query_vars for a get_items() response and
|
||||
* prepare for WP_Query.
|
||||
|
|
|
@ -188,7 +188,6 @@ abstract class WC_REST_Terms_Controller extends WP_REST_Controller {
|
|||
*/
|
||||
public function get_items( $request ) {
|
||||
$taxonomy = $this->get_taxonomy( $request );
|
||||
|
||||
$prepared_args = array(
|
||||
'exclude' => $request['exclude'],
|
||||
'include' => $request['include'],
|
||||
|
@ -300,8 +299,8 @@ abstract class WC_REST_Terms_Controller extends WP_REST_Controller {
|
|||
$taxonomy = $this->get_taxonomy( $request );
|
||||
$name = $request['name'];
|
||||
$args = array();
|
||||
|
||||
$schema = $this->get_item_schema();
|
||||
|
||||
if ( ! empty( $schema['properties']['description'] ) && isset( $request['description'] ) ) {
|
||||
$args['description'] = $request['description'];
|
||||
}
|
||||
|
|
|
@ -188,7 +188,6 @@ class WC_REST_Authentication {
|
|||
*/
|
||||
private function check_oauth_signature( $user, $params ) {
|
||||
$http_method = strtoupper( $_SERVER['REQUEST_METHOD'] );
|
||||
|
||||
$request_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
|
||||
$wp_base = get_home_url( null, '/', 'relative' );
|
||||
if ( substr( $request_path, 0, strlen( $wp_base ) ) === $wp_base ) {
|
||||
|
@ -218,7 +217,6 @@ class WC_REST_Authentication {
|
|||
}
|
||||
}
|
||||
$query_string = implode( '%26', $query_parameters ); // Join with ampersand.
|
||||
|
||||
$string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string;
|
||||
|
||||
if ( $params['oauth_signature_method'] !== 'HMAC-SHA1' && $params['oauth_signature_method'] !== 'HMAC-SHA256' ) {
|
||||
|
@ -226,7 +224,6 @@ class WC_REST_Authentication {
|
|||
}
|
||||
|
||||
$hash_algorithm = strtolower( str_replace( 'HMAC-', '', $params['oauth_signature_method'] ) );
|
||||
|
||||
$secret = $user->consumer_secret . '&';
|
||||
$signature = base64_encode( hash_hmac( $hash_algorithm, $string_to_sign, $secret, true ) );
|
||||
|
||||
|
|
|
@ -130,7 +130,6 @@ class WC_REST_Customer_Downloads_Controller extends WP_REST_Controller {
|
|||
*/
|
||||
protected function prepare_links( $download, $request ) {
|
||||
$base = str_replace( '(?P<customer_id>[\d]+)', $request['customer_id'], $this->rest_base );
|
||||
|
||||
$links = array(
|
||||
'collection' => array(
|
||||
'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ),
|
||||
|
|
|
@ -355,8 +355,8 @@ class WC_REST_Customers_Controller extends WP_REST_Controller {
|
|||
*/
|
||||
public function update_item( $request ) {
|
||||
$id = (int) $request['id'];
|
||||
|
||||
$customer = get_userdata( $id );
|
||||
|
||||
if ( ! $customer ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
|
|
@ -344,7 +344,6 @@ class WC_REST_Order_Notes_Controller extends WP_REST_Controller {
|
|||
protected function prepare_links( $note ) {
|
||||
$order_id = (int) $note->comment_post_ID;
|
||||
$base = str_replace( '(?P<order_id>[\d]+)', $order_id, $this->rest_base );
|
||||
|
||||
$links = array(
|
||||
'self' => array(
|
||||
'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $base, $note->comment_ID ) ),
|
||||
|
|
|
@ -196,14 +196,6 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
|
|||
$line_item['taxes'] = array_values( $line_tax );
|
||||
}
|
||||
|
||||
// if ( in_array( 'products', $expand ) ) {
|
||||
// $_product_data = WC()->api->WC_API_Products->get_product( $product_id );
|
||||
|
||||
// if ( isset( $_product_data['product'] ) ) {
|
||||
// $line_item['product_data'] = $_product_data['product'];
|
||||
// }
|
||||
// }
|
||||
|
||||
$data['line_items'][] = $line_item;
|
||||
}
|
||||
|
||||
|
@ -238,7 +230,6 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
|
|||
protected function prepare_links( $refund ) {
|
||||
$order_id = $refund->post->post_parent;
|
||||
$base = str_replace( '(?P<order_id>[\d]+)', $order_id, $this->rest_base );
|
||||
|
||||
$links = array(
|
||||
'self' => array(
|
||||
'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $base, $refund->id ) ),
|
||||
|
|
|
@ -187,7 +187,6 @@ class WC_REST_Product_Attributes_Controller extends WP_REST_Controller {
|
|||
*/
|
||||
public function get_items( $request ) {
|
||||
$attributes = wc_get_attribute_taxonomies();
|
||||
|
||||
$data = array();
|
||||
foreach ( $attributes as $attribute_obj ) {
|
||||
$attribute = $this->prepare_item_for_response( $attribute_obj, $request );
|
||||
|
@ -476,7 +475,6 @@ class WC_REST_Product_Attributes_Controller extends WP_REST_Controller {
|
|||
*/
|
||||
protected function prepare_links( $attribute ) {
|
||||
$base = '/' . $this->namespace . '/' . $this->rest_base;
|
||||
|
||||
$links = array(
|
||||
'self' => array(
|
||||
'href' => rest_url( trailingslashit( $base ) . $attribute->attribute_id ),
|
||||
|
|
|
@ -107,7 +107,6 @@ class WC_REST_Product_Reviews_Controller extends WP_REST_Controller {
|
|||
}
|
||||
|
||||
$reviews = get_approved_comments( $product->ID );
|
||||
|
||||
$data = array();
|
||||
foreach ( $reviews as $review_data ) {
|
||||
$review = $this->prepare_item_for_response( $review_data, $request );
|
||||
|
@ -191,7 +190,6 @@ class WC_REST_Product_Reviews_Controller extends WP_REST_Controller {
|
|||
protected function prepare_links( $review, $request ) {
|
||||
$product_id = (int) $request['product_id'];
|
||||
$base = str_replace( '(?P<product_id>[\d]+)', $product_id, $this->rest_base );
|
||||
|
||||
$links = array(
|
||||
'self' => array(
|
||||
'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $base, $review->comment_ID ) ),
|
||||
|
|
|
@ -503,7 +503,6 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
|
|||
*/
|
||||
public function prepare_item_for_response( $post, $request ) {
|
||||
$product = wc_get_product( $post );
|
||||
|
||||
$data = $this->get_product_data( $product );
|
||||
|
||||
// Add variations to variable products.
|
||||
|
|
|
@ -188,7 +188,6 @@ class WC_REST_Webhook_Deliveries_Controller extends WP_REST_Controller {
|
|||
protected function prepare_links( $log ) {
|
||||
$webhook_id = (int) $log->request_headers['X-WC-Webhook-ID'];
|
||||
$base = str_replace( '(?P<webhook_id>[\d]+)', $webhook_id, $this->rest_base );
|
||||
|
||||
$links = array(
|
||||
'self' => array(
|
||||
'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $base, $log->id ) ),
|
||||
|
|
|
@ -387,7 +387,6 @@ class WC_REST_Webhooks_Controller extends WC_REST_Posts_Controller {
|
|||
public function prepare_item_for_response( $post, $request ) {
|
||||
$id = (int) $post->ID;
|
||||
$webhook = new WC_Webhook( $id );
|
||||
|
||||
$data = array(
|
||||
'id' => $webhook->id,
|
||||
'name' => $webhook->get_name(),
|
||||
|
|
Loading…
Reference in New Issue