Update with master

This commit is contained in:
claudiulodro 2017-11-22 11:02:14 -08:00
commit 5513dc4546
65 changed files with 779 additions and 680 deletions

View File

@ -6,7 +6,6 @@ sudo: false
php:
- 5.6
- 7.0
- 7.1
env:
- WP_VERSION=latest WP_MULTISITE=0
@ -20,6 +19,8 @@ matrix:
dist: precise
- php: 5.2
dist: precise
- php: 7.1
env: WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1
- php: 7.1
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
allow_failures:
@ -27,7 +28,6 @@ matrix:
before_script:
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- if [[ $TRAVIS_PHP_VERSION == '7.1' ]]; then composer install; fi
- bash tests/bin/install.sh woocommerce_test root '' localhost $WP_VERSION
- bash tests/bin/travis.sh before
@ -37,3 +37,10 @@ script:
after_script:
- bash tests/bin/travis.sh after
# Specifies that Travis should create builds for master and release branches and also tags.
branches:
only:
- master
- /^\d+\.\d+(\.\d+)?(-\S*)?$/
- /^release\//

View File

@ -334,9 +334,9 @@ module.exports = function( grunt ) {
// Register tasks
grunt.registerTask( 'default', [
'jshint',
'uglify',
'css'
'js',
'css',
'i18n'
]);
grunt.registerTask( 'js', [
@ -358,8 +358,13 @@ module.exports = function( grunt ) {
'shell:apigen'
]);
// Only an alias to 'default' task.
grunt.registerTask( 'dev', [
'default',
'default'
]);
grunt.registerTask( 'i18n', [
'checktextdomain',
'makepot'
]);

View File

@ -145,7 +145,7 @@
classes = _.indexBy( model.get( 'classes' ), 'term_id' ),
changes = {},
size = _.size( classes ),
newRow = _.extend( {}, data.default_class, {
newRow = _.extend( {}, data.default_shipping_class, {
term_id: 'new-' + size + '-' + Date.now(),
editing: true,
newRow : true

View File

@ -9,7 +9,7 @@
},
"require-dev": {
"squizlabs/php_codesniffer": "*",
"wp-coding-standards/wpcs": "0.13.1",
"wp-coding-standards/wpcs": "^0.14",
"phpunit/phpunit": "6.2.3",
"woocommerce/woocommerce-git-hooks": "1.0.3",
"wimg/php-compatibility": "^8.0",

14
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "9a9c7e81cc3a30935c03b1b2d64c201c",
"content-hash": "f8dbe5807f695e87ad3453a8b629b6bf",
"packages": [
{
"name": "composer/installers",
@ -1783,16 +1783,16 @@
},
{
"name": "wp-coding-standards/wpcs",
"version": "0.13.1",
"version": "0.14.0",
"source": {
"type": "git",
"url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
"reference": "1f64b1a0b5b789822d0303436ee4e30e0135e4dc"
"reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/1f64b1a0b5b789822d0303436ee4e30e0135e4dc",
"reference": "1f64b1a0b5b789822d0303436ee4e30e0135e4dc",
"url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/8cadf48fa1c70b2381988e0a79e029e011a8f41c",
"reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c",
"shasum": ""
},
"require": {
@ -1800,7 +1800,7 @@
"squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.1"
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3"
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
@ -1819,7 +1819,7 @@
"standards",
"wordpress"
],
"time": "2017-08-05T16:08:58+00:00"
"time": "2017-11-01T15:10:46+00:00"
}
],
"aliases": [],

View File

@ -285,7 +285,7 @@ abstract class WC_Data {
if ( ! $has_setter_or_getter ) {
return false;
}
/* translators: %s: $key Key to check */
wc_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'woocommerce' ), $key ), '3.2.0' );
return true;
@ -400,7 +400,7 @@ abstract class WC_Data {
* @param string $value
* @param int $meta_id
*/
public function update_meta_data( $key, $value, $meta_id = '' ) {
public function update_meta_data( $key, $value, $meta_id = 0 ) {
if ( $this->is_internal_meta_key( $key ) ) {
$function = 'set_' . $key;

View File

@ -1531,7 +1531,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* @return bool
*/
public function is_shipping_taxable() {
return $this->get_tax_status() === 'taxable' || $this->get_tax_status() === 'shipping';
return $this->needs_shipping() && ( $this->get_tax_status() === 'taxable' || $this->get_tax_status() === 'shipping' );
}
/**

View File

@ -83,11 +83,11 @@ class WC_Admin_Settings {
self::add_message( __( 'Your settings have been saved.', 'woocommerce' ) );
self::check_download_folder_protection();
// Clear any unwanted data and flush rules
// Clear any unwanted data and flush rules on next init.
add_option( 'woocommerce_queue_flush_rewrite_rules', 'true' );
delete_transient( 'woocommerce_cache_excluded_uris' );
WC()->query->init_query_vars();
WC()->query->add_endpoints();
wp_schedule_single_event( time(), 'woocommerce_flush_rewrite_rules' );
do_action( 'woocommerce_settings_saved' );
}

View File

@ -1664,7 +1664,7 @@ class WC_Admin_Setup_Wizard {
$docs_url = 'https://docs.woocommerce.com/documentation/plugins/woocommerce/getting-started/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=woocommerceplugin';
$help_text = sprintf(
/* translators: %1$s: link to videos, %2$s: link to docs */
__( 'Watch our <a href="%1$s" target="_blank">guided tour videos</a> to learn more about WooCommerce, and visit WooCommerce.com to learn more about <a href="%2$s" target="_blank">getting started</a>.' ),
__( 'Watch our <a href="%1$s" target="_blank">guided tour videos</a> to learn more about WooCommerce, and visit WooCommerce.com to learn more about <a href="%2$s" target="_blank">getting started</a>.', 'woocommerce' ),
$videos_url,
$docs_url
);

View File

@ -284,12 +284,18 @@ class WC_Meta_Box_Product_Data {
$attribute_key = sanitize_title( $attribute->get_name() );
if ( ! is_null( $index ) ) {
$value = isset( $_POST[ $key_prefix . $attribute_key ][ $index ] ) ? stripslashes( $_POST[ $key_prefix . $attribute_key ][ $index ] ) : '';
$value = isset( $_POST[ $key_prefix . $attribute_key ][ $index ] ) ? wp_unslash( $_POST[ $key_prefix . $attribute_key ][ $index ] ) : '';
} else {
$value = isset( $_POST[ $key_prefix . $attribute_key ] ) ? stripslashes( $_POST[ $key_prefix . $attribute_key ] ) : '';
$value = isset( $_POST[ $key_prefix . $attribute_key ] ) ? wp_unslash( $_POST[ $key_prefix . $attribute_key ] ) : '';
}
if ( $attribute->is_taxonomy() ) {
// Don't use wc_clean as it destroys sanitized characters.
$value = sanitize_title( $value );
} else {
$value = html_entity_decode( wc_clean( $value ), ENT_QUOTES, get_bloginfo( 'charset' ) ); // WPCS: sanitization ok.
}
$value = $attribute->is_taxonomy() ? sanitize_title( $value ) : wc_clean( $value ); // Don't use wc_clean as it destroys sanitized characters in terms.
$attributes[ $attribute_key ] = $value;
}
}

View File

@ -5,7 +5,7 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<div class="wc-metabox closed">
<h3 class="fixed">
<button type="button" data-permission_id="<?php echo esc_attr( $download->get_id() ); ?>" rel="<?php echo esc_attr( $download->get_product_id() ) . ',' . esc_attr( $download->get_download_id() ); ?>" class="revoke_access button"><?php _e( 'Revoke access', 'woocommerce' ); ?></button>
<button type="button" data-permission_id="<?php echo esc_attr( $download->get_id() ); ?>" rel="<?php echo esc_attr( $download->get_product_id() ) . ',' . esc_attr( $download->get_download_id() ); ?>" class="revoke_access button"><?php esc_html_e( 'Revoke access', 'woocommerce' ); ?></button>
<div class="handlediv" aria-label="<?php esc_attr_e( 'Click to toggle', 'woocommerce' ); ?>"></div>
<strong><?php
printf(
@ -16,19 +16,19 @@ if ( ! defined( 'ABSPATH' ) ) {
esc_html( wc_get_filename_from_url( $product->get_file_download_path( $download->get_download_id() ) ) )
);
printf( _n( 'Downloaded %s time', 'Downloaded %s times', $download->get_download_count(), 'woocommerce' ), esc_html( $download->get_download_count() ) )
?></strong>
?></strong>
</h3>
<table cellpadding="0" cellspacing="0" class="wc-metabox-content">
<tbody>
<tr>
<td>
<label><?php esc_html_e( 'Downloads remaining', 'woocommerce' ); ?></label>
<input type="hidden" name="permission_id[<?php echo $loop; ?>]" value="<?php echo esc_attr( $download->get_id() ); ?>" />
<input type="number" step="1" min="0" class="short" name="downloads_remaining[<?php echo $loop; ?>]" value="<?php echo esc_attr( $download->get_downloads_remaining() ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'woocommerce' ); ?>" />
<input type="hidden" name="permission_id[<?php echo esc_attr( $loop ); ?>]" value="<?php echo esc_attr( $download->get_id() ); ?>" />
<input type="number" step="1" min="0" class="short" name="downloads_remaining[<?php echo esc_attr( $loop ); ?>]" value="<?php echo esc_attr( $download->get_downloads_remaining() ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'woocommerce' ); ?>" />
</td>
<td>
<label><?php esc_html_e( 'Access expires', 'woocommerce' ); ?></label>
<input type="text" class="short date-picker" name="access_expires[<?php echo $loop; ?>]" value="<?php echo ! is_null( $download->get_access_expires() ) ? date_i18n( 'Y-m-d', $download->get_access_expires()->getTimestamp() ) : ''; ?>" maxlength="10" placeholder="<?php esc_attr_e( 'Never', 'woocommerce' ); ?>" pattern="<?php echo esc_attr( apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ); ?>" />
<input type="text" class="short date-picker" name="access_expires[<?php echo esc_attr( $loop ); ?>]" value="<?php echo ! is_null( $download->get_access_expires() ) ? esc_attr( date_i18n( 'Y-m-d', $download->get_access_expires()->getTimestamp() ) ) : ''; ?>" maxlength="10" placeholder="<?php esc_attr_e( 'Never', 'woocommerce' ); ?>" pattern="<?php echo esc_attr( apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ); ?>" />
</td>
<td>
<label><?php esc_html_e( 'Customer download link', 'woocommerce' ); ?></label>

View File

@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<tr class="fee <?php echo ( ! empty( $class ) ) ? $class : ''; ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>">
<tr class="fee <?php echo ( ! empty( $class ) ) ? esc_attr( $class ) : ''; ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>">
<td class="thumb"><div></div></td>
<td class="name">
@ -22,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" />
<input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_tax_class() ); ?>" />
</div>
<?php do_action( 'woocommerce_after_order_fee_item_name', $item_id, $item, null ) ?>
<?php do_action( 'woocommerce_after_order_fee_item_name', $item_id, $item, null ); ?>
</td>
<?php do_action( 'woocommerce_admin_order_item_values', null, $item, absint( $item_id ) ); ?>
@ -41,10 +41,10 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
</div>
<div class="edit" style="display: none;">
<input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" class="line_total wc_input_price" />
<input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" class="line_total wc_input_price" />
</div>
<div class="refund" style="display: none;">
<input type="text" name="refund_line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" class="refund_line_total wc_input_price" />
<input type="text" name="refund_line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_total wc_input_price" />
</div>
</td>
@ -65,10 +65,10 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
</div>
<div class="edit" style="display: none;">
<input type="text" name="line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo ( isset( $tax_item_total ) ) ? esc_attr( wc_format_localized_price( $tax_item_total ) ) : ''; ?>" class="line_tax wc_input_price" />
<input type="text" name="line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo ( isset( $tax_item_total ) ) ? esc_attr( wc_format_localized_price( $tax_item_total ) ) : ''; ?>" class="line_tax wc_input_price" />
</div>
<div class="refund" style="display: none;">
<input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
<input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
</div>
</td>

View File

@ -18,8 +18,9 @@ $hidden_order_itemmeta = apply_filters( 'woocommerce_hidden_order_itemmeta', arr
?><div class="view">
<?php if ( $meta_data = $item->get_formatted_meta_data( '' ) ) : ?>
<table cellspacing="0" class="display_meta">
<?php foreach ( $meta_data as $meta_id => $meta ) :
if ( in_array( $meta->key, $hidden_order_itemmeta ) ) {
<?php
foreach ( $meta_data as $meta_id => $meta ) :
if ( in_array( $meta->key, $hidden_order_itemmeta, true ) ) {
continue;
}
?>
@ -35,8 +36,9 @@ $hidden_order_itemmeta = apply_filters( 'woocommerce_hidden_order_itemmeta', arr
<table class="meta" cellspacing="0">
<tbody class="meta_items">
<?php if ( $meta_data = $item->get_formatted_meta_data( '' ) ) : ?>
<?php foreach ( $meta_data as $meta_id => $meta ) :
if ( in_array( $meta->key, $hidden_order_itemmeta ) ) {
<?php
foreach ( $meta_data as $meta_id => $meta ) :
if ( in_array( $meta->key, $hidden_order_itemmeta, true ) ) {
continue;
}
?>
@ -52,7 +54,7 @@ $hidden_order_itemmeta = apply_filters( 'woocommerce_hidden_order_itemmeta', arr
</tbody>
<tfoot>
<tr>
<td colspan="4"><button class="add_order_item_meta button"><?php _e( 'Add&nbsp;meta', 'woocommerce' ); ?></button></td>
<td colspan="4"><button class="add_order_item_meta button"><?php esc_html_e( 'Add&nbsp;meta', 'woocommerce' ); ?></button></td>
</tr>
</tfoot>
</table>

View File

@ -12,7 +12,7 @@ $product = $item->get_product();
$product_link = $product ? admin_url( 'post.php?post=' . $item->get_product_id() . '&action=edit' ) : '';
$thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnail', $product->get_image( 'thumbnail', array( 'title' => '' ), false ), $item_id, $item ) : '';
?>
<tr class="item <?php echo apply_filters( 'woocommerce_admin_html_order_item_class', ( ! empty( $class ) ? $class : '' ), $item, $order ); ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>">
<tr class="item <?php echo esc_attr( apply_filters( 'woocommerce_admin_html_order_item_class', ( ! empty( $class ) ? $class : '' ), $item, $order ) ); ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>">
<td class="thumb">
<?php echo '<div class="wc-order-item-thumbnail">' . wp_kses_post( $thumbnail ) . '</div>'; ?>
</td>
@ -21,11 +21,11 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai
echo $product_link ? '<a href="' . esc_url( $product_link ) . '" class="wc-order-item-name">' . esc_html( $item->get_name() ) . '</a>' : '<div class="wc-order-item-name">' . esc_html( $item->get_name() ) . '</div>';
if ( $product && $product->get_sku() ) {
echo '<div class="wc-order-item-sku"><strong>' . __( 'SKU:', 'woocommerce' ) . '</strong> ' . esc_html( $product->get_sku() ) . '</div>';
echo '<div class="wc-order-item-sku"><strong>' . esc_html__( 'SKU:', 'woocommerce' ) . '</strong> ' . esc_html( $product->get_sku() ) . '</div>';
}
if ( $item->get_variation_id() ) {
echo '<div class="wc-order-item-variation"><strong>' . __( 'Variation ID:', 'woocommerce' ) . '</strong> ';
echo '<div class="wc-order-item-variation"><strong>' . esc_html__( 'Variation ID:', 'woocommerce' ) . '</strong> ';
if ( 'product_variation' === get_post_type( $item->get_variation_id() ) ) {
echo esc_html( $item->get_variation_id() );
} else {
@ -38,9 +38,9 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai
<input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" />
<input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_tax_class() ); ?>" />
<?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, $product ) ?>
<?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, $product ); ?>
<?php include( 'html-order-item-meta.php' ); ?>
<?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, $product ) ?>
<?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, $product ); ?>
</td>
<?php do_action( 'woocommerce_admin_order_item_values', $product, $item, absint( $item_id ) ); ?>
@ -67,10 +67,10 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai
?>
</div>
<div class="edit" style="display: none;">
<input type="number" step="<?php echo apply_filters( 'woocommerce_quantity_input_step', '1', $product ); ?>" min="0" autocomplete="off" name="order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" value="<?php echo esc_attr( $item->get_quantity() ); ?>" data-qty="<?php echo esc_attr( $item->get_quantity() ); ?>" size="4" class="quantity" />
<input type="number" step="<?php echo esc_attr( apply_filters( 'woocommerce_quantity_input_step', '1', $product ) ); ?>" min="0" autocomplete="off" name="order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" value="<?php echo esc_attr( $item->get_quantity() ); ?>" data-qty="<?php echo esc_attr( $item->get_quantity() ); ?>" size="4" class="quantity" />
</div>
<div class="refund" style="display: none;">
<input type="number" step="<?php echo apply_filters( 'woocommerce_quantity_input_step', '1', $product ); ?>" min="0" max="<?php echo $item->get_quantity(); ?>" autocomplete="off" name="refund_order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" size="4" class="refund_order_item_qty" />
<input type="number" step="<?php echo esc_attr( apply_filters( 'woocommerce_quantity_input_step', '1', $product ) ); ?>" min="0" max="<?php echo absint( $item->get_quantity() ); ?>" autocomplete="off" name="refund_order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" size="4" class="refund_order_item_qty" />
</div>
</td>
<td class="line_cost" width="1%" data-sort-value="<?php echo esc_attr( $item->get_total() ); ?>">
@ -91,16 +91,16 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai
<div class="split-input">
<div class="input">
<label><?php esc_attr_e( 'Pre-discount:', 'woocommerce' ); ?></label>
<input type="text" name="line_subtotal[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_subtotal() ) ); ?>" class="line_subtotal wc_input_price" data-subtotal="<?php echo esc_attr( wc_format_localized_price( $item->get_subtotal() ) ); ?>" />
<input type="text" name="line_subtotal[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_subtotal() ) ); ?>" class="line_subtotal wc_input_price" data-subtotal="<?php echo esc_attr( wc_format_localized_price( $item->get_subtotal() ) ); ?>" />
</div>
<div class="input">
<label><?php esc_attr_e( 'Total:', 'woocommerce' ); ?></label>
<input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" class="line_total wc_input_price" data-tip="<?php esc_attr_e( 'After pre-tax discounts.', 'woocommerce' ); ?>" data-total="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" />
<input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" class="line_total wc_input_price" data-tip="<?php esc_attr_e( 'After pre-tax discounts.', 'woocommerce' ); ?>" data-total="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" />
</div>
</div>
</div>
<div class="refund" style="display: none;">
<input type="text" name="refund_line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" class="refund_line_total wc_input_price" />
<input type="text" name="refund_line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_total wc_input_price" />
</div>
</td>
@ -114,7 +114,7 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai
<td class="line_tax" width="1%">
<div class="view">
<?php
if ( '' != $tax_item_total ) {
if ( '' !== $tax_item_total ) {
echo wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) );
} else {
echo '&ndash;';
@ -137,16 +137,16 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai
<div class="split-input">
<div class="input">
<label><?php esc_attr_e( 'Pre-discount:', 'woocommerce' ); ?></label>
<input type="text" name="line_subtotal_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $tax_item_subtotal ) ); ?>" class="line_subtotal_tax wc_input_price" data-subtotal_tax="<?php echo esc_attr( wc_format_localized_price( $tax_item_subtotal ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
<input type="text" name="line_subtotal_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $tax_item_subtotal ) ); ?>" class="line_subtotal_tax wc_input_price" data-subtotal_tax="<?php echo esc_attr( wc_format_localized_price( $tax_item_subtotal ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
</div>
<div class="input">
<label><?php esc_attr_e( 'Total:', 'woocommerce' ); ?></label>
<input type="text" name="line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $tax_item_total ) ); ?>" class="line_tax wc_input_price" data-total_tax="<?php echo esc_attr( wc_format_localized_price( $tax_item_total ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
<input type="text" name="line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $tax_item_total ) ); ?>" class="line_tax wc_input_price" data-total_tax="<?php echo esc_attr( wc_format_localized_price( $tax_item_total ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
</div>
</div>
</div>
<div class="refund" style="display: none;">
<input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
<input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
</div>
</td>
<?php

View File

@ -26,23 +26,24 @@ if ( wc_tax_enabled() ) {
<table cellpadding="0" cellspacing="0" class="woocommerce_order_items">
<thead>
<tr>
<th class="item sortable" colspan="2" data-sort="string-ins"><?php _e( 'Item', 'woocommerce' ); ?></th>
<th class="item sortable" colspan="2" data-sort="string-ins"><?php esc_html_e( 'Item', 'woocommerce' ); ?></th>
<?php do_action( 'woocommerce_admin_order_item_headers', $order ); ?>
<th class="item_cost sortable" data-sort="float"><?php _e( 'Cost', 'woocommerce' ); ?></th>
<th class="quantity sortable" data-sort="int"><?php _e( 'Qty', 'woocommerce' ); ?></th>
<th class="line_cost sortable" data-sort="float"><?php _e( 'Total', 'woocommerce' ); ?></th>
<th class="item_cost sortable" data-sort="float"><?php esc_html_e( 'Cost', 'woocommerce' ); ?></th>
<th class="quantity sortable" data-sort="int"><?php esc_html_e( 'Qty', 'woocommerce' ); ?></th>
<th class="line_cost sortable" data-sort="float"><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
<?php
if ( ! empty( $order_taxes ) ) :
foreach ( $order_taxes as $tax_id => $tax_item ) :
$tax_class = wc_get_tax_class_by_tax_id( $tax_item['rate_id'] );
$tax_class_name = isset( $classes_options[ $tax_class ] ) ? $classes_options[ $tax_class ] : __( 'Tax', 'woocommerce' );
$column_label = ! empty( $tax_item['label'] ) ? $tax_item['label'] : __( 'Tax', 'woocommerce' );
/* translators: %1$s: tax item name %2$s: tax class name */
$column_tip = sprintf( esc_html__( '%1$s (%2$s)', 'woocommerce' ), $tax_item['name'], $tax_class_name );
?>
<th class="line_tax tips" data-tip="<?php echo esc_attr( $column_tip ); ?>">
<?php echo esc_attr( $column_label ); ?>
<input type="hidden" class="order-tax-id" name="order_taxes[<?php echo $tax_id; ?>]" value="<?php echo esc_attr( $tax_item['rate_id'] ); ?>">
<a class="delete-order-tax" href="#" data-rate_id="<?php echo $tax_id; ?>"></a>
<input type="hidden" class="order-tax-id" name="order_taxes[<?php echo esc_attr( $tax_id ); ?>]" value="<?php echo esc_attr( $tax_item['rate_id'] ); ?>">
<a class="delete-order-tax" href="#" data-rate_id="<?php echo esc_attr( $tax_id ); ?>"></a>
</th>
<?php
endforeach;
@ -94,11 +95,11 @@ if ( wc_tax_enabled() ) {
</div>
<div class="wc-order-data-row wc-order-item-bulk-edit" style="display:none;">
<?php if ( $order->is_editable() ) : ?>
<button type="button" class="button bulk-delete-items"><?php _e( 'Delete selected row(s)', 'woocommerce' ); ?></button>
<button type="button" class="button bulk-delete-items"><?php esc_html_e( 'Delete selected row(s)', 'woocommerce' ); ?></button>
<?php endif; ?>
<button type="button" class="button bulk-decrease-stock"><?php _e( 'Reduce stock', 'woocommerce' ); ?></button>
<button type="button" class="button bulk-increase-stock"><?php _e( 'Increase stock', 'woocommerce' ); ?></button>
<button type="button" class="button bulk-decrease-stock"><?php esc_html_e( 'Reduce stock', 'woocommerce' ); ?></button>
<button type="button" class="button bulk-increase-stock"><?php esc_html_e( 'Increase stock', 'woocommerce' ); ?></button>
<?php do_action( 'woocommerce_admin_order_item_bulk_actions', $order ); ?>
</div>
<div class="wc-order-data-row wc-order-totals-items wc-order-items-editable">
@ -108,7 +109,7 @@ if ( wc_tax_enabled() ) {
?>
<div class="wc-used-coupons">
<ul class="wc_coupon_list"><?php
echo '<li><strong>' . __( 'Coupon(s)', 'woocommerce' ) . '</strong></li>';
echo '<li><strong>' . esc_html__( 'Coupon(s)', 'woocommerce' ) . '</strong></li>';
foreach ( $coupons as $item_id => $item ) {
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' LIMIT 1;", $item->get_code() ) );
@ -126,7 +127,7 @@ if ( wc_tax_enabled() ) {
<table class="wc-order-totals">
<?php if ( 0 < $order->get_total_discount() ) : ?>
<tr>
<td class="label"><?php _e( 'Discount:', 'woocommerce' ); ?></td>
<td class="label"><?php esc_html_e( 'Discount:', 'woocommerce' ); ?></td>
<td width="1%"></td>
<td class="total">
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_currency() ) ); ?>
@ -138,10 +139,12 @@ if ( wc_tax_enabled() ) {
<?php if ( $order->get_shipping_methods() ) : ?>
<tr>
<td class="label"><?php _e( 'Shipping:', 'woocommerce' ); ?></td>
<td class="label"><?php esc_html_e( 'Shipping:', 'woocommerce' ); ?></td>
<td width="1%"></td>
<td class="total"><?php
if ( ( $refunded = $order->get_total_shipping_refunded() ) > 0 ) {
<td class="total">
<?php
$refunded = $order->get_total_shipping_refunded();
if ( $refunded > 0 ) {
echo '<del>' . strip_tags( wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ) ) . '</del> <ins>' . wc_price( $order->get_shipping_total() - $refunded, array( 'currency' => $order->get_currency() ) ) . '</ins>';
} else {
echo wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) );
@ -155,15 +158,18 @@ if ( wc_tax_enabled() ) {
<?php if ( wc_tax_enabled() ) : ?>
<?php foreach ( $order->get_tax_totals() as $code => $tax ) : ?>
<tr>
<td class="label"><?php echo $tax->label; ?>:</td>
<td class="label"><?php echo esc_html( $tax->label ); ?>:</td>
<td width="1%"></td>
<td class="total"><?php
if ( ( $refunded = $order->get_total_tax_refunded_by_rate_id( $tax->rate_id ) ) > 0 ) {
<td class="total">
<?php
$refunded = $order->get_total_tax_refunded_by_rate_id( $tax->rate_id );
if ( $refunded > 0 ) {
echo '<del>' . strip_tags( $tax->formatted_amount ) . '</del> <ins>' . wc_price( WC_Tax::round( $tax->amount, wc_get_price_decimals() ) - WC_Tax::round( $refunded, wc_get_price_decimals() ), array( 'currency' => $order->get_currency() ) ) . '</ins>';
} else {
echo $tax->formatted_amount;
}
?></td>
?>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
@ -171,7 +177,7 @@ if ( wc_tax_enabled() ) {
<?php do_action( 'woocommerce_admin_order_totals_after_tax', $order->get_id() ); ?>
<tr>
<td class="label"><?php _e( 'Total', 'woocommerce' ); ?>:</td>
<td class="label"><?php esc_html_e( 'Total', 'woocommerce' ); ?>:</td>
<td width="1%"></td>
<td class="total">
<?php echo $order->get_formatted_order_total(); ?>
@ -182,7 +188,7 @@ if ( wc_tax_enabled() ) {
<?php if ( $order->get_total_refunded() ) : ?>
<tr>
<td class="label refunded-total"><?php _e( 'Refunded', 'woocommerce' ); ?>:</td>
<td class="label refunded-total"><?php esc_html_e( 'Refunded', 'woocommerce' ); ?>:</td>
<td width="1%"></td>
<td class="total refunded-total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); ?></td>
</tr>
@ -196,63 +202,63 @@ if ( wc_tax_enabled() ) {
<div class="wc-order-data-row wc-order-bulk-actions wc-order-data-row-toggle">
<p class="add-items">
<?php if ( $order->is_editable() ) : ?>
<button type="button" class="button add-line-item"><?php _e( 'Add item(s)', 'woocommerce' ); ?></button>
<button type="button" class="button add-coupon"><?php _e( 'Apply coupon', 'woocommerce' ); ?></button>
<button type="button" class="button add-line-item"><?php esc_html_e( 'Add item(s)', 'woocommerce' ); ?></button>
<button type="button" class="button add-coupon"><?php esc_html_e( 'Apply coupon', 'woocommerce' ); ?></button>
<?php else : ?>
<span class="description"><?php echo wc_help_tip( __( 'To edit this order change the status back to "Pending"', 'woocommerce' ) ); ?> <?php _e( 'This order is no longer editable.', 'woocommerce' ); ?></span>
<span class="description"><?php echo wc_help_tip( __( 'To edit this order change the status back to "Pending"', 'woocommerce' ) ); ?> <?php esc_html_e( 'This order is no longer editable.', 'woocommerce' ); ?></span>
<?php endif; ?>
<?php if ( 0 < $order->get_total() - $order->get_total_refunded() || 0 < absint( $order->get_item_count() - $order->get_item_count_refunded() ) ) : ?>
<button type="button" class="button refund-items"><?php _e( 'Refund', 'woocommerce' ); ?></button>
<button type="button" class="button refund-items"><?php esc_html_e( 'Refund', 'woocommerce' ); ?></button>
<?php endif; ?>
<?php
// allow adding custom buttons
do_action( 'woocommerce_order_item_add_action_buttons', $order );
?>
<?php if ( $order->is_editable() ) : ?>
<button type="button" class="button button-primary calculate-action"><?php _e( 'Recalculate', 'woocommerce' ); ?></button>
<button type="button" class="button button-primary calculate-action"><?php esc_html_e( 'Recalculate', 'woocommerce' ); ?></button>
<?php endif; ?>
</p>
</div>
<div class="wc-order-data-row wc-order-add-item wc-order-data-row-toggle" style="display:none;">
<button type="button" class="button add-order-item"><?php _e( 'Add product(s)', 'woocommerce' ); ?></button>
<button type="button" class="button add-order-fee"><?php _e( 'Add fee', 'woocommerce' ); ?></button>
<button type="button" class="button add-order-shipping"><?php _e( 'Add shipping', 'woocommerce' ); ?></button>
<button type="button" class="button add-order-item"><?php esc_html_e( 'Add product(s)', 'woocommerce' ); ?></button>
<button type="button" class="button add-order-fee"><?php esc_html_e( 'Add fee', 'woocommerce' ); ?></button>
<button type="button" class="button add-order-shipping"><?php esc_html_e( 'Add shipping', 'woocommerce' ); ?></button>
<?php if ( wc_tax_enabled() ) : ?>
<button type="button" class="button add-order-tax"><?php _e( 'Add tax', 'woocommerce' ); ?></button>
<button type="button" class="button add-order-tax"><?php esc_html_e( 'Add tax', 'woocommerce' ); ?></button>
<?php endif; ?>
<?php
// allow adding custom buttons
do_action( 'woocommerce_order_item_add_line_buttons', $order );
?>
<button type="button" class="button cancel-action"><?php _e( 'Cancel', 'woocommerce' ); ?></button>
<button type="button" class="button button-primary save-action"><?php _e( 'Save', 'woocommerce' ); ?></button>
<button type="button" class="button cancel-action"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></button>
<button type="button" class="button button-primary save-action"><?php esc_html_e( 'Save', 'woocommerce' ); ?></button>
</div>
<?php if ( 0 < $order->get_total() - $order->get_total_refunded() || 0 < absint( $order->get_item_count() - $order->get_item_count_refunded() ) ) : ?>
<div class="wc-order-data-row wc-order-refund-items wc-order-data-row-toggle" style="display: none;">
<table class="wc-order-totals">
<?php if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) : ?>
<tr>
<td class="label"><label for="restock_refunded_items"><?php _e( 'Restock refunded items', 'woocommerce' ); ?>:</label></td>
<td class="label"><label for="restock_refunded_items"><?php esc_html_e( 'Restock refunded items', 'woocommerce' ); ?>:</label></td>
<td class="total"><input type="checkbox" id="restock_refunded_items" name="restock_refunded_items" checked="checked" /></td>
</tr>
<?php endif; ?>
<tr>
<td class="label"><?php _e( 'Amount already refunded', 'woocommerce' ); ?>:</td>
<td class="label"><?php esc_html_e( 'Amount already refunded', 'woocommerce' ); ?>:</td>
<td class="total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); ?></td>
</tr>
<tr>
<td class="label"><?php _e( 'Total available to refund', 'woocommerce' ); ?>:</td>
<td class="label"><?php esc_html_e( 'Total available to refund', 'woocommerce' ); ?>:</td>
<td class="total"><?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); ?></td>
</tr>
<tr>
<td class="label"><label for="refund_amount"><?php _e( 'Refund amount', 'woocommerce' ); ?>:</label></td>
<td class="label"><label for="refund_amount"><?php esc_html_e( 'Refund amount', 'woocommerce' ); ?>:</label></td>
<td class="total">
<input type="text" id="refund_amount" name="refund_amount" class="wc_input_price" />
<div class="clear"></div>
</td>
</tr>
<tr>
<td class="label"><label for="refund_reason"><?php echo wc_help_tip( __( 'Note: the refund reason will be visible by the customer.', 'woocommerce' ) ); ?> <?php _e( 'Reason for refund (optional):', 'woocommerce' ); ?></label></td>
<td class="label"><label for="refund_reason"><?php echo wc_help_tip( __( 'Note: the refund reason will be visible by the customer.', 'woocommerce' ) ); ?> <?php esc_html_e( 'Reason for refund (optional):', 'woocommerce' ); ?></label></td>
<td class="total">
<input type="text" id="refund_reason" name="refund_reason" />
<div class="clear"></div>
@ -266,9 +272,11 @@ if ( wc_tax_enabled() ) {
$gateway_supports_refunds = false !== $payment_gateway && $payment_gateway->supports( 'refunds' );
$gateway_name = false !== $payment_gateway ? ( ! empty( $payment_gateway->method_title ) ? $payment_gateway->method_title : $payment_gateway->get_title() ) : __( 'Payment gateway', 'woocommerce' );
?>
<button type="button" class="button <?php echo $gateway_supports_refunds ? 'button-primary do-api-refund' : 'tips disabled'; ?>" <?php echo $gateway_supports_refunds ? '' : 'data-tip="' . esc_attr__( 'The payment gateway used to place this order does not support automatic refunds.', 'woocommerce' ) . '"'; ?>><?php printf( __( 'Refund %1$s via %2$s', 'woocommerce' ), $refund_amount, $gateway_name ); ?></button>
<button type="button" class="button button-primary do-manual-refund tips" data-tip="<?php esc_attr_e( 'You will need to manually issue a refund through your payment gateway after using this.', 'woocommerce' ); ?>"><?php printf( __( 'Refund %s manually', 'woocommerce' ), $refund_amount ); ?></button>
<button type="button" class="button cancel-action"><?php _e( 'Cancel', 'woocommerce' ); ?></button>
<?php /* translators: refund amount, gateway name */ ?>
<button type="button" class="button <?php echo $gateway_supports_refunds ? 'button-primary do-api-refund' : 'tips disabled'; ?>" <?php echo $gateway_supports_refunds ? '' : 'data-tip="' . esc_attr__( 'The payment gateway used to place this order does not support automatic refunds.', 'woocommerce' ) . '"'; ?>><?php printf( esc_html__( 'Refund %1$s via %2$s', 'woocommerce' ), $refund_amount, $gateway_name ); ?></button>
<?php /* translators: refund amount */ ?>
<button type="button" class="button button-primary do-manual-refund tips" data-tip="<?php esc_attr_e( 'You will need to manually issue a refund through your payment gateway after using this.', 'woocommerce' ); ?>"><?php printf( esc_html__( 'Refund %s manually', 'woocommerce' ), $refund_amount ); ?></button>
<button type="button" class="button cancel-action"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></button>
<input type="hidden" id="refunded_amount" name="refunded_amount" value="<?php echo esc_attr( $order->get_total_refunded() ); ?>" />
<div class="clear"></div>
</div>
@ -280,7 +288,7 @@ if ( wc_tax_enabled() ) {
<div class="wc-backbone-modal-content">
<section class="wc-backbone-modal-main" role="main">
<header class="wc-backbone-modal-header">
<h1><?php _e( 'Add products', 'woocommerce' ); ?></h1>
<h1><?php esc_html_e( 'Add products', 'woocommerce' ); ?></h1>
<button class="modal-close modal-close-link dashicons dashicons-no-alt">
<span class="screen-reader-text">Close modal panel</span>
</button>
@ -292,7 +300,7 @@ if ( wc_tax_enabled() ) {
</article>
<footer>
<div class="inner">
<button id="btn-ok" class="button button-primary button-large"><?php _e( 'Add', 'woocommerce' ); ?></button>
<button id="btn-ok" class="button button-primary button-large"><?php esc_html_e( 'Add', 'woocommerce' ); ?></button>
</div>
</footer>
</section>
@ -306,7 +314,7 @@ if ( wc_tax_enabled() ) {
<div class="wc-backbone-modal-content">
<section class="wc-backbone-modal-main" role="main">
<header class="wc-backbone-modal-header">
<h1><?php _e( 'Add tax', 'woocommerce' ); ?></h1>
<h1><?php esc_html_e( 'Add tax', 'woocommerce' ); ?></h1>
<button class="modal-close modal-close-link dashicons dashicons-no-alt">
<span class="screen-reader-text">Close modal panel</span>
</button>
@ -317,10 +325,10 @@ if ( wc_tax_enabled() ) {
<thead>
<tr>
<th>&nbsp;</th>
<th><?php _e( 'Rate name', 'woocommerce' ); ?></th>
<th><?php _e( 'Tax class', 'woocommerce' ); ?></th>
<th><?php _e( 'Rate code', 'woocommerce' ); ?></th>
<th><?php _e( 'Rate %', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'Rate name', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'Tax class', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'Rate code', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'Rate %', 'woocommerce' ); ?></th>
</tr>
</thead>
<?php
@ -341,7 +349,7 @@ if ( wc_tax_enabled() ) {
</table>
<?php if ( absint( $wpdb->get_var( "SELECT COUNT(tax_rate_id) FROM {$wpdb->prefix}woocommerce_tax_rates;" ) ) > 100 ) : ?>
<p>
<label for="manual_tax_rate_id"><?php _e( 'Or, enter tax rate ID:', 'woocommerce' ); ?></label><br/>
<label for="manual_tax_rate_id"><?php esc_html_e( 'Or, enter tax rate ID:', 'woocommerce' ); ?></label><br/>
<input type="number" name="manual_tax_rate_id" id="manual_tax_rate_id" step="1" placeholder="<?php esc_attr_e( 'Optional', 'woocommerce' ); ?>" />
</p>
<?php endif; ?>
@ -349,7 +357,7 @@ if ( wc_tax_enabled() ) {
</article>
<footer>
<div class="inner">
<button id="btn-ok" class="button button-primary button-large"><?php _e( 'Add', 'woocommerce' ); ?></button>
<button id="btn-ok" class="button button-primary button-large"><?php esc_html_e( 'Add', 'woocommerce' ); ?></button>
</div>
</footer>
</section>

View File

@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
$who_refunded = new WP_User( $refund->get_refunded_by() );
?>
<tr class="refund <?php echo ( ! empty( $class ) ) ? $class : ''; ?>" data-order_refund_id="<?php echo $refund->get_id(); ?>">
<tr class="refund <?php echo ( ! empty( $class ) ) ? esc_attr( $class ) : ''; ?>" data-order_refund_id="<?php echo esc_attr( $refund->get_id() ); ?>">
<td class="thumb"><div></div></td>
<td class="name">
@ -16,11 +16,12 @@ $who_refunded = new WP_User( $refund->get_refunded_by() );
if ( $who_refunded->exists() ) {
printf(
/* translators: 1: refund id 2: refund date 3: username */
__( 'Refund #%1$s - %2$s by %3$s', 'woocommerce' ),
esc_html__( 'Refund #%1$s - %2$s by %3$s', 'woocommerce' ),
$refund->get_id(),
wc_format_datetime( $refund->get_date_created(), get_option( 'date_format' ) . ', ' . get_option( 'time_format' ) ),
sprintf(
'<abbr class="refund_by" title="%1$s">%2$s</abbr>',
/* translators: 1: ID who refunded */
sprintf( esc_attr__( 'ID: %d', 'woocommerce' ), absint( $who_refunded->ID ) ),
esc_html( $who_refunded->display_name )
)
@ -28,7 +29,7 @@ $who_refunded = new WP_User( $refund->get_refunded_by() );
} else {
printf(
/* translators: 1: refund id 2: refund date */
__( 'Refund #%1$s - %2$s', 'woocommerce' ),
esc_html__( 'Refund #%1$s - %2$s', 'woocommerce' ),
$refund->get_id(),
wc_format_datetime( $refund->get_date_created(), get_option( 'date_format' ) . ', ' . get_option( 'time_format' ) )
);

View File

@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<tr class="shipping <?php echo ( ! empty( $class ) ) ? $class : ''; ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>">
<tr class="shipping <?php echo ( ! empty( $class ) ) ? esc_attr( $class ) : ''; ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>">
<td class="thumb"><div></div></td>
<td class="name">
@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<input type="text" class="shipping_method_name" placeholder="<?php esc_attr_e( 'Shipping name', 'woocommerce' ); ?>" name="shipping_method_title[<?php echo esc_attr( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_name() ); ?>" />
<select class="shipping_method" name="shipping_method[<?php echo esc_attr( $item_id ); ?>]">
<optgroup label="<?php esc_attr_e( 'Shipping method', 'woocommerce' ); ?>">
<option value=""><?php _e( 'N/A', 'woocommerce' ); ?></option>
<option value=""><?php esc_html_e( 'N/A', 'woocommerce' ); ?></option>
<?php
$found_method = false;
@ -36,18 +36,18 @@ if ( ! defined( 'ABSPATH' ) ) {
}
if ( ! $found_method && $item->get_method_id() ) {
echo '<option value="' . esc_attr( $item->get_method_id() ) . '" selected="selected">' . __( 'Other', 'woocommerce' ) . '</option>';
echo '<option value="' . esc_attr( $item->get_method_id() ) . '" selected="selected">' . esc_html__( 'Other', 'woocommerce' ) . '</option>';
} else {
echo '<option value="other">' . __( 'Other', 'woocommerce' ) . '</option>';
echo '<option value="other">' . esc_html__( 'Other', 'woocommerce' ) . '</option>';
}
?>
</optgroup>
</select>
</div>
<?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, null ) ?>
<?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, null ); ?>
<?php include( 'html-order-item-meta.php' ); ?>
<?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, null ) ?>
<?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, null ); ?>
</td>
<?php do_action( 'woocommerce_admin_order_item_values', null, $item, absint( $item_id ) ); ?>
@ -59,17 +59,17 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="view">
<?php
echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) );
if ( $refunded = $order->get_total_refunded_for_item( $item_id, 'shipping' ) ) {
$refunded = $order->get_total_refunded_for_item( $item_id, 'shipping' );
if ( $refunded ) {
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
}
?>
</div>
<div class="edit" style="display: none;">
<input type="text" name="shipping_cost[<?php echo esc_attr( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" class="line_total wc_input_price" />
<input type="text" name="shipping_cost[<?php echo esc_attr( $item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" class="line_total wc_input_price" />
</div>
<div class="refund" style="display: none;">
<input type="text" name="refund_line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" class="refund_line_total wc_input_price" />
<input type="text" name="refund_line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_total wc_input_price" />
</div>
</td>
@ -83,17 +83,17 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="view">
<?php
echo ( '' !== $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ) : '&ndash;';
if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'shipping' ) ) {
$refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'shipping' );
if ( $refunded ) {
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
}
?>
</div>
<div class="edit" style="display: none;">
<input type="text" name="shipping_taxes[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo ( isset( $tax_item_total ) ) ? esc_attr( wc_format_localized_price( $tax_item_total ) ) : ''; ?>" class="line_tax wc_input_price" />
<input type="text" name="shipping_taxes[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo ( isset( $tax_item_total ) ) ? esc_attr( wc_format_localized_price( $tax_item_total ) ) : ''; ?>" class="line_tax wc_input_price" />
</div>
<div class="refund" style="display: none;">
<input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
<input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
</div>
</td>
<?php

View File

@ -5,7 +5,7 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<div data-taxonomy="<?php echo esc_attr( $attribute->get_taxonomy() ); ?>" class="woocommerce_attribute wc-metabox closed <?php echo esc_attr( implode( ' ', $metabox_class ) ); ?>" rel="<?php echo esc_attr( $attribute->get_position() ); ?>">
<h3>
<a href="#" class="remove_row delete"><?php _e( 'Remove', 'woocommerce' ); ?></a>
<a href="#" class="remove_row delete"><?php esc_html_e( 'Remove', 'woocommerce' ); ?></a>
<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'woocommerce' ); ?>"></div>
<strong class="attribute_name"><?php echo esc_html( wc_attribute_label( $attribute->get_name() ) ); ?></strong>
</h3>
@ -14,24 +14,26 @@ if ( ! defined( 'ABSPATH' ) ) {
<tbody>
<tr>
<td class="attribute_name">
<label><?php _e( 'Name', 'woocommerce' ); ?>:</label>
<label><?php esc_html_e( 'Name', 'woocommerce' ); ?>:</label>
<?php if ( $attribute->is_taxonomy() ) : ?>
<strong><?php echo esc_html( wc_attribute_label( $attribute->get_name() ) ); ?></strong>
<input type="hidden" name="attribute_names[<?php echo $i; ?>]" value="<?php echo esc_attr( $attribute->get_name() ); ?>" />
<input type="hidden" name="attribute_names[<?php echo esc_attr( $i ); ?>]" value="<?php echo esc_attr( $attribute->get_name() ); ?>" />
<?php else : ?>
<input type="text" class="attribute_name" name="attribute_names[<?php echo $i; ?>]" value="<?php echo esc_attr( $attribute->get_name() ); ?>" />
<input type="text" class="attribute_name" name="attribute_names[<?php echo esc_attr( $i ); ?>]" value="<?php echo esc_attr( $attribute->get_name() ); ?>" />
<?php endif; ?>
<input type="hidden" name="attribute_position[<?php echo $i; ?>]" class="attribute_position" value="<?php echo esc_attr( $attribute->get_position() ); ?>" />
<input type="hidden" name="attribute_position[<?php echo esc_attr( $i ); ?>]" class="attribute_position" value="<?php echo esc_attr( $attribute->get_position() ); ?>" />
</td>
<td rowspan="3">
<label><?php _e( 'Value(s)', 'woocommerce' ); ?>:</label>
<label><?php esc_html_e( 'Value(s)', 'woocommerce' ); ?>:</label>
<?php if ( $attribute->is_taxonomy() && ( $attribute_taxonomy = $attribute->get_taxonomy_object() ) ) : ?>
<?php
if ( $attribute->is_taxonomy() && $attribute_taxonomy = $attribute->get_taxonomy_object() ) :
?>
<?php if ( 'select' === $attribute_taxonomy->attribute_type ) : ?>
<select multiple="multiple" data-placeholder="<?php esc_attr_e( 'Select terms', 'woocommerce' ); ?>" class="multiselect attribute_values wc-enhanced-select" name="attribute_values[<?php echo $i; ?>][]">
<select multiple="multiple" data-placeholder="<?php esc_attr_e( 'Select terms', 'woocommerce' ); ?>" class="multiselect attribute_values wc-enhanced-select" name="attribute_values[<?php echo esc_attr( $i ); ?>][]">
<?php
$args = array(
'orderby' => 'name',
@ -42,18 +44,18 @@ if ( ! defined( 'ABSPATH' ) ) {
foreach ( $all_terms as $term ) {
$options = $attribute->get_options();
$options = ! empty( $options ) ? $options : array();
echo '<option value="' . esc_attr( $term->term_id ) . '" ' . selected( in_array( $term->term_id, $options ), true, false ) . '>' . esc_attr( apply_filters( 'woocommerce_product_attribute_term_name', $term->name, $term ) ) . '</option>';
echo '<option value="' . esc_attr( $term->term_id ) . '" ' . selected( in_array( $term->term_id, $options, true ), true, false ) . '>' . esc_attr( apply_filters( 'woocommerce_product_attribute_term_name', $term->name, $term ) ) . '</option>';
}
}
?>
</select>
<button class="button plus select_all_attributes"><?php _e( 'Select all', 'woocommerce' ); ?></button>
<button class="button minus select_no_attributes"><?php _e( 'Select none', 'woocommerce' ); ?></button>
<button class="button fr plus add_new_attribute"><?php _e( 'Add new', 'woocommerce' ); ?></button>
<button class="button plus select_all_attributes"><?php esc_html_e( 'Select all', 'woocommerce' ); ?></button>
<button class="button minus select_no_attributes"><?php esc_html_e( 'Select none', 'woocommerce' ); ?></button>
<button class="button fr plus add_new_attribute"><?php esc_html_e( 'Add new', 'woocommerce' ); ?></button>
<?php elseif ( 'text' == $attribute_taxonomy->attribute_type ) : ?>
<?php elseif ( 'text' === $attribute_taxonomy->attribute_type ) : ?>
<input type="text" name="attribute_values[<?php echo $i; ?>]" value="<?php
<input type="text" name="attribute_values[<?php echo esc_attr( $i ); ?>]" value="<?php
// Text attributes should list terms pipe separated
echo esc_attr( wc_implode_text_attributes( wp_list_pluck( $attribute->get_terms(), 'name' ) ) );
@ -70,21 +72,21 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php do_action( 'woocommerce_product_option_terms', $attribute_taxonomy, $i ); ?>
<?php else : ?>
<textarea name="attribute_values[<?php echo $i; ?>]" cols="5" rows="5" placeholder="<?php printf( esc_attr__( 'Enter some text, or some attributes by "%s" separating values.', 'woocommerce' ), WC_DELIMITER ); ?>"><?php echo esc_textarea( wc_implode_text_attributes( $attribute->get_options() ) ); ?></textarea>
<?php /* translators: %s: WC_DELIMITER */ ?>
<textarea name="attribute_values[<?php echo esc_attr( $i ); ?>]" cols="5" rows="5" placeholder="<?php printf( esc_attr__( 'Enter some text, or some attributes by "%s" separating values.', 'woocommerce' ), WC_DELIMITER ); ?>"><?php echo esc_textarea( wc_implode_text_attributes( $attribute->get_options() ) ); ?></textarea>
<?php endif; ?>
</td>
</tr>
<tr>
<td>
<label><input type="checkbox" class="checkbox" <?php checked( $attribute->get_visible(), true ); ?> name="attribute_visibility[<?php echo $i; ?>]" value="1" /> <?php _e( 'Visible on the product page', 'woocommerce' ); ?></label>
<label><input type="checkbox" class="checkbox" <?php checked( $attribute->get_visible(), true ); ?> name="attribute_visibility[<?php echo esc_attr( $i ); ?>]" value="1" /> <?php esc_html_e( 'Visible on the product page', 'woocommerce' ); ?></label>
</td>
</tr>
<tr>
<td>
<div class="enable_variation show_if_variable">
<label><input type="checkbox" class="checkbox" <?php checked( $attribute->get_variation(), true ); ?> name="attribute_variation[<?php echo $i; ?>]" value="1" /> <?php _e( 'Used for variations', 'woocommerce' ); ?></label>
<label><input type="checkbox" class="checkbox" <?php checked( $attribute->get_variation(), true ); ?> name="attribute_variation[<?php echo esc_attr( $i ); ?>]" value="1" /> <?php esc_html_e( 'Used for variations', 'woocommerce' ); ?></label>
</div>
</td>
</tr>

View File

@ -6,10 +6,10 @@ if ( ! defined( 'ABSPATH' ) ) {
<div id="product_attributes" class="panel wc-metaboxes-wrapper hidden">
<div class="toolbar toolbar-top">
<span class="expand-close">
<a href="#" class="expand_all"><?php _e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php _e( 'Close', 'woocommerce' ); ?></a>
<a href="#" class="expand_all"><?php esc_html_e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php esc_html_e( 'Close', 'woocommerce' ); ?></a>
</span>
<select name="attribute_taxonomy" class="attribute_taxonomy">
<option value=""><?php _e( 'Custom product attribute', 'woocommerce' ); ?></option>
<option value=""><?php esc_html_e( 'Custom product attribute', 'woocommerce' ); ?></option>
<?php
global $wc_product_attributes;
@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
?>
</select>
<button type="button" class="button add_attribute"><?php _e( 'Add', 'woocommerce' ); ?></button>
<button type="button" class="button add_attribute"><?php esc_html_e( 'Add', 'woocommerce' ); ?></button>
</div>
<div class="product_attributes wc-metaboxes">
<?php
@ -48,9 +48,9 @@ if ( ! defined( 'ABSPATH' ) ) {
</div>
<div class="toolbar">
<span class="expand-close">
<a href="#" class="expand_all"><?php _e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php _e( 'Close', 'woocommerce' ); ?></a>
<a href="#" class="expand_all"><?php esc_html_e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php esc_html_e( 'Close', 'woocommerce' ); ?></a>
</span>
<button type="button" class="button save_attributes button-primary"><?php _e( 'Save attributes', 'woocommerce' ); ?></button>
<button type="button" class="button save_attributes button-primary"><?php esc_html_e( 'Save attributes', 'woocommerce' ); ?></button>
</div>
<?php do_action( 'woocommerce_product_options_attributes' ); ?>
</div>

View File

@ -46,10 +46,10 @@ if ( ! defined( 'ABSPATH' ) ) {
$sale_price_dates_to = $product_object->get_date_on_sale_to( 'edit' ) && ( $date = $product_object->get_date_on_sale_to( 'edit' )->getOffsetTimestamp() ) ? date_i18n( 'Y-m-d', $date ) : '';
echo '<p class="form-field sale_price_dates_fields">
<label for="_sale_price_dates_from">' . __( 'Sale price dates', 'woocommerce' ) . '</label>
<input type="text" class="short" name="_sale_price_dates_from" id="_sale_price_dates_from" value="' . esc_attr( $sale_price_dates_from ) . '" placeholder="' . _x( 'From&hellip;', 'placeholder', 'woocommerce' ) . ' YYYY-MM-DD" maxlength="10" pattern="' . esc_attr( apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ) . '" />
<input type="text" class="short" name="_sale_price_dates_to" id="_sale_price_dates_to" value="' . esc_attr( $sale_price_dates_to ) . '" placeholder="' . _x( 'To&hellip;', 'placeholder', 'woocommerce' ) . ' YYYY-MM-DD" maxlength="10" pattern="' . esc_attr( apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ) . '" />
<a href="#" class="description cancel_sale_schedule">' . __( 'Cancel', 'woocommerce' ) . '</a>' . wc_help_tip( __( 'The sale will end at the beginning of the set date.', 'woocommerce' ) ) . '
<label for="_sale_price_dates_from">' . esc_html__( 'Sale price dates', 'woocommerce' ) . '</label>
<input type="text" class="short" name="_sale_price_dates_from" id="_sale_price_dates_from" value="' . esc_attr( $sale_price_dates_from ) . '" placeholder="' . esc_html( _x( 'From&hellip;', 'placeholder', 'woocommerce' ) ) . ' YYYY-MM-DD" maxlength="10" pattern="' . esc_attr( apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ) . '" />
<input type="text" class="short" name="_sale_price_dates_to" id="_sale_price_dates_to" value="' . esc_attr( $sale_price_dates_to ) . '" placeholder="' . esc_html( _x( 'To&hellip;', 'placeholder', 'woocommerce' ) ) . ' YYYY-MM-DD" maxlength="10" pattern="' . esc_attr( apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ) . '" />
<a href="#" class="description cancel_sale_schedule">' . esc_html__( 'Cancel', 'woocommerce' ) . '</a>' . wc_help_tip( __( 'The sale will end at the beginning of the set date.', 'woocommerce' ) ) . '
</p>';
do_action( 'woocommerce_product_options_pricing' );
@ -58,19 +58,20 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="options_group show_if_downloadable hidden">
<div class="form-field downloadable_files">
<label><?php _e( 'Downloadable files', 'woocommerce' ); ?></label>
<label><?php esc_html_e( 'Downloadable files', 'woocommerce' ); ?></label>
<table class="widefat">
<thead>
<tr>
<th class="sort">&nbsp;</th>
<th><?php _e( 'Name', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the name of the download shown to the customer.', 'woocommerce' ) ); ?></th>
<th colspan="2"><?php _e( 'File URL', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the URL or absolute path to the file which customers will get access to. URLs entered here should already be encoded.', 'woocommerce' ) ); ?></th>
<th><?php esc_html_e( 'Name', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the name of the download shown to the customer.', 'woocommerce' ) ); ?></th>
<th colspan="2"><?php esc_html_e( 'File URL', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the URL or absolute path to the file which customers will get access to. URLs entered here should already be encoded.', 'woocommerce' ) ); ?></th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<?php
if ( $downloadable_files = $product_object->get_downloads( 'edit' ) ) {
$downloadable_files = $product_object->get_downloads( 'edit' );
if ( $downloadable_files ) {
foreach ( $downloadable_files as $key => $file ) {
include( 'html-product-download.php' );
}
@ -89,7 +90,7 @@ if ( ! defined( 'ABSPATH' ) ) {
ob_start();
include( 'html-product-download.php' );
echo esc_attr( ob_get_clean() );
?>"><?php _e( 'Add File', 'woocommerce' ); ?></a>
?>"><?php esc_html_e( 'Add File', 'woocommerce' ); ?></a>
</th>
</tr>
</tfoot>

View File

@ -11,7 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
woocommerce_wp_text_input( array(
'id' => '_sku',
'value' => $product_object->get_sku( 'edit' ),
'label' => '<abbr title="' . __( 'Stock Keeping Unit', 'woocommerce' ) . '">' . __( 'SKU', 'woocommerce' ) . '</abbr>',
'label' => '<abbr title="' . esc_attr__( 'Stock Keeping Unit', 'woocommerce' ) . '">' . esc_html__( 'SKU', 'woocommerce' ) . '</abbr>',
'desc_tip' => true,
'description' => __( 'SKU refers to a Stock-keeping unit, a unique identifier for each distinct product and service that can be purchased.', 'woocommerce' ),
) );

View File

@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="options_group show_if_grouped">
<p class="form-field">
<label for="grouped_products"><?php _e( 'Grouped products', 'woocommerce' ); ?></label>
<label for="grouped_products"><?php esc_html_e( 'Grouped products', 'woocommerce' ); ?></label>
<select class="wc-product-search" multiple="multiple" style="width: 50%;" id="grouped_products" name="grouped_products[]" data-sortable="true" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products" data-exclude="<?php echo intval( $post->ID ); ?>">
<?php
$product_ids = $product_object->get_children( 'edit' );
@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="options_group">
<p class="form-field">
<label for="upsell_ids"><?php _e( 'Upsells', 'woocommerce' ); ?></label>
<label for="upsell_ids"><?php esc_html_e( 'Upsells', 'woocommerce' ); ?></label>
<select class="wc-product-search" multiple="multiple" style="width: 50%;" id="upsell_ids" name="upsell_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-exclude="<?php echo intval( $post->ID ); ?>">
<?php
$product_ids = $product_object->get_upsell_ids( 'edit' );
@ -41,7 +41,7 @@ if ( ! defined( 'ABSPATH' ) ) {
</p>
<p class="form-field hide_if_grouped hide_if_external">
<label for="crosssell_ids"><?php _e( 'Cross-sells', 'woocommerce' ); ?></label>
<label for="crosssell_ids"><?php esc_html_e( 'Cross-sells', 'woocommerce' ); ?></label>
<select class="wc-product-search" multiple="multiple" style="width: 50%;" id="crosssell_ids" name="crosssell_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-exclude="<?php echo intval( $post->ID ); ?>">
<?php
$product_ids = $product_object->get_cross_sell_ids( 'edit' );

View File

@ -32,8 +32,8 @@ if ( ! defined( 'ABSPATH' ) ) {
<ul class="product_data_tabs wc-tabs">
<?php foreach ( self::get_product_data_tabs() as $key => $tab ) : ?>
<li class="<?php echo $key; ?>_options <?php echo $key; ?>_tab <?php echo esc_attr( isset( $tab['class'] ) ? implode( ' ' , (array) $tab['class'] ) : '' ); ?>">
<a href="#<?php echo $tab['target']; ?>"><span><?php echo esc_html( $tab['label'] ); ?></span></a>
<li class="<?php echo esc_attr( $key ); ?>_options <?php echo esc_attr( $key ); ?>_tab <?php echo esc_attr( isset( $tab['class'] ) ? implode( ' ' , (array) $tab['class'] ) : '' ); ?>">
<a href="#<?php echo esc_attr( $tab['target'] ); ?>"><span><?php echo esc_html( $tab['label'] ); ?></span></a>
</li>
<?php endforeach; ?>
<?php do_action( 'woocommerce_product_write_panel_tabs' ); ?>

View File

@ -21,6 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( wc_product_dimensions_enabled() ) {
?><p class="form-field dimensions_field">
<?php /* translators: WooCommerce dimension unit*/ ?>
<label for="product_length"><?php printf( __( 'Dimensions (%s)', 'woocommerce' ), get_option( 'woocommerce_dimension_unit' ) ); ?></label>
<span class="wrap">
<input id="product_length" placeholder="<?php esc_attr_e( 'Length', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="_length" value="<?php echo esc_attr( wc_format_localized_decimal( $product_object->get_length( 'edit' ) ) ); ?>" />
@ -47,7 +48,7 @@ if ( ! defined( 'ABSPATH' ) ) {
'class' => 'select short',
);
?><p class="form-field dimensions_field">
<label for="product_shipping_class"><?php _e( 'Shipping class', 'woocommerce' ); ?></label>
<label for="product_shipping_class"><?php esc_html_e( 'Shipping class', 'woocommerce' ); ?></label>
<?php wp_dropdown_categories( $args ); ?>
<?php echo wc_help_tip( __( 'Shipping classes are used by certain shipping methods to group similar products.', 'woocommerce' ) ); ?>
</p><?php

View File

@ -9,20 +9,21 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php if ( ! count( $variation_attributes ) ) : ?>
<div id="message" class="inline notice woocommerce-message">
<p><?php _e( 'Before you can add a variation you need to add some variation attributes on the <strong>Attributes</strong> tab.', 'woocommerce' ); ?></p>
<p><a class="button-primary" href="<?php echo esc_url( apply_filters( 'woocommerce_docs_url', 'https://docs.woocommerce.com/document/variable-product/', 'product-variations' ) ); ?>" target="_blank"><?php _e( 'Learn more', 'woocommerce' ); ?></a></p>
<p><?php echo wp_kses_post( __( 'Before you can add a variation you need to add some variation attributes on the <strong>Attributes</strong> tab.', 'woocommerce' ) ); ?></p>
<p><a class="button-primary" href="<?php echo esc_url( apply_filters( 'woocommerce_docs_url', 'https://docs.woocommerce.com/document/variable-product/', 'product-variations' ) ); ?>" target="_blank"><?php esc_html_e( 'Learn more', 'woocommerce' ); ?></a></p>
</div>
<?php else : ?>
<div class="toolbar toolbar-variations-defaults">
<div class="variations-defaults">
<strong><?php _e( 'Default Form Values', 'woocommerce' ); ?>: <?php echo wc_help_tip( __( 'These are the attributes that will be pre-selected on the frontend.', 'woocommerce' ) ); ?></strong>
<strong><?php esc_html_e( 'Default Form Values', 'woocommerce' ); ?>: <?php echo wc_help_tip( __( 'These are the attributes that will be pre-selected on the frontend.', 'woocommerce' ) ); ?></strong>
<?php
foreach ( $variation_attributes as $attribute ) {
$selected_value = isset( $default_attributes[ sanitize_title( $attribute->get_name() ) ] ) ? $default_attributes[ sanitize_title( $attribute->get_name() ) ] : '';
?>
<select name="default_attribute_<?php echo sanitize_title( $attribute->get_name() ); ?>" data-current="<?php echo esc_attr( $selected_value ); ?>">
<?php /* translators: WooCommerce attribute label */ ?>
<option value=""><?php printf( esc_html__( 'No default %s&hellip;', 'woocommerce' ), wc_attribute_label( $attribute->get_name() ) ); ?></option>
<?php if ( $attribute->is_taxonomy() ) : ?>
<?php foreach ( $attribute->get_terms() as $option ) : ?>
@ -43,22 +44,22 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="toolbar toolbar-top">
<select id="field_to_edit" class="variation_actions">
<option data-global="true" value="add_variation"><?php _e( 'Add variation', 'woocommerce' ); ?></option>
<option data-global="true" value="link_all_variations"><?php _e( 'Create variations from all attributes', 'woocommerce' ); ?></option>
<option value="delete_all"><?php _e( 'Delete all variations', 'woocommerce' ); ?></option>
<option data-global="true" value="add_variation"><?php esc_html_e( 'Add variation', 'woocommerce' ); ?></option>
<option data-global="true" value="link_all_variations"><?php esc_html_e( 'Create variations from all attributes', 'woocommerce' ); ?></option>
<option value="delete_all"><?php esc_html_e( 'Delete all variations', 'woocommerce' ); ?></option>
<optgroup label="<?php esc_attr_e( 'Status', 'woocommerce' ); ?>">
<option value="toggle_enabled"><?php _e( 'Toggle &quot;Enabled&quot;', 'woocommerce' ); ?></option>
<option value="toggle_downloadable"><?php _e( 'Toggle &quot;Downloadable&quot;', 'woocommerce' ); ?></option>
<option value="toggle_virtual"><?php _e( 'Toggle &quot;Virtual&quot;', 'woocommerce' ); ?></option>
<option value="toggle_enabled"><?php esc_html_e( 'Toggle &quot;Enabled&quot;', 'woocommerce' ); ?></option>
<option value="toggle_downloadable"><?php esc_html_e( 'Toggle &quot;Downloadable&quot;', 'woocommerce' ); ?></option>
<option value="toggle_virtual"><?php esc_html_e( 'Toggle &quot;Virtual&quot;', 'woocommerce' ); ?></option>
</optgroup>
<optgroup label="<?php esc_attr_e( 'Pricing', 'woocommerce' ); ?>">
<option value="variable_regular_price"><?php _e( 'Set regular prices', 'woocommerce' ); ?></option>
<option value="variable_regular_price_increase"><?php _e( 'Increase regular prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
<option value="variable_regular_price_decrease"><?php _e( 'Decrease regular prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
<option value="variable_sale_price"><?php _e( 'Set sale prices', 'woocommerce' ); ?></option>
<option value="variable_sale_price_increase"><?php _e( 'Increase sale prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
<option value="variable_sale_price_decrease"><?php _e( 'Decrease sale prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
<option value="variable_sale_schedule"><?php _e( 'Set scheduled sale dates', 'woocommerce' ); ?></option>
<option value="variable_regular_price"><?php esc_html_e( 'Set regular prices', 'woocommerce' ); ?></option>
<option value="variable_regular_price_increase"><?php esc_html_e( 'Increase regular prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
<option value="variable_regular_price_decrease"><?php esc_html_e( 'Decrease regular prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
<option value="variable_sale_price"><?php esc_html_e( 'Set sale prices', 'woocommerce' ); ?></option>
<option value="variable_sale_price_increase"><?php esc_html_e( 'Increase sale prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
<option value="variable_sale_price_decrease"><?php esc_html_e( 'Decrease sale prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
<option value="variable_sale_schedule"><?php esc_html_e( 'Set scheduled sale dates', 'woocommerce' ); ?></option>
</optgroup>
<optgroup label="<?php esc_attr_e( 'Inventory', 'woocommerce' ); ?>">
<option value="toggle_manage_stock"><?php _e( 'Toggle &quot;Manage stock&quot;', 'woocommerce' ); ?></option>
@ -68,35 +69,36 @@ if ( ! defined( 'ABSPATH' ) ) {
<option value="variable_stock_status_onbackorder"><?php _e( 'Set Status - On backorder', 'woocommerce' ); ?></option>
</optgroup>
<optgroup label="<?php esc_attr_e( 'Shipping', 'woocommerce' ); ?>">
<option value="variable_length"><?php _e( 'Length', 'woocommerce' ); ?></option>
<option value="variable_width"><?php _e( 'Width', 'woocommerce' ); ?></option>
<option value="variable_height"><?php _e( 'Height', 'woocommerce' ); ?></option>
<option value="variable_weight"><?php _e( 'Weight', 'woocommerce' ); ?></option>
<option value="variable_length"><?php esc_html_e( 'Length', 'woocommerce' ); ?></option>
<option value="variable_width"><?php esc_html_e( 'Width', 'woocommerce' ); ?></option>
<option value="variable_height"><?php esc_html_e( 'Height', 'woocommerce' ); ?></option>
<option value="variable_weight"><?php esc_html_e( 'Weight', 'woocommerce' ); ?></option>
</optgroup>
<optgroup label="<?php esc_attr_e( 'Downloadable products', 'woocommerce' ); ?>">
<option value="variable_download_limit"><?php _e( 'Download limit', 'woocommerce' ); ?></option>
<option value="variable_download_expiry"><?php _e( 'Download expiry', 'woocommerce' ); ?></option>
<option value="variable_download_limit"><?php esc_html_e( 'Download limit', 'woocommerce' ); ?></option>
<option value="variable_download_expiry"><?php esc_html_e( 'Download expiry', 'woocommerce' ); ?></option>
</optgroup>
<?php do_action( 'woocommerce_variable_product_bulk_edit_actions' ); ?>
</select>
<a class="button bulk_edit do_variation_action"><?php _e( 'Go', 'woocommerce' ); ?></a>
<a class="button bulk_edit do_variation_action"><?php esc_html_e( 'Go', 'woocommerce' ); ?></a>
<div class="variations-pagenav">
<span class="displaying-num"><?php printf( _n( '%s item', '%s items', $variations_count, 'woocommerce' ), $variations_count ); ?></span>
<?php /* translators: variations count */ ?>
<span class="displaying-num"><?php printf( esc_html( _n( '%s item', '%s items', $variations_count, 'woocommerce' ), $variations_count ) ); ?></span>
<span class="expand-close">
(<a href="#" class="expand_all"><?php _e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php _e( 'Close', 'woocommerce' ); ?></a>)
(<a href="#" class="expand_all"><?php esc_html_e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php esc_html_e( 'Close', 'woocommerce' ); ?></a>)
</span>
<span class="pagination-links">
<a class="first-page disabled" title="<?php esc_attr_e( 'Go to the first page', 'woocommerce' ); ?>" href="#">&laquo;</a>
<a class="prev-page disabled" title="<?php esc_attr_e( 'Go to the previous page', 'woocommerce' ); ?>" href="#">&lsaquo;</a>
<span class="paging-select">
<label for="current-page-selector-1" class="screen-reader-text"><?php _e( 'Select Page', 'woocommerce' ); ?></label>
<label for="current-page-selector-1" class="screen-reader-text"><?php esc_html_e( 'Select Page', 'woocommerce' ); ?></label>
<select class="page-selector" id="current-page-selector-1" title="<?php esc_attr_e( 'Current page', 'woocommerce' ); ?>">
<?php for ( $i = 1; $i <= $variations_total_pages; $i++ ) : ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php endfor; ?>
</select>
<?php _ex( 'of', 'number of pages', 'woocommerce' ); ?> <span class="total-pages"><?php echo $variations_total_pages; ?></span>
<?php _ex( 'of', 'number of pages', 'woocommerce' ); ?> <span class="total-pages"><?php echo esc_html( $variations_total_pages ); ?></span>
</span>
<a class="next-page" title="<?php esc_attr_e( 'Go to the next page', 'woocommerce' ); ?>" href="#">&rsaquo;</a>
<a class="last-page" title="<?php esc_attr_e( 'Go to the last page', 'woocommerce' ); ?>" href="#">&raquo;</a>
@ -107,24 +109,25 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="woocommerce_variations wc-metaboxes" data-attributes="<?php
// esc_attr does not double encode - htmlspecialchars does
echo htmlspecialchars( json_encode( wc_list_pluck( $variation_attributes, 'get_data' ) ) );
?>" data-total="<?php echo $variations_count; ?>" data-total_pages="<?php echo $variations_total_pages; ?>" data-page="1" data-edited="false">
echo htmlspecialchars( wp_json_encode( wc_list_pluck( $variation_attributes, 'get_data' ) ) );
?>" data-total="<?php echo esc_attr( $variations_count ); ?>" data-total_pages="<?php echo esc_attr( $variations_total_pages ); ?>" data-page="1" data-edited="false">
</div>
<div class="toolbar">
<button type="button" class="button-primary save-variation-changes" disabled="disabled"><?php _e( 'Save changes', 'woocommerce' ); ?></button>
<button type="button" class="button cancel-variation-changes" disabled="disabled"><?php _e( 'Cancel', 'woocommerce' ); ?></button>
<button type="button" class="button-primary save-variation-changes" disabled="disabled"><?php esc_html_e( 'Save changes', 'woocommerce' ); ?></button>
<button type="button" class="button cancel-variation-changes" disabled="disabled"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></button>
<div class="variations-pagenav">
<?php /* translators: variations count*/ ?>
<span class="displaying-num"><?php printf( _n( '%s item', '%s items', $variations_count, 'woocommerce' ), $variations_count ); ?></span>
<span class="expand-close">
(<a href="#" class="expand_all"><?php _e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php _e( 'Close', 'woocommerce' ); ?></a>)
(<a href="#" class="expand_all"><?php esc_html_e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php esc_html_e( 'Close', 'woocommerce' ); ?></a>)
</span>
<span class="pagination-links">
<a class="first-page disabled" title="<?php esc_attr_e( 'Go to the first page', 'woocommerce' ); ?>" href="#">&laquo;</a>
<a class="prev-page disabled" title="<?php esc_attr_e( 'Go to the previous page', 'woocommerce' ); ?>" href="#">&lsaquo;</a>
<span class="paging-select">
<label for="current-page-selector-1" class="screen-reader-text"><?php _e( 'Select Page', 'woocommerce' ); ?></label>
<label for="current-page-selector-1" class="screen-reader-text"><?php esc_html_e( 'Select Page', 'woocommerce' ); ?></label>
<select class="page-selector" id="current-page-selector-1" title="<?php esc_attr_e( 'Current page', 'woocommerce' ); ?>">
<?php for ( $i = 1; $i <= $variations_total_pages; $i++ ) : ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>

View File

@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<input type="text" class="input_text" placeholder="<?php esc_attr_e( 'File name', 'woocommerce' ); ?>" name="_wc_file_names[]" value="<?php echo esc_attr( $file['name'] ); ?>" />
<input type="hidden" name="_wc_file_hashes[]" value="<?php echo esc_attr( $key ); ?>" />
</td>
<td class="file_url"><input type="text" class="input_text" placeholder="<?php esc_attr_e( "http://", 'woocommerce' ); ?>" name="_wc_file_urls[]" value="<?php echo esc_attr( $file['file'] ); ?>" /></td>
<td class="file_url_choose" width="1%"><a href="#" class="button upload_file_button" data-choose="<?php esc_attr_e( 'Choose file', 'woocommerce' ); ?>" data-update="<?php esc_attr_e( 'Insert file URL', 'woocommerce' ); ?>"><?php echo str_replace( ' ', '&nbsp;', __( 'Choose file', 'woocommerce' ) ); ?></a></td>
<td width="1%"><a href="#" class="delete"><?php _e( 'Delete', 'woocommerce' ); ?></a></td>
<td class="file_url"><input type="text" class="input_text" placeholder="<?php esc_attr_e( 'http://', 'woocommerce' ); ?>" name="_wc_file_urls[]" value="<?php echo esc_attr( $file['file'] ); ?>" /></td>
<td class="file_url_choose" width="1%"><a href="#" class="button upload_file_button" data-choose="<?php esc_attr_e( 'Choose file', 'woocommerce' ); ?>" data-update="<?php esc_attr_e( 'Insert file URL', 'woocommerce' ); ?>"><?php echo esc_html__( 'Choose file', 'woocommerce' ); ?></a></td>
<td width="1%"><a href="#" class="delete"><?php esc_html_e( 'Delete', 'woocommerce' ); ?></a></td>
</tr>

View File

@ -5,10 +5,10 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<tr>
<td class="file_name">
<input type="text" class="input_text" placeholder="<?php esc_attr_e( 'File name', 'woocommerce' ); ?>" name="_wc_variation_file_names[<?php echo $variation_id; ?>][]" value="<?php echo esc_attr( $file['name'] ); ?>" />
<input type="hidden" name="_wc_variation_file_hashes[<?php echo $variation_id; ?>][]" value="<?php echo esc_attr( $key ); ?>" />
<input type="text" class="input_text" placeholder="<?php esc_attr_e( 'File name', 'woocommerce' ); ?>" name="_wc_variation_file_names[<?php echo esc_attr( $variation_id ); ?>][]" value="<?php echo esc_attr( $file['name'] ); ?>" />
<input type="hidden" name="_wc_variation_file_hashes[<?php echo esc_attr( $variation_id ); ?>][]" value="<?php echo esc_attr( $key ); ?>" />
</td>
<td class="file_url"><input type="text" class="input_text" placeholder="<?php esc_attr_e( "http://", 'woocommerce' ); ?>" name="_wc_variation_file_urls[<?php echo $variation_id; ?>][]" value="<?php echo esc_attr( $file['file'] ); ?>" /></td>
<td class="file_url_choose" width="1%"><a href="#" class="button upload_file_button" data-choose="<?php esc_attr_e( 'Choose file', 'woocommerce' ); ?>" data-update="<?php esc_attr_e( 'Insert file URL', 'woocommerce' ); ?>"><?php echo str_replace( ' ', '&nbsp;', __( 'Choose file', 'woocommerce' ) ); ?></a></td>
<td width="1%"><a href="#" class="delete"><?php _e( 'Delete', 'woocommerce' ); ?></a></td>
<td class="file_url"><input type="text" class="input_text" placeholder="<?php esc_attr_e( 'http://', 'woocommerce' ); ?>" name="_wc_variation_file_urls[<?php echo esc_attr( $variation_id ); ?>][]" value="<?php echo esc_attr( $file['file'] ); ?>" /></td>
<td class="file_url_choose" width="1%"><a href="#" class="button upload_file_button" data-choose="<?php esc_attr_e( 'Choose file', 'woocommerce' ); ?>" data-update="<?php esc_attr_e( 'Insert file URL', 'woocommerce' ); ?>"><?php esc_html_e( 'Choose file', 'woocommerce' ); ?></a></td>
<td width="1%"><a href="#" class="delete"><?php esc_html_e( 'Delete', 'woocommerce' ); ?></a></td>
</tr>

View File

@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<div class="woocommerce_variation wc-metabox closed">
<h3>
<a href="#" class="remove_variation delete" rel="<?php echo esc_attr( $variation_id ); ?>"><?php _e( 'Remove', 'woocommerce' ); ?></a>
<a href="#" class="remove_variation delete" rel="<?php echo esc_attr( $variation_id ); ?>"><?php esc_html_e( 'Remove', 'woocommerce' ); ?></a>
<div class="handlediv" aria-label="<?php esc_attr_e( 'Click to toggle', 'woocommerce' ); ?>"></div>
<div class="tips sort" data-tip="<?php esc_attr_e( 'Drag and drop, or click to set admin variation order', 'woocommerce' ); ?>"></div>
<strong>#<?php echo esc_html( $variation_id ); ?> </strong>
@ -44,14 +44,14 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php
}
?>
<input type="hidden" name="variable_post_id[<?php echo $loop; ?>]" value="<?php echo esc_attr( $variation_id ); ?>" />
<input type="hidden" class="variation_menu_order" name="variation_menu_order[<?php echo $loop; ?>]" value="<?php echo esc_attr( $variation_object->get_menu_order( 'edit' ) ); ?>" />
<input type="hidden" name="variable_post_id[<?php echo esc_attr( $loop ); ?>]" value="<?php echo esc_attr( $variation_id ); ?>" />
<input type="hidden" class="variation_menu_order" name="variation_menu_order[<?php echo esc_attr( $loop ); ?>]" value="<?php echo esc_attr( $variation_object->get_menu_order( 'edit' ) ); ?>" />
</h3>
<div class="woocommerce_variable_attributes wc-metabox-content" style="display: none;">
<div class="data">
<p class="form-row form-row-first upload_image">
<a href="#" class="upload_image_button tips <?php echo $variation_object->get_image_id( 'edit' ) ? 'remove' : ''; ?>" data-tip="<?php echo $variation_object->get_image_id( 'edit' ) ? esc_attr__( 'Remove this image', 'woocommerce' ) : esc_attr__( 'Upload an image', 'woocommerce' ); ?>" rel="<?php echo esc_attr( $variation_id ); ?>">
<img src="<?php echo $variation_object->get_image_id( 'edit' ) ? esc_url( wp_get_attachment_thumb_url( $variation_object->get_image_id( 'edit' ) ) ) : esc_url( wc_placeholder_img_src() ); ?>" /><input type="hidden" name="upload_image_id[<?php echo $loop; ?>]" class="upload_image_id" value="<?php echo esc_attr( $variation_object->get_image_id( 'edit' ) ); ?>" />
<img src="<?php echo $variation_object->get_image_id( 'edit' ) ? esc_url( wp_get_attachment_thumb_url( $variation_object->get_image_id( 'edit' ) ) ) : esc_url( wc_placeholder_img_src() ); ?>" /><input type="hidden" name="upload_image_id[<?php echo esc_attr( $loop ); ?>]" class="upload_image_id" value="<?php echo esc_attr( $variation_object->get_image_id( 'edit' ) ); ?>" />
</a>
</p>
<?php
@ -70,22 +70,22 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<p class="form-row form-row-full options">
<label>
<?php _e( 'Enabled', 'woocommerce' ); ?>:
<input type="checkbox" class="checkbox" name="variable_enabled[<?php echo $loop; ?>]" <?php checked( in_array( $variation_object->get_status( 'edit' ), array( 'publish', false ) ), true ); ?> />
<?php esc_html_e( 'Enabled', 'woocommerce' ); ?>:
<input type="checkbox" class="checkbox" name="variable_enabled[<?php echo $loop; ?>]" <?php checked( in_array( $variation_object->get_status( 'edit' ), array( 'publish', false ), true ), true ); ?> />
</label>
<label class="tips" data-tip="<?php _e( 'Enable this option if access is given to a downloadable file upon purchase of a product', 'woocommerce' ); ?>">
<?php _e( 'Downloadable', 'woocommerce' ); ?>:
<input type="checkbox" class="checkbox variable_is_downloadable" name="variable_is_downloadable[<?php echo $loop; ?>]" <?php checked( $variation_object->get_downloadable( 'edit' ), true ); ?> />
<label class="tips" data-tip="<?php esc_html_e( 'Enable this option if access is given to a downloadable file upon purchase of a product', 'woocommerce' ); ?>">
<?php esc_html_e( 'Downloadable', 'woocommerce' ); ?>:
<input type="checkbox" class="checkbox variable_is_downloadable" name="variable_is_downloadable[<?php echo esc_attr( $loop ); ?>]" <?php checked( $variation_object->get_downloadable( 'edit' ), true ); ?> />
</label>
<label class="tips" data-tip="<?php _e( 'Enable this option if a product is not shipped or there is no shipping cost', 'woocommerce' ); ?>">
<?php _e( 'Virtual', 'woocommerce' ); ?>:
<input type="checkbox" class="checkbox variable_is_virtual" name="variable_is_virtual[<?php echo $loop; ?>]" <?php checked( $variation_object->get_virtual( 'edit' ), true ); ?> />
<label class="tips" data-tip="<?php esc_html_e( 'Enable this option if a product is not shipped or there is no shipping cost', 'woocommerce' ); ?>">
<?php esc_html_e( 'Virtual', 'woocommerce' ); ?>:
<input type="checkbox" class="checkbox variable_is_virtual" name="variable_is_virtual[<?php echo esc_attr( $loop ); ?>]" <?php checked( $variation_object->get_virtual( 'edit' ), true ); ?> />
</label>
<?php if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) : ?>
<label class="tips" data-tip="<?php _e( 'Enable this option to enable stock management at variation level', 'woocommerce' ); ?>">
<?php _e( 'Manage stock?', 'woocommerce' ); ?>
<input type="checkbox" class="checkbox variable_manage_stock" name="variable_manage_stock[<?php echo $loop; ?>]" <?php checked( $variation_object->get_manage_stock( 'edit' ), true ); ?> />
<label class="tips" data-tip="<?php esc_html_e( 'Enable this option to enable stock management at variation level', 'woocommerce' ); ?>">
<?php esc_html_e( 'Manage stock?', 'woocommerce' ); ?>
<input type="checkbox" class="checkbox variable_manage_stock" name="variable_manage_stock[<?php echo esc_attr( $loop ); ?>]" <?php checked( $variation_object->get_manage_stock( 'edit' ), true ); ?> />
</label>
<?php endif; ?>
@ -94,8 +94,8 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="variable_pricing">
<?php
/* translators: %s: currency symbol */
$label = sprintf(
/* translators: %s: currency symbol */
__( 'Regular price (%s)', 'woocommerce' ),
get_woocommerce_currency_symbol()
);
@ -109,9 +109,9 @@ if ( ! defined( 'ABSPATH' ) ) {
'wrapper_class' => 'form-row form-row-first',
'placeholder' => __( 'Variation price (required)', 'woocommerce' ),
) );
/* translators: %s: currency symbol */
$label = sprintf(
/* translators: %s: currency symbol */
__( 'Sale price (%s)', 'woocommerce' ),
get_woocommerce_currency_symbol()
);
@ -121,7 +121,7 @@ if ( ! defined( 'ABSPATH' ) ) {
'name' => "variable_sale_price[{$loop}]",
'value' => wc_format_localized_price( $variation_object->get_sale_price( 'edit' ) ),
'data_type' => 'price',
'label' => $label . ' <a href="#" class="sale_schedule">' . __( 'Schedule', 'woocommerce' ) . '</a><a href="#" class="cancel_sale_schedule hidden">' . __( 'Cancel schedule', 'woocommerce' ) . '</a>',
'label' => $label . ' <a href="#" class="sale_schedule">' . esc_html__( 'Schedule', 'woocommerce' ) . '</a><a href="#" class="cancel_sale_schedule hidden">' . esc_html__( 'Cancel schedule', 'woocommerce' ) . '</a>',
'wrapper_class' => 'form-row form-row-last',
) );
@ -135,7 +135,7 @@ if ( ! defined( 'ABSPATH' ) ) {
</p>
<p class="form-row form-row-last">
<label>' . __( 'Sale end date', 'woocommerce' ) . '</label>
<input type="text" class="sale_price_dates_to" name="variable_sale_price_dates_to[' . $loop . ']" value="' . esc_attr( $sale_price_dates_to ) . '" placeholder="' . _x( 'To&hellip;', 'placeholder', 'woocommerce' ) . ' YYYY-MM-DD" maxlength="10" pattern="' . esc_attr( apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ) . '" />
<input type="text" class="sale_price_dates_to" name="variable_sale_price_dates_to[' . esc_attr( $loop ) . ']" value="' . esc_attr( $sale_price_dates_to ) . '" placeholder="' . esc_html_x( 'To&hellip;', 'placeholder', 'woocommerce' ) . ' YYYY-MM-DD" maxlength="10" pattern="' . esc_attr( apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ) . '" />
</p>
</div>';
@ -170,7 +170,7 @@ if ( ! defined( 'ABSPATH' ) ) {
'wrapper_class' => 'form-row form-row-first',
) );
echo '<input type="hidden" name="variable_original_stock[' . $loop . ']" value="' . esc_attr( wc_stock_amount( $variation_object->get_stock_quantity( 'edit' ) ) ) . '" />';
echo '<input type="hidden" name="variable_original_stock[' . esc_attr( $loop ) . ']" value="' . esc_attr( wc_stock_amount( $variation_object->get_stock_quantity( 'edit' ) ) ) . '" />';
woocommerce_wp_select( array(
'id' => "variable_backorders{$loop}",
@ -211,8 +211,8 @@ if ( ! defined( 'ABSPATH' ) ) {
) );
if ( wc_product_weight_enabled() ) {
/* translators: %s: weight unit */
$label = sprintf(
/* translators: %s: weight unit */
__( 'Weight (%s)', 'woocommerce' ),
esc_html( get_option( 'woocommerce_weight_unit' ) )
);
@ -238,17 +238,17 @@ if ( ! defined( 'ABSPATH' ) ) {
?><p class="form-field form-row dimensions_field hide_if_variation_virtual form-row-last">
<label for="product_length"><?php
/* translators: %s: dimension unit */
printf(
__( 'Dimensions (L&times;W&times;H) (%s)', 'woocommerce' ),
/* translators: %s: dimension unit */
esc_html__( 'Dimensions (L&times;W&times;H) (%s)', 'woocommerce' ),
get_option( 'woocommerce_dimension_unit' )
);
?></label>
<?php echo wc_help_tip( __( 'Length x width x height in decimal form', 'woocommerce' ) ); ?>
<span class="wrap">
<input id="product_length" placeholder="<?php echo $parent_length ? esc_attr( $parent_length ) : esc_attr__( 'Length', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="variable_length[<?php echo $loop; ?>]" value="<?php echo esc_attr( wc_format_localized_decimal( $variation_object->get_length( 'edit' ) ) ); ?>" />
<input placeholder="<?php echo $parent_width ? esc_attr( $parent_width ) : esc_attr__( 'Width', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="variable_width[<?php echo $loop; ?>]" value="<?php echo esc_attr( wc_format_localized_decimal( $variation_object->get_width( 'edit' ) ) ); ?>" />
<input placeholder="<?php echo $parent_height ? esc_attr( $parent_height ) : esc_attr__( 'Height', 'woocommerce' ); ?>" class="input-text wc_input_decimal last" size="6" type="text" name="variable_height[<?php echo $loop; ?>]" value="<?php echo esc_attr( wc_format_localized_decimal( $variation_object->get_height( 'edit' ) ) ); ?>" />
<input id="product_length" placeholder="<?php echo $parent_length ? esc_attr( $parent_length ) : esc_attr__( 'Length', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="variable_length[<?php echo esc_attr( $loop ); ?>]" value="<?php echo esc_attr( wc_format_localized_decimal( $variation_object->get_length( 'edit' ) ) ); ?>" />
<input placeholder="<?php echo $parent_width ? esc_attr( $parent_width ) : esc_attr__( 'Width', 'woocommerce' ); ?>" class="input-text wc_input_decimal" size="6" type="text" name="variable_width[<?php echo esc_attr( $loop ); ?>]" value="<?php echo esc_attr( wc_format_localized_decimal( $variation_object->get_width( 'edit' ) ) ); ?>" />
<input placeholder="<?php echo $parent_height ? esc_attr( $parent_height ) : esc_attr__( 'Height', 'woocommerce' ); ?>" class="input-text wc_input_decimal last" size="6" type="text" name="variable_height[<?php echo esc_attr( $loop ); ?>]" value="<?php echo esc_attr( wc_format_localized_decimal( $variation_object->get_height( 'edit' ) ) ); ?>" />
</span>
</p><?php
}
@ -267,7 +267,7 @@ if ( ! defined( 'ABSPATH' ) ) {
</div>
<div>
<p class="form-row hide_if_variation_virtual form-row-full"><label><?php _e( 'Shipping class', 'woocommerce' ); ?></label> <?php
<p class="form-row hide_if_variation_virtual form-row-full"><label><?php esc_html_e( 'Shipping class', 'woocommerce' ); ?></label> <?php
wp_dropdown_categories( array(
'taxonomy' => 'product_shipping_class',
'hide_empty' => 0,
@ -319,12 +319,12 @@ if ( ! defined( 'ABSPATH' ) ) {
</div>
<div class="show_if_variation_downloadable" style="display: none;">
<div class="form-row form-row-full downloadable_files">
<label><?php _e( 'Downloadable files', 'woocommerce' ); ?></label>
<label><?php esc_html_e( 'Downloadable files', 'woocommerce' ); ?></label>
<table class="widefat">
<thead>
<div>
<th><?php _e( 'Name', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the name of the download shown to the customer.', 'woocommerce' ) ); ?></th>
<th colspan="2"><?php _e( 'File URL', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the URL or absolute path to the file which customers will get access to. URLs entered here should already be encoded.', 'woocommerce' ) ); ?></th>
<th><?php esc_html_e( 'Name', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the name of the download shown to the customer.', 'woocommerce' ) ); ?></th>
<th colspan="2"><?php esc_html_e( 'File URL', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the URL or absolute path to the file which customers will get access to. URLs entered here should already be encoded.', 'woocommerce' ) ); ?></th>
<th>&nbsp;</th>
</div>
</thead>
@ -349,7 +349,7 @@ if ( ! defined( 'ABSPATH' ) ) {
ob_start();
include( 'html-product-variation-download.php' );
echo esc_attr( ob_get_clean() );
?>"><?php _e( 'Add file', 'woocommerce' ); ?></a>
?>"><?php esc_html_e( 'Add file', 'woocommerce' ); ?></a>
</th>
</div>
</tfoot>

View File

@ -658,8 +658,12 @@ class WC_Admin_Report {
return;
}
if ( ! isset( $_GET['wc_reports_nonce'] ) || ! wp_verify_nonce( $_GET['wc_reports_nonce'], 'custom_range' ) ) {
wp_safe_redirect( remove_query_arg( array( 'start_date', 'end_date', 'range', 'wc_reports_nonce' ) ) );
if ( ! isset( $_GET['wc_reports_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_GET['wc_reports_nonce'] ), 'custom_range' ) ) { // WPCS: input var ok, CSRF ok.
wp_die(
/* translators: %1$s: open link, %2$s: close link */
sprintf( esc_html__( 'This report link has expired. %1$sClick here to view the filtered report%2$s.', 'woocommerce' ), '<a href="' . esc_url( wp_nonce_url( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'custom_range', 'wc_reports_nonce' ) ) . '">', '</a>' ), // @codingStandardsIgnoreLine.
esc_attr__( 'Confirm navigation', 'woocommerce' )
);
exit;
}
}

View File

@ -507,7 +507,7 @@ class WC_REST_Coupons_Controller extends WC_REST_Legacy_Coupons_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
),

View File

@ -354,7 +354,7 @@ class WC_REST_Customers_Controller extends WC_REST_Customers_V1_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
),

View File

@ -401,7 +401,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Orders_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
),
@ -422,12 +422,12 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Orders_Controller {
),
'name' => array(
'description' => __( 'Product name.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'product_id' => array(
'description' => __( 'Product ID.', 'woocommerce' ),
'type' => 'integer',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'variation_id' => array(
@ -513,7 +513,7 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Orders_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
),

View File

@ -597,8 +597,9 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
protected function maybe_set_item_meta_data( $item, $posted ) {
if ( ! empty( $posted['meta_data'] ) && is_array( $posted['meta_data'] ) ) {
foreach ( $posted['meta_data'] as $meta ) {
if ( isset( $meta['key'], $meta['value'] ) ) {
$item->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' );
if ( isset( $meta['key'] ) ) {
$value = isset( $meta['value'] ) ? $meta['value'] : null;
$item->update_meta_data( $meta['key'], $value, isset( $meta['id'] ) ? $meta['id'] : '' );
}
}
}
@ -1118,7 +1119,7 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
),
@ -1139,12 +1140,12 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
),
'name' => array(
'description' => __( 'Product name.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'product_id' => array(
'description' => __( 'Product ID.', 'woocommerce' ),
'type' => 'integer',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'variation_id' => array(
@ -1230,7 +1231,7 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
),
@ -1321,7 +1322,7 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
),
@ -1345,12 +1346,12 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
),
'method_title' => array(
'description' => __( 'Shipping method name.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'method_id' => array(
'description' => __( 'Shipping method ID.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'total' => array(
@ -1407,7 +1408,7 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
),
@ -1431,7 +1432,7 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
),
'name' => array(
'description' => __( 'Fee name.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'tax_class' => array(
@ -1505,7 +1506,7 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
),
@ -1529,7 +1530,7 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
),
'code' => array(
'description' => __( 'Coupon code.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'discount' => array(
@ -1563,7 +1564,7 @@ class WC_REST_Orders_Controller extends WC_REST_Legacy_Orders_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
),

View File

@ -945,7 +945,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
),

View File

@ -1991,7 +1991,7 @@ class WC_REST_Products_Controller extends WC_REST_Legacy_Products_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
),

View File

@ -378,7 +378,7 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
),
'name' => array(
'description' => __( 'Product name.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
@ -390,7 +390,7 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
),
'product_id' => array(
'description' => __( 'Product ID.', 'woocommerce' ),
'type' => 'integer',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'variation_id' => array(
@ -486,7 +486,7 @@ class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),

View File

@ -1211,7 +1211,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
),
'name' => array(
'description' => __( 'Product name.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
@ -1223,7 +1223,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
),
'product_id' => array(
'description' => __( 'Product ID.', 'woocommerce' ),
'type' => 'integer',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'variation_id' => array(
@ -1319,7 +1319,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
@ -1397,12 +1397,12 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
),
'method_title' => array(
'description' => __( 'Shipping method name.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'method_id' => array(
'description' => __( 'Shipping method ID.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'total' => array(
@ -1457,7 +1457,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
),
'name' => array(
'description' => __( 'Fee name.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'tax_class' => array(
@ -1528,7 +1528,7 @@ class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
),
'code' => array(
'description' => __( 'Coupon code.', 'woocommerce' ),
'type' => 'string',
'type' => 'mixed',
'context' => array( 'view', 'edit' ),
),
'discount' => array(

View File

@ -388,7 +388,7 @@ class WC_AJAX {
}
/**
* AJAX add to cart.
* AJAX remove from cart.
*/
public static function remove_from_cart() {
ob_start();

View File

@ -227,7 +227,7 @@ final class WC_Cart_Totals {
$item->taxable = 'taxable' === $cart_item['data']->get_tax_status();
$item->price_includes_tax = wc_prices_include_tax();
$item->quantity = $cart_item['quantity'];
$item->price = wc_add_number_precision_deep( $cart_item['data']->get_price() ) * $cart_item['quantity'];
$item->price = wc_add_number_precision_deep( $cart_item['data']->get_price() * $cart_item['quantity'] );
$item->product = $cart_item['data'];
$item->tax_rates = $this->get_item_tax_rates( $item );
$this->items[ $cart_item_key ] = $item;

View File

@ -981,6 +981,23 @@ class WC_Cart extends WC_Legacy_Cart {
return array_unique( $found_tax_classes );
}
/**
* Get all tax classes for shipping based on the items in the cart.
*
* @return array
*/
public function get_cart_item_tax_classes_for_shipping() {
$found_tax_classes = array();
foreach ( WC()->cart->get_cart() as $item ) {
if ( $item['data'] && ( $item['data']->is_shipping_taxable() ) ) {
$found_tax_classes[] = $item['data']->get_tax_class();
}
}
return array_unique( $found_tax_classes );
}
/**
* Determines the value that the customer spent and the subtotal
* displayed, used for things like coupon validation.
@ -1085,7 +1102,7 @@ class WC_Cart extends WC_Legacy_Cart {
}
// Load cart item data - may be added by other plugins.
$cart_item_data = (array) apply_filters( 'woocommerce_add_cart_item_data', $cart_item_data, $product_id, $variation_id );
$cart_item_data = (array) apply_filters( 'woocommerce_add_cart_item_data', $cart_item_data, $product_id, $variation_id, $quantity );
// Generate a ID based on product ID, variation ID, variation data, and other cart item data.
$cart_id = $this->generate_cart_id( $product_id, $variation_id, $variation, $cart_item_data );

View File

@ -469,7 +469,7 @@ class WC_Checkout {
* @param WC_Cart $cart
*/
public function create_order_tax_lines( &$order, $cart ) {
foreach ( array_keys( $cart->get_cart_contents_taxes() + $cart->get_shipping_taxes() ) as $tax_rate_id ) {
foreach ( array_keys( $cart->get_cart_contents_taxes() + $cart->get_shipping_taxes() + $cart->get_fee_taxes() ) as $tax_rate_id ) {
if ( $tax_rate_id && apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) !== $tax_rate_id ) {
$item = new WC_Order_Item_Tax();
$item->set_props( array(

View File

@ -887,7 +887,7 @@ class WC_Form_Handler {
// Don't use wc_clean as it destroys sanitized characters.
$value = sanitize_title( wp_unslash( $_REQUEST[ $taxonomy ] ) );
} else {
$value = wc_clean( wp_unslash( $_REQUEST[ $taxonomy ] ) ); // WPCS: sanitization ok.
$value = html_entity_decode( wc_clean( wp_unslash( $_REQUEST[ $taxonomy ] ) ), ENT_QUOTES, get_bloginfo( 'charset' ) ); // WPCS: sanitization ok.
}
// Allow if valid or show error.

View File

@ -258,7 +258,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
$meta->value = rawurldecode( (string) $meta->value );
$attribute_key = str_replace( 'attribute_', '', $meta->key );
$display_key = wc_attribute_label( $attribute_key, $product );
$display_value = $meta->value;
$display_value = sanitize_text_field( $meta->value );
if ( taxonomy_exists( $attribute_key ) ) {
$term = get_term_by( 'slug', $meta->value, $attribute_key );

View File

@ -29,6 +29,7 @@ class WC_Post_types {
add_action( 'init', array( __CLASS__, 'register_post_status' ), 9 );
add_action( 'init', array( __CLASS__, 'support_jetpack_omnisearch' ) );
add_filter( 'rest_api_allowed_post_types', array( __CLASS__, 'rest_api_allowed_post_types' ) );
add_action( 'woocommerce_after_register_post_type', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
add_action( 'woocommerce_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
}
@ -529,6 +530,18 @@ class WC_Post_types {
}
}
/**
* Flush rules if the event is queued.
*
* @since 3.3.0
*/
public static function maybe_flush_rewrite_rules() {
if ( 'true' === get_option( 'woocommerce_queue_flush_rewrite_rules' ) ) {
delete_option( 'woocommerce_queue_flush_rewrite_rules' );
self::flush_rewrite_rules();
}
}
/**
* Flush rewrite rules.
*/

View File

@ -3,7 +3,7 @@
* Contains the query functions for WooCommerce which alter the front-end post queries and loops
*
* @version 3.2.0
* @package WooCommerce/Classes
* @package WooCommerce\Classes
* @author Automattic
*/
@ -50,7 +50,9 @@ class WC_Query {
* Get any errors from querystring.
*/
public function get_errors() {
if ( ! empty( $_GET['wc_error'] ) && ( $error = sanitize_text_field( $_GET['wc_error'] ) ) && ! wc_has_notice( $error, 'error' ) ) {
$error = ! empty( $_GET['wc_error'] ) ? sanitize_text_field( wp_unslash( $_GET['wc_error'] ) ) : ''; // WPCS: input var ok, CSRF ok.
if ( $error && ! wc_has_notice( $error, 'error' ) ) {
wc_add_notice( $error, 'error' );
}
}
@ -81,53 +83,54 @@ class WC_Query {
/**
* Get page title for an endpoint.
* @param string
*
* @param string $endpoint Endpoint key.
* @return string
*/
public function get_endpoint_title( $endpoint ) {
global $wp;
switch ( $endpoint ) {
case 'order-pay' :
case 'order-pay':
$title = __( 'Pay for order', 'woocommerce' );
break;
case 'order-received' :
break;
case 'order-received':
$title = __( 'Order received', 'woocommerce' );
break;
case 'orders' :
break;
case 'orders':
if ( ! empty( $wp->query_vars['orders'] ) ) {
/* translators: %s: page */
$title = sprintf( __( 'Orders (page %d)', 'woocommerce' ), intval( $wp->query_vars['orders'] ) );
} else {
$title = __( 'Orders', 'woocommerce' );
}
break;
case 'view-order' :
break;
case 'view-order':
$order = wc_get_order( $wp->query_vars['view-order'] );
/* translators: %s: order number */
$title = ( $order ) ? sprintf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ) : '';
break;
case 'downloads' :
break;
case 'downloads':
$title = __( 'Downloads', 'woocommerce' );
break;
case 'edit-account' :
break;
case 'edit-account':
$title = __( 'Account details', 'woocommerce' );
break;
case 'edit-address' :
break;
case 'edit-address':
$title = __( 'Addresses', 'woocommerce' );
break;
case 'payment-methods' :
break;
case 'payment-methods':
$title = __( 'Payment methods', 'woocommerce' );
break;
case 'add-payment-method' :
break;
case 'add-payment-method':
$title = __( 'Add payment method', 'woocommerce' );
break;
case 'lost-password' :
break;
case 'lost-password':
$title = __( 'Lost password', 'woocommerce' );
break;
default :
break;
default:
$title = '';
break;
break;
}
return apply_filters( 'woocommerce_endpoint_' . $endpoint . '_title', $title, $endpoint );
@ -145,7 +148,7 @@ class WC_Query {
$myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' );
$checkout_page_id = get_option( 'woocommerce_checkout_page_id' );
if ( in_array( $page_on_front, array( $myaccount_page_id, $checkout_page_id ) ) ) {
if ( in_array( $page_on_front, array( $myaccount_page_id, $checkout_page_id ), true ) ) {
return EP_ROOT | EP_PAGES;
}
}
@ -159,7 +162,7 @@ class WC_Query {
public function add_endpoints() {
$mask = $this->get_endpoints_mask();
foreach ( $this->query_vars as $key => $var ) {
foreach ( $this->get_query_vars() as $key => $var ) {
if ( ! empty( $var ) ) {
add_rewrite_endpoint( $var, $mask );
}
@ -170,7 +173,8 @@ class WC_Query {
* Add query vars.
*
* @access public
* @param array $vars
*
* @param array $vars Query vars.
* @return array
*/
public function add_query_vars( $vars ) {
@ -210,10 +214,10 @@ class WC_Query {
public function parse_request() {
global $wp;
// Map query vars to their keys, or get them if endpoints are not supported
// Map query vars to their keys, or get them if endpoints are not supported.
foreach ( $this->get_query_vars() as $key => $var ) {
if ( isset( $_GET[ $var ] ) ) {
$wp->query_vars[ $key ] = $_GET[ $var ];
if ( isset( $_GET[ $var ] ) ) { // WPCS: input var ok, CSRF ok.
$wp->query_vars[ $key ] = sanitize_text_field( wp_unslash( $_GET[ $var ] ) ); // WPCS: input var ok, CSRF ok.
} elseif ( isset( $wp->query_vars[ $var ] ) ) {
$wp->query_vars[ $key ] = $wp->query_vars[ $var ];
}
@ -223,8 +227,7 @@ class WC_Query {
/**
* Are we currently on the front page?
*
* @param object $q
*
* @param WP_Query $q Query instance.
* @return bool
*/
private function is_showing_page_on_front( $q ) {
@ -234,8 +237,7 @@ class WC_Query {
/**
* Is the front page a page we define?
*
* @param int $page_id
*
* @param int $page_id Page ID.
* @return bool
*/
private function page_on_front_is( $page_id ) {
@ -245,18 +247,18 @@ class WC_Query {
/**
* Hook into pre_get_posts to do the main product query.
*
* @param object $q query object
* @param WP_Query $q Query instance.
*/
public function pre_get_posts( $q ) {
// We only want to affect the main query
// We only want to affect the main query.
if ( ! $q->is_main_query() ) {
return;
}
// Fix for endpoints on the homepage
// Fix for endpoints on the homepage.
if ( $this->is_showing_page_on_front( $q ) && ! $this->page_on_front_is( $q->get( 'page_id' ) ) ) {
$_query = wp_parse_args( $q->query );
if ( ! empty( $_query ) && array_intersect( array_keys( $_query ), array_keys( $this->query_vars ) ) ) {
if ( ! empty( $_query ) && array_intersect( array_keys( $_query ), array_keys( $this->get_query_vars() ) ) ) {
$q->is_page = true;
$q->is_home = false;
$q->is_singular = true;
@ -276,14 +278,14 @@ class WC_Query {
}
}
// Fix product feeds
// Fix product feeds.
if ( $q->is_feed() && $q->is_post_type_archive( 'product' ) ) {
$q->is_comment_feed = false;
}
// Special check for shops with the product archive on front
// Special check for shops with the product archive on front.
if ( $q->is_page() && 'page' === get_option( 'show_on_front' ) && absint( $q->get( 'page_id' ) ) === wc_get_page_id( 'shop' ) ) {
// This is a front-page shop
// This is a front-page shop.
$q->set( 'post_type', 'product' );
$q->set( 'page_id', '' );
@ -291,54 +293,55 @@ class WC_Query {
$q->set( 'paged', $q->query['paged'] );
}
// Define a variable so we know this is the front page shop later on
// Define a variable so we know this is the front page shop later on.
wc_maybe_define_constant( 'SHOP_IS_ON_FRONT', true );
// Get the actual WP page to avoid errors and let us use is_front_page()
// This is hacky but works. Awaiting https://core.trac.wordpress.org/ticket/21096
// Get the actual WP page to avoid errors and let us use is_front_page().
// This is hacky but works. Awaiting https://core.trac.wordpress.org/ticket/21096.
global $wp_post_types;
$shop_page = get_post( wc_get_page_id( 'shop' ) );
$shop_page = get_post( wc_get_page_id( 'shop' ) );
$wp_post_types['product']->ID = $shop_page->ID;
$wp_post_types['product']->post_title = $shop_page->post_title;
$wp_post_types['product']->post_name = $shop_page->post_name;
$wp_post_types['product']->post_type = $shop_page->post_type;
$wp_post_types['product']->ancestors = get_ancestors( $shop_page->ID, $shop_page->post_type );
$wp_post_types['product']->ID = $shop_page->ID;
$wp_post_types['product']->post_title = $shop_page->post_title;
$wp_post_types['product']->post_name = $shop_page->post_name;
$wp_post_types['product']->post_type = $shop_page->post_type;
$wp_post_types['product']->ancestors = get_ancestors( $shop_page->ID, $shop_page->post_type );
// Fix conditional Functions like is_front_page
// Fix conditional Functions like is_front_page.
$q->is_singular = false;
$q->is_post_type_archive = true;
$q->is_archive = true;
$q->is_page = true;
// Remove post type archive name from front page title tag
// Remove post type archive name from front page title tag.
add_filter( 'post_type_archive_title', '__return_empty_string', 5 );
// Fix WP SEO
// Fix WP SEO.
if ( class_exists( 'WPSEO_Meta' ) ) {
add_filter( 'wpseo_metadesc', array( $this, 'wpseo_metadesc' ) );
add_filter( 'wpseo_metakey', array( $this, 'wpseo_metakey' ) );
}
// Only apply to product categories, the product post archive, the shop page, product tags, and product attribute taxonomies
} elseif ( ! $q->is_post_type_archive( 'product' ) && ! $q->is_tax( get_object_taxonomies( 'product' ) ) ) {
// Only apply to product categories, the product post archive, the shop page, product tags, and product attribute taxonomies.
return;
}
$this->product_query( $q );
// And remove the pre_get_posts hook
// And remove the pre_get_posts hook.
$this->remove_product_query();
}
/**
* Search post excerpt.
*
* @deprecated 3.2.0 - Not needed anymore since WordPress 4.5.
* @param string $deprecated Deprecated.
*/
public function search_post_excerpt( $where = '' ) {
public function search_post_excerpt( $deprecated = '' ) {
wc_deprecated_function( 'WC_Query::search_post_excerpt', '3.2.0', 'Excerpt added to search query by default since WordPress 4.5.' );
return $where;
return $deprecated;
}
/**
@ -346,7 +349,6 @@ class WC_Query {
*
* Hooked into wpseo_ hook already, so no need for function_exist.
*
* @access public
* @return string
*/
public function wpseo_metadesc() {
@ -366,9 +368,10 @@ class WC_Query {
}
/**
* Query the products, applying sorting/ordering etc. This applies to the main wordpress loop.
* Query the products, applying sorting/ordering etc.
* This applies to the main WordPress loop.
*
* @param mixed $q
* @param WP_Query $q Query instance.
*/
public function product_query( $q ) {
if ( ! is_feed() ) {
@ -381,7 +384,7 @@ class WC_Query {
}
}
// Query vars that affect posts shown
// Query vars that affect posts shown.
$q->set( 'meta_query', $this->get_meta_query( $q->get( 'meta_query' ), true ) );
$q->set( 'tax_query', $this->get_tax_query( $q->get( 'tax_query' ), true ) );
$q->set( 'posts_per_page', $q->get( 'posts_per_page' ) ? $q->get( 'posts_per_page' ) : apply_filters( 'loop_shop_per_page', get_option( 'posts_per_page' ) ) );
@ -391,7 +394,6 @@ class WC_Query {
do_action( 'woocommerce_product_query', $q, $this );
}
/**
* Remove the query.
*/
@ -411,6 +413,7 @@ class WC_Query {
/**
* Remove the posts_where filter.
*
* @deprecated 3.2.0 - Nothing to remove anymore because search_post_excerpt() is deprecated.
*/
public function remove_posts_where() {
@ -420,19 +423,17 @@ class WC_Query {
/**
* Returns an array of arguments for ordering products based on the selected values.
*
* @access public
*
* @param string $orderby
* @param string $order
* @param string $orderby Order by.
* @param string $order Sorting order.
*
* @return array
*/
public function get_catalog_ordering_args( $orderby = '', $order = '' ) {
// Get ordering from query string unless defined
// Get ordering from query string unless defined.
if ( ! $orderby ) {
$orderby_value = isset( $_GET['orderby'] ) ? wc_clean( (string) $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
$orderby_value = isset( $_GET['orderby'] ) ? wc_clean( wp_unslash( (string) $_GET['orderby'] ) ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); // WPCS: input var ok, CSRF ok.
// Get order + orderby args from string
// Get order + orderby args from string.
$orderby_value = explode( '-', $orderby_value );
$orderby = esc_attr( $orderby_value[0] );
$order = ! empty( $orderby_value[1] ) ? $orderby_value[1] : $order;
@ -443,49 +444,49 @@ class WC_Query {
$args = array(
'orderby' => 'relevance',
'order' => 'DESC',
'meta_key' => '',
'meta_key' => '', // WPCS: slow query ok.
);
// Set to default. Menu order for non-searches, relevance for searches.
if ( ! is_search() ) {
$args['orderby'] = 'menu_order title';
$args['order'] = ( 'DESC' === $order ) ? 'DESC' : 'ASC';
$args['meta_key'] = '';
$args['meta_key'] = ''; // WPCS: slow query ok.
}
switch ( $orderby ) {
case 'rand' :
case 'rand':
$args['orderby'] = 'rand';
break;
case 'date' :
case 'date':
$args['orderby'] = 'date ID';
$args['order'] = ( 'ASC' === $order ) ? 'ASC' : 'DESC';
break;
case 'price' :
case 'price':
if ( 'DESC' === $order ) {
add_filter( 'posts_clauses', array( $this, 'order_by_price_desc_post_clauses' ) );
} else {
add_filter( 'posts_clauses', array( $this, 'order_by_price_asc_post_clauses' ) );
}
break;
case 'popularity' :
$args['meta_key'] = 'total_sales';
case 'popularity':
$args['meta_key'] = 'total_sales'; // WPCS: slow query ok.
// Sorting handled later though a hook
// Sorting handled later though a hook.
add_filter( 'posts_clauses', array( $this, 'order_by_popularity_post_clauses' ) );
break;
case 'rating' :
$args['meta_key'] = '_wc_average_rating';
case 'rating':
$args['meta_key'] = '_wc_average_rating'; // WPCS: slow query ok.
$args['orderby'] = array(
'meta_value_num' => 'DESC',
'ID' => 'ASC',
);
break;
case 'title' :
case 'title':
$args['orderby'] = 'title';
$args['order'] = ( 'DESC' === $order ) ? 'DESC' : 'ASC';
break;
case 'relevance' :
case 'relevance':
$args['orderby'] = 'relevance';
$args['order'] = 'DESC';
break;
@ -497,8 +498,7 @@ class WC_Query {
/**
* Handle numeric price sorting.
*
* @access public
* @param array $args
* @param array $args Query args.
* @return array
*/
public function order_by_price_asc_post_clauses( $args ) {
@ -527,8 +527,7 @@ class WC_Query {
/**
* Handle numeric price sorting.
*
* @access public
* @param array $args
* @param array $args Query args.
* @return array
*/
public function order_by_price_desc_post_clauses( $args ) {
@ -560,8 +559,7 @@ class WC_Query {
*
* This lets us sort by meta value desc, and have a second orderby param.
*
* @access public
* @param array $args
* @param array $args Query args.
* @return array
*/
public function order_by_popularity_post_clauses( $args ) {
@ -574,7 +572,7 @@ class WC_Query {
* Order by rating post clauses.
*
* @deprecated 3.0.0
* @param array $args
* @param array $args Query args.
* @return array
*/
public function order_by_rating_post_clauses( $args ) {
@ -597,8 +595,8 @@ class WC_Query {
/**
* Appends meta queries to an array.
*
* @param array $meta_query
* @param bool $main_query
* @param array $meta_query Meta query.
* @param bool $main_query If is main query.
* @return array
*/
public function get_meta_query( $meta_query = array(), $main_query = false ) {
@ -611,18 +609,21 @@ class WC_Query {
/**
* Appends tax queries to an array.
* @param array $tax_query
* @param bool $main_query
*
* @param array $tax_query Tax query.
* @param bool $main_query If is main query.
* @return array
*/
public function get_tax_query( $tax_query = array(), $main_query = false ) {
if ( ! is_array( $tax_query ) ) {
$tax_query = array( 'relation' => 'AND' );
$tax_query = array(
'relation' => 'AND',
);
}
// Layered nav filters on terms.
if ( $main_query && ( $_chosen_attributes = $this->get_layered_nav_chosen_attributes() ) ) {
foreach ( $_chosen_attributes as $taxonomy => $data ) {
if ( $main_query ) {
foreach ( $this->get_layered_nav_chosen_attributes() as $taxonomy => $data ) {
$tax_query[] = array(
'taxonomy' => $taxonomy,
'field' => 'slug',
@ -642,11 +643,11 @@ class WC_Query {
}
// Filter by rating.
if ( isset( $_GET['rating_filter'] ) ) {
$rating_filter = array_filter( array_map( 'absint', explode( ',', $_GET['rating_filter'] ) ) );
if ( isset( $_GET['rating_filter'] ) ) { // WPCS: input var ok, CSRF ok.
$rating_filter = array_filter( array_map( 'absint', explode( ',', $_GET['rating_filter'] ) ) ); // WPCS: input var ok, CSRF ok, Sanitization ok.
$rating_terms = array();
for ( $i = 1; $i <= 5; $i ++ ) {
if ( in_array( $i, $rating_filter ) && isset( $product_visibility_terms[ 'rated-' . $i ] ) ) {
if ( in_array( $i, $rating_filter, true ) && isset( $product_visibility_terms[ 'rated-' . $i ] ) ) {
$rating_terms[] = $product_visibility_terms[ 'rated-' . $i ];
}
}
@ -675,11 +676,12 @@ class WC_Query {
/**
* Return a meta query for filtering by price.
*
* @return array
*/
private function price_filter_meta_query() {
if ( isset( $_GET['max_price'] ) || isset( $_GET['min_price'] ) ) {
$meta_query = wc_get_min_max_price_meta_query( $_GET );
if ( isset( $_GET['max_price'] ) || isset( $_GET['min_price'] ) ) { // WPCS: input var ok, CSRF ok.
$meta_query = wc_get_min_max_price_meta_query( $_GET ); // WPCS: input var ok, CSRF ok.
$meta_query['price_filter'] = true;
return $meta_query;
@ -702,7 +704,7 @@ class WC_Query {
* Returns a meta query to handle product visibility.
*
* @deprecated 3.0.0 Replaced with taxonomy.
* @param string $compare (default: 'IN')
* @param string $compare Compare type.
* @return array
*/
public function visibility_meta_query( $compare = 'IN' ) {
@ -713,7 +715,7 @@ class WC_Query {
* Returns a meta query to handle product stock status.
*
* @deprecated 3.0.0 Replaced with taxonomy.
* @param string $status (default: 'instock')
* @param string $status Status.
* @return array
*/
public function stock_status_meta_query( $status = 'instock' ) {
@ -722,6 +724,7 @@ class WC_Query {
/**
* Get the tax query which was used by the main query.
*
* @return array
*/
public static function get_main_tax_query() {
@ -734,6 +737,7 @@ class WC_Query {
/**
* Get the meta query which was used by the main query.
*
* @return array
*/
public static function get_main_meta_query() {
@ -769,7 +773,7 @@ class WC_Query {
}
$like = '%' . $wpdb->esc_like( $term ) . '%';
$sql[] = $wpdb->prepare( "(($wpdb->posts.post_title $like_op %s) $andor_op ($wpdb->posts.post_excerpt $like_op %s) $andor_op ($wpdb->posts.post_content $like_op %s))", $like, $like, $like );
$sql[] = $wpdb->prepare( "(($wpdb->posts.post_title $like_op %s) $andor_op ($wpdb->posts.post_excerpt $like_op %s) $andor_op ($wpdb->posts.post_content $like_op %s))", $like, $like, $like ); // WPCS: db call ok, cache ok, unprepared SQL ok.
}
if ( ! empty( $sql ) && ! is_user_logged_in() ) {
@ -781,23 +785,26 @@ class WC_Query {
/**
* Layered Nav Init.
*
* @return array
*/
public static function get_layered_nav_chosen_attributes() {
if ( ! is_array( self::$_chosen_attributes ) ) {
self::$_chosen_attributes = array();
if ( $attribute_taxonomies = wc_get_attribute_taxonomies() ) {
$attribute_taxonomies = wc_get_attribute_taxonomies();
if ( $attribute_taxonomies ) {
foreach ( $attribute_taxonomies as $tax ) {
$attribute = wc_sanitize_taxonomy_name( $tax->attribute_name );
$taxonomy = wc_attribute_taxonomy_name( $attribute );
$filter_terms = ! empty( $_GET[ 'filter_' . $attribute ] ) ? explode( ',', wc_clean( $_GET[ 'filter_' . $attribute ] ) ) : array();
$filter_terms = ! empty( $_GET[ 'filter_' . $attribute ] ) ? explode( ',', wc_clean( wp_unslash( $_GET[ 'filter_' . $attribute ] ) ) ) : array(); // WPCS: input var ok, CSRF ok.
if ( empty( $filter_terms ) || ! taxonomy_exists( $taxonomy ) ) {
continue;
}
$query_type = ! empty( $_GET[ 'query_type_' . $attribute ] ) && in_array( $_GET[ 'query_type_' . $attribute ], array( 'and', 'or' ) ) ? wc_clean( $_GET[ 'query_type_' . $attribute ] ) : '';
self::$_chosen_attributes[ $taxonomy ]['terms'] = array_map( 'sanitize_title', $filter_terms ); // Ensures correct encoding
$query_type = ! empty( $_GET[ 'query_type_' . $attribute ] ) && in_array( wp_unslash( $_GET[ 'query_type_' . $attribute ] ), array( 'and', 'or' ), true ) ? wc_clean( wp_unslash( $_GET[ 'query_type_' . $attribute ] ) ) : ''; // WPCS: input var ok, CSRF ok.
self::$_chosen_attributes[ $taxonomy ]['terms'] = array_map( 'sanitize_title', $filter_terms ); // Ensures correct encoding.
self::$_chosen_attributes[ $taxonomy ]['query_type'] = $query_type ? $query_type : apply_filters( 'woocommerce_layered_nav_default_query_type', 'and' );
}
}
@ -806,6 +813,8 @@ class WC_Query {
}
/**
* Layered nav init.
*
* @deprecated 2.6.0
*/
public function layered_nav_init() {
@ -814,6 +823,7 @@ class WC_Query {
/**
* Get an unpaginated list all product IDs (both filtered and unfiltered). Makes use of transients.
*
* @deprecated 2.6.0 due to performance concerns
*/
public function get_products_in_view() {
@ -822,11 +832,12 @@ class WC_Query {
/**
* Layered Nav post filter.
*
* @deprecated 2.6.0 due to performance concerns
*
* @param $filtered_posts
* @param mixed $deprecated Deprecated.
*/
public function layered_nav_query( $filtered_posts ) {
public function layered_nav_query( $deprecated ) {
wc_deprecated_function( 'layered_nav_query', '2.6' );
}
}

View File

@ -579,7 +579,7 @@ class WC_Tax {
} elseif ( WC()->cart->get_cart() ) {
// This will be per order shipping - loop through the order and find the highest tax class rate
$cart_tax_classes = WC()->cart->get_cart_item_tax_classes();
$cart_tax_classes = WC()->cart->get_cart_item_tax_classes_for_shipping();
// No tax classes = no taxable items.
if ( empty( $cart_tax_classes ) ) {

View File

@ -128,23 +128,23 @@ class WC_Legacy_API {
public function includes() {
// API server / response handlers.
include_once( dirname( __FILE__ ) . '/api/legacy/v3/class-wc-api-exception.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v3/class-wc-api-server.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v3/interface-wc-api-handler.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v3/class-wc-api-json-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-exception.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-server.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/interface-wc-api-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-json-handler.php' );
// Authentication.
include_once( dirname( __FILE__ ) . '/api/legacy/v3/class-wc-api-authentication.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-authentication.php' );
$this->authentication = new WC_API_Authentication();
include_once( dirname( __FILE__ ) . '/api/legacy/v3/class-wc-api-resource.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v3/class-wc-api-coupons.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v3/class-wc-api-customers.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v3/class-wc-api-orders.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v3/class-wc-api-products.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v3/class-wc-api-reports.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v3/class-wc-api-taxes.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v3/class-wc-api-webhooks.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-resource.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-coupons.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-customers.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-orders.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-products.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-reports.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-taxes.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-webhooks.php' );
// Allow plugins to load other response handlers or resource classes.
do_action( 'woocommerce_api_loaded' );
@ -186,20 +186,20 @@ class WC_Legacy_API {
private function handle_v1_rest_api_request() {
// Include legacy required files for v1 REST API request.
include_once( dirname( __FILE__ ) . '/api/legacy/v1/class-wc-api-server.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v1/interface-wc-api-handler.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v1/class-wc-api-json-handler.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v1/class-wc-api-xml-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-server.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/interface-wc-api-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-json-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-xml-handler.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v1/class-wc-api-authentication.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-authentication.php' );
$this->authentication = new WC_API_Authentication();
include_once( dirname( __FILE__ ) . '/api/legacy/v1/class-wc-api-resource.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v1/class-wc-api-coupons.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v1/class-wc-api-customers.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v1/class-wc-api-orders.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v1/class-wc-api-products.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v1/class-wc-api-reports.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-resource.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-coupons.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-customers.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-orders.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-products.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-reports.php' );
// Allow plugins to load other response handlers or resource classes.
do_action( 'woocommerce_api_loaded' );
@ -232,21 +232,21 @@ class WC_Legacy_API {
* @deprecated 2.6.0
*/
private function handle_v2_rest_api_request() {
include_once( dirname( __FILE__ ) . '/api/legacy/v2/class-wc-api-exception.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v2/class-wc-api-server.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v2/interface-wc-api-handler.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v2/class-wc-api-json-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-exception.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-server.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/interface-wc-api-handler.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-json-handler.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v2/class-wc-api-authentication.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-authentication.php' );
$this->authentication = new WC_API_Authentication();
include_once( dirname( __FILE__ ) . '/api/legacy/v2/class-wc-api-resource.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v2/class-wc-api-coupons.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v2/class-wc-api-customers.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v2/class-wc-api-orders.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v2/class-wc-api-products.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v2/class-wc-api-reports.php' );
include_once( dirname( __FILE__ ) . '/api/legacy/v2/class-wc-api-webhooks.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-resource.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-coupons.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-customers.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-orders.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-products.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-reports.php' );
include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-webhooks.php' );
// allow plugins to load other response handlers or resource classes.
do_action( 'woocommerce_api_loaded' );

View File

@ -4,30 +4,29 @@
*
* Functions related to pages and menus.
*
* @author WooThemes
* @author Automattic
* @category Core
* @package WooCommerce/Functions
* @package WooCommerce\Functions
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit; // Exit if accessed directly.
}
/**
* Replace a page title with the endpoint title.
* @param string $title
*
* @param string $title Post title.
* @return string
*/
function wc_page_endpoint_title( $title ) {
global $wp_query;
if ( ! is_null( $wp_query ) && ! is_admin() && is_main_query() && in_the_loop() && is_page() && is_wc_endpoint_url() ) {
$endpoint = WC()->query->get_current_endpoint();
if ( $endpoint_title = WC()->query->get_endpoint_title( $endpoint ) ) {
$title = $endpoint_title;
}
$endpoint = WC()->query->get_current_endpoint();
$endpoint_title = WC()->query->get_endpoint_title( $endpoint );
$title = $endpoint_title ? $endpoint_title : $title;
remove_filter( 'the_title', 'wc_page_endpoint_title' );
}
@ -40,12 +39,11 @@ add_filter( 'the_title', 'wc_page_endpoint_title' );
/**
* Retrieve page ids - used for myaccount, edit_address, shop, cart, checkout, pay, view_order, terms. returns -1 if no page is found.
*
* @param string $page
* @param string $page Page slug.
* @return int
*/
function wc_get_page_id( $page ) {
if ( 'pay' == $page || 'thanks' == $page ) {
if ( 'pay' === $page || 'thanks' === $page ) {
wc_deprecated_argument( __FUNCTION__, '2.1', 'The "pay" and "thanks" pages are no-longer used - an endpoint is added to the checkout instead. To get a valid link use the WC_Order::get_checkout_payment_url() or WC_Order::get_checkout_order_received_url() methods instead.' );
$page = 'checkout';
@ -64,7 +62,7 @@ function wc_get_page_id( $page ) {
/**
* Retrieve page permalink.
*
* @param string $page
* @param string $page page slug.
* @return string
*/
function wc_get_page_permalink( $page ) {
@ -78,9 +76,9 @@ function wc_get_page_permalink( $page ) {
*
* Gets the URL for an endpoint, which varies depending on permalink settings.
*
* @param string $endpoint
* @param string $value
* @param string $permalink
* @param string $endpoint Endpoint slug.
* @param string $value Query param value.
* @param string $permalink Permalink.
*
* @return string
*/
@ -89,13 +87,14 @@ function wc_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {
$permalink = get_permalink();
}
// Map endpoint to options
$endpoint = ! empty( WC()->query->query_vars[ $endpoint ] ) ? WC()->query->query_vars[ $endpoint ] : $endpoint;
$value = ( get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ) === $endpoint ) ? wc_edit_address_i18n( $value ) : $value;
// Map endpoint to options.
$query_vars = WC()->query->get_query_vars();
$endpoint = ! empty( $query_vars[ $endpoint ] ) ? $query_vars[ $endpoint ] : $endpoint;
$value = ( get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ) === $endpoint ) ? wc_edit_address_i18n( $value ) : $value;
if ( get_option( 'permalink_structure' ) ) {
if ( strstr( $permalink, '?' ) ) {
$query_string = '?' . parse_url( $permalink, PHP_URL_QUERY );
$query_string = '?' . wp_parse_url( $permalink, PHP_URL_QUERY );
$permalink = current( explode( '?', $permalink ) );
} else {
$query_string = '';
@ -123,8 +122,8 @@ function wc_nav_menu_items( $items ) {
if ( empty( $item->url ) ) {
continue;
}
$path = parse_url( $item->url, PHP_URL_PATH );
$query = parse_url( $item->url, PHP_URL_QUERY );
$path = wp_parse_url( $item->url, PHP_URL_PATH );
$query = wp_parse_url( $item->url, PHP_URL_QUERY );
if ( strstr( $path, $customer_logout ) || strstr( $query, $customer_logout ) ) {
unset( $items[ $key ] );
@ -141,43 +140,41 @@ add_filter( 'wp_nav_menu_objects', 'wc_nav_menu_items', 10 );
/**
* Fix active class in nav for shop page.
*
* @param array $menu_items
* @param array $menu_items Menu items.
* @return array
*/
function wc_nav_menu_item_classes( $menu_items ) {
if ( ! is_woocommerce() ) {
return $menu_items;
}
$shop_page = (int) wc_get_page_id( 'shop' );
$shop_page = (int) wc_get_page_id( 'shop' );
$page_for_posts = (int) get_option( 'page_for_posts' );
if ( ! empty( $menu_items ) && is_array( $menu_items ) ) {
foreach ( $menu_items as $key => $menu_item ) {
$classes = (array) $menu_item->classes;
$menu_id = (int) $menu_item->object_id;
// Unset active class for blog page
if ( $page_for_posts == $menu_item->object_id ) {
// Unset active class for blog page.
if ( $page_for_posts === $menu_id ) {
$menu_items[ $key ]->current = false;
if ( in_array( 'current_page_parent', $classes ) ) {
unset( $classes[ array_search( 'current_page_parent', $classes ) ] );
if ( in_array( 'current_page_parent', $classes, true ) ) {
unset( $classes[ array_search( 'current_page_parent', $classes, true ) ] );
}
if ( in_array( 'current-menu-item', $classes ) ) {
unset( $classes[ array_search( 'current-menu-item', $classes ) ] );
if ( in_array( 'current-menu-item', $classes, true ) ) {
unset( $classes[ array_search( 'current-menu-item', $classes, true ) ] );
}
// Set active state if this is the shop page link
} elseif ( is_shop() && $shop_page == $menu_item->object_id && 'page' === $menu_item->object ) {
} elseif ( is_shop() && $shop_page === $menu_id && 'page' === $menu_item->object ) {
// Set active state if this is the shop page link.
$menu_items[ $key ]->current = true;
$classes[] = 'current-menu-item';
$classes[] = 'current_page_item';
// Set parent state if this is a product page
} elseif ( is_singular( 'product' ) && $shop_page == $menu_item->object_id ) {
} elseif ( is_singular( 'product' ) && $shop_page === $menu_id ) {
// Set parent state if this is a product page.
$classes[] = 'current_page_parent';
}
@ -193,10 +190,9 @@ add_filter( 'wp_nav_menu_objects', 'wc_nav_menu_item_classes', 2 );
/**
* Fix active class in wp_list_pages for shop page.
*
* https://github.com/woocommerce/woocommerce/issues/177.
* See details in https://github.com/woocommerce/woocommerce/issues/177.
*
* @author Jessor, Peter Sterling
* @param string $pages
* @param string $pages Pages list.
* @return string
*/
function wc_list_pages( $pages ) {

View File

@ -4,9 +4,9 @@
*
* Functions for the templating system.
*
* @author WooThemes
* @author Automattic
* @category Core
* @package WooCommerce/Functions
* @package WooCommerce\Functions
* @version 2.5.0
*/
@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
function wc_template_redirect() {
global $wp_query, $wp;
if ( ! empty( $_GET['page_id'] ) && '' === get_option( 'permalink_structure' ) && wc_get_page_id( 'shop' ) == $_GET['page_id'] ) {
if ( ! empty( $_GET['page_id'] ) && '' === get_option( 'permalink_structure' ) && wc_get_page_id( 'shop' ) === absint( $_GET['page_id'] ) ) { // WPCS: input var ok, CSRF ok.
// When default permalinks are enabled, redirect shop page to post type archive url.
wp_safe_redirect( get_post_type_archive_link( 'product' ) );
@ -33,11 +33,7 @@ function wc_template_redirect() {
wp_redirect( wc_get_page_permalink( 'cart' ) );
exit;
} elseif (
isset( $wp->query_vars['customer-logout'] ) &&
! empty( $_REQUEST['_wpnonce'] ) &&
wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'customer-logout' )
) {
} elseif ( isset( $wp->query_vars['customer-logout'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'customer-logout' ) ) { // WPCS: input var ok, CSRF ok.
// Logout.
wp_redirect( str_replace( '&amp;', '&', wp_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) );
@ -97,8 +93,8 @@ add_action( 'template_redirect', 'wc_send_frame_options_header' );
* @since 2.5.3
*/
function wc_prevent_endpoint_indexing() {
if ( is_wc_endpoint_url() || isset( $_GET['download_file'] ) ) {
@header( 'X-Robots-Tag: noindex' );
if ( is_wc_endpoint_url() || isset( $_GET['download_file'] ) ) { // WPCS: input var ok, CSRF ok.
@header( 'X-Robots-Tag: noindex' ); // @codingStandardsIgnoreLine
}
}
add_action( 'template_redirect', 'wc_prevent_endpoint_indexing' );
@ -142,7 +138,7 @@ function wc_setup_product_data( $post ) {
$the_post = $post;
}
if ( empty( $the_post->post_type ) || ! in_array( $the_post->post_type, array( 'product', 'product_variation' ) ) ) {
if ( empty( $the_post->post_type ) || ! in_array( $the_post->post_type, array( 'product', 'product_variation' ), true ) ) {
return;
}
@ -156,8 +152,6 @@ if ( ! function_exists( 'woocommerce_reset_loop' ) ) {
/**
* Reset the loop's index and columns when we're done outputting a product loop.
*
* @subpackage Loop
*/
function woocommerce_reset_loop() {
$GLOBALS['woocommerce_loop'] = array(
@ -189,6 +183,7 @@ function wc_products_rss_feed() {
if ( $term ) {
$feed = add_query_arg( 'product_cat', $term->slug, get_post_type_archive_feed_link( 'product' ) );
/* translators: %s: category name */
echo '<link rel="alternate" type="application/rss+xml" title="' . esc_attr( sprintf( __( 'New products added to %s', 'woocommerce' ), $term->name ) ) . '" href="' . esc_url( $feed ) . '" />';
}
} elseif ( is_tax( 'product_tag' ) ) {
@ -197,7 +192,8 @@ function wc_products_rss_feed() {
if ( $term ) {
$feed = add_query_arg( 'product_tag', $term->slug, get_post_type_archive_feed_link( 'product' ) );
echo '<link rel="alternate" type="application/rss+xml" title="' . sprintf( esc_attr__( 'New products tagged %s', 'woocommerce' ), urlencode( $term->name ) ) . '" href="' . esc_url( $feed ) . '" />';
/* translators: %s: tag name */
echo '<link rel="alternate" type="application/rss+xml" title="' . sprintf( esc_attr__( 'New products tagged %s', 'woocommerce' ), rawurlencode( $term->name ) ) . '" href="' . esc_url( $feed ) . '" />';
}
}
}
@ -259,7 +255,7 @@ function wc_body_class( $classes ) {
$classes[] = 'woocommerce-demo-store';
}
foreach ( WC()->query->query_vars as $key => $value ) {
foreach ( WC()->query->get_query_vars() as $key => $value ) {
if ( is_wc_endpoint_url( $key ) ) {
$classes[] = 'woocommerce-' . sanitize_html_class( $key );
}
@ -289,7 +285,7 @@ function wc_product_cat_class( $class = '', $category = null ) {
function wc_get_loop_class() {
global $woocommerce_loop;
$woocommerce_loop['loop'] = ! empty( $woocommerce_loop['loop'] ) ? $woocommerce_loop['loop'] + 1 : 1;
$woocommerce_loop['loop'] = ! empty( $woocommerce_loop['loop'] ) ? $woocommerce_loop['loop'] + 1 : 1;
$woocommerce_loop['columns'] = max( 1, ! empty( $woocommerce_loop['columns'] ) ? $woocommerce_loop['columns'] : apply_filters( 'loop_shop_columns', 4 ) );
if ( 0 === ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] || 1 === $woocommerce_loop['columns'] ) {
@ -331,7 +327,7 @@ function wc_get_product_cat_class( $class = '', $category = null ) {
* @return array
*/
function wc_product_post_class( $classes, $class = '', $post_id = '' ) {
if ( ! $post_id || ! in_array( get_post_type( $post_id ), array( 'product', 'product_variation' ) ) ) {
if ( ! $post_id || ! in_array( get_post_type( $post_id ), array( 'product', 'product_variation' ), true ) ) {
return $classes;
}
@ -379,7 +375,8 @@ function wc_product_post_class( $classes, $class = '', $post_id = '' ) {
}
}
if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) {
$key = array_search( 'hentry', $classes, true );
if ( false !== $key ) {
unset( $classes[ $key ] );
}
@ -398,7 +395,7 @@ function wc_product_post_class( $classes, $class = '', $post_id = '' ) {
*/
function wc_query_string_form_fields( $values = null, $exclude = array(), $current_key = '', $return = false ) {
if ( is_null( $values ) ) {
$values = $_GET;
$values = $_GET; // WPCS: input var ok, CSRF ok.
}
$html = '';
@ -440,13 +437,13 @@ if ( ! function_exists( 'woocommerce_content' ) ) {
if ( is_singular( 'product' ) ) {
while ( have_posts() ) : the_post();
while ( have_posts() ) :
the_post();
wc_get_template_part( 'content', 'single-product' );
endwhile;
} else { ?>
} else {
?>
<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
@ -464,7 +461,8 @@ if ( ! function_exists( 'woocommerce_content' ) ) {
<?php woocommerce_product_subcategories(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php while ( have_posts() ) : ?>
<?php the_post(); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
@ -474,12 +472,17 @@ if ( ! function_exists( 'woocommerce_content' ) ) {
<?php do_action( 'woocommerce_after_shop_loop' ); ?>
<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>
<?php
elseif ( ! woocommerce_product_subcategories( array(
'before' => woocommerce_product_loop_start( false ),
'after' => woocommerce_product_loop_end( false ),
) ) ) :
?>
<?php do_action( 'woocommerce_no_products_found' ); ?>
<?php endif;
<?php
endif;
}
}
}
@ -552,9 +555,11 @@ if ( ! function_exists( 'woocommerce_page_title' ) ) {
function woocommerce_page_title( $echo = true ) {
if ( is_search() ) {
/* translators: %s: search query */
$page_title = sprintf( __( 'Search results: &ldquo;%s&rdquo;', 'woocommerce' ), get_search_query() );
if ( get_query_var( 'paged' ) ) {
/* translators: %s: page number */
$page_title .= sprintf( __( '&nbsp;&ndash; Page %s', 'woocommerce' ), get_query_var( 'paged' ) );
}
} elseif ( is_tax() ) {
@ -679,8 +684,6 @@ if ( ! function_exists( 'woocommerce_taxonomy_archive_description' ) ) {
/**
* Show an archive description on taxonomy archives.
*
* @subpackage Archives
*/
function woocommerce_taxonomy_archive_description() {
if ( is_product_taxonomy() && 0 === absint( get_query_var( 'paged' ) ) ) {
@ -720,8 +723,6 @@ if ( ! function_exists( 'woocommerce_template_loop_add_to_cart' ) ) {
/**
* Get the add to cart template for the loop.
*
* @subpackage Loop
*
* @param array $args Arguments.
*/
function woocommerce_template_loop_add_to_cart( $args = array() ) {
@ -731,10 +732,10 @@ if ( ! function_exists( 'woocommerce_template_loop_add_to_cart' ) ) {
$defaults = array(
'quantity' => 1,
'class' => implode( ' ', array_filter( array(
'button',
'product_type_' . $product->get_type(),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
$product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '',
'button',
'product_type_' . $product->get_type(),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
$product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '',
) ) ),
);
@ -748,8 +749,6 @@ if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ) {
/**
* Get the product thumbnail for the loop.
*
* @subpackage Loop
*/
function woocommerce_template_loop_product_thumbnail() {
echo woocommerce_get_product_thumbnail(); // WPCS: XSS ok.
@ -759,8 +758,6 @@ if ( ! function_exists( 'woocommerce_template_loop_price' ) ) {
/**
* Get the product price for the loop.
*
* @subpackage Loop
*/
function woocommerce_template_loop_price() {
wc_get_template( 'loop/price.php' );
@ -770,8 +767,6 @@ if ( ! function_exists( 'woocommerce_template_loop_rating' ) ) {
/**
* Display the average rating in the loop.
*
* @subpackage Loop
*/
function woocommerce_template_loop_rating() {
wc_get_template( 'loop/rating.php' );
@ -781,8 +776,6 @@ if ( ! function_exists( 'woocommerce_show_product_loop_sale_flash' ) ) {
/**
* Get the sale flash for the loop.
*
* @subpackage Loop
*/
function woocommerce_show_product_loop_sale_flash() {
wc_get_template( 'loop/sale-flash.php' );
@ -794,7 +787,6 @@ if ( ! function_exists( 'woocommerce_get_product_thumbnail' ) ) {
/**
* Get the product thumbnail, or the placeholder if not set.
*
* @subpackage Loop
* @param string $size (default: 'woocommerce_thumbnail').
* @param int $deprecated1 Deprecated since WooCommerce 2.0 (default: 0).
* @param int $deprecated2 Deprecated since WooCommerce 2.0 (default: 0).
@ -813,8 +805,6 @@ if ( ! function_exists( 'woocommerce_result_count' ) ) {
/**
* Output the result count text (Showing x - x of x results).
*
* @subpackage Loop
*/
function woocommerce_result_count() {
wc_get_template( 'loop/result-count.php' );
@ -825,8 +815,6 @@ if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) {
/**
* Output the product sorting options.
*
* @subpackage Loop
*/
function woocommerce_catalog_ordering() {
global $wp_query;
@ -835,7 +823,7 @@ if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) {
return;
}
$orderby = isset( $_GET['orderby'] ) ? wc_clean( wp_unslash( $_GET['orderby'] ) ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
$orderby = isset( $_GET['orderby'] ) ? wc_clean( wp_unslash( $_GET['orderby'] ) ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); // WPCS: input var ok, CSRF ok.
$show_default_orderby = 'menu_order' === apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
$catalog_orderby_options = apply_filters( 'woocommerce_catalog_orderby', array(
'menu_order' => __( 'Default sorting', 'woocommerce' ),
@ -847,7 +835,9 @@ if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) {
) );
if ( $wp_query->is_search() ) {
$catalog_orderby_options = array_merge( array( 'relevance' => __( 'Relevance', 'woocommerce' ) ), $catalog_orderby_options );
$catalog_orderby_options = array_merge( array(
'relevance' => __( 'Relevance', 'woocommerce' ),
), $catalog_orderby_options );
unset( $catalog_orderby_options['menu_order'] );
if ( 'menu_order' === $orderby ) {
$orderby = 'relevance';
@ -862,7 +852,11 @@ if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) {
unset( $catalog_orderby_options['rating'] );
}
wc_get_template( 'loop/orderby.php', array( 'catalog_orderby_options' => $catalog_orderby_options, 'orderby' => $orderby, 'show_default_orderby' => $show_default_orderby ) );
wc_get_template( 'loop/orderby.php', array(
'catalog_orderby_options' => $catalog_orderby_options,
'orderby' => $orderby,
'show_default_orderby' => $show_default_orderby,
) );
}
}
@ -870,8 +864,6 @@ if ( ! function_exists( 'woocommerce_pagination' ) ) {
/**
* Output the pagination.
*
* @subpackage Loop
*/
function woocommerce_pagination() {
wc_get_template( 'loop/pagination.php' );
@ -886,8 +878,6 @@ if ( ! function_exists( 'woocommerce_show_product_images' ) ) {
/**
* Output the product image before the single product summary.
*
* @subpackage Product
*/
function woocommerce_show_product_images() {
wc_get_template( 'single-product/product-image.php' );
@ -897,8 +887,6 @@ if ( ! function_exists( 'woocommerce_show_product_thumbnails' ) ) {
/**
* Output the product thumbnails.
*
* @subpackage Product
*/
function woocommerce_show_product_thumbnails() {
wc_get_template( 'single-product/product-thumbnails.php' );
@ -909,8 +897,6 @@ if ( ! function_exists( 'woocommerce_output_product_data_tabs' ) ) {
/**
* Output the product tabs.
*
* @subpackage Product/Tabs
*/
function woocommerce_output_product_data_tabs() {
wc_get_template( 'single-product/tabs/tabs.php' );
@ -920,8 +906,6 @@ if ( ! function_exists( 'woocommerce_template_single_title' ) ) {
/**
* Output the product title.
*
* @subpackage Product
*/
function woocommerce_template_single_title() {
wc_get_template( 'single-product/title.php' );
@ -931,8 +915,6 @@ if ( ! function_exists( 'woocommerce_template_single_rating' ) ) {
/**
* Output the product rating.
*
* @subpackage Product
*/
function woocommerce_template_single_rating() {
if ( post_type_supports( 'product', 'comments' ) ) {
@ -944,8 +926,6 @@ if ( ! function_exists( 'woocommerce_template_single_price' ) ) {
/**
* Output the product price.
*
* @subpackage Product
*/
function woocommerce_template_single_price() {
wc_get_template( 'single-product/price.php' );
@ -955,8 +935,6 @@ if ( ! function_exists( 'woocommerce_template_single_excerpt' ) ) {
/**
* Output the product short description (excerpt).
*
* @subpackage Product
*/
function woocommerce_template_single_excerpt() {
wc_get_template( 'single-product/short-description.php' );
@ -966,8 +944,6 @@ if ( ! function_exists( 'woocommerce_template_single_meta' ) ) {
/**
* Output the product meta.
*
* @subpackage Product
*/
function woocommerce_template_single_meta() {
wc_get_template( 'single-product/meta.php' );
@ -977,8 +953,6 @@ if ( ! function_exists( 'woocommerce_template_single_sharing' ) ) {
/**
* Output the product sharing.
*
* @subpackage Product
*/
function woocommerce_template_single_sharing() {
wc_get_template( 'single-product/share.php' );
@ -988,8 +962,6 @@ if ( ! function_exists( 'woocommerce_show_product_sale_flash' ) ) {
/**
* Output the product sale flash.
*
* @subpackage Product
*/
function woocommerce_show_product_sale_flash() {
wc_get_template( 'single-product/sale-flash.php' );
@ -1000,8 +972,6 @@ if ( ! function_exists( 'woocommerce_template_single_add_to_cart' ) ) {
/**
* Trigger the single product add to cart action.
*
* @subpackage Product
*/
function woocommerce_template_single_add_to_cart() {
global $product;
@ -1012,8 +982,6 @@ if ( ! function_exists( 'woocommerce_simple_add_to_cart' ) ) {
/**
* Output the simple product add to cart area.
*
* @subpackage Product
*/
function woocommerce_simple_add_to_cart() {
wc_get_template( 'single-product/add-to-cart/simple.php' );
@ -1023,8 +991,6 @@ if ( ! function_exists( 'woocommerce_grouped_add_to_cart' ) ) {
/**
* Output the grouped product add to cart area.
*
* @subpackage Product
*/
function woocommerce_grouped_add_to_cart() {
global $product;
@ -1044,8 +1010,6 @@ if ( ! function_exists( 'woocommerce_variable_add_to_cart' ) ) {
/**
* Output the variable product add to cart area.
*
* @subpackage Product
*/
function woocommerce_variable_add_to_cart() {
global $product;
@ -1068,8 +1032,6 @@ if ( ! function_exists( 'woocommerce_external_add_to_cart' ) ) {
/**
* Output the external product add to cart area.
*
* @subpackage Product
*/
function woocommerce_external_add_to_cart() {
global $product;
@ -1139,8 +1101,6 @@ if ( ! function_exists( 'woocommerce_product_description_tab' ) ) {
/**
* Output the description tab content.
*
* @subpackage Product/Tabs
*/
function woocommerce_product_description_tab() {
wc_get_template( 'single-product/tabs/description.php' );
@ -1150,8 +1110,6 @@ if ( ! function_exists( 'woocommerce_product_additional_information_tab' ) ) {
/**
* Output the attributes tab content.
*
* @subpackage Product/Tabs
*/
function woocommerce_product_additional_information_tab() {
wc_get_template( 'single-product/tabs/additional-information.php' );
@ -1162,8 +1120,7 @@ if ( ! function_exists( 'woocommerce_product_reviews_tab' ) ) {
/**
* Output the reviews tab content.
*
* @deprecated 2.4.0 Unused
* @subpackage Product/Tabs
* @deprecated 2.4.0 Unused.
*/
function woocommerce_product_reviews_tab() {
wc_deprecated_function( 'woocommerce_product_reviews_tab', '2.4' );
@ -1202,6 +1159,7 @@ if ( ! function_exists( 'woocommerce_default_product_tabs' ) ) {
// Reviews tab - shows comments.
if ( comments_open() ) {
$tabs['reviews'] = array(
/* translators: %s: reviews count */
'title' => sprintf( __( 'Reviews (%d)', 'woocommerce' ), $product->get_review_count() ),
'priority' => 30,
'callback' => 'comments_template',
@ -1224,7 +1182,7 @@ if ( ! function_exists( 'woocommerce_sort_product_tabs' ) ) {
// Make sure the $tabs parameter is an array.
if ( ! is_array( $tabs ) ) {
trigger_error( 'Function woocommerce_sort_product_tabs() expects an array as the first parameter. Defaulting to empty array.' );
trigger_error( 'Function woocommerce_sort_product_tabs() expects an array as the first parameter. Defaulting to empty array.' ); // @codingStandardsIgnoreLine
$tabs = array();
}
@ -1256,14 +1214,17 @@ if ( ! function_exists( 'woocommerce_comments' ) ) {
/**
* Output the Review comments template.
*
* @subpackage Product
* @param WP_Comment $comment Comment object.
* @param array $args Arguments.
* @param int $depth Depth.
*/
function woocommerce_comments( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment; // WPCS: override ok.
wc_get_template( 'single-product/review.php', array( 'comment' => $comment, 'args' => $args, 'depth' => $depth ) );
wc_get_template( 'single-product/review.php', array(
'comment' => $comment,
'args' => $args,
'depth' => $depth,
) );
}
}
@ -1319,15 +1280,13 @@ if ( ! function_exists( 'woocommerce_output_related_products' ) ) {
/**
* Output the related products.
*
* @subpackage Product
*/
function woocommerce_output_related_products() {
$args = array(
'posts_per_page' => 4,
'columns' => 4,
'orderby' => 'rand',
'posts_per_page' => 4,
'columns' => 4,
'orderby' => 'rand',
);
woocommerce_related_products( apply_filters( 'woocommerce_output_related_products_args', $args ) );
@ -1420,8 +1379,6 @@ if ( ! function_exists( 'woocommerce_shipping_calculator' ) ) {
/**
* Output the cart shipping calculator.
*
* @subpackage Cart
*/
function woocommerce_shipping_calculator() {
wc_get_template( 'cart/shipping-calculator.php' );
@ -1432,8 +1389,6 @@ if ( ! function_exists( 'woocommerce_cart_totals' ) ) {
/**
* Output the cart totals.
*
* @subpackage Cart
*/
function woocommerce_cart_totals() {
if ( is_checkout() ) {
@ -1486,8 +1441,6 @@ if ( ! function_exists( 'woocommerce_button_proceed_to_checkout' ) ) {
/**
* Output the proceed to checkout button.
*
* @subpackage Cart
*/
function woocommerce_button_proceed_to_checkout() {
wc_get_template( 'cart/proceed-to-checkout-button.php' );
@ -1498,8 +1451,6 @@ if ( ! function_exists( 'woocommerce_widget_shopping_cart_button_view_cart' ) )
/**
* Output the view cart button.
*
* @subpackage Cart
*/
function woocommerce_widget_shopping_cart_button_view_cart() {
echo '<a href="' . esc_url( wc_get_cart_url() ) . '" class="button wc-forward">' . esc_html__( 'View cart', 'woocommerce' ) . '</a>';
@ -1510,8 +1461,6 @@ if ( ! function_exists( 'woocommerce_widget_shopping_cart_proceed_to_checkout' )
/**
* Output the proceed to checkout button.
*
* @subpackage Cart
*/
function woocommerce_widget_shopping_cart_proceed_to_checkout() {
echo '<a href="' . esc_url( wc_get_checkout_url() ) . '" class="button checkout wc-forward">' . esc_html__( 'Checkout', 'woocommerce' ) . '</a>';
@ -1546,7 +1495,6 @@ if ( ! function_exists( 'woocommerce_login_form' ) ) {
/**
* Output the WooCommerce Login Form.
*
* @subpackage Forms
* @param array $args Arguments.
*/
function woocommerce_login_form( $args = array() ) {
@ -1567,11 +1515,11 @@ if ( ! function_exists( 'woocommerce_checkout_login_form' ) ) {
/**
* Output the WooCommerce Checkout Login Form.
*
* @subpackage Checkout
*/
function woocommerce_checkout_login_form() {
wc_get_template( 'checkout/form-login.php', array( 'checkout' => WC()->checkout() ) );
wc_get_template( 'checkout/form-login.php', array(
'checkout' => WC()->checkout(),
) );
}
}
@ -1616,12 +1564,12 @@ if ( ! function_exists( 'woocommerce_order_review' ) ) {
/**
* Output the Order review table for the checkout.
*
* @subpackage Checkout
*
* @param bool $deprecated Deprecated param.
*/
function woocommerce_order_review( $deprecated = false ) {
wc_get_template( 'checkout/review-order.php', array( 'checkout' => WC()->checkout() ) );
wc_get_template( 'checkout/review-order.php', array(
'checkout' => WC()->checkout(),
) );
}
}
@ -1629,8 +1577,6 @@ if ( ! function_exists( 'woocommerce_checkout_payment' ) ) {
/**
* Output the Payment Methods on the checkout.
*
* @subpackage Checkout
*/
function woocommerce_checkout_payment() {
if ( WC()->cart->needs_payment() ) {
@ -1652,11 +1598,11 @@ if ( ! function_exists( 'woocommerce_checkout_coupon_form' ) ) {
/**
* Output the Coupon form for the checkout.
*
* @subpackage Checkout
*/
function woocommerce_checkout_coupon_form() {
wc_get_template( 'checkout/form-coupon.php', array( 'checkout' => WC()->checkout() ) );
wc_get_template( 'checkout/form-coupon.php', array(
'checkout' => WC()->checkout(),
) );
}
}
@ -1665,7 +1611,6 @@ if ( ! function_exists( 'woocommerce_products_will_display' ) ) {
/**
* Check if we will be showing products or not (and not sub-categories only).
*
* @subpackage Loop
* @return bool
*/
function woocommerce_products_will_display() {
@ -1687,19 +1632,18 @@ if ( ! function_exists( 'woocommerce_products_will_display' ) ) {
if ( is_product_category() ) {
switch ( get_woocommerce_term_meta( $term->term_id, 'display_type', true ) ) {
case 'subcategories' :
case 'subcategories':
// Nothing - we want to continue to see if there are products/subcats.
break;
case 'products' :
case 'both' :
break;
case 'products':
case 'both':
return true;
break;
default :
default:
// Default - no setting.
if ( get_option( 'woocommerce_category_archive_display' ) != 'subcategories' ) {
if ( get_option( 'woocommerce_category_archive_display' ) !== 'subcategories' ) {
return true;
}
break;
break;
}
}
@ -1708,10 +1652,11 @@ if ( ! function_exists( 'woocommerce_products_will_display' ) ) {
return true;
}
$transient_name = 'wc_products_will_display_' . $term->term_id . '_' . WC_Cache_Helper::get_transient_version( 'product_query' );
$transient_name = 'wc_products_will_display_' . $term->term_id . '_' . WC_Cache_Helper::get_transient_version( 'product_query' );
$products_will_display = get_transient( $transient_name );
if ( false === ( $products_will_display = get_transient( $transient_name ) ) ) {
$has_children = $wpdb->get_col( $wpdb->prepare( "SELECT term_id FROM {$wpdb->term_taxonomy} WHERE parent = %d AND taxonomy = %s", $term->term_id, $term->taxonomy ) ); // WPCS: cache ok.
if ( false === $products_will_display ) {
$has_children = $wpdb->get_col( $wpdb->prepare( "SELECT term_id FROM {$wpdb->term_taxonomy} WHERE parent = %d AND taxonomy = %s", $term->term_id, $term->taxonomy ) ); // WPCS: db call ok, cache ok.
if ( $has_children ) {
// Check terms have products inside - parents first. If products are found inside, subcats will be shown instead of products so we can return false.
@ -1744,7 +1689,6 @@ if ( ! function_exists( 'woocommerce_product_subcategories' ) ) {
/**
* Display product sub categories as thumbnails.
*
* @subpackage Loop
* @param array $args Arguments.
* @return null|boolean
*/
@ -1777,21 +1721,20 @@ if ( ! function_exists( 'woocommerce_product_subcategories' ) ) {
}
// Find the category + category parent, if applicable.
$term = get_queried_object();
$parent_id = empty( $term->term_id ) ? 0 : $term->term_id;
$term = get_queried_object();
$parent_id = empty( $term->term_id ) ? 0 : $term->term_id;
if ( is_product_category() ) {
$display_type = get_woocommerce_term_meta( $term->term_id, 'display_type', true );
switch ( $display_type ) {
case 'products' :
case 'products':
return;
break;
case '' :
case '':
if ( '' === get_option( 'woocommerce_category_archive_display' ) ) {
return;
}
break;
break;
}
}
@ -1806,7 +1749,9 @@ if ( ! function_exists( 'woocommerce_product_subcategories' ) ) {
) ) );
if ( apply_filters( 'woocommerce_product_subcategories_hide_empty', true ) ) {
$product_categories = wp_list_filter( $product_categories, array( 'count' => 0 ), 'NOT' );
$product_categories = wp_list_filter( $product_categories, array(
'count' => 0,
), 'NOT' );
}
if ( $product_categories ) {
@ -1823,16 +1768,16 @@ if ( ! function_exists( 'woocommerce_product_subcategories' ) ) {
$display_type = get_woocommerce_term_meta( $term->term_id, 'display_type', true );
switch ( $display_type ) {
case 'subcategories' :
case 'subcategories':
$wp_query->post_count = 0;
$wp_query->max_num_pages = 0;
break;
case '' :
break;
case '':
if ( 'subcategories' === get_option( 'woocommerce_category_archive_display' ) ) {
$wp_query->post_count = 0;
$wp_query->max_num_pages = 0;
}
break;
break;
}
}
@ -1854,12 +1799,11 @@ if ( ! function_exists( 'woocommerce_subcategory_thumbnail' ) ) {
* Show subcategory thumbnails.
*
* @param mixed $category Category.
* @subpackage Loop
*/
function woocommerce_subcategory_thumbnail( $category ) {
$small_thumbnail_size = apply_filters( 'subcategory_archive_thumbnail_size', 'woocommerce_thumbnail' );
$dimensions = wc_get_image_size( $small_thumbnail_size );
$thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true );
$small_thumbnail_size = apply_filters( 'subcategory_archive_thumbnail_size', 'woocommerce_thumbnail' );
$dimensions = wc_get_image_size( $small_thumbnail_size );
$thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true );
if ( $thumbnail_id ) {
$image = wp_get_attachment_image_src( $thumbnail_id, $small_thumbnail_size );
@ -1868,7 +1812,8 @@ if ( ! function_exists( 'woocommerce_subcategory_thumbnail' ) ) {
$image_sizes = function_exists( 'wp_get_attachment_image_sizes' ) ? wp_get_attachment_image_sizes( $thumbnail_id, $small_thumbnail_size ) : false;
} else {
$image = wc_placeholder_img_src();
$image_srcset = $image_sizes = false;
$image_srcset = false;
$image_sizes = false;
}
if ( $image ) {
@ -1892,7 +1837,6 @@ if ( ! function_exists( 'woocommerce_order_details_table' ) ) {
* Displays order details in a table.
*
* @param mixed $order_id Order ID.
* @subpackage Orders
*/
function woocommerce_order_details_table( $order_id ) {
if ( ! $order_id ) {
@ -1929,7 +1873,6 @@ if ( ! function_exists( 'woocommerce_order_again_button' ) ) {
* Display an 'order again' button on the view order page.
*
* @param object $order Order.
* @subpackage Orders
*/
function woocommerce_order_again_button( $order ) {
if ( ! $order || ! $order->has_status( apply_filters( 'woocommerce_valid_order_statuses_for_order_again', array( 'completed' ) ) ) || ! is_user_logged_in() ) {
@ -1949,12 +1892,9 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
/**
* Outputs a checkout/address form field.
*
* @subpackage Forms
*
* @param string $key Key.
* @param mixed $args Arguments.
* @param string $value (default: null).
*
* @return string
*/
function woocommerce_form_field( $key, $args, $value = null ) {
@ -2031,8 +1971,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
$field_container = '<p class="form-row %1$s" id="%2$s" data-priority="' . esc_attr( $sort ) . '">%3$s</p>';
switch ( $args['type'] ) {
case 'country' :
case 'country':
$countries = 'shipping_country' === $key ? WC()->countries->get_shipping_countries() : WC()->countries->get_allowed_countries();
if ( 1 === count( $countries ) ) {
@ -2056,7 +1995,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
}
break;
case 'state' :
case 'state':
/* Get country this state field is representing */
$for_country = isset( $args['country'] ) ? $args['country'] : WC()->checkout->get_value( 'billing_state' === $key ? 'billing_country' : 'shipping_country' );
$states = WC()->countries->get_states( $for_country );
@ -2085,30 +2024,27 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
}
break;
case 'textarea' :
case 'textarea':
$field .= '<textarea name="' . esc_attr( $key ) . '" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" ' . ( empty( $args['custom_attributes']['rows'] ) ? ' rows="2"' : '' ) . ( empty( $args['custom_attributes']['cols'] ) ? ' cols="5"' : '' ) . implode( ' ', $custom_attributes ) . '>' . esc_textarea( $value ) . '</textarea>';
break;
case 'checkbox' :
case 'checkbox':
$field = '<label class="checkbox ' . implode( ' ', $args['label_class'] ) . '" ' . implode( ' ', $custom_attributes ) . '>
<input type="' . esc_attr( $args['type'] ) . '" class="input-checkbox ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" value="1" ' . checked( $value, 1, false ) . ' /> '
. $args['label'] . $required . '</label>';
break;
case 'password' :
case 'text' :
case 'email' :
case 'tel' :
case 'number' :
case 'password':
case 'text':
case 'email':
case 'tel':
case 'number':
$field .= '<input type="' . esc_attr( $args['type'] ) . '" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
break;
case 'select' :
$options = $field = '';
case 'select':
$field = '';
$options = '';
if ( ! empty( $args['options'] ) ) {
foreach ( $args['options'] as $option_key => $option_text ) {
@ -2128,8 +2064,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
}
break;
case 'radio' :
case 'radio':
$label_id = current( array_keys( $args['options'] ) );
if ( ! empty( $args['options'] ) ) {
@ -2145,7 +2080,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
if ( ! empty( $field ) ) {
$field_html = '';
if ( $args['label'] && 'checkbox' != $args['type'] ) {
if ( $args['label'] && 'checkbox' !== $args['type'] ) {
$field_html .= '<label for="' . esc_attr( $label_id ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) . '">' . $args['label'] . $required . '</label>';
}
@ -2181,11 +2116,10 @@ if ( ! function_exists( 'get_product_search_form' ) ) {
*
* The default searchform uses html5.
*
* @subpackage Forms
* @param bool $echo (default: true).
* @return string
*/
function get_product_search_form( $echo = true ) {
function get_product_search_form( $echo = true ) {
global $product_search_form_index;
ob_start();
@ -2263,7 +2197,7 @@ if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) {
'options' => false,
'attribute' => false,
'product' => false,
'selected' => false,
'selected' => false,
'name' => '',
'id' => '',
'class' => '',
@ -2290,10 +2224,12 @@ if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) {
if ( ! empty( $options ) ) {
if ( $product && taxonomy_exists( $attribute ) ) {
// Get terms if this is a taxonomy - ordered. We need the names too.
$terms = wc_get_product_terms( $product->get_id(), $attribute, array( 'fields' => 'all' ) );
$terms = wc_get_product_terms( $product->get_id(), $attribute, array(
'fields' => 'all',
) );
foreach ( $terms as $term ) {
if ( in_array( $term->slug, $options ) ) {
if ( in_array( $term->slug, $options, true ) ) {
$html .= '<option value="' . esc_attr( $term->slug ) . '" ' . selected( sanitize_title( $args['selected'] ), $term->slug, false ) . '>' . esc_html( apply_filters( 'woocommerce_variation_option_name', $term->name ) ) . '</option>';
}
}
@ -2360,7 +2296,11 @@ if ( ! function_exists( 'woocommerce_account_orders' ) ) {
*/
function woocommerce_account_orders( $current_page ) {
$current_page = empty( $current_page ) ? 1 : absint( $current_page );
$customer_orders = wc_get_orders( apply_filters( 'woocommerce_my_account_my_orders_query', array( 'customer' => get_current_user_id(), 'page' => $current_page, 'paginate' => true ) ) );
$customer_orders = wc_get_orders( apply_filters( 'woocommerce_my_account_my_orders_query', array(
'customer' => get_current_user_id(),
'page' => $current_page,
'paginate' => true,
) ) );
wc_get_template(
'myaccount/orders.php',
@ -2504,10 +2444,10 @@ if ( ! function_exists( 'wc_display_item_meta' ) ) {
$html = '';
$args = wp_parse_args( $args, array(
'before' => '<ul class="wc-item-meta"><li>',
'after' => '</li></ul>',
'separator' => '</li><li>',
'echo' => true,
'autop' => false,
'after' => '</li></ul>',
'separator' => '</li><li>',
'echo' => true,
'autop' => false,
) );
foreach ( $item->get_formatted_meta_data() as $meta_id => $meta ) {
@ -2549,7 +2489,9 @@ if ( ! function_exists( 'wc_display_item_downloads' ) ) {
'show_url' => false,
) );
if ( is_object( $item ) && $item->is_type( 'line_item' ) && ( $downloads = $item->get_item_downloads() ) ) {
$downloads = is_object( $item ) && $item->is_type( 'line_item' ) ? $item->get_item_downloads() : array();
if ( $downloads ) {
$i = 0;
foreach ( $downloads as $file ) {
$i ++;
@ -2557,6 +2499,7 @@ if ( ! function_exists( 'wc_display_item_downloads' ) ) {
if ( $args['show_url'] ) {
$strings[] = '<strong class="wc-item-download-label">' . esc_html( $file['name'] ) . ':</strong> ' . esc_html( $file['download_url'] );
} else {
/* translators: %d: downloads count */
$prefix = count( $downloads ) > 1 ? sprintf( __( 'Download %d', 'woocommerce' ), $i ) : __( 'Download', 'woocommerce' );
$strings[] = '<strong class="wc-item-download-label">' . $prefix . ':</strong> <a href="' . esc_url( $file['download_url'] ) . '" target="_blank">' . esc_html( $file['name'] ) . '</a>';
}

View File

@ -264,7 +264,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
continue;
}
echo '<option value="' . esc_attr( $term->slug ) . '" ' . selected( $option_is_set, true, false ) . '>' . esc_html( $term->name ) . '</option>';
echo '<option value="' . esc_attr( urldecode( $term->slug ) ) . '" ' . selected( $option_is_set, true, false ) . '>' . esc_html( $term->name ) . '</option>';
}
echo '</select>';

View File

@ -45,7 +45,7 @@
"istanbul": "^1.0.0-alpha",
"mocha": "^3.0.2",
"stylelint": "~8.2.0",
"wc-e2e-page-objects": "0.4.0"
"wc-e2e-page-objects": "0.5.0"
},
"engines": {
"node": ">=6.9.4",

View File

@ -11,14 +11,20 @@
<exclude-pattern>includes/gateways/simplify-commerce/includes/</exclude-pattern>
<exclude-pattern>includes/libraries/</exclude-pattern>
<exclude-pattern>includes/api/legacy/</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<!-- Configs -->
<config name="minimum_supported_wp_version" value="4.5" />
<config name="testVersion" value="5.2-"/>
<!-- Rules -->
<rule ref="PHPCompatibility"/>
<rule ref="WordPress">
<exclude name="WordPress.VIP.RestrictedFunctions" />
<exclude name="WordPress.VIP.OrderByRand" />
</rule>
<rule ref="WordPress.VIP.ValidatedSanitizedInput">
<properties>
<property name="customSanitizingFunctions" type="array" value="wc_clean,wc_sanitize_tooltip,wc_format_decimal,wc_stock_amount" />
@ -28,5 +34,10 @@
<properties>
<property name="customEscapingFunctions" type="array" value="wc_help_tip,wc_sanitize_tooltip" />
</properties>
</rule>
</rule>
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="woocommerce" />
</properties>
</rule>
</ruleset>

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
if [[ $TRAVIS_PHP_VERSION == '7.1' ]]; then
if [[ ${RUN_PHPCS} == 1 ]]; then
CHANGED_FILES=`git diff --name-only --diff-filter=ACMR $TRAVIS_COMMIT_RANGE | grep \\\\.php | awk '{print}' ORS=' '`
IGNORE="tests/cli/,apigen/,includes/gateways/simplify-commerce/includes/,includes/libraries/,includes/api/legacy/"

View File

@ -15,6 +15,10 @@ if [ $1 == 'before' ]; then
composer global require "phpunit/phpunit=6.2.*"
fi
if [[ ${RUN_PHPCS} == 1 ]]; then
composer install
fi
# Remove Xdebug from PHP runtime for all PHP version except 7.1 to speed up builds.
# We need Xdebug enabled in the PHP 7.1 build job as it is used to generate code coverage.
if [[ ${RUN_CODE_COVERAGE} != 1 ]]; then

View File

@ -12,7 +12,8 @@ let manager;
let driver;
test.describe( 'Cart page', function() {
test.before( 'open browser', function() {
// open browser
test.before( function() {
this.timeout( config.get( 'startBrowserTimeoutMs' ) );
manager = new WebDriverManager( 'chrome', { baseUrl: config.get( 'url' ) } );
@ -93,7 +94,7 @@ test.describe( 'Cart page', function() {
);
} );
test.it( 'should go to the checkout page when "Proceed to Chcekout" is clicked', () => {
test.it( 'should go to the checkout page when "Proceed to Checkout" is clicked', () => {
const cartPage = new CartPage( driver, { url: manager.getPageUrl( '/cart' ) } );
const checkoutPage = cartPage.checkout();
@ -104,7 +105,8 @@ test.describe( 'Cart page', function() {
);
} );
test.after( 'quit browser', () => {
// quit browser
test.after( () => {
manager.quitBrowser();
} );
} );

View File

@ -26,7 +26,8 @@ let manager;
let driver;
test.describe( 'Checkout Page', function() {
test.before( 'open browser', function() {
// open browser
test.before( function() {
this.timeout( config.get( 'startBrowserTimeoutMs' ) );
manager = new WebDriverManager( 'chrome', { baseUrl: config.get( 'url' ) } );
@ -148,7 +149,8 @@ test.describe( 'Checkout Page', function() {
);
} );
test.after( 'quit browser', () => {
// quit browser
test.after( () => {
manager.quitBrowser();
} );
} );

View File

@ -16,7 +16,8 @@ let manager;
let driver;
test.describe( 'Single Product Page', function() {
test.before( 'open browser', function() {
// open browser
test.before( function() {
this.timeout( config.get( 'startBrowserTimeoutMs' ) );
manager = new WebDriverManager( 'chrome', { baseUrl: config.get( 'url' ) } );
@ -52,7 +53,8 @@ test.describe( 'Single Product Page', function() {
assert.eventually.equal( cartPage.hasItem( 'Hoodie - Green' ), true );
} );
test.after( 'quit browser', () => {
// quit browser
test.after( () => {
manager.quitBrowser();
} );
} );

View File

@ -12,7 +12,8 @@ let manager;
let driver;
test.describe( 'Add New Coupon Page', function() {
test.before( 'open browser', function() {
// open browser
test.before( function() {
this.timeout( config.get( 'startBrowserTimeoutMs' ) );
manager = new WebDriverManager( 'chrome', { baseUrl: config.get( 'url' ) } );
@ -45,7 +46,8 @@ test.describe( 'Add New Coupon Page', function() {
assert.eventually.ok( couponPage.hasNotice( 'Coupon updated.' ) );
} );
test.after( 'quit browser', () => {
// quit browser
test.after( () => {
manager.quitBrowser();
} );
} );

View File

@ -12,7 +12,8 @@ let manager;
let driver;
test.describe( 'Add New Order Page', function() {
test.before( 'open browser', function() {
// open browser
test.before( function() {
this.timeout( config.get( 'startBrowserTimeoutMs' ) );
manager = new WebDriverManager( 'chrome', { baseUrl: config.get( 'url' ) } );
@ -46,7 +47,8 @@ test.describe( 'Add New Order Page', function() {
assert.eventually.ok( orderNotes.hasNote( 'Order status changed from Pending payment to Processing.' ) );
} );
test.after( 'quit browser', () => {
// quit browser
test.after( () => {
manager.quitBrowser();
} );
} );

View File

@ -13,7 +13,8 @@ let manager;
let driver;
test.describe( 'Add New Product Page', function() {
test.before( 'open browser', function() {
// open browser
test.before( function() {
this.timeout( config.get( 'startBrowserTimeoutMs' ) );
manager = new WebDriverManager( 'chrome', { baseUrl: config.get( 'url' ) } );
@ -24,7 +25,8 @@ test.describe( 'Add New Product Page', function() {
this.timeout( config.get( 'mochaTimeoutMs' ) );
test.before( 'login', () => {
// login
test.before( () => {
const wpLogin = new WPLogin( driver, { url: manager.getPageUrl( '/wp-login.php' ) } );
wpLogin.login( config.get( 'users.admin.username' ), config.get( 'users.admin.password' ) );
} );
@ -121,7 +123,8 @@ test.describe( 'Add New Product Page', function() {
assert.eventually.ok( product.hasNotice( '1 product moved to the Trash.' ) );
} );
test.after( 'quit browser', () => {
// quit browser
test.after( () => {
manager.quitBrowser();
} );
} );

View File

@ -13,7 +13,8 @@ let manager;
let driver;
test.describe( 'WooCommerce General Settings', function() {
test.before( 'open browser', function() {
// open browser
test.before( function() {
this.timeout( config.get( 'startBrowserTimeoutMs' ) );
manager = new WebDriverManager( 'chrome', { baseUrl: config.get( 'url' ) } );
@ -24,7 +25,8 @@ test.describe( 'WooCommerce General Settings', function() {
this.timeout( config.get( 'mochaTimeoutMs' ) );
test.before( 'login', () => {
// login
test.before( () => {
const wpLogin = new WPLogin( driver, { url: manager.getPageUrl( '/wp-login.php' ) } );
wpLogin.login( config.get( 'users.admin.username' ), config.get( 'users.admin.password' ) );
} );
@ -64,7 +66,8 @@ test.describe( 'WooCommerce General Settings', function() {
assert.eventually.ok( settings.hasNotice( 'Your settings have been saved.' ) );
} );
test.after( 'quit browser', () => {
// quit browser
test.after( () => {
manager.quitBrowser();
} );
} );

View File

@ -13,7 +13,8 @@ let manager;
let driver;
test.describe( 'WooCommerce Products > Downloadable Products Settings', function() {
test.before( 'open browser', function() {
// open browser
test.before( function() {
this.timeout( config.get( 'startBrowserTimeoutMs' ) );
manager = new WebDriverManager( 'chrome', { baseUrl: config.get( 'url' ) } );
@ -24,7 +25,8 @@ test.describe( 'WooCommerce Products > Downloadable Products Settings', function
this.timeout( config.get( 'mochaTimeoutMs' ) );
test.before( 'login', () => {
// login
test.before( () => {
const wpLogin = new WPLogin( driver, { url: manager.getPageUrl( '/wp-login.php' ) } );
wpLogin.login( config.get( 'users.admin.username' ), config.get( 'users.admin.password' ) );
} );
@ -49,7 +51,8 @@ test.describe( 'WooCommerce Products > Downloadable Products Settings', function
assert.eventually.ok( settings.hasNotice( 'Your settings have been saved.' ) );
} );
test.after( 'quit browser', () => {
// quit browser
test.after( () => {
manager.quitBrowser();
} );
} );

View File

@ -13,7 +13,8 @@ let manager;
let driver;
test.describe( 'WooCommerce Tax Settings', function() {
test.before( 'open browser', function() {
// open browser
test.before( function() {
this.timeout( config.get( 'startBrowserTimeoutMs' ) );
manager = new WebDriverManager( 'chrome', { baseUrl: config.get( 'url' ) } );
@ -24,7 +25,8 @@ test.describe( 'WooCommerce Tax Settings', function() {
this.timeout( config.get( 'mochaTimeoutMs' ) );
test.before( 'login', () => {
// login
test.before( () => {
const wpLogin = new WPLogin( driver, { url: manager.getPageUrl( '/wp-login.php' ) } );
wpLogin.login( config.get( 'users.admin.username' ), config.get( 'users.admin.password' ) );
} );
@ -93,7 +95,8 @@ test.describe( 'WooCommerce Tax Settings', function() {
assert.eventually.ifError( settings.hasSubTab( 'Fancy rates' ) );
} );
test.after( 'quit browser', () => {
// quit browser
test.after( () => {
manager.quitBrowser();
} );
} );

View File

@ -16,15 +16,15 @@ class WC_Helper_Order {
$order = wc_get_order( $order_id );
// Delete all products in the order
foreach ( $order->get_items() as $item ) :
// Delete all products in the order.
foreach ( $order->get_items() as $item ) {
WC_Helper_Product::delete_product( $item['product_id'] );
endforeach;
}
WC_Helper_Shipping::delete_simple_flat_rate();
// Delete the order post
wp_delete_post( $order_id, true );
// Delete the order post.
$order->delete( true );
}
/**

View File

@ -267,12 +267,13 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
/**
* Tests updating an order.
*
* @since 3.0.0
*/
public function test_update_order() {
wp_set_current_user( $this->user );
$order = WC_Helper_Order::create_order();
$request = new WP_REST_Request( 'POST', '/wc/v2/orders/' . $order->get_id() );
$order = WC_Helper_Order::create_order();
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
$request->set_body_params( array(
'payment_method' => 'test-update',
'billing' => array(
@ -288,17 +289,56 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
$this->assertEquals( 'Fish', $data['billing']['first_name'] );
$this->assertEquals( 'Face', $data['billing']['last_name'] );
wp_delete_post( $order->get_id(), true );
WC_Helper_Order::delete_order( $order->get_id() );
}
/**
* Tests updating an order and removing items.
*
* @since 3.0.0
*/
public function test_update_order_remove_items() {
wp_set_current_user( $this->user );
$order = WC_Helper_Order::create_order();
$fee = new WC_Order_Item_Fee();
$fee->set_props( array(
'name' => 'Some Fee',
'tax_status' => 'taxable',
'total' => '100',
'tax_class' => '',
) );
$order->add_item( $fee );
$order->save();
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
$fee_data = current( $order->get_items( 'fee' ) );
$request->set_body_params( array(
'fee_lines' => array(
array(
'id' => $fee_data->get_id(),
'name' => null,
),
),
) );
$response = $this->server->dispatch( $request );
$data = $response->get_data();
$this->assertEquals( 200, $response->get_status() );
$this->assertTrue( empty( $data['fee_lines'] ) );
WC_Helper_Order::delete_order( $order->get_id() );
}
/**
* Tests updating an order without the correct permissions.
*
* @since 3.0.0
*/
public function test_update_order_without_permission() {
wp_set_current_user( 0 );
$order = WC_Helper_Order::create_order();
$request = new WP_REST_Request( 'POST', '/wc/v2/orders/' . $order->get_id() );
$order = WC_Helper_Order::create_order();
$request = new WP_REST_Request( 'PUT', '/wc/v2/orders/' . $order->get_id() );
$request->set_body_params( array(
'payment_method' => 'test-update',
'billing' => array(
@ -308,6 +348,7 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
) );
$response = $this->server->dispatch( $request );
$this->assertEquals( 401, $response->get_status() );
WC_Helper_Order::delete_order( $order->get_id() );
}
/**