From 21a54b93d80b1608e43ad922adbe4e70fe2d7dee Mon Sep 17 00:00:00 2001 From: Illimar Tambek Date: Thu, 9 Mar 2017 11:00:35 +0200 Subject: [PATCH] Use wc_clean to sanitize fee title in legacy apis This will bring legacy APIs in line with the new REST API, where the order item names are sanitized using wc_clean and fix the backwards-incompatible change of using sanitize_title. --- includes/api/legacy/v2/class-wc-api-orders.php | 4 ++-- includes/api/legacy/v3/class-wc-api-orders.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/api/legacy/v2/class-wc-api-orders.php b/includes/api/legacy/v2/class-wc-api-orders.php index a161c64e73c..9e4c8d1a048 100644 --- a/includes/api/legacy/v2/class-wc-api-orders.php +++ b/includes/api/legacy/v2/class-wc-api-orders.php @@ -1070,7 +1070,7 @@ class WC_API_Orders extends WC_API_Resource { $item = new WC_Order_Item_Fee(); $item->set_order_id( $order->get_id() ); - $item->set_name( sanitize_title( $fee['title'] ) ); + $item->set_name( wc_clean( $fee['title'] ) ); $item->set_total( isset( $fee['total'] ) ? floatval( $fee['total'] ) : 0 ); // if taxable, tax class and total are required @@ -1102,7 +1102,7 @@ class WC_API_Orders extends WC_API_Resource { $item = new WC_Order_Item_Fee( $fee['id'] ); if ( isset( $fee['title'] ) ) { - $item->set_name( sanitize_title( $fee['title'] ) ); + $item->set_name( wc_clean( $fee['title'] ) ); } if ( isset( $fee['tax_class'] ) ) { diff --git a/includes/api/legacy/v3/class-wc-api-orders.php b/includes/api/legacy/v3/class-wc-api-orders.php index 86e82061168..5431bec2c46 100644 --- a/includes/api/legacy/v3/class-wc-api-orders.php +++ b/includes/api/legacy/v3/class-wc-api-orders.php @@ -1120,7 +1120,7 @@ class WC_API_Orders extends WC_API_Resource { $item = new WC_Order_Item_Fee(); $item->set_order_id( $order->get_id() ); - $item->set_name( sanitize_title( $fee['title'] ) ); + $item->set_name( wc_clean( $fee['title'] ) ); $item->set_total( isset( $fee['total'] ) ? floatval( $fee['total'] ) : 0 ); // if taxable, tax class and total are required @@ -1152,7 +1152,7 @@ class WC_API_Orders extends WC_API_Resource { $item = new WC_Order_Item_Fee( $fee['id'] ); if ( isset( $fee['title'] ) ) { - $item->set_name( sanitize_title( $fee['title'] ) ); + $item->set_name( wc_clean( $fee['title'] ) ); } if ( isset( $fee['tax_class'] ) ) {