Merge remote-tracking branch 'woothemes/master'

This commit is contained in:
Job 2016-07-25 16:17:31 +02:00
commit bf3b9b508d
25 changed files with 935 additions and 434 deletions

View File

@ -45,9 +45,9 @@ class WC_HookFinder {
private static function get_hook_link( $hook, $details = array() ) {
if ( ! empty( $details['class'] ) ) {
$link = 'http://docs.woothemes.com/wc-apidocs/source-class-' . $details['class'] . '.html#' . $details['line'];
$link = 'http://docs.woocommerce.com/wc-apidocs/source-class-' . $details['class'] . '.html#' . $details['line'];
} elseif ( ! empty( $details['function'] ) ) {
$link = 'http://docs.woothemes.com/wc-apidocs/source-function-' . $details['function'] . '.html#' . $details['line'];
$link = 'http://docs.woocommerce.com/wc-apidocs/source-function-' . $details['function'] . '.html#' . $details['line'];
} else {
$link = 'https://github.com/woothemes/woocommerce/search?utf8=%E2%9C%93&q=' . $hook;
}

File diff suppressed because one or more lines are too long

View File

@ -585,7 +585,7 @@ ul.wc_coupon_list_block {
.hour,
.minute {
width: 2.5em;
width: 3em;
}
small {

View File

@ -104,14 +104,15 @@
$form.find( '.variations select' ).each( function() {
var attribute_name = $( this ).data( 'attribute_name' ) || $( this ).attr( 'name' );
var value = $( this ).val() || '';
if ( $( this ).val().length === 0 ) {
if ( value.length === 0 ) {
all_attributes_chosen = false;
} else {
some_attributes_chosen = true;
}
data[ attribute_name ] = $( this ).val();
data[ attribute_name ] = value;
});
if ( all_attributes_chosen ) {
@ -266,8 +267,9 @@
$form.find( '.variations select' ).each( function() {
var attribute_name = $( this ).data( 'attribute_name' ) || $( this ).attr( 'name' );
var value = $( this ).val() || '';
if ( $( this ).val().length === 0 ) {
if ( value.length === 0 ) {
all_attributes_chosen = false;
} else {
some_attributes_chosen = true;
@ -278,7 +280,7 @@
current_settings[ attribute_name ] = '';
} else {
// Add to settings array
current_settings[ attribute_name ] = $( this ).val();
current_settings[ attribute_name ] = value;
}
});

File diff suppressed because one or more lines are too long

View File

@ -574,6 +574,10 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
'posts_per_page',
'meta_query',
'tax_query',
'meta_key',
'meta_value',
'meta_compare',
'meta_value_num',
);
$valid_vars = array_merge( $valid_vars, $rest_valid );

View File

@ -650,7 +650,7 @@ class WC_Admin_Post_Types {
$item_meta = new WC_Order_Item_Meta( $item, $product );
$item_meta_html = $item_meta->display( true, true );
?>
<tr class="<?php echo apply_filters( 'woocommerce_admin_order_item_class', '', $item ); ?>">
<tr class="<?php echo apply_filters( 'woocommerce_admin_order_item_class', '', $item, $the_order ); ?>">
<td class="qty"><?php echo absint( $item['qty'] ); ?></td>
<td class="name">
<?php if ( $product ) : ?>

View File

@ -153,7 +153,7 @@ class WC_Admin_Profile {
foreach ( $show_fields as $fieldset ) :
?>
<h3><?php echo $fieldset['title']; ?></h3>
<h2><?php echo $fieldset['title']; ?></h2>
<table class="form-table">
<?php
foreach ( $fieldset['fields'] as $key => $field ) :

View File

@ -197,7 +197,7 @@ class WC_Meta_Box_Order_Data {
<h3><?php _e( 'General Details', 'woocommerce' ); ?></h3>
<p class="form-field form-field-wide"><label for="order_date"><?php _e( 'Order date:', 'woocommerce' ) ?></label>
<input type="text" class="date-picker" name="order_date" id="order_date" maxlength="10" value="<?php echo date_i18n( 'Y-m-d', strtotime( $post->post_date ) ); ?>" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />@<input type="text" class="hour" placeholder="<?php esc_attr_e( 'h', 'woocommerce' ) ?>" name="order_date_hour" id="order_date_hour" maxlength="2" size="2" value="<?php echo date_i18n( 'H', strtotime( $post->post_date ) ); ?>" pattern="([01]?[0-9]{1}|2[0-3]{1})" />:<input type="text" class="minute" placeholder="<?php esc_attr_e( 'm', 'woocommerce' ) ?>" name="order_date_minute" id="order_date_minute" maxlength="2" size="2" value="<?php echo date_i18n( 'i', strtotime( $post->post_date ) ); ?>" pattern="[0-5]{1}[0-9]{1}" />
<input type="text" class="date-picker" name="order_date" id="order_date" maxlength="10" value="<?php echo date_i18n( 'Y-m-d', strtotime( $post->post_date ) ); ?>" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />@<input type="number" class="hour" placeholder="<?php esc_attr_e( 'h', 'woocommerce' ) ?>" name="order_date_hour" id="order_date_hour" min="0" max="23" step="1" value="<?php echo date_i18n( 'H', strtotime( $post->post_date ) ); ?>" pattern="([01]?[0-9]{1}|2[0-3]{1})" />:<input type="number" class="minute" placeholder="<?php esc_attr_e( 'm', 'woocommerce' ) ?>" name="order_date_minute" id="order_date_minute" min="0" max="59" step="1" value="<?php echo date_i18n( 'i', strtotime( $post->post_date ) ); ?>" pattern="[0-5]{1}[0-9]{1}" />
</p>
<p class="form-field form-field-wide wc-order-status"><label for="order_status"><?php _e( 'Order status:', 'woocommerce' ) ?> <?php

View File

@ -15,7 +15,7 @@ $tax_data = empty( $legacy_order ) && wc_tax_enabled() ? maybe_unserialize(
$item_total = ( isset( $item['line_total'] ) ) ? esc_attr( wc_format_localized_price( $item['line_total'] ) ) : '';
$item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_localized_price( $item['line_subtotal'] ) ) : '';
?>
<tr class="item <?php echo apply_filters( 'woocommerce_admin_html_order_item_class', ( ! empty( $class ) ? $class : '' ), $item ); ?>" data-order_item_id="<?php echo $item_id; ?>">
<tr class="item <?php echo apply_filters( 'woocommerce_admin_html_order_item_class', ( ! empty( $class ) ? $class : '' ), $item, $order ); ?>" data-order_item_id="<?php echo $item_id; ?>">
<td class="thumb">
<?php
echo '<div class="wc-order-item-thumbnail">' . wp_kses_post( $thumbnail ) . '</div>';

View File

@ -181,7 +181,7 @@ class WC_Settings_Products extends WC_Settings_Page {
array(
'title' => __( 'Catalog Images', 'woocommerce' ),
'desc' => __( 'This size is usually used in product listings', 'woocommerce' ),
'desc' => __( 'This size is usually used in product listings. (W x H)', 'woocommerce' ),
'id' => 'shop_catalog_image_size',
'css' => '',
'type' => 'image_width',
@ -195,7 +195,7 @@ class WC_Settings_Products extends WC_Settings_Page {
array(
'title' => __( 'Single Product Image', 'woocommerce' ),
'desc' => __( 'This is the size used by the main image on the product page.', 'woocommerce' ),
'desc' => __( 'This is the size used by the main image on the product page. (W x H)', 'woocommerce' ),
'id' => 'shop_single_image_size',
'css' => '',
'type' => 'image_width',
@ -209,7 +209,7 @@ class WC_Settings_Products extends WC_Settings_Page {
array(
'title' => __( 'Product Thumbnails', 'woocommerce' ),
'desc' => __( 'This size is usually used for the gallery of images on the product page.', 'woocommerce' ),
'desc' => __( 'This size is usually used for the gallery of images on the product page. (W x H)', 'woocommerce' ),
'id' => 'shop_thumbnail_image_size',
'css' => '',
'type' => 'image_width',

View File

@ -399,7 +399,7 @@ global $wpdb;
if ( file_exists( WC_Geolocation::get_local_database_path() ) ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> <code class="private">' . esc_html( WC_Geolocation::get_local_database_path() ) . '</code></mark> ';
} else {
printf( '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'The MaxMind GeoIP Database does not exist - Geolocation will not function. You can download and install it manually from %1$s to the path: %2$s', 'woocommerce' ), make_clickable( 'http://dev.maxmind.com/geoip/legacy/geolite/' ), '<code class="private">' . WC_Geolocation::get_local_database_path() . '</code>' ) . '</mark>', WC_LOG_DIR );
printf( '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'The MaxMind GeoIP Database does not exist - Geolocation will not function. You can download and install it manually from %1$s to the path: %2$s. Scroll down to \"Downloads\" and download the \"Binary / gzip\" file next to \"GeoLite Country\"', 'woocommerce' ), make_clickable( 'http://dev.maxmind.com/geoip/legacy/geolite/' ), '<code class="private">' . WC_Geolocation::get_local_database_path() . '</code>' ) . '</mark>', WC_LOG_DIR );
}
?></td>
</tr>

View File

@ -831,12 +831,8 @@ class WC_Cart {
*/
public function find_product_in_cart( $cart_id = false ) {
if ( $cart_id !== false ) {
if ( is_array( $this->cart_contents ) ) {
foreach ( $this->cart_contents as $cart_item_key => $cart_item ) {
if ( $cart_item_key == $cart_id ) {
return $cart_item_key;
}
}
if ( is_array( $this->cart_contents ) && isset( $this->cart_contents[ $cart_id ] ) ) {
return $cart_id;
}
}
return '';

View File

@ -376,7 +376,7 @@ class WC_Checkout {
$this->posted['createaccount'] = isset( $_POST['createaccount'] ) && ! empty( $_POST['createaccount'] ) ? 1 : 0;
$this->posted['payment_method'] = isset( $_POST['payment_method'] ) ? stripslashes( $_POST['payment_method'] ) : '';
$this->posted['shipping_method'] = isset( $_POST['shipping_method'] ) ? $_POST['shipping_method'] : '';
$this->posted['ship_to_different_address'] = isset( $_POST['ship_to_different_address'] ) ? true : false;
$this->posted['ship_to_different_address'] = ! empty( $_POST['ship_to_different_address'] );
if ( isset( $_POST['shiptobilling'] ) ) {
_deprecated_argument( 'WC_Checkout::process_checkout()', '2.1', 'The "shiptobilling" field is deprecated. The template files are out of date' );

View File

@ -254,7 +254,8 @@ class WC_Product_Variable extends WC_Product {
}
}
$price_hash = md5( json_encode( apply_filters( 'woocommerce_get_variation_prices_hash', $price_hash, $this, $display ) ) );
$price_hash[] = WC_Cache_Helper::get_transient_version( 'product' );
$price_hash = md5( json_encode( apply_filters( 'woocommerce_get_variation_prices_hash', $price_hash, $this, $display ) ) );
// If the value has already been generated, we don't need to grab the values again.
if ( empty( $this->prices_array[ $price_hash ] ) ) {

View File

@ -355,7 +355,8 @@ class WC_Webhook {
if ( is_wp_error( $response ) ) {
$response_code = $response->get_error_code();
$response_message = $response->get_error_message();
$response_headers = $response_body = array();
$response_headers = array();
$response_body = '';
} else {
$response_code = wp_remote_retrieve_response_code( $response );

View File

@ -1448,13 +1448,13 @@ class WC_CLI_Product extends WC_CLI_Command {
// Product categories
if ( isset( $data['categories'] ) ) {
$term_ids = array_unique( array_map( 'intval', (array) $data['categories'] ) );
$term_ids = array_unique( array_map( 'intval', explode( ',', $data['categories'] ) ) );
wp_set_object_terms( $product_id, $term_ids, 'product_cat' );
}
// Product tags
if ( isset( $data['tags'] ) ) {
$term_ids = array_unique( array_map( 'intval', (array) $data['tags'] ) );
$term_ids = array_unique( array_map( 'intval', explode( ',', $data['tags'] ) ) );
wp_set_object_terms( $product_id, $term_ids, 'product_tag' );
}

File diff suppressed because it is too large Load Diff

View File

@ -1367,15 +1367,16 @@ function wc_shipping_zone_method_order_uasort_comparison( $a, $b ) {
/**
* Get rounding precision.
* Get rounding precision for internal WC calculations.
* Will increase the precision of wc_get_price_decimals by 2 decimals, unless WC_ROUNDING_PRECISION is set to a higher number.
*
* @since 2.6.3
* @return int
*/
function wc_get_rounding_precision() {
if ( defined( 'WC_ROUNDING_PRECISION' ) ) {
return absint( WC_ROUNDING_PRECISION );
$precision = wc_get_price_decimals() + 2;
if ( absint( WC_ROUNDING_PRECISION ) > $precision ) {
$precision = absint( WC_ROUNDING_PRECISION );
}
return wc_get_price_decimals() + 2;
return $precision;
}

View File

@ -602,6 +602,11 @@ if ( ! function_exists( 'woocommerce_product_archive_description' ) ) {
* @subpackage Archives
*/
function woocommerce_product_archive_description() {
// Don't display the description on search results page
if ( is_search() ) {
return;
}
if ( is_post_type_archive( 'product' ) && 0 === absint( get_query_var( 'paged' ) ) ) {
$shop_page = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {

View File

@ -32,9 +32,11 @@ get_header( 'shop' ); ?>
do_action( 'woocommerce_before_main_content' );
?>
<header class="woocommerce-products-header">
<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
<h1 class="page-title"><?php woocommerce_page_title(); ?></h1>
<h1 class="woocommerce-products-header__title page-title"><?php woocommerce_page_title(); ?></h1>
<?php endif; ?>
@ -48,6 +50,8 @@ get_header( 'shop' ); ?>
do_action( 'woocommerce_archive_description' );
?>
</header>
<?php if ( have_posts() ) : ?>
<?php

View File

@ -30,6 +30,8 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php if ( ! WC()->cart->is_empty() ) : ?>
<?php do_action( 'woocommerce_before_mini_cart_contents' ); ?>
<?php
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
@ -67,6 +69,8 @@ if ( ! defined( 'ABSPATH' ) ) {
}
?>
<?php do_action( 'woocommerce_mini_cart_contents' ); ?>
<?php else : ?>
<li class="empty"><?php _e( 'No products in the cart.', 'woocommerce' ); ?></li>

View File

@ -61,7 +61,7 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?>
<td class="label">
<label for="product-<?php echo $product_id; ?>">
<?php echo $product->is_visible() ? '<a href="' . esc_url( apply_filters( 'woocommerce_grouped_product_list_link', get_permalink(), $product_id ) ) . '">' . esc_html( get_the_title() ) . '</a>' : esc_html( get_the_title() ); ?>
<?php echo $product->is_visible() ? '<a href="' . esc_url( apply_filters( 'woocommerce_grouped_product_list_link', get_permalink(), $product_id ) ) . '">' . get_the_title() . '</a>' : get_the_title(); ?>
</label>
</td>

View File

@ -46,6 +46,7 @@ class WC_Tests_Main_Class extends WC_Unit_Test_Case {
$this->assertEquals( $this->wc->version, WC_VERSION );
$this->assertEquals( WC_VERSION, WOOCOMMERCE_VERSION );
$this->assertEquals( 4, WC_ROUNDING_PRECISION );
$this->assertContains( WC_TAX_ROUNDING_MODE, array( 2, 1 ) );
$this->assertEquals( '|', WC_DELIMITER );
$this->assertNotEquals( WC_LOG_DIR, '' );

View File

@ -181,6 +181,7 @@ final class WooCommerce {
$this->define( 'WC_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
$this->define( 'WC_VERSION', $this->version );
$this->define( 'WOOCOMMERCE_VERSION', $this->version );
$this->define( 'WC_ROUNDING_PRECISION', 4 );
$this->define( 'WC_DISCOUNT_ROUNDING_MODE', 2 );
$this->define( 'WC_TAX_ROUNDING_MODE', 'yes' === get_option( 'woocommerce_prices_include_tax', 'no' ) ? 2 : 1 );
$this->define( 'WC_DELIMITER', '|' );