merging upstream changes

This commit is contained in:
Patrick Rauland 2014-02-25 08:07:39 -06:00
commit 61a175173e
5 changed files with 45 additions and 34 deletions

View File

@ -566,15 +566,6 @@ class WC_Admin_CPT_Shop_Order extends WC_Admin_CPT {
// Search orders
$post_ids = array_unique( array_merge(
$wpdb->get_col(
$wpdb->prepare( "
SELECT post_id
FROM {$wpdb->postmeta}
WHERE meta_key IN ('" . implode( "','", $search_fields ) . "') AND meta_value LIKE '%%%s%%'
",
esc_attr( $_GET['s'] )
)
),
$wpdb->get_col(
$wpdb->prepare( "
SELECT p1.post_id
@ -584,8 +575,10 @@ class WC_Admin_CPT_Shop_Order extends WC_Admin_CPT {
( p1.meta_key = '_billing_first_name' AND p2.meta_key = '_billing_last_name' AND CONCAT(p1.meta_value, ' ', p2.meta_value) LIKE '%%%s%%' )
OR
( p1.meta_key = '_shipping_first_name' AND p2.meta_key = '_shipping_last_name' AND CONCAT(p1.meta_value, ' ', p2.meta_value) LIKE '%%%s%%' )
OR
( p1.meta_key IN ('" . implode( "','", $search_fields ) . "') AND p1.meta_value LIKE '%%%s%%' )
",
esc_attr( $_GET['s'] ), esc_attr( $_GET['s'] )
esc_attr( $_GET['s'] ), esc_attr( $_GET['s'] ), esc_attr( $_GET['s'] )
)
),
$wpdb->get_col(

View File

@ -576,7 +576,7 @@ class WC_API_Server {
}
/**
* Returns the request URL with the page query parmeter set to the specified page
* Returns the request URL with the page query parameter set to the specified page
*
* @since 2.1
* @param int $page
@ -590,8 +590,10 @@ class WC_API_Server {
// add provided page query param
$request = urldecode( add_query_arg( 'page', $page, $request ) );
// return full URL
return get_woocommerce_api_url( str_replace( '/wc-api/v1/', '', $request ) );
// get the home host
$host = parse_url( get_home_url(), PHP_URL_HOST );
return set_url_scheme( "http://{$host}{$request}" );
}
/**

View File

@ -256,7 +256,15 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
$extra_rate['label'] = $this_option[0];
$this_cost = $this_option[1];
if (preg_match('/(\d+\.?\d*)\s*(\+|-)\s*(\d+\.?\d*)\%/', $this_cost, $this_cost_matches)) {
$pattern =
'/' . // start regex
'(\d+\.?\d*)' . // capture digits, optionally capture a `.` and more digits
'\s*' . // match whitespace
'(\+|-)' . // capture the operand
'\s*'. // match whitespace
'(\d+\.?\d*)'. // capture digits, optionally capture a `.` and more digits
'\%/'; // match the percent sign & end regex
if ( preg_match( $pattern, $this_cost, $this_cost_matches ) ) {
$this_cost_mathop = $this_cost_matches[2];
$this_cost_percents = $this_cost_matches[3] / 100;
$this_cost = $this_cost_matches[1];
@ -280,12 +288,7 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
if ( $this_cost_percents ) {
foreach ( $this->find_shipping_classes( $package ) as $shipping_class => $items ){
foreach ( $items as $item_id => $values ) {
if ($this_cost_mathop == '+') {
$this_cost += $this_cost_percents * $values['line_total'];
}
else {
$this_cost -= $this_cost_percents * $values['line_total'];
}
$this_cost = $this->calc_percentage_adjustment( $this_cost, $this_cost_percents, $this_cost_mathop, $values['line_total'] );
}
}
}
@ -296,22 +299,14 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
// Factor $this_cost by the percentage if provided.
if ( $this_cost_percents ) {
foreach ( $package['contents'] as $item_id => $values ) {
if ($this_cost_mathop == '+') {
$this_cost += $this_cost_percents * $values['line_total'];
} else {
$this_cost -= $this_cost_percents * $values['line_total'];
}
$this_cost = $this->calc_percentage_adjustment( $this_cost, $this_cost_percents, $this_cost_mathop, $values['line_total'] );
}
}
break;
case 'order' :
// Factor $this_cost by the percentage if provided.
if ( $this_cost_percents ) {
if ($this_cost_mathop == '+') {
$this_cost += $this_cost_percents * $package['contents_cost'];
} else {
$this_cost -= $this_cost_percents * $package['contents_cost'];
}
$this_cost = $this->calc_percentage_adjustment( $this_cost, $this_cost_percents, $this_cost_mathop, $package['contents_cost'] );
}
break;
}
@ -328,6 +323,27 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
}
/**
* Calculate the percentage adjustment for each shipping rate.
*
* @access public
* @param float $cost
* @param float $percent_adjustment
* @param string $percent_operator
* @param float $base_price
* @return float
*/
function calc_percentage_adjustment( $cost, $percent_adjustment, $percent_operator, $base_price ) {
if ( '+' == $percent_operator ) {
$cost += $percent_adjustment * $base_price;
} else {
$cost -= $percent_adjustment * $base_price;
}
return $cost;
}
/**
* order_shipping function.
*

View File

@ -212,7 +212,7 @@ class WC_Shortcode_My_Account {
wc_add_notice( __( 'Enter a username or e-mail address.', 'woocommerce' ), 'error' );
} elseif ( strpos( $_POST['user_login'], '@' ) ) {
} elseif ( strpos( $_POST['user_login'], '@' ) && apply_filters( 'woocommerce_get_username_from_email', true ) ) {
$user_data = get_user_by( 'email', trim( $_POST['user_login'] ) );
@ -223,7 +223,7 @@ class WC_Shortcode_My_Account {
$login = trim( $_POST['user_login'] );
$user_data = get_user_by('login', $login );
$user_data = get_user_by( 'login', $login );
}
do_action('lostpassword_post');

View File

@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
foreach ( $item_data as $data ) :
$key = sanitize_text_field( $data['key'] );
?>
<dt class="variation-<?php echo $key; ?>"><?php echo wp_kses_post( $data['key'] ); ?>:</dt>
<dd class="variation-<?php echo $key; ?>"><?php echo wp_kses_post( wpautop( $data['value'] ) ); ?></dd>
<dt class="variation-<?php echo sanitize_html_class( $key ); ?>"><?php echo wp_kses_post( $data['key'] ); ?>:</dt>
<dd class="variation-<?php echo sanitize_html_class( $key ); ?>"><?php echo wp_kses_post( wpautop( $data['value'] ) ); ?></dd>
<?php endforeach; ?>
</dl>