Merge pull request #2547 from thenbrent/variation-patches
Variation patch & sanitized product_type names
This commit is contained in:
commit
356042e655
|
@ -372,7 +372,7 @@ function woocommerce_products_by_type() {
|
||||||
$output = "<select name='product_type' id='dropdown_product_type'>";
|
$output = "<select name='product_type' id='dropdown_product_type'>";
|
||||||
$output .= '<option value="">'.__( 'Show all product types', 'woocommerce' ).'</option>';
|
$output .= '<option value="">'.__( 'Show all product types', 'woocommerce' ).'</option>';
|
||||||
foreach($terms as $term) :
|
foreach($terms as $term) :
|
||||||
$output .="<option value='$term->name' ";
|
$output .="<option value='" . sanitize_title( $term->name ) . "' ";
|
||||||
if ( isset( $wp_query->query['product_type'] ) ) $output .=selected($term->slug, $wp_query->query['product_type'], false);
|
if ( isset( $wp_query->query['product_type'] ) ) $output .=selected($term->slug, $wp_query->query['product_type'], false);
|
||||||
$output .=">";
|
$output .=">";
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ function woocommerce_product_data_box() {
|
||||||
$thepostid = $post->ID;
|
$thepostid = $post->ID;
|
||||||
|
|
||||||
if ( $terms = wp_get_object_terms( $post->ID, 'product_type' ) )
|
if ( $terms = wp_get_object_terms( $post->ID, 'product_type' ) )
|
||||||
$product_type = current( $terms )->name;
|
$product_type = sanitize_title( current( $terms )->name );
|
||||||
else
|
else
|
||||||
$product_type = 'simple';
|
$product_type = 'simple';
|
||||||
|
|
||||||
|
|
|
@ -454,7 +454,7 @@ function woocommerce_admin_scripts() {
|
||||||
'currency_format_decimal_sep' => esc_attr( stripslashes( get_option( 'woocommerce_price_decimal_sep' ) ) ),
|
'currency_format_decimal_sep' => esc_attr( stripslashes( get_option( 'woocommerce_price_decimal_sep' ) ) ),
|
||||||
'currency_format_thousand_sep' => esc_attr( stripslashes( get_option( 'woocommerce_price_thousand_sep' ) ) ),
|
'currency_format_thousand_sep' => esc_attr( stripslashes( get_option( 'woocommerce_price_thousand_sep' ) ) ),
|
||||||
'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ), // For accounting JS
|
'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ), // For accounting JS
|
||||||
'product_types' => get_terms( 'product_type', array( 'fields' => 'names' ) )
|
'product_types' => array_map( 'sanitize_title', get_terms( 'product_type', array( 'fields' => 'names' ) ) )
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_localize_script( 'woocommerce_writepanel', 'woocommerce_writepanel_params', $woocommerce_witepanel_params );
|
wp_localize_script( 'woocommerce_writepanel', 'woocommerce_writepanel_params', $woocommerce_witepanel_params );
|
||||||
|
|
|
@ -43,10 +43,11 @@ class WC_Product_Factory {
|
||||||
$product_type = 'variation';
|
$product_type = 'variation';
|
||||||
} else {
|
} else {
|
||||||
$terms = get_the_terms( $product_id, 'product_type' );
|
$terms = get_the_terms( $product_id, 'product_type' );
|
||||||
$product_type = ! empty( $terms ) && isset( current( $terms )->name ) ? current( $terms )->name : 'simple';
|
$product_type = ! empty( $terms ) && isset( current( $terms )->name ) ? sanitize_title( current( $terms )->name ) : 'simple';
|
||||||
}
|
}
|
||||||
|
|
||||||
$classname = 'WC_Product_' . preg_replace( '/(?<=_)(.)/e', "strtoupper( '$1' )", ucfirst( $product_type ) );
|
// Create a WC coding standards compliant class name e.g. WC_Product_Type_Class instead of WC_Product_type-class
|
||||||
|
$classname = 'WC_Product_' . preg_replace( '/-(.)/e', "'_' . strtoupper( '$1' )", ucfirst( $product_type ) );
|
||||||
} else {
|
} else {
|
||||||
$classname = false;
|
$classname = false;
|
||||||
$product_type = false;
|
$product_type = false;
|
||||||
|
|
|
@ -655,6 +655,7 @@ function woocommerce_add_variation() {
|
||||||
|
|
||||||
$_tax_class = '';
|
$_tax_class = '';
|
||||||
$image_id = 0;
|
$image_id = 0;
|
||||||
|
$variation = get_post( $variation_id ); // Get the variation object
|
||||||
|
|
||||||
include( 'admin/post-types/writepanels/variation-admin-html.php' );
|
include( 'admin/post-types/writepanels/variation-admin-html.php' );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue