Fixed rest functions names

This commit is contained in:
Claudio Sanches 2016-03-29 19:54:37 -03:00
parent 4a625fc2f2
commit a16b32825f
10 changed files with 22 additions and 22 deletions

View File

@ -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 ),

View File

@ -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 ),

View File

@ -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 ),
);

View File

@ -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(),

View File

@ -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(),

View File

@ -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 ) ) {

View File

@ -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',
),
);

View File

@ -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'] );

View File

@ -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';

View File

@ -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 ] ) ) {