WOOCOMMERCE_DELIMITER constant. Closes #3476.
This commit is contained in:
parent
a5d71a8113
commit
9a98be6a15
|
@ -482,7 +482,7 @@ class WC_Meta_Box_Product_Data {
|
|||
$values = array();
|
||||
foreach ( $post_terms as $term )
|
||||
$values[] = $term->name;
|
||||
echo esc_attr( implode( ' | ', $values ) );
|
||||
echo esc_attr( implode( ' ' . WOOCOMMERCE_DELIMITER . ' ', $values ) );
|
||||
}
|
||||
|
||||
?>" placeholder="<?php _e( 'Pipe (|) separate terms', 'woocommerce' ); ?>" />
|
||||
|
@ -907,7 +907,7 @@ class WC_Meta_Box_Product_Data {
|
|||
|
||||
} else {
|
||||
|
||||
$options = array_map( 'trim', explode( '|', $attribute['value'] ) );
|
||||
$options = array_map( 'trim', explode( WOOCOMMERCE_DELIMITER, $attribute['value'] ) );
|
||||
|
||||
foreach ( $options as $option )
|
||||
echo '<option ' . selected( sanitize_title( $variation_selected_value ), sanitize_title( $option ), false ) . ' value="' . esc_attr( sanitize_title( $option ) ) . '">' . esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ) . '</option>';
|
||||
|
@ -1034,7 +1034,7 @@ class WC_Meta_Box_Product_Data {
|
|||
|
||||
// Text based attributes - Posted values are term names - don't change to slugs
|
||||
} else {
|
||||
$values = array_map( 'stripslashes', array_map( 'strip_tags', explode( '|', $attribute_values[ $i ] ) ) );
|
||||
$values = array_map( 'stripslashes', array_map( 'strip_tags', explode( WOOCOMMERCE_DELIMITER, $attribute_values[ $i ] ) ) );
|
||||
}
|
||||
|
||||
// Remove empty items in the array
|
||||
|
@ -1063,7 +1063,7 @@ class WC_Meta_Box_Product_Data {
|
|||
} elseif ( isset( $attribute_values[ $i ] ) ) {
|
||||
|
||||
// Text based, separate by pipe
|
||||
$values = implode( ' | ', array_map( 'woocommerce_clean', explode( '|', $attribute_values[ $i ] ) ) );
|
||||
$values = implode( ' ' . WOOCOMMERCE_DELIMITER . ' ', array_map( 'woocommerce_clean', explode( WOOCOMMERCE_DELIMITER, $attribute_values[ $i ] ) ) );
|
||||
|
||||
// Custom attribute - Add attribute to array and set the values
|
||||
$attributes[ sanitize_title( $attribute_names[ $i ] ) ] = array(
|
||||
|
|
|
@ -30,7 +30,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
|
||||
} else {
|
||||
|
||||
$options = array_map( 'trim', explode( '|', $attribute['value'] ) );
|
||||
$options = array_map( 'trim', explode( WOOCOMMERCE_DELIMITER, $attribute['value'] ) );
|
||||
|
||||
foreach ( $options as $option ) {
|
||||
echo '<option ' . selected( sanitize_title( $variation_selected_value ), sanitize_title( $option ), false ) . ' value="' . esc_attr( sanitize_title( $option ) ) . '">' . esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ) . '</option>';
|
||||
|
|
|
@ -506,7 +506,7 @@ class WC_Form_Handler {
|
|||
$variations[ $taxonomy ] = $value;
|
||||
else {
|
||||
// For custom attributes, get the name from the slug
|
||||
$options = array_map( 'trim', explode( '|', $attribute['value'] ) );
|
||||
$options = array_map( 'trim', explode( WOOCOMMERCE_DELIMITER, $attribute['value'] ) );
|
||||
foreach ( $options as $option ) {
|
||||
if ( sanitize_title( $option ) == $value ) {
|
||||
$value = $option;
|
||||
|
|
|
@ -299,7 +299,7 @@ class WC_Product_Variable extends WC_Product {
|
|||
foreach ( $post_terms as $term )
|
||||
$values[] = $term->slug;
|
||||
} else {
|
||||
$values = array_map( 'trim', explode( '|', $attribute['value'] ) );
|
||||
$values = array_map( 'trim', explode( WOOCOMMERCE_DELIMITER, $attribute['value'] ) );
|
||||
}
|
||||
|
||||
$values = array_unique( $values );
|
||||
|
@ -307,7 +307,7 @@ class WC_Product_Variable extends WC_Product {
|
|||
// Order custom attributes (non taxonomy) as defined
|
||||
} elseif ( ! $attribute['is_taxonomy'] ) {
|
||||
|
||||
$option_names = array_map( 'trim', explode( '|', $attribute['value'] ) );
|
||||
$option_names = array_map( 'trim', explode( WOOCOMMERCE_DELIMITER, $attribute['value'] ) );
|
||||
$option_slugs = $values;
|
||||
$values = array();
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
|
|||
// Loop options
|
||||
foreach ( $this->options as $option ) {
|
||||
|
||||
$this_option = array_map( 'trim', explode( '|', $option ) );
|
||||
$this_option = array_map( 'trim', explode( WOOCOMMERCE_DELIMITER, $option ) );
|
||||
|
||||
if ( sizeof( $this_option ) !== 3 ) continue;
|
||||
|
||||
|
|
|
@ -183,6 +183,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Feature - Handling for password protected products.
|
||||
* Feature - Schema markup selector for downloadables.
|
||||
* Feature - woocommerce_get_featured_product_ids function.
|
||||
* Feature - WOOCOMMERCE_DELIMITER to customise the pipes for attributes
|
||||
* Tweak - Added pagination to tax rate screens.
|
||||
* Tweak - Added filter to check the 'Create account' checkbox on checkout by default.
|
||||
* Tweak - Update CPT parameters for 'product_variation' and 'shop_coupon' to be no longer public.
|
||||
|
|
|
@ -59,7 +59,7 @@ if ( empty( $attributes ) && ( ! $product->enable_dimensions_display() || ( ! $p
|
|||
} else {
|
||||
|
||||
// Convert pipes to commas and display values
|
||||
$values = array_map( 'trim', explode( '|', $attribute['value'] ) );
|
||||
$values = array_map( 'trim', explode( WOOCOMMERCE_DELIMITER, $attribute['value'] ) );
|
||||
echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
|
||||
|
||||
}
|
||||
|
|
|
@ -454,7 +454,7 @@ function woocommerce_save_attributes() {
|
|||
|
||||
// Text based attributes - Posted values are term names - don't change to slugs
|
||||
} else {
|
||||
$values = array_map( 'stripslashes', array_map( 'strip_tags', explode( '|', $attribute_values[ $i ] ) ) );
|
||||
$values = array_map( 'stripslashes', array_map( 'strip_tags', explode( WOOCOMMERCE_DELIMITER, $attribute_values[ $i ] ) ) );
|
||||
}
|
||||
|
||||
// Remove empty items in the array
|
||||
|
@ -483,7 +483,7 @@ function woocommerce_save_attributes() {
|
|||
} elseif ( isset( $attribute_values[ $i ] ) ) {
|
||||
|
||||
// Text based, separate by pipe
|
||||
$values = implode( ' | ', array_map( 'woocommerce_clean', array_map( 'stripslashes', explode( '|', $attribute_values[ $i ] ) ) ) );
|
||||
$values = implode( ' ' . WOOCOMMERCE_DELIMITER . ' ', array_map( 'woocommerce_clean', array_map( 'stripslashes', explode( WOOCOMMERCE_DELIMITER, $attribute_values[ $i ] ) ) ) );
|
||||
|
||||
// Custom attribute - Add attribute to array and set the values
|
||||
$attributes[ sanitize_title( $attribute_names[ $i ] ) ] = array(
|
||||
|
@ -635,7 +635,7 @@ function woocommerce_link_all_variations() {
|
|||
$options[] = $term->slug;
|
||||
}
|
||||
} else {
|
||||
$options = explode( '|', $attribute['value'] );
|
||||
$options = explode( WOOCOMMERCE_DELIMITER, $attribute['value'] );
|
||||
}
|
||||
|
||||
$options = array_map( 'sanitize_title', array_map( 'trim', $options ) );
|
||||
|
|
|
@ -91,6 +91,8 @@ final class WooCommerce {
|
|||
define( 'WOOCOMMERCE_PLUGIN_FILE', __FILE__ );
|
||||
define( 'WOOCOMMERCE_VERSION', $this->version );
|
||||
define( 'WOOCOMMERCE_TEMPLATE_PATH', $this->template_path() );
|
||||
if ( ! defined( 'WOOCOMMERCE_DELIMITER' ) )
|
||||
define( 'WOOCOMMERCE_DELIMITER', '|' );
|
||||
|
||||
// Include required files
|
||||
$this->includes();
|
||||
|
|
Loading…
Reference in New Issue