From 4ceb9885362b24dba9e745df176d210c16097db5 Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Thu, 21 Feb 2013 15:13:23 +1000 Subject: [PATCH 1/3] Use product_type slug not sanitized term name --- classes/class-wc-product-factory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-wc-product-factory.php b/classes/class-wc-product-factory.php index 610d3fa15a8..e6343c30f6d 100644 --- a/classes/class-wc-product-factory.php +++ b/classes/class-wc-product-factory.php @@ -43,7 +43,7 @@ class WC_Product_Factory { $product_type = 'variation'; } else { $terms = get_the_terms( $product_id, 'product_type' ); - $product_type = ! empty( $terms ) && isset( current( $terms )->name ) ? sanitize_title( current( $terms )->name ) : 'simple'; + $product_type = ! empty( $terms ) && isset( current( $terms )->slug ) ? current( $terms )->slug : 'simple'; } $classname = 'WC_Product_' . ucfirst( $product_type ); From 102cbe78b093097182b6af748ae27b083f406f4e Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Thu, 21 Feb 2013 16:32:20 +1000 Subject: [PATCH 2/3] Make slug elements ucfirst for class name For example, instead of `WC_Product_Variable_subscription` create the class name `WC_Product_Variable_Subscription`. --- classes/class-wc-product-factory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-wc-product-factory.php b/classes/class-wc-product-factory.php index e6343c30f6d..58b1a5c2b1d 100644 --- a/classes/class-wc-product-factory.php +++ b/classes/class-wc-product-factory.php @@ -46,7 +46,7 @@ class WC_Product_Factory { $product_type = ! empty( $terms ) && isset( current( $terms )->slug ) ? current( $terms )->slug : 'simple'; } - $classname = 'WC_Product_' . ucfirst( $product_type ); + $classname = 'WC_Product_' . preg_replace( '/(?<=_)(.)/e', "strtoupper( '$1' )", ucfirst( $product_type ) ); } else { $classname = false; $product_type = false; From c0797549e94b509328d446007fd33e01085fda49 Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Thu, 21 Feb 2013 09:10:47 +0100 Subject: [PATCH 3/3] Use slug instead of sanitzed title of term to determine product type Props @thenbrent for: https://github.com/woothemes/woocommerce/commit/b2a868301c622d03702f5828 5cb6d97972511953#commitcomment-2663540 --- classes/class-wc-product-factory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-wc-product-factory.php b/classes/class-wc-product-factory.php index 610d3fa15a8..e6343c30f6d 100644 --- a/classes/class-wc-product-factory.php +++ b/classes/class-wc-product-factory.php @@ -43,7 +43,7 @@ class WC_Product_Factory { $product_type = 'variation'; } else { $terms = get_the_terms( $product_id, 'product_type' ); - $product_type = ! empty( $terms ) && isset( current( $terms )->name ) ? sanitize_title( current( $terms )->name ) : 'simple'; + $product_type = ! empty( $terms ) && isset( current( $terms )->slug ) ? current( $terms )->slug : 'simple'; } $classname = 'WC_Product_' . ucfirst( $product_type );