From a16b32825f0490b3a5da639208149ba7493a289f Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Tue, 29 Mar 2016 19:54:37 -0300 Subject: [PATCH] Fixed rest functions names --- includes/api/class-wc-rest-coupons-controller.php | 6 +++--- includes/api/class-wc-rest-customers-controller.php | 6 +++--- includes/api/class-wc-rest-order-notes-controller.php | 2 +- includes/api/class-wc-rest-order-refunds-controller.php | 2 +- includes/api/class-wc-rest-orders-controller.php | 6 +++--- .../api/class-wc-rest-product-categories-controller.php | 4 ++-- includes/api/class-wc-rest-report-sales-controller.php | 4 ++-- includes/api/class-wc-rest-webhook-deliveries.php | 2 +- includes/api/class-wc-rest-webhooks-controller.php | 4 ++-- includes/wc-rest-functions.php | 8 ++++---- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/includes/api/class-wc-rest-coupons-controller.php b/includes/api/class-wc-rest-coupons-controller.php index 57afd3a707b..c42c7201c9c 100644 --- a/includes/api/class-wc-rest-coupons-controller.php +++ b/includes/api/class-wc-rest-coupons-controller.php @@ -116,8 +116,8 @@ class WC_REST_Coupons_Controller extends WC_REST_Posts_Controller { 'id' => $coupon->id, 'code' => $coupon->code, 'type' => $coupon->type, - 'created_at' => wc_rest_api_prepare_date_response( $post->post_date_gmt ), - 'updated_at' => wc_rest_api_prepare_date_response( $post->post_modified_gmt ), + 'created_at' => wc_rest_prepare_date_response( $post->post_date_gmt ), + 'updated_at' => wc_rest_prepare_date_response( $post->post_modified_gmt ), 'amount' => wc_format_decimal( $coupon->coupon_amount, 2 ), 'individual_use' => ( 'yes' === $coupon->individual_use ), 'product_ids' => array_map( 'absint', (array) $coupon->product_ids ), @@ -126,7 +126,7 @@ class WC_REST_Coupons_Controller extends WC_REST_Posts_Controller { 'usage_limit_per_user' => ( ! empty( $coupon->usage_limit_per_user ) ) ? $coupon->usage_limit_per_user : null, 'limit_usage_to_x_items' => (int) $coupon->limit_usage_to_x_items, 'usage_count' => (int) $coupon->usage_count, - 'expiry_date' => ( ! empty( $coupon->expiry_date ) ) ? wc_rest_api_prepare_date_response( $coupon->expiry_date ) : null, + 'expiry_date' => ( ! empty( $coupon->expiry_date ) ) ? wc_rest_prepare_date_response( $coupon->expiry_date ) : null, 'enable_free_shipping' => $coupon->enable_free_shipping(), 'product_category_ids' => array_map( 'absint', (array) $coupon->product_categories ), 'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->exclude_product_categories ), diff --git a/includes/api/class-wc-rest-customers-controller.php b/includes/api/class-wc-rest-customers-controller.php index ef0779f2614..18cdc13c380 100644 --- a/includes/api/class-wc-rest-customers-controller.php +++ b/includes/api/class-wc-rest-customers-controller.php @@ -492,15 +492,15 @@ class WC_REST_Customers_Controller extends WP_REST_Controller { $data = array( 'id' => $customer->ID, - 'created_at' => wc_rest_api_prepare_date_response( $customer->user_registered ), - 'updated_at' => $customer->last_update ? wc_rest_api_prepare_date_response( date( 'Y-m-d H:i:s', $customer->last_update ) ) : null, + 'created_at' => wc_rest_prepare_date_response( $customer->user_registered ), + 'updated_at' => $customer->last_update ? wc_rest_prepare_date_response( date( 'Y-m-d H:i:s', $customer->last_update ) ) : null, 'email' => $customer->user_email, 'first_name' => $customer->first_name, 'last_name' => $customer->last_name, 'username' => $customer->user_login, 'last_order' => array( 'id' => is_object( $last_order ) ? $last_order->id : null, - 'date' => is_object( $last_order ) ? wc_rest_api_prepare_date_response( $last_order->post->post_date_gmt ) : null + 'date' => is_object( $last_order ) ? wc_rest_prepare_date_response( $last_order->post->post_date_gmt ) : null ), 'orders_count' => wc_get_customer_order_count( $customer->ID ), 'total_spent' => wc_format_decimal( wc_get_customer_total_spent( $customer->ID ), 2 ), diff --git a/includes/api/class-wc-rest-order-notes-controller.php b/includes/api/class-wc-rest-order-notes-controller.php index f38176cfa65..38c6aa652bc 100644 --- a/includes/api/class-wc-rest-order-notes-controller.php +++ b/includes/api/class-wc-rest-order-notes-controller.php @@ -307,7 +307,7 @@ class WC_REST_Order_Notes_Controller extends WP_REST_Controller { public function prepare_item_for_response( $note, $request ) { $data = array( 'id' => $note->comment_ID, - 'created_at' => wc_rest_api_prepare_date_response( $note->comment_date_gmt ), + 'created_at' => wc_rest_prepare_date_response( $note->comment_date_gmt ), 'note' => $note->comment_content, 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ), ); diff --git a/includes/api/class-wc-rest-order-refunds-controller.php b/includes/api/class-wc-rest-order-refunds-controller.php index b19b372f674..b55d58fea9a 100644 --- a/includes/api/class-wc-rest-order-refunds-controller.php +++ b/includes/api/class-wc-rest-order-refunds-controller.php @@ -196,7 +196,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller { $data = array( 'id' => $refund->id, - 'date_created' => wc_rest_api_prepare_date_response( $refund->date ), + 'date_created' => wc_rest_prepare_date_response( $refund->date ), 'amount' => wc_format_decimal( $refund->get_refund_amount(), $dp ), 'reason' => $refund->get_refund_reason(), 'line_items' => array(), diff --git a/includes/api/class-wc-rest-orders-controller.php b/includes/api/class-wc-rest-orders-controller.php index b191b3d6233..b72c3546f3c 100644 --- a/includes/api/class-wc-rest-orders-controller.php +++ b/includes/api/class-wc-rest-orders-controller.php @@ -192,8 +192,8 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { 'currency' => $order->get_order_currency(), 'version' => $order->order_version, 'prices_include_tax' => $order->prices_include_tax, - 'date_created' => wc_rest_api_prepare_date_response( $post->post_date_gmt ), - 'date_modified' => wc_rest_api_prepare_date_response( $post->post_modified_gmt ), + 'date_created' => wc_rest_prepare_date_response( $post->post_date_gmt ), + 'date_modified' => wc_rest_prepare_date_response( $post->post_modified_gmt ), 'customer_id' => $order->get_user_id(), 'discount_total' => wc_format_decimal( $order->get_total_discount(), $dp ), 'discount_tax' => wc_format_decimal( $order->cart_discount_tax, $dp ), @@ -211,7 +211,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { 'customer_user_agent' => $order->customer_user_agent, 'created_via' => $order->created_via, 'customer_note' => $order->customer_note, - 'date_completed' => wc_rest_api_prepare_date_response( $order->completed_date, true ), + 'date_completed' => wc_rest_prepare_date_response( $order->completed_date, true ), 'date_paid' => $order->paid_date, 'cart_hash' => $order->cart_hash, 'line_items' => array(), diff --git a/includes/api/class-wc-rest-product-categories-controller.php b/includes/api/class-wc-rest-product-categories-controller.php index b1a8073d35e..18b490bdce9 100644 --- a/includes/api/class-wc-rest-product-categories-controller.php +++ b/includes/api/class-wc-rest-product-categories-controller.php @@ -104,13 +104,13 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Terms_Controller { update_woocommerce_term_meta( $id, 'display_type', $request['display'] ); if ( ! empty( $request['image'] ) ) { - $upload = wc_rest_api_upload_image_from_url( esc_url_raw( $request['image'] ) ); + $upload = wc_rest_upload_image_from_url( esc_url_raw( $request['image'] ) ); if ( is_wp_error( $upload ) ) { return $upload; } - $image_id = wc_rest_api_set_uploaded_image_as_attachment( $upload ); + $image_id = wc_rest_set_uploaded_image_as_attachment( $upload ); // Check if image_id is a valid image attachment before updating the term meta. if ( $image_id && wp_attachment_is_image( $image_id ) ) { diff --git a/includes/api/class-wc-rest-report-sales-controller.php b/includes/api/class-wc-rest-report-sales-controller.php index 8e20274f34f..84ec69865ee 100644 --- a/includes/api/class-wc-rest-report-sales-controller.php +++ b/includes/api/class-wc-rest-report-sales-controller.php @@ -380,14 +380,14 @@ class WC_REST_Report_Sales_Controller extends WP_REST_Controller { 'description' => sprintf( __( 'Return sales for a specific start date, the date need to be in the %s format.', 'woocommerce' ), 'YYYY-MM-AA' ), 'type' => 'string', 'format' => 'date', - 'validate_callback' => 'rest_validate_reports_request_arg', + 'validate_callback' => 'wc_rest_validate_reports_request_arg', 'sanitize_callback' => 'sanitize_text_field', ), 'date_max' => array( 'description' => sprintf( __( 'Return sales for a specific end date, the date need to be in the %s format.', 'woocommerce' ), 'YYYY-MM-AA' ), 'type' => 'string', 'format' => 'date', - 'validate_callback' => 'rest_validate_reports_request_arg', + 'validate_callback' => 'wc_rest_validate_reports_request_arg', 'sanitize_callback' => 'sanitize_text_field', ), ); diff --git a/includes/api/class-wc-rest-webhook-deliveries.php b/includes/api/class-wc-rest-webhook-deliveries.php index 5767bd04c51..a841a0a20d2 100644 --- a/includes/api/class-wc-rest-webhook-deliveries.php +++ b/includes/api/class-wc-rest-webhook-deliveries.php @@ -154,7 +154,7 @@ class WC_REST_Webhook_Deliveries_Controller extends WP_REST_Controller { $data = (array) $log; // Add timestamp. - $data['created_at'] = wc_rest_api_prepare_date_response( $log->comment->comment_date_gmt ); + $data['created_at'] = wc_rest_prepare_date_response( $log->comment->comment_date_gmt ); // Remove comment object. unset( $data['comment'] ); diff --git a/includes/api/class-wc-rest-webhooks-controller.php b/includes/api/class-wc-rest-webhooks-controller.php index 6f5930973fe..b464088d23c 100644 --- a/includes/api/class-wc-rest-webhooks-controller.php +++ b/includes/api/class-wc-rest-webhooks-controller.php @@ -467,8 +467,8 @@ class WC_REST_Webhooks_Controller extends WC_REST_Posts_Controller { 'event' => $webhook->get_event(), 'hooks' => $webhook->get_hooks(), 'delivery_url' => $webhook->get_delivery_url(), - 'created_at' => wc_rest_api_prepare_date_response( $webhook->get_post_data()->post_date_gmt ), - 'updated_at' => wc_rest_api_prepare_date_response( $webhook->get_post_data()->post_modified_gmt ), + 'created_at' => wc_rest_prepare_date_response( $webhook->get_post_data()->post_date_gmt ), + 'updated_at' => wc_rest_prepare_date_response( $webhook->get_post_data()->post_modified_gmt ), ); $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; diff --git a/includes/wc-rest-functions.php b/includes/wc-rest-functions.php index 79ec0c24729..f2665c48cd8 100644 --- a/includes/wc-rest-functions.php +++ b/includes/wc-rest-functions.php @@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) { * @param string|null $date * @return string|null ISO8601/RFC3339 formatted datetime. */ -function wc_rest_api_prepare_date_response( $date_gmt, $date = null ) { +function wc_rest_prepare_date_response( $date_gmt, $date = null ) { // Check if mysql_to_rfc3339 exists first! if ( ! function_exists( 'mysql_to_rfc3339' ) ) { return null; @@ -52,7 +52,7 @@ function wc_rest_api_prepare_date_response( $date_gmt, $date = null ) { * @param string $image_url * @return array|WP_Error Attachment data or error message. */ -function wc_rest_api_upload_image_from_url( $image_url ) { +function wc_rest_upload_image_from_url( $image_url ) { $file_name = basename( current( explode( '?', $image_url ) ) ); $wp_filetype = wp_check_filetype( $file_name, null ); $parsed_url = @parse_url( $image_url ); @@ -117,7 +117,7 @@ function wc_rest_api_upload_image_from_url( $image_url ) { * @param int $id Post ID. Default to 0. * @return int Attachment ID */ -function wc_rest_api_set_uploaded_image_as_attachment( $upload, $id = 0 ) { +function wc_rest_set_uploaded_image_as_attachment( $upload, $id = 0 ) { $info = wp_check_filetype( $upload['file'] ); $title = ''; $content = ''; @@ -160,7 +160,7 @@ function wc_rest_api_set_uploaded_image_as_attachment( $upload, $id = 0 ) { * @param string $param * @return WP_Error|boolean */ -function rest_validate_reports_request_arg( $value, $request, $param ) { +function wc_rest_validate_reports_request_arg( $value, $request, $param ) { $attributes = $request->get_attributes(); if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) {