Merge remote-tracking branch 'main/master' into fix-for-margin-on-email-header-image

This commit is contained in:
Klaus Paiva 2019-04-20 09:38:52 +10:00
commit 8ae11196a1
45 changed files with 812 additions and 203 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3931,6 +3931,11 @@ img.help_tip {
margin-bottom: 3px;
}
.select2-container + span.description {
display: block;
margin-top: 8px;
}
table.widefat th {
padding-right: inherit;
}

View File

@ -1,5 +1,5 @@
/*!
* SelectWoo 1.0.5
* SelectWoo 1.0.6
* https://github.com/woocommerce/selectWoo
*
* Released under the MIT license
@ -1613,7 +1613,7 @@ S2.define('select2/selection/single',[
var $rendered = this.$selection.find('.select2-selection__rendered');
var formatted = this.display(selection, $rendered);
$rendered.empty().text(formatted);
$rendered.empty().append(formatted);
$rendered.prop('title', selection.title || selection.text);
};

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*!
* SelectWoo 1.0.5
* SelectWoo 1.0.6
* https://github.com/woocommerce/selectWoo
*
* Released under the MIT license
@ -1613,7 +1613,7 @@ S2.define('select2/selection/single',[
var $rendered = this.$selection.find('.select2-selection__rendered');
var formatted = this.display(selection, $rendered);
$rendered.empty().text(formatted);
$rendered.empty().append(formatted);
$rendered.prop('title', selection.title || selection.text);
};

File diff suppressed because one or more lines are too long

View File

@ -112,7 +112,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION );
wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.5' );
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' );
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
wp_register_script( 'js-cookie', WC()->plugin_url() . '/assets/js/js-cookie/js.cookie' . $suffix . '.js', array(), '2.1.4', true );

View File

@ -269,6 +269,8 @@ class WC_Admin_Notices {
/**
* Show a notice asking users to convert to shipping zones.
*
* @todo remove in 4.0.0
*/
public static function legacy_shipping_notice() {
$maybe_load_legacy_methods = array( 'flat_rate', 'free_shipping', 'international_delivery', 'local_delivery', 'local_pickup' );

View File

@ -168,7 +168,7 @@ class WC_Admin_Setup_Wizard {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.5' );
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.6' );
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
wp_localize_script(
'wc-enhanced-select',

View File

@ -204,7 +204,7 @@ class WC_Admin {
public function preview_emails() {
if ( isset( $_GET['preview_woocommerce_mail'] ) ) {
if ( ! ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'], 'preview-mail' ) ) ) ) ) {
if ( ! ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'preview-mail' ) ) ) {
die( 'Security check' );
}

View File

@ -644,7 +644,7 @@ class WC_Product_CSV_Importer_Controller {
// Get index for special column names.
$index = $item;
if ( preg_match( '/\d+$/', $item, $matches ) ) {
if ( preg_match( '/\d+/', $item, $matches ) ) {
$index = $matches[0];
}

View File

@ -756,7 +756,7 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table {
}
?>
<select class="wc-customer-search" name="_customer_user" data-placeholder="<?php esc_attr_e( 'Filter by registered customer', 'woocommerce' ); ?>" data-allow_clear="true">
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo wp_kses_post( $user_string ); ?><option>
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo htmlspecialchars( wp_kses_post( $user_string ) ); // htmlspecialchars to prevent XSS when rendered by selectWoo. ?><option>
</select>
<?php
}

View File

@ -338,7 +338,7 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
?>
<select class="wc-category-search" name="product_cat" data-placeholder="<?php esc_attr_e( 'Filter by category', 'woocommerce' ); ?>" data-allow_clear="true">
<?php if ( $current_category_slug && $current_category ) : ?>
<option value="<?php echo esc_attr( $current_category_slug ); ?>" selected="selected"><?php echo esc_html( $current_category->name ); ?><option>
<option value="<?php echo esc_attr( $current_category_slug ); ?>" selected="selected"><?php echo htmlspecialchars( wp_kses_post( $current_category->name ) ); ?><option>
<?php endif; ?>
</select>
<?php

View File

@ -301,7 +301,7 @@ class WC_Meta_Box_Order_Data {
}
?>
<select class="wc-customer-search" id="customer_user" name="customer_user" data-placeholder="<?php esc_attr_e( 'Guest', 'woocommerce' ); ?>" data-allow_clear="true">
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo htmlspecialchars( $user_string ); ?></option>
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo htmlspecialchars( wp_kses_post( $user_string ) ); // htmlspecialchars to prevent XSS when rendered by selectWoo. ?></option>
</select>
<!--/email_off-->
</p>

View File

@ -51,7 +51,8 @@ class WC_Settings_General extends WC_Settings_Page {
}
$settings = apply_filters(
'woocommerce_general_settings', array(
'woocommerce_general_settings',
array(
array(
'title' => __( 'Store Address', 'woocommerce' ),
@ -316,56 +317,12 @@ class WC_Settings_General extends WC_Settings_Page {
</div>';
}
/**
* Show a notice showing where the store notice setting has moved.
*
* @since 3.3.1
* @todo remove in next major release.
*/
private function store_notice_setting_moved_notice() {
if ( get_user_meta( get_current_user_id(), 'dismissed_store_notice_setting_moved_notice', true ) ) {
return;
}
?>
<div id="message" class="updated woocommerce-message inline">
<a class="woocommerce-message-close notice-dismiss" style="top:0;" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'store_notice_setting_moved' ), 'woocommerce_hide_notices_nonce', '_wc_notice_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'woocommerce' ); ?></a>
<p>
<?php
echo wp_kses(
sprintf(
/* translators: %s: URL to customizer. */
__( 'Looking for the store notice setting? It can now be found <a href="%s">in the Customizer</a>.', 'woocommerce' ), esc_url(
add_query_arg(
array(
'autofocus' => array(
'panel' => 'woocommerce',
),
'url' => wc_get_page_permalink( 'shop' ),
), admin_url( 'customize.php' )
)
)
), array(
'a' => array(
'href' => array(),
'title' => array(),
),
)
);
?>
</p>
</div>
<?php
}
/**
* Output the settings.
*/
public function output() {
$settings = $this->get_settings();
$this->store_notice_setting_moved_notice();
WC_Admin_Settings::output_fields( $settings );
}

View File

@ -52,56 +52,9 @@ class WC_Settings_Products extends WC_Settings_Page {
$settings = $this->get_settings( $current_section );
$this->product_display_settings_moved_notice();
WC_Admin_Settings::output_fields( $settings );
}
/**
* Show a notice showing where some options have moved.
*
* @since 3.3.0
* @todo remove in next major release.
*/
private function product_display_settings_moved_notice() {
if ( get_user_meta( get_current_user_id(), 'dismissed_product_display_settings_moved_notice', true ) ) {
return;
}
?>
<div id="message" class="updated woocommerce-message inline">
<a class="woocommerce-message-close notice-dismiss" style="top:0;" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'product_display_settings_moved' ), 'woocommerce_hide_notices_nonce', '_wc_notice_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'woocommerce' ); ?></a>
<p>
<?php
echo wp_kses(
sprintf(
/* translators: %s: URL to customizer. */
__( 'Looking for the product display options? They can now be found in the Customizer. <a href="%s">Go see them in action here.</a>', 'woocommerce' ),
esc_url(
add_query_arg(
array(
'autofocus' => array(
'panel' => 'woocommerce',
),
'url' => wc_get_page_permalink( 'shop' ),
),
admin_url( 'customize.php' )
)
)
),
array(
'a' => array(
'href' => array(),
'title' => array(),
),
)
);
?>
</p>
</div>
<?php
}
/**
* Save settings.
*/
@ -330,7 +283,7 @@ class WC_Settings_Products extends WC_Settings_Page {
array(
'title' => __( 'Shop page', 'woocommerce' ),
/* translators: %s: URL to settings. */
'desc' => '<br/>' . sprintf( __( 'The base page can also be used in your <a href="%s">product permalinks</a>.', 'woocommerce' ), admin_url( 'options-permalink.php' ) ),
'desc' => sprintf( __( 'The base page can also be used in your <a href="%s">product permalinks</a>.', 'woocommerce' ), admin_url( 'options-permalink.php' ) ),
'id' => 'woocommerce_shop_page_id',
'type' => 'single_select_page',
'default' => '',

View File

@ -47,7 +47,7 @@ defined( 'ABSPATH' ) || exit;
);
?>
<select class="wc-customer-search" id="key_user" data-placeholder="<?php esc_attr_e( 'Search for a user&hellip;', 'woocommerce' ); ?>" data-allow_clear="true">
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo esc_html( $user_string ); ?></option>
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo htmlspecialchars( wp_kses_post( $user_string ) ); // htmlspecialchars to prevent XSS when rendered by selectWoo. ?></option>
</select>
</td>
</tr>

View File

@ -55,11 +55,15 @@ class WC_REST_Authentication {
}
$rest_prefix = trailingslashit( rest_get_url_prefix() );
$request_uri = esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) );
// Check if the request is to the WC API endpoints.
$woocommerce = ( false !== strpos( $request_uri, $rest_prefix . 'wc/' ) );
// Allow third party plugins use our authentication methods.
$third_party = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix . 'wc-' ) ); // @codingStandardsIgnoreLine
$third_party = ( false !== strpos( $request_uri, $rest_prefix . 'wc-' ) );
return apply_filters( 'woocommerce_rest_is_request_to_rest_api', WC()->is_rest_api_request() || $third_party );
return apply_filters( 'woocommerce_rest_is_request_to_rest_api', $woocommerce || $third_party );
}
/**

View File

@ -226,7 +226,9 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller {
* @return WC_Product
*/
protected function set_product_images( $product, $images ) {
if ( is_array( $images ) ) {
$images = is_array( $images ) ? array_filter( $images ) : array();
if ( ! empty( $images ) ) {
$gallery = array();
foreach ( $images as $index => $image ) {

View File

@ -119,8 +119,11 @@ class WC_REST_Network_Orders_V2_Controller extends WC_REST_Orders_V2_Controller
$blog_id = $request->get_param( 'blog_id' );
$blog_id = ! empty( $blog_id ) ? $blog_id : get_current_blog_id();
$active_plugins = get_blog_option( $blog_id, 'active_plugins', array() );
$network_active_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
$plugins = array_merge( $active_plugins, $network_active_plugins );
$wc_active = false;
foreach ( $active_plugins as $plugin ) {
foreach ( $plugins as $plugin ) {
if ( substr_compare( $plugin, '/woocommerce.php', strlen( $plugin ) - strlen( '/woocommerce.php' ), strlen( '/woocommerce.php' ) ) === 0 ) {
$wc_active = true;
}

View File

@ -361,7 +361,9 @@ class WC_Cart extends WC_Legacy_Cart {
* @return bool
*/
public function display_prices_including_tax() {
return apply_filters( 'woocommerce_cart_' . __FUNCTION__, 'incl' === $this->tax_display_cart );
$customer_exempt = $this->get_customer() && $this->get_customer()->get_is_vat_exempt();
return apply_filters( 'woocommerce_cart_' . __FUNCTION__, 'incl' === $this->tax_display_cart && ! $customer_exempt );
}
/*
@ -634,9 +636,9 @@ class WC_Cart extends WC_Legacy_Cart {
* @param bool $clear_persistent_cart Should the persistant cart be cleared too. Defaults to true.
*/
public function empty_cart( $clear_persistent_cart = true ) {
do_action( 'woocommerce_before_cart_emptied' );
$this->cart_contents = array();
$this->removed_cart_contents = array();
$this->shipping_methods = array();

View File

@ -921,6 +921,11 @@ class WC_Countries {
'required' => false,
),
),
'GR' => array(
'state' => array(
'required' => false,
),
),
'HK' => array(
'postcode' => array(
'required' => false,

View File

@ -218,7 +218,7 @@ class WC_Frontend_Scripts {
'selectWoo' => array(
'src' => self::get_asset_url( 'assets/js/selectWoo/selectWoo.full' . $suffix . '.js' ),
'deps' => array( 'jquery' ),
'version' => '1.0.5',
'version' => '1.0.6',
),
'wc-address-i18n' => array(
'src' => self::get_asset_url( 'assets/js/frontend/address-i18n' . $suffix . '.js' ),

View File

@ -235,6 +235,8 @@ class WC_Post_Types {
'new_item_name' => sprintf( __( 'New %s', 'woocommerce' ), $label ),
/* translators: %s: attribute name */
'not_found' => sprintf( __( 'No &quot;%s&quot; found', 'woocommerce' ), $label ),
/* translators: %s: attribute name */
'back_to_items' => sprintf( __( '&larr; Back to "%s" attributes', 'woocommerce' ), $label ),
),
'show_ui' => true,
'show_in_quick_edit' => false,

View File

@ -285,10 +285,17 @@ class WC_Product_Variable extends WC_Product {
* @return array
*/
public function get_available_variations() {
$variation_ids = $this->get_children();
$available_variations = array();
foreach ( $this->get_children() as $child_id ) {
$variation = wc_get_product( $child_id );
if ( is_callable( '_prime_post_caches' ) ) {
_prime_post_caches( $variation_ids );
}
foreach ( $variation_ids as $variation_id ) {
$variation = wc_get_product( $variation_id );
// Hide out of stock variations if 'Hide out of stock items from the catalog' is checked.
if ( ! $variation || ! $variation->exists() || ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && ! $variation->is_in_stock() ) ) {
@ -302,6 +309,7 @@ class WC_Product_Variable extends WC_Product {
$available_variations[] = $this->get_available_variation( $variation );
}
$available_variations = array_values( array_filter( $available_variations ) );
return $available_variations;

View File

@ -233,9 +233,10 @@ class WC_Structured_Data {
);
} else {
$markup_offer = array(
'@type' => 'AggregateOffer',
'lowPrice' => wc_format_decimal( $lowest, wc_get_price_decimals() ),
'highPrice' => wc_format_decimal( $highest, wc_get_price_decimals() ),
'@type' => 'AggregateOffer',
'lowPrice' => wc_format_decimal( $lowest, wc_get_price_decimals() ),
'highPrice' => wc_format_decimal( $highest, wc_get_price_decimals() ),
'offerCount' => count( $product->get_children() ),
);
}
} else {

View File

@ -864,19 +864,6 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
$outofstock_where = ' AND exclude_join.object_id IS NULL';
}
// Fetch a list of non-published parent products and exlude them, quicker than joining in the main query below.
$non_published_products = $wpdb->get_col(
"
SELECT posts.ID as id FROM `$wpdb->posts` AS posts
WHERE posts.post_type = 'product'
AND posts.post_parent = 0
AND posts.post_status != 'publish'
"
);
if ( 0 < count( $non_published_products ) ) {
$non_published_where = ' AND posts.post_parent NOT IN ( ' . implode( ',', $non_published_products ) . ')';
}
return $wpdb->get_results(
// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
"
@ -888,7 +875,12 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
AND posts.post_status = 'publish'
AND lookup.onsale = 1
$outofstock_where
$non_published_where
AND posts.post_parent NOT IN (
SELECT ID FROM `$wpdb->posts` as posts
WHERE posts.post_type = 'product'
AND posts.post_parent = 0
AND posts.post_status != 'publish'
)
GROUP BY posts.ID
"
// phpcs:enable WordPress.DB.PreparedSQL.NotPrepared

View File

@ -84,11 +84,11 @@ if ( ! class_exists( 'WC_Email_Customer_Invoice', false ) ) :
if ( $this->object->has_status( array( 'completed', 'processing' ) ) ) {
$subject = $this->get_option( 'subject_paid', $this->get_default_subject( true ) );
return apply_filters( 'woocommerce_email_subject_customer_invoice_paid', $this->format_string( $subject ), $this->object );
return apply_filters( 'woocommerce_email_subject_customer_invoice_paid', $this->format_string( $subject ), $this->object, $this );
}
$subject = $this->get_option( 'subject', $this->get_default_subject() );
return apply_filters( 'woocommerce_email_subject_customer_invoice', $this->format_string( $subject ), $this->object );
return apply_filters( 'woocommerce_email_subject_customer_invoice', $this->format_string( $subject ), $this->object, $this );
}
/**
@ -99,11 +99,11 @@ if ( ! class_exists( 'WC_Email_Customer_Invoice', false ) ) :
public function get_heading() {
if ( $this->object->has_status( wc_get_is_paid_statuses() ) ) {
$heading = $this->get_option( 'heading_paid', $this->get_default_heading( true ) );
return apply_filters( 'woocommerce_email_heading_customer_invoice_paid', $this->format_string( $heading ), $this->object );
return apply_filters( 'woocommerce_email_heading_customer_invoice_paid', $this->format_string( $heading ), $this->object, $this );
}
$heading = $this->get_option( 'heading', $this->get_default_heading() );
return apply_filters( 'woocommerce_email_heading_customer_invoice', $this->format_string( $heading ), $this->object );
return apply_filters( 'woocommerce_email_heading_customer_invoice', $this->format_string( $heading ), $this->object, $this );
}
/**

View File

@ -102,7 +102,7 @@ if ( ! class_exists( 'WC_Email_Customer_Refunded_Order', false ) ) :
} else {
$subject = $this->get_option( 'subject_full', $this->get_default_subject() );
}
return apply_filters( 'woocommerce_email_subject_customer_refunded_order', $this->format_string( $subject ), $this->object );
return apply_filters( 'woocommerce_email_subject_customer_refunded_order', $this->format_string( $subject ), $this->object, $this );
}
/**
@ -116,7 +116,7 @@ if ( ! class_exists( 'WC_Email_Customer_Refunded_Order', false ) ) :
} else {
$heading = $this->get_option( 'heading_full', $this->get_default_heading() );
}
return apply_filters( 'woocommerce_email_heading_customer_refunded_order', $this->format_string( $heading ), $this->object );
return apply_filters( 'woocommerce_email_heading_customer_refunded_order', $this->format_string( $heading ), $this->object, $this );
}
/**

View File

@ -351,7 +351,7 @@ class WC_Email extends WC_Settings_API {
* @return string
*/
public function get_subject() {
return apply_filters( 'woocommerce_email_subject_' . $this->id, $this->format_string( $this->get_option( 'subject', $this->get_default_subject() ) ), $this->object );
return apply_filters( 'woocommerce_email_subject_' . $this->id, $this->format_string( $this->get_option( 'subject', $this->get_default_subject() ) ), $this->object, $this );
}
/**
@ -360,7 +360,7 @@ class WC_Email extends WC_Settings_API {
* @return string
*/
public function get_heading() {
return apply_filters( 'woocommerce_email_heading_' . $this->id, $this->format_string( $this->get_option( 'heading', $this->get_default_heading() ) ), $this->object );
return apply_filters( 'woocommerce_email_heading_' . $this->id, $this->format_string( $this->get_option( 'heading', $this->get_default_heading() ) ), $this->object, $this );
}
/**
@ -369,7 +369,7 @@ class WC_Email extends WC_Settings_API {
* @return string
*/
public function get_recipient() {
$recipient = apply_filters( 'woocommerce_email_recipient_' . $this->id, $this->recipient, $this->object );
$recipient = apply_filters( 'woocommerce_email_recipient_' . $this->id, $this->recipient, $this->object, $this );
$recipients = array_map( 'trim', explode( ',', $recipient ) );
$recipients = array_filter( $recipients, 'is_email' );
return implode( ', ', $recipients );
@ -391,7 +391,7 @@ class WC_Email extends WC_Settings_API {
$header .= 'Reply-to: ' . $this->get_from_name() . ' <' . $this->get_from_address() . ">\r\n";
}
return apply_filters( 'woocommerce_email_headers', $header, $this->id, $this->object );
return apply_filters( 'woocommerce_email_headers', $header, $this->id, $this->object, $this );
}
/**
@ -400,7 +400,7 @@ class WC_Email extends WC_Settings_API {
* @return array
*/
public function get_attachments() {
return apply_filters( 'woocommerce_email_attachments', array(), $this->id, $this->object );
return apply_filters( 'woocommerce_email_attachments', array(), $this->id, $this->object, $this );
}
/**
@ -464,7 +464,7 @@ class WC_Email extends WC_Settings_API {
* @return bool
*/
public function is_enabled() {
return apply_filters( 'woocommerce_email_enabled_' . $this->id, 'yes' === $this->enabled, $this->object );
return apply_filters( 'woocommerce_email_enabled_' . $this->id, 'yes' === $this->enabled, $this->object, $this );
}
/**

View File

@ -492,7 +492,7 @@ class WC_Gateway_Paypal_Request {
$item = apply_filters(
'woocommerce_paypal_line_item',
array(
'item_name' => html_entity_decode( wc_trim_string( $item_name ? $item_name : __( 'Item', 'woocommerce' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
'item_name' => html_entity_decode( wc_trim_string( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'woocommerce' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
'quantity' => (int) $quantity,
'amount' => wc_float_to_string( (float) $amount ),
'item_number' => $item_number,

View File

@ -61,7 +61,8 @@ function wc_customer_edit_account_url() {
*/
function wc_edit_address_i18n( $id, $flip = false ) {
$slugs = apply_filters(
'woocommerce_edit_address_slugs', array(
'woocommerce_edit_address_slugs',
array(
'billing' => sanitize_title( _x( 'billing', 'edit-address-slug', 'woocommerce' ) ),
'shipping' => sanitize_title( _x( 'shipping', 'edit-address-slug', 'woocommerce' ) ),
)
@ -148,6 +149,8 @@ function wc_get_account_menu_item_classes( $endpoint ) {
$current = isset( $wp->query_vars[ $endpoint ] );
if ( 'dashboard' === $endpoint && ( isset( $wp->query_vars['page'] ) || empty( $wp->query_vars ) ) ) {
$current = true; // Dashboard is not an endpoint, so needs a custom check.
} elseif ( 'orders' === $endpoint && isset( $wp->query_vars['view-order'] ) ) {
$current = true; // When looking at individual order, highlight Orders list item (to signify where in the menu the user currently is).
}
if ( $current ) {
@ -186,7 +189,8 @@ function wc_get_account_endpoint_url( $endpoint ) {
*/
function wc_get_account_orders_columns() {
$columns = apply_filters(
'woocommerce_account_orders_columns', array(
'woocommerce_account_orders_columns',
array(
'order-number' => __( 'Order', 'woocommerce' ),
'order-date' => __( 'Date', 'woocommerce' ),
'order-status' => __( 'Status', 'woocommerce' ),
@ -207,7 +211,8 @@ function wc_get_account_orders_columns() {
*/
function wc_get_account_downloads_columns() {
$columns = apply_filters(
'woocommerce_account_downloads_columns', array(
'woocommerce_account_downloads_columns',
array(
'download-product' => __( 'Product', 'woocommerce' ),
'download-remaining' => __( 'Downloads remaining', 'woocommerce' ),
'download-expires' => __( 'Expires', 'woocommerce' ),
@ -231,7 +236,8 @@ function wc_get_account_downloads_columns() {
*/
function wc_get_account_payment_methods_columns() {
return apply_filters(
'woocommerce_account_payment_methods_columns', array(
'woocommerce_account_payment_methods_columns',
array(
'method' => __( 'Method', 'woocommerce' ),
'expires' => __( 'Expires', 'woocommerce' ),
'actions' => '&nbsp;',
@ -247,7 +253,8 @@ function wc_get_account_payment_methods_columns() {
*/
function wc_get_account_payment_methods_types() {
return apply_filters(
'woocommerce_payment_methods_types', array(
'woocommerce_payment_methods_types',
array(
'cc' => __( 'Credit card', 'woocommerce' ),
'echeck' => __( 'eCheck', 'woocommerce' ),
)

View File

@ -576,6 +576,8 @@ function wc_create_attribute( $args ) {
// Update product attributes which use this taxonomy.
$old_taxonomy_name = 'pa_' . $old_slug;
$new_taxonomy_name = 'pa_' . $data['attribute_name'];
$old_attribute_key = sanitize_title( $old_taxonomy_name ); // @see WC_Product::set_attributes().
$new_attribute_key = sanitize_title( $new_taxonomy_name ); // @see WC_Product::set_attributes().
$metadatas = $wpdb->get_results(
$wpdb->prepare(
"SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_product_attributes' AND meta_value LIKE %s",
@ -586,13 +588,14 @@ function wc_create_attribute( $args ) {
foreach ( $metadatas as $metadata ) {
$product_id = $metadata['post_id'];
$unserialized_data = maybe_unserialize( $metadata['meta_value'] );
if ( ! $unserialized_data || ! is_array( $unserialized_data ) || ! isset( $unserialized_data[ $old_taxonomy_name ] ) ) {
if ( ! $unserialized_data || ! is_array( $unserialized_data ) || ! isset( $unserialized_data[ $old_attribute_key ] ) ) {
continue;
}
$unserialized_data[ $new_taxonomy_name ] = $unserialized_data[ $old_taxonomy_name ];
unset( $unserialized_data[ $old_taxonomy_name ] );
$unserialized_data[ $new_taxonomy_name ]['name'] = $new_taxonomy_name;
$unserialized_data[ $new_attribute_key ] = $unserialized_data[ $old_attribute_key ];
unset( $unserialized_data[ $old_attribute_key ] );
$unserialized_data[ $new_attribute_key ]['name'] = $new_taxonomy_name;
update_post_meta( $product_id, '_product_attributes', wp_slash( $unserialized_data ) );
}

View File

@ -1623,9 +1623,9 @@ function wc_uasort_comparison( $a, $b ) {
* @return int
*/
function wc_ascii_uasort_comparison( $a, $b ) {
if ( function_exists( 'iconv' ) ) {
$a = iconv( 'UTF-8', 'ASCII//TRANSLIT', $a );
$b = iconv( 'UTF-8', 'ASCII//TRANSLIT', $b );
if ( function_exists( 'iconv' ) && defined( 'ICONV_IMPL' ) && @strcasecmp( ICONV_IMPL, 'unknown' ) !== 0 ) {
$a = @iconv( 'UTF-8', 'ASCII//TRANSLIT//IGNORE', $a );
$b = @iconv( 'UTF-8', 'ASCII//TRANSLIT//IGNORE', $b );
}
return strcmp( $a, $b );
}

View File

@ -606,10 +606,8 @@ function wc_price( $price, $args = array() ) {
* @return int
*/
function wc_let_to_num( $size ) {
$l = substr( $size, -1 );
$ret = substr( $size, 0, -1 );
$byte = 1024;
$l = substr( $size, -1 );
$ret = (int) substr( $size, 0, -1 );
switch ( strtoupper( $l ) ) {
case 'P':
$ret *= 1024;

View File

@ -43,7 +43,6 @@ function wc_update_product_stock( $product, $stock_quantity = null, $operation =
// Re-read product data after updating stock, then have stock status calculated and saved.
$product_with_stock = wc_get_product( $product_id_with_stock );
$product_with_stock->set_stock_status();
$product_with_stock->set_date_modified( current_time( 'timestamp', true ) );
$product_with_stock->save();
if ( $product_with_stock->is_type( 'variation' ) ) {
@ -195,7 +194,7 @@ function wc_reduce_stock_levels( $order_id ) {
*
* @since 3.5.0
* @param WC_Order $order order object.
* @param array $changes Array of changes.
* @param array $changes Array of changes.
*/
function wc_trigger_stock_change_notifications( $order, $changes ) {
if ( empty( $changes ) ) {
@ -216,7 +215,8 @@ function wc_trigger_stock_change_notifications( $order, $changes ) {
if ( $change['to'] < 0 ) {
do_action(
'woocommerce_product_on_backorder', array(
'woocommerce_product_on_backorder',
array(
'product' => wc_get_product( $change['product']->get_id() ),
'order_id' => $order->get_id(),
'quantity' => abs( $change['from'] - $change['to'] ),
@ -320,7 +320,7 @@ function wc_get_held_stock_quantity( $product, $exclude_order_id = 0 ) {
/**
* Return low stock amount to determine if notification needs to be sent
*
* @param WC_Product $product
* @param WC_Product $product Product to get data from.
* @since 3.5.0
* @return int
*/

View File

@ -686,7 +686,22 @@ function wc_query_string_form_fields( $values = null, $exclude = array(), $curre
$values = array();
if ( ! empty( $url_parts['query'] ) ) {
parse_str( $url_parts['query'], $values );
// This is to preserve full-stops and spaces in the query string when ran through parse_str.
$replace_chars = array(
'.' => '{dot}',
'+' => '{plus}',
'%20' => '{space}',
);
$query_string = str_replace( array_keys( $replace_chars ), array_values( $replace_chars ), $url_parts['query'] );
// Parse the string.
parse_str( $query_string, $parsed_query_string );
// Convert the full-stops back and add to values array.
foreach ( $parsed_query_string as $key => $value ) {
$values[ str_replace( array_values( $replace_chars ), array_keys( $replace_chars ), $key ) ] = $value;
}
}
}
$html = '';

View File

@ -58,7 +58,7 @@ class WC_Widget_Cart extends WC_Widget {
$hide_if_empty = empty( $instance['hide_if_empty'] ) ? 0 : 1;
if ( empty( $instance['title'] ) ) {
if ( ! isset( $instance['title'] ) ) {
$instance['title'] = __( 'Cart', 'woocommerce' );
}

613
package-lock.json generated
View File

@ -2024,9 +2024,9 @@
}
},
"babel-plugin-add-module-exports": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/babel-plugin-add-module-exports/-/babel-plugin-add-module-exports-1.0.0.tgz",
"integrity": "sha512-m0sMxPL4FaN2K69GQgaRJa4Ny15qKSdoknIcpN+gz+NaJlAW9pge/povs13tPYsKDboflrEQC+/3kfIsONBTaw==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/babel-plugin-add-module-exports/-/babel-plugin-add-module-exports-1.0.2.tgz",
"integrity": "sha512-4paN7RivvU3Rzju1vGSHWPjO8Y0rI6droWvSFKI6dvEQ4mvoV0zGojnlzVRfI6N8zISo6VERXt3coIuVmzuvNg==",
"dev": true,
"requires": {
"chokidar": "^2.0.4"
@ -2041,6 +2041,18 @@
"requires": {
"micromatch": "^3.1.4",
"normalize-path": "^2.1.1"
},
"dependencies": {
"normalize-path": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
"integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
"dev": true,
"optional": true,
"requires": {
"remove-trailing-separator": "^1.0.1"
}
}
}
},
"arr-diff": {
@ -2089,25 +2101,24 @@
}
},
"chokidar": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.4.tgz",
"integrity": "sha512-z9n7yt9rOvIJrMhvDtDictKrkFHeihkNl6uWMmZlmL6tJtX9Cs+87oK+teBx+JIgzvbX3yZHT3eF8vpbDxHJXQ==",
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.5.tgz",
"integrity": "sha512-i0TprVWp+Kj4WRPtInjexJ8Q+BqTE909VpH8xVhXrJkoc5QC8VO9TryGOqTr+2hljzc1sC62t22h5tZePodM/A==",
"dev": true,
"optional": true,
"requires": {
"anymatch": "^2.0.0",
"async-each": "^1.0.0",
"braces": "^2.3.0",
"fsevents": "^1.2.2",
"async-each": "^1.0.1",
"braces": "^2.3.2",
"fsevents": "^1.2.7",
"glob-parent": "^3.1.0",
"inherits": "^2.0.1",
"inherits": "^2.0.3",
"is-binary-path": "^1.0.0",
"is-glob": "^4.0.0",
"lodash.debounce": "^4.0.8",
"normalize-path": "^2.1.1",
"normalize-path": "^3.0.0",
"path-is-absolute": "^1.0.0",
"readdirp": "^2.0.0",
"upath": "^1.0.5"
"readdirp": "^2.2.1",
"upath": "^1.1.1"
}
},
"expand-brackets": {
@ -2275,6 +2286,554 @@
}
}
},
"fsevents": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.8.tgz",
"integrity": "sha512-tPvHgPGB7m40CZ68xqFGkKuzN+RnpGmSV+hgeKxhRpbxdqKXUFJGC3yonBOLzQBcJyGpdZFDfCsdOC2KFsXzeA==",
"dev": true,
"optional": true,
"requires": {
"nan": "^2.12.1",
"node-pre-gyp": "^0.12.0"
},
"dependencies": {
"abbrev": {
"version": "1.1.1",
"bundled": true,
"dev": true,
"optional": true
},
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
"bundled": true,
"dev": true,
"optional": true
},
"are-we-there-yet": {
"version": "1.1.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"delegates": "^1.0.0",
"readable-stream": "^2.0.6"
}
},
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"chownr": {
"version": "1.1.1",
"bundled": true,
"dev": true,
"optional": true
},
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
},
"debug": {
"version": "4.1.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ms": "^2.1.1"
}
},
"deep-extend": {
"version": "0.6.0",
"bundled": true,
"dev": true,
"optional": true
},
"delegates": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
},
"detect-libc": {
"version": "1.0.3",
"bundled": true,
"dev": true,
"optional": true
},
"fs-minipass": {
"version": "1.2.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minipass": "^2.2.1"
}
},
"fs.realpath": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
},
"gauge": {
"version": "2.7.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"aproba": "^1.0.3",
"console-control-strings": "^1.0.0",
"has-unicode": "^2.0.0",
"object-assign": "^4.1.0",
"signal-exit": "^3.0.0",
"string-width": "^1.0.1",
"strip-ansi": "^3.0.1",
"wide-align": "^1.1.0"
}
},
"glob": {
"version": "7.1.3",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"has-unicode": {
"version": "2.0.1",
"bundled": true,
"dev": true,
"optional": true
},
"iconv-lite": {
"version": "0.4.24",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safer-buffer": ">= 2.1.2 < 3"
}
},
"ignore-walk": {
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimatch": "^3.0.4"
}
},
"inflight": {
"version": "1.0.6",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
"bundled": true,
"dev": true,
"optional": true
},
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
},
"isarray": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
},
"minimatch": {
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
}
},
"minizlib": {
"version": "1.2.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minipass": "^2.2.1"
}
},
"mkdirp": {
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
},
"ms": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
},
"needle": {
"version": "2.3.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"debug": "^4.1.0",
"iconv-lite": "^0.4.4",
"sax": "^1.2.4"
}
},
"node-pre-gyp": {
"version": "0.12.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"detect-libc": "^1.0.2",
"mkdirp": "^0.5.1",
"needle": "^2.2.1",
"nopt": "^4.0.1",
"npm-packlist": "^1.1.6",
"npmlog": "^4.0.2",
"rc": "^1.2.7",
"rimraf": "^2.6.1",
"semver": "^5.3.0",
"tar": "^4"
}
},
"nopt": {
"version": "4.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"abbrev": "1",
"osenv": "^0.1.4"
}
},
"npm-bundled": {
"version": "1.0.6",
"bundled": true,
"dev": true,
"optional": true
},
"npm-packlist": {
"version": "1.4.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ignore-walk": "^3.0.1",
"npm-bundled": "^1.0.1"
}
},
"npmlog": {
"version": "4.1.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"are-we-there-yet": "~1.1.2",
"console-control-strings": "~1.1.0",
"gauge": "~2.7.3",
"set-blocking": "~2.0.0"
}
},
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
"bundled": true,
"dev": true,
"optional": true
},
"once": {
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
},
"os-homedir": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
},
"os-tmpdir": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
},
"osenv": {
"version": "0.1.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"os-homedir": "^1.0.0",
"os-tmpdir": "^1.0.0"
}
},
"path-is-absolute": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
},
"process-nextick-args": {
"version": "2.0.0",
"bundled": true,
"dev": true,
"optional": true
},
"rc": {
"version": "1.2.8",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"deep-extend": "^0.6.0",
"ini": "~1.3.0",
"minimist": "^1.2.0",
"strip-json-comments": "~2.0.1"
},
"dependencies": {
"minimist": {
"version": "1.2.0",
"bundled": true,
"dev": true,
"optional": true
}
}
},
"readable-stream": {
"version": "2.3.6",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"rimraf": {
"version": "2.6.3",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"glob": "^7.1.3"
}
},
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
"bundled": true,
"dev": true,
"optional": true
},
"sax": {
"version": "1.2.4",
"bundled": true,
"dev": true,
"optional": true
},
"semver": {
"version": "5.7.0",
"bundled": true,
"dev": true,
"optional": true
},
"set-blocking": {
"version": "2.0.0",
"bundled": true,
"dev": true,
"optional": true
},
"signal-exit": {
"version": "3.0.2",
"bundled": true,
"dev": true,
"optional": true
},
"string-width": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
"strip-ansi": "^3.0.0"
}
},
"string_decoder": {
"version": "1.1.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "~5.1.0"
}
},
"strip-ansi": {
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
},
"strip-json-comments": {
"version": "2.0.1",
"bundled": true,
"dev": true,
"optional": true
},
"tar": {
"version": "4.4.8",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"chownr": "^1.1.1",
"fs-minipass": "^1.2.5",
"minipass": "^2.3.4",
"minizlib": "^1.1.1",
"mkdirp": "^0.5.0",
"safe-buffer": "^5.1.2",
"yallist": "^3.0.2"
}
},
"util-deprecate": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
},
"wide-align": {
"version": "1.1.3",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"string-width": "^1.0.2 || 2"
}
},
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true,
"optional": true
}
}
},
"glob-parent": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz",
@ -2338,9 +2897,9 @@
"optional": true
},
"is-glob": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz",
"integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=",
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz",
"integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==",
"dev": true,
"optional": true,
"requires": {
@ -2404,6 +2963,13 @@
"snapdragon": "^0.8.1",
"to-regex": "^3.0.2"
}
},
"normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"dev": true,
"optional": true
}
}
},
@ -8285,13 +8851,6 @@
"integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=",
"dev": true
},
"lodash.debounce": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
"integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=",
"dev": true,
"optional": true
},
"lodash.find": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/lodash.find/-/lodash.find-3.2.1.tgz",
@ -13345,9 +13904,9 @@
}
},
"upath": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/upath/-/upath-1.1.0.tgz",
"integrity": "sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw==",
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz",
"integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==",
"dev": true,
"optional": true
},

View File

@ -23,7 +23,7 @@
"babel": "6.23.0",
"babel-cli": "6.26.0",
"babel-eslint": "10.0.1",
"babel-plugin-add-module-exports": "1.0.0",
"babel-plugin-add-module-exports": "1.0.2",
"babel-preset-es2015": "6.24.1",
"babel-preset-stage-2": "6.24.1",
"chai": "4.2.0",

View File

@ -602,14 +602,18 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
* @since 2.2
*/
public function test_wc_let_to_num() {
$this->assertEquals(
array( 10240, 10485760, 10737418240, 10995116277760, 11258999068426240 ),
$this->assertSame(
array( 10240, 10485760, 10737418240, 10995116277760, 11258999068426240, 0, 0, 0, 0 ),
array(
wc_let_to_num( '10K' ),
wc_let_to_num( '10M' ),
wc_let_to_num( '10G' ),
wc_let_to_num( '10T' ),
wc_let_to_num( '10P' ),
wc_let_to_num( false ),
wc_let_to_num( true ),
wc_let_to_num( '' ),
wc_let_to_num( 'ABC' ),
)
);
}

View File

@ -213,8 +213,55 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
$this->assertEquals( '_cart', $query_array['cmd'] );
$this->check_shipping_tax( $query_array, $shipping_tax_included );
}
}
/**
* Test removing HTML tags from product title and request URL
*
* @param bool $testmode Whether to use Paypal sandbox.
*/
protected function check_product_title_containing_html( $testmode ) {
$order = WC_Helper_Order::create_order();
foreach ( $order->get_items() as $item ) {
$order->remove_item( $item->get_id() );
}
$product = new WC_Product_Simple();
$product->set_props(
array(
'name' => 'New Product <a href="#" style="color: red;">Link</a>',
'regular_price' => 10,
'price' => 10,
)
);
$product->save();
$product = wc_get_product( $product->get_id() );
$qty = 1;
$item = new WC_Order_Item_Product();
$item->set_props( array(
'product' => $product,
'quantity' => $qty,
'subtotal' => wc_get_price_excluding_tax( $product, array( 'qty' => $qty ) ),
'total' => wc_get_price_excluding_tax( $product, array( 'qty' => $qty ) ),
) );
$item->save();
$order->add_item( $item );
$order->save();
$request_url = $this->paypal_request->get_request_url( $order, $testmode );
$query_string = wp_parse_url( $request_url, PHP_URL_QUERY )
? wp_parse_url( $request_url, PHP_URL_QUERY )
: '';
$query_array = array();
parse_str( $query_string, $query_array );
$this->assertEquals( $query_array['item_name_1'], 'New Product Link x ' . $qty );
}
/**
* Return true if value is < 0, false otherwise.
@ -348,7 +395,10 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
// Test order with URL longer than limit.
// Many items in order -> forced to use one line item -> shipping tax included.
$this->check_large_order( true, $testmode );
$this->check_large_order( true, $testmode );
// Test removing tags from line item name
$this->check_product_title_containing_html( $testmode );
// Test amount < 0.
$this->check_negative_amount( $testmode );

View File

@ -115,4 +115,31 @@ class WC_Tests_Template_Functions extends WC_Unit_Test_Case {
unset( $_REQUEST['attribute_pa_size'] );
}
/**
* Test wc_query_string_form_fields.
*
* @return void
*/
public function test_wc_query_string_form_fields() {
$actual_html = wc_query_string_form_fields( '?test=1', array(), '', true );
$expected_html = '<input type="hidden" name="test" value="1" />';
$this->assertEquals( $expected_html, $actual_html, var_export( $actual_html, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
$actual_html = wc_query_string_form_fields( '?test=1&test2=something', array(), '', true );
$expected_html = '<input type="hidden" name="test" value="1" /><input type="hidden" name="test2" value="something" />';
$this->assertEquals( $expected_html, $actual_html, var_export( $actual_html, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
$actual_html = wc_query_string_form_fields( '?test.something=something', array(), '', true );
$expected_html = '<input type="hidden" name="test.something" value="something" />';
$this->assertEquals( $expected_html, $actual_html, var_export( $actual_html, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
$actual_html = wc_query_string_form_fields( '?test+something=something', array(), '', true );
$expected_html = '<input type="hidden" name="test+something" value="something" />';
$this->assertEquals( $expected_html, $actual_html, var_export( $actual_html, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
$actual_html = wc_query_string_form_fields( '?test%20something=something', array(), '', true );
$expected_html = '<input type="hidden" name="test%20something" value="something" />';
$this->assertEquals( $expected_html, $actual_html, var_export( $actual_html, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
}
}

View File

@ -562,12 +562,14 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case {
* @expectedIncorrectUsage wc_get_template
*/
public function test_wc_get_template_invalid_action_args() {
ob_start();
wc_get_template(
'global/wrapper-start.php',
array(
'action_args' => 'this is bad',
)
);
$template = ob_get_clean();
}
/**