WordPress.PHP.YodaConditions.NotYoda
This commit is contained in:
parent
734f284fa4
commit
9668247b95
|
@ -710,7 +710,7 @@ class WC_Admin_Post_Types {
|
||||||
|
|
||||||
$latest_note = current( $latest_notes );
|
$latest_note = current( $latest_notes );
|
||||||
|
|
||||||
if ( isset( $latest_note->comment_content ) && $post->comment_count == 1 ) {
|
if ( isset( $latest_note->comment_content ) && 1 == $post->comment_count ) {
|
||||||
echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $latest_note->comment_content ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
|
echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $latest_note->comment_content ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
|
||||||
} elseif ( isset( $latest_note->comment_content ) ) {
|
} elseif ( isset( $latest_note->comment_content ) ) {
|
||||||
echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $latest_note->comment_content . '<br/><small style="display:block">' . sprintf( _n( 'plus %d other note', 'plus %d other notes', ( $post->comment_count - 1 ), 'woocommerce' ), $post->comment_count - 1 ) . '</small>' ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
|
echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $latest_note->comment_content . '<br/><small style="display:block">' . sprintf( _n( 'plus %d other note', 'plus %d other notes', ( $post->comment_count - 1 ), 'woocommerce' ), $post->comment_count - 1 ) . '</small>' ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
|
||||||
|
@ -931,7 +931,7 @@ class WC_Admin_Post_Types {
|
||||||
return $views;
|
return $views;
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = ( isset( $wp_query->query['orderby'] ) && $wp_query->query['orderby'] == 'menu_order title' ) ? 'current' : '';
|
$class = ( isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) ? 'current' : '';
|
||||||
$query_string = remove_query_arg( array( 'orderby', 'order' ) );
|
$query_string = remove_query_arg( array( 'orderby', 'order' ) );
|
||||||
$query_string = add_query_arg( 'orderby', urlencode( 'menu_order title' ), $query_string );
|
$query_string = add_query_arg( 'orderby', urlencode( 'menu_order title' ), $query_string );
|
||||||
$query_string = add_query_arg( 'order', urlencode( 'ASC' ), $query_string );
|
$query_string = add_query_arg( 'order', urlencode( 'ASC' ), $query_string );
|
||||||
|
@ -1111,13 +1111,13 @@ class WC_Admin_Post_Types {
|
||||||
if ( $product->is_type( 'simple' ) || $product->is_type( 'external' ) ) {
|
if ( $product->is_type( 'simple' ) || $product->is_type( 'external' ) ) {
|
||||||
|
|
||||||
if ( isset( $_REQUEST['_regular_price'] ) ) {
|
if ( isset( $_REQUEST['_regular_price'] ) ) {
|
||||||
$new_regular_price = $_REQUEST['_regular_price'] === '' ? '' : wc_format_decimal( $_REQUEST['_regular_price'] );
|
$new_regular_price = ( '' === $_REQUEST['_regular_price'] ) ? '' : wc_format_decimal( $_REQUEST['_regular_price'] );
|
||||||
update_post_meta( $post_id, '_regular_price', $new_regular_price );
|
update_post_meta( $post_id, '_regular_price', $new_regular_price );
|
||||||
} else {
|
} else {
|
||||||
$new_regular_price = null;
|
$new_regular_price = null;
|
||||||
}
|
}
|
||||||
if ( isset( $_REQUEST['_sale_price'] ) ) {
|
if ( isset( $_REQUEST['_sale_price'] ) ) {
|
||||||
$new_sale_price = $_REQUEST['_sale_price'] === '' ? '' : wc_format_decimal( $_REQUEST['_sale_price'] );
|
$new_sale_price = ( '' === $_REQUEST['_sale_price'] ) ? '' : wc_format_decimal( $_REQUEST['_sale_price'] );
|
||||||
update_post_meta( $post_id, '_sale_price', $new_sale_price );
|
update_post_meta( $post_id, '_sale_price', $new_sale_price );
|
||||||
} else {
|
} else {
|
||||||
$new_sale_price = null;
|
$new_sale_price = null;
|
||||||
|
@ -1136,7 +1136,7 @@ class WC_Admin_Post_Types {
|
||||||
update_post_meta( $post_id, '_sale_price_dates_from', '' );
|
update_post_meta( $post_id, '_sale_price_dates_from', '' );
|
||||||
update_post_meta( $post_id, '_sale_price_dates_to', '' );
|
update_post_meta( $post_id, '_sale_price_dates_to', '' );
|
||||||
|
|
||||||
if ( ! is_null( $new_sale_price ) && $new_sale_price !== '' ) {
|
if ( ! is_null( $new_sale_price ) && '' !== $new_sale_price ) {
|
||||||
update_post_meta( $post_id, '_price', $new_sale_price );
|
update_post_meta( $post_id, '_price', $new_sale_price );
|
||||||
} else {
|
} else {
|
||||||
update_post_meta( $post_id, '_price', $new_regular_price );
|
update_post_meta( $post_id, '_price', $new_regular_price );
|
||||||
|
@ -1254,7 +1254,7 @@ class WC_Admin_Post_Types {
|
||||||
|
|
||||||
// Sold Individually
|
// Sold Individually
|
||||||
if ( ! empty( $_REQUEST['_sold_individually'] ) ) {
|
if ( ! empty( $_REQUEST['_sold_individually'] ) ) {
|
||||||
if ( $_REQUEST['_sold_individually'] == 'yes' ) {
|
if ( 'yes' === $_REQUEST['_sold_individually'] ) {
|
||||||
update_post_meta( $post_id, '_sold_individually', 'yes' );
|
update_post_meta( $post_id, '_sold_individually', 'yes' );
|
||||||
} else {
|
} else {
|
||||||
update_post_meta( $post_id, '_sold_individually', '' );
|
update_post_meta( $post_id, '_sold_individually', '' );
|
||||||
|
@ -1386,7 +1386,7 @@ class WC_Admin_Post_Types {
|
||||||
|
|
||||||
if ( ! empty( $_REQUEST['_manage_stock'] ) ) {
|
if ( ! empty( $_REQUEST['_manage_stock'] ) ) {
|
||||||
|
|
||||||
if ( $_REQUEST['_manage_stock'] == 'yes' ) {
|
if ( 'yes' === $_REQUEST['_manage_stock'] ) {
|
||||||
update_post_meta( $post_id, '_manage_stock', 'yes' );
|
update_post_meta( $post_id, '_manage_stock', 'yes' );
|
||||||
} else {
|
} else {
|
||||||
update_post_meta( $post_id, '_manage_stock', 'no' );
|
update_post_meta( $post_id, '_manage_stock', 'no' );
|
||||||
|
@ -1506,7 +1506,7 @@ class WC_Admin_Post_Types {
|
||||||
public function shop_order_search_custom_fields( $wp ) {
|
public function shop_order_search_custom_fields( $wp ) {
|
||||||
global $pagenow;
|
global $pagenow;
|
||||||
|
|
||||||
if ( 'edit.php' != $pagenow || empty( $wp->query_vars['s'] ) || $wp->query_vars['post_type'] != 'shop_order' ) {
|
if ( 'edit.php' != $pagenow || empty( $wp->query_vars['s'] ) || 'shop_order' !== $wp->query_vars['post_type'] ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1537,7 +1537,7 @@ class WC_Admin_Post_Types {
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $typenow != 'shop_order' ) {
|
if ( 'shop_order' !== $typenow ) {
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ class WC_Tax_Rate_Importer extends WP_Importer {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function format_data_from_csv( $data, $enc ) {
|
public function format_data_from_csv( $data, $enc ) {
|
||||||
return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
|
return ( 'UTF-8' === $enc ) ? $data : utf8_encode( $data );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -302,7 +302,7 @@ class WC_Meta_Box_Order_Data {
|
||||||
$found_method = false;
|
$found_method = false;
|
||||||
|
|
||||||
foreach ( $payment_gateways as $gateway ) {
|
foreach ( $payment_gateways as $gateway ) {
|
||||||
if ( $gateway->enabled == "yes" ) {
|
if ( 'yes' === $gateway->enabled ) {
|
||||||
echo '<option value="' . esc_attr( $gateway->id ) . '" ' . selected( $payment_method, $gateway->id, false ) . '>' . esc_html( $gateway->get_title() ) . '</option>';
|
echo '<option value="' . esc_attr( $gateway->id ) . '" ' . selected( $payment_method, $gateway->id, false ) . '>' . esc_html( $gateway->get_title() ) . '</option>';
|
||||||
if ( $payment_method == $gateway->id ) {
|
if ( $payment_method == $gateway->id ) {
|
||||||
$found_method = true;
|
$found_method = true;
|
||||||
|
|
|
@ -47,7 +47,7 @@ class WC_Meta_Box_Order_Notes {
|
||||||
|
|
||||||
$note_classes = array( 'note' );
|
$note_classes = array( 'note' );
|
||||||
$note_classes[] = get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? 'customer-note' : '';
|
$note_classes[] = get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? 'customer-note' : '';
|
||||||
$note_classes[] = $note->comment_author === __( 'WooCommerce', 'woocommerce' ) ? 'system-note' : '';
|
$note_classes[] = ( __( 'WooCommerce', 'woocommerce' ) === $note->comment_author ) ? 'system-note' : '';
|
||||||
$note_classes = apply_filters( 'woocommerce_order_note_class', array_filter( $note_classes ), $note );
|
$note_classes = apply_filters( 'woocommerce_order_note_class', array_filter( $note_classes ), $note );
|
||||||
?>
|
?>
|
||||||
<li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( implode( ' ', $note_classes ) ); ?>">
|
<li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( implode( ' ', $note_classes ) ); ?>">
|
||||||
|
@ -56,7 +56,9 @@ class WC_Meta_Box_Order_Notes {
|
||||||
</div>
|
</div>
|
||||||
<p class="meta">
|
<p class="meta">
|
||||||
<abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( 'added on %1$s at %2$s', 'woocommerce' ), date_i18n( wc_date_format(), strtotime( $note->comment_date ) ), date_i18n( wc_time_format(), strtotime( $note->comment_date ) ) ); ?></abbr>
|
<abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( 'added on %1$s at %2$s', 'woocommerce' ), date_i18n( wc_date_format(), strtotime( $note->comment_date ) ), date_i18n( wc_time_format(), strtotime( $note->comment_date ) ) ); ?></abbr>
|
||||||
<?php if ( $note->comment_author !== __( 'WooCommerce', 'woocommerce' ) ) printf( ' ' . __( 'by %s', 'woocommerce' ), $note->comment_author ); ?>
|
<?php if ( __( 'WooCommerce', 'woocommerce' ) !== $note->comment_author ) : ?>
|
||||||
|
<?php printf( ' ' . __( 'by %s', 'woocommerce' ), $note->comment_author ); ?>
|
||||||
|
<?php endif; ?>
|
||||||
<a href="#" class="delete_note"><?php _e( 'Delete note', 'woocommerce' ); ?></a>
|
<a href="#" class="delete_note"><?php _e( 'Delete note', 'woocommerce' ); ?></a>
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -865,7 +865,7 @@ class WC_Meta_Box_Product_Data {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save shipping class
|
// Save shipping class
|
||||||
$product_shipping_class = $_POST['product_shipping_class'] > 0 && $product_type != 'external' ? absint( $_POST['product_shipping_class'] ) : '';
|
$product_shipping_class = ( $_POST['product_shipping_class'] > 0 && 'external' !== $product_type ) ? absint( $_POST['product_shipping_class'] ) : '';
|
||||||
wp_set_object_terms( $post_id, $product_shipping_class, 'product_shipping_class' );
|
wp_set_object_terms( $post_id, $product_shipping_class, 'product_shipping_class' );
|
||||||
|
|
||||||
// Unique SKU
|
// Unique SKU
|
||||||
|
@ -1422,7 +1422,7 @@ class WC_Meta_Box_Product_Data {
|
||||||
// Price handling
|
// Price handling
|
||||||
_wc_save_product_price( $variation_id, $variable_regular_price[ $i ], $variable_sale_price[ $i ], $variable_sale_price_dates_from[ $i ], $variable_sale_price_dates_to[ $i ] );
|
_wc_save_product_price( $variation_id, $variable_regular_price[ $i ], $variable_sale_price[ $i ], $variable_sale_price_dates_from[ $i ], $variable_sale_price_dates_to[ $i ] );
|
||||||
|
|
||||||
if ( isset( $variable_tax_class[ $i ] ) && $variable_tax_class[ $i ] !== 'parent' ) {
|
if ( isset( $variable_tax_class[ $i ] ) && 'parent' !== $variable_tax_class[ $i ] ) {
|
||||||
update_post_meta( $variation_id, '_tax_class', wc_clean( $variable_tax_class[ $i ] ) );
|
update_post_meta( $variation_id, '_tax_class', wc_clean( $variable_tax_class[ $i ] ) );
|
||||||
} else {
|
} else {
|
||||||
delete_post_meta( $variation_id, '_tax_class' );
|
delete_post_meta( $variation_id, '_tax_class' );
|
||||||
|
|
|
@ -259,7 +259,7 @@ class WC_Admin_Report {
|
||||||
$query['where'] .= ' ' . $relation;
|
$query['where'] .= ' ' . $relation;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $value['type'] ) && $value['type'] == 'order_item_meta' ) {
|
if ( isset( $value['type'] ) && 'order_item_meta' === $value['type'] ) {
|
||||||
|
|
||||||
if ( is_array( $value['meta_key'] ) ) {
|
if ( is_array( $value['meta_key'] ) ) {
|
||||||
$query['where'] .= " ( order_item_meta_{$key}.meta_key IN ('" . implode( "','", $value['meta_key'] ) . "')";
|
$query['where'] .= " ( order_item_meta_{$key}.meta_key IN ('" . implode( "','", $value['meta_key'] ) . "')";
|
||||||
|
@ -408,7 +408,7 @@ class WC_Admin_Report {
|
||||||
public function sales_sparkline( $id = '', $days = 7, $type = 'sales' ) {
|
public function sales_sparkline( $id = '', $days = 7, $type = 'sales' ) {
|
||||||
|
|
||||||
if ( $id ) {
|
if ( $id ) {
|
||||||
$meta_key = $type == 'sales' ? '_line_total' : '_qty';
|
$meta_key = ( 'sales' === $type ) ? '_line_total' : '_qty';
|
||||||
|
|
||||||
$data = $this->get_order_report_data( array(
|
$data = $this->get_order_report_data( array(
|
||||||
'data' => array(
|
'data' => array(
|
||||||
|
@ -479,7 +479,7 @@ class WC_Admin_Report {
|
||||||
$total += $d->sparkline_value;
|
$total += $d->sparkline_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $type == 'sales' ) {
|
if ( 'sales' === $type ) {
|
||||||
$tooltip = sprintf( __( 'Sold %1$s worth in the last %2$d days', 'woocommerce' ), strip_tags( wc_price( $total ) ), $days );
|
$tooltip = sprintf( __( 'Sold %1$s worth in the last %2$d days', 'woocommerce' ), strip_tags( wc_price( $total ) ), $days );
|
||||||
} else {
|
} else {
|
||||||
$tooltip = sprintf( _n( 'Sold 1 item in the last %2$d days', 'Sold %1$d items in the last %2$d days', $total, 'woocommerce' ), $total, $days );
|
$tooltip = sprintf( _n( 'Sold 1 item in the last %2$d days', 'Sold %1$d items in the last %2$d days', $total, 'woocommerce' ), $total, $days );
|
||||||
|
@ -487,7 +487,7 @@ class WC_Admin_Report {
|
||||||
|
|
||||||
$sparkline_data = array_values( $this->prepare_chart_data( $data, 'post_date', 'sparkline_value', $days - 1, strtotime( 'midnight -' . ( $days - 1 ) . ' days', current_time( 'timestamp' ) ), 'day' ) );
|
$sparkline_data = array_values( $this->prepare_chart_data( $data, 'post_date', 'sparkline_value', $days - 1, strtotime( 'midnight -' . ( $days - 1 ) . ' days', current_time( 'timestamp' ) ), 'day' ) );
|
||||||
|
|
||||||
return '<span class="wc_sparkline ' . ( $type == 'sales' ? 'lines' : 'bars' ) . ' tips" data-color="#777" data-tip="' . esc_attr( $tooltip ) . '" data-barwidth="' . 60 * 60 * 16 * 1000 . '" data-sparkline="' . esc_attr( json_encode( $sparkline_data ) ) . '"></span>';
|
return '<span class="wc_sparkline ' . ( ( 'sales' === $type ) ? 'lines' : 'bars' ) . ' tips" data-color="#777" data-tip="' . esc_attr( $tooltip ) . '" data-barwidth="' . 60 * 60 * 16 * 1000 . '" data-sparkline="' . esc_attr( json_encode( $sparkline_data ) ) . '"></span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -506,7 +506,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
tickColor: 'transparent',
|
tickColor: 'transparent',
|
||||||
mode: "time",
|
mode: "time",
|
||||||
timeformat: "<?php echo ( $this->chart_groupby == 'day' ) ? '%d %b' : '%b'; ?>",
|
timeformat: "<?php echo ( 'day' === $this->chart_groupby ) ? '%d %b' : '%b'; ?>",
|
||||||
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ) ?>,
|
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ) ?>,
|
||||||
tickLength: 1,
|
tickLength: 1,
|
||||||
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
|
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
|
||||||
|
|
|
@ -375,7 +375,7 @@ class WC_Report_Customers extends WC_Admin_Report {
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
tickColor: 'transparent',
|
tickColor: 'transparent',
|
||||||
mode: "time",
|
mode: "time",
|
||||||
timeformat: "<?php echo ( $this->chart_groupby == 'day' ) ? '%d %b' : '%b'; ?>",
|
timeformat: "<?php echo ( 'day' === $this->chart_groupby ) ? '%d %b' : '%b'; ?>",
|
||||||
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ) ?>,
|
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ) ?>,
|
||||||
tickLength: 1,
|
tickLength: 1,
|
||||||
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
|
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
|
||||||
|
|
|
@ -396,7 +396,7 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
tickColor: 'transparent',
|
tickColor: 'transparent',
|
||||||
mode: "time",
|
mode: "time",
|
||||||
timeformat: "<?php echo ( $this->chart_groupby == 'day' ) ? '%d %b' : '%b'; ?>",
|
timeformat: "<?php echo ( 'day' === $this->chart_groupby ) ? '%d %b' : '%b'; ?>",
|
||||||
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ); ?>,
|
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ); ?>,
|
||||||
tickLength: 1,
|
tickLength: 1,
|
||||||
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
|
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
|
||||||
|
|
|
@ -674,7 +674,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
tickColor: 'transparent',
|
tickColor: 'transparent',
|
||||||
mode: "time",
|
mode: "time",
|
||||||
timeformat: "<?php echo ( $this->chart_groupby == 'day' ) ? '%d %b' : '%b'; ?>",
|
timeformat: "<?php echo ( 'day' === $this->chart_groupby ) ? '%d %b' : '%b'; ?>",
|
||||||
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ) ?>,
|
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ) ?>,
|
||||||
tickLength: 1,
|
tickLength: 1,
|
||||||
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
|
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
|
||||||
|
|
|
@ -539,7 +539,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
tickColor: 'transparent',
|
tickColor: 'transparent',
|
||||||
mode: "time",
|
mode: "time",
|
||||||
timeformat: "<?php echo ( $this->chart_groupby == 'day' ) ? '%d %b' : '%b'; ?>",
|
timeformat: "<?php echo ( 'day' === $this->chart_groupby ) ? '%d %b' : '%b'; ?>",
|
||||||
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ) ?>,
|
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ) ?>,
|
||||||
tickLength: 1,
|
tickLength: 1,
|
||||||
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
|
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
|
||||||
|
|
|
@ -51,7 +51,7 @@ class WC_Report_Stock extends WP_List_Table {
|
||||||
*/
|
*/
|
||||||
public function display_tablenav( $position ) {
|
public function display_tablenav( $position ) {
|
||||||
|
|
||||||
if ( $position != 'top' ) {
|
if ( 'top' !== $position ) {
|
||||||
parent::display_tablenav( $position );
|
parent::display_tablenav( $position );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ class WC_Report_Taxes_By_Date extends WC_Admin_Report {
|
||||||
$tax_rows = array();
|
$tax_rows = array();
|
||||||
|
|
||||||
foreach ( $tax_rows_orders as $tax_row ) {
|
foreach ( $tax_rows_orders as $tax_row ) {
|
||||||
$key = date( $this->chart_groupby == 'month' ? 'Ym' : 'Ymd', strtotime( $tax_row->post_date ) );
|
$key = date( ( 'month' === $this->chart_groupby ) ? 'Ym' : 'Ymd', strtotime( $tax_row->post_date ) );
|
||||||
$tax_rows[ $key ] = isset( $tax_rows[ $key ] ) ? $tax_rows[ $key ] : (object) array( 'tax_amount' => 0, 'shipping_tax_amount' => 0, 'total_sales' => 0, 'total_shipping' => 0, 'total_orders' => 0 );
|
$tax_rows[ $key ] = isset( $tax_rows[ $key ] ) ? $tax_rows[ $key ] : (object) array( 'tax_amount' => 0, 'shipping_tax_amount' => 0, 'total_sales' => 0, 'total_shipping' => 0, 'total_orders' => 0 );
|
||||||
$tax_rows[ $key ]->tax_amount += $tax_row->tax_amount;
|
$tax_rows[ $key ]->tax_amount += $tax_row->tax_amount;
|
||||||
$tax_rows[ $key ]->shipping_tax_amount += $tax_row->shipping_tax_amount;
|
$tax_rows[ $key ]->shipping_tax_amount += $tax_row->shipping_tax_amount;
|
||||||
|
@ -138,7 +138,7 @@ class WC_Report_Taxes_By_Date extends WC_Admin_Report {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $tax_rows_partial_refunds as $tax_row ) {
|
foreach ( $tax_rows_partial_refunds as $tax_row ) {
|
||||||
$key = date( $this->chart_groupby == 'month' ? 'Ym' : 'Ymd', strtotime( $tax_row->post_date ) );
|
$key = date( ( 'month' === $this->chart_groupby ) ? 'Ym' : 'Ymd', strtotime( $tax_row->post_date ) );
|
||||||
$tax_rows[ $key ] = isset( $tax_rows[ $key ] ) ? $tax_rows[ $key ] : (object) array( 'tax_amount' => 0, 'shipping_tax_amount' => 0, 'total_sales' => 0, 'total_shipping' => 0, 'total_orders' => 0 );
|
$tax_rows[ $key ] = isset( $tax_rows[ $key ] ) ? $tax_rows[ $key ] : (object) array( 'tax_amount' => 0, 'shipping_tax_amount' => 0, 'total_sales' => 0, 'total_shipping' => 0, 'total_orders' => 0 );
|
||||||
$tax_rows[ $key ]->tax_amount += $tax_row->tax_amount;
|
$tax_rows[ $key ]->tax_amount += $tax_row->tax_amount;
|
||||||
$tax_rows[ $key ]->shipping_tax_amount += $tax_row->shipping_tax_amount;
|
$tax_rows[ $key ]->shipping_tax_amount += $tax_row->shipping_tax_amount;
|
||||||
|
@ -165,12 +165,9 @@ class WC_Report_Taxes_By_Date extends WC_Admin_Report {
|
||||||
$total_tax = $tax_row->tax_amount + $tax_row->shipping_tax_amount;
|
$total_tax = $tax_row->tax_amount + $tax_row->shipping_tax_amount;
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?php
|
<th scope="row">
|
||||||
if ( $this->chart_groupby == 'month' )
|
<?php echo ( 'month' === $this->chart_groupby ) ? date_i18n( 'F', strtotime( $date . '01' ) ) : date_i18n( get_option( 'date_format' ), strtotime( $date ) ); ?>
|
||||||
echo date_i18n( 'F', strtotime( $date . '01' ) );
|
</th>
|
||||||
else
|
|
||||||
echo date_i18n( get_option( 'date_format' ), strtotime( $date ) );
|
|
||||||
?></th>
|
|
||||||
<td class="total_row"><?php echo $tax_row->total_orders; ?></td>
|
<td class="total_row"><?php echo $tax_row->total_orders; ?></td>
|
||||||
<td class="total_row"><?php echo wc_price( $gross ); ?></td>
|
<td class="total_row"><?php echo wc_price( $gross ); ?></td>
|
||||||
<td class="total_row"><?php echo wc_price( $tax_row->total_shipping ); ?></td>
|
<td class="total_row"><?php echo wc_price( $tax_row->total_shipping ); ?></td>
|
||||||
|
|
|
@ -135,7 +135,7 @@ class WC_Settings_Rest_API extends WC_Settings_Page {
|
||||||
|
|
||||||
if ( 'webhooks' == $current_section ) {
|
if ( 'webhooks' == $current_section ) {
|
||||||
WC_Admin_Webhooks::page_output();
|
WC_Admin_Webhooks::page_output();
|
||||||
} else if ( 'keys' == $current_section ) {
|
} elseif ( 'keys' === $current_section ) {
|
||||||
WC_Admin_API_Keys::page_output();
|
WC_Admin_API_Keys::page_output();
|
||||||
} else {
|
} else {
|
||||||
$settings = $this->get_settings( $current_section );
|
$settings = $this->get_settings( $current_section );
|
||||||
|
|
|
@ -325,12 +325,7 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
|
||||||
|
|
||||||
case 'status' :
|
case 'status' :
|
||||||
echo '<td class="status">';
|
echo '<td class="status">';
|
||||||
|
echo ( 'yes' === $gateway->enabled ) ? '<span class="status-enabled tips" data-tip="' . __( 'Yes', 'woocommerce' ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>' : '-';
|
||||||
if ( $gateway->enabled == 'yes' )
|
|
||||||
echo '<span class="status-enabled tips" data-tip="' . __( 'Yes', 'woocommerce' ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
|
|
||||||
else
|
|
||||||
echo '-';
|
|
||||||
|
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ class WC_Settings_Emails extends WC_Settings_Page {
|
||||||
|
|
||||||
if ( in_array( $current_section, array_map( 'sanitize_title', array_keys( $wc_emails->get_emails() ) ) ) ) {
|
if ( in_array( $current_section, array_map( 'sanitize_title', array_keys( $wc_emails->get_emails() ) ) ) ) {
|
||||||
foreach ( $wc_emails->get_emails() as $email_id => $email ) {
|
foreach ( $wc_emails->get_emails() as $email_id => $email ) {
|
||||||
if ( $current_section === sanitize_title( $email_id ) ) {
|
if ( sanitize_title( $email_id ) === $current_section ) {
|
||||||
do_action( 'woocommerce_update_options_' . $this->id . '_' . $email->id );
|
do_action( 'woocommerce_update_options_' . $this->id . '_' . $email->id );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ class WC_Settings_Tax extends WC_Settings_Page {
|
||||||
|
|
||||||
$tax_classes = WC_Tax::get_tax_classes();
|
$tax_classes = WC_Tax::get_tax_classes();
|
||||||
|
|
||||||
if ( $current_section == 'standard' || in_array( $current_section, array_map( 'sanitize_title', $tax_classes ) ) ) {
|
if ( 'standard' === $current_section || in_array( $current_section, array_map( 'sanitize_title', $tax_classes ) ) ) {
|
||||||
$this->output_tax_rates();
|
$this->output_tax_rates();
|
||||||
} else {
|
} else {
|
||||||
$settings = $this->get_settings();
|
$settings = $this->get_settings();
|
||||||
|
@ -260,7 +260,7 @@ class WC_Settings_Tax extends WC_Settings_Page {
|
||||||
|
|
||||||
// Loop posted fields
|
// Loop posted fields
|
||||||
foreach ( $_POST['tax_rate_country'] as $key => $value ) {
|
foreach ( $_POST['tax_rate_country'] as $key => $value ) {
|
||||||
$mode = 0 === strpos( $key, 'new-' ) ? 'insert' : 'update';
|
$mode = ( 0 === strpos( $key, 'new-' ) ) ? 'insert' : 'update';
|
||||||
$tax_rate = $this->get_posted_tax_rate( $key, $index ++, $current_class );
|
$tax_rate = $this->get_posted_tax_rate( $key, $index ++, $current_class );
|
||||||
|
|
||||||
if ( 'insert' === $mode ) {
|
if ( 'insert' === $mode ) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
<?php if ( $sections ) : ?>
|
<?php if ( $sections ) : ?>
|
||||||
<ul class="subsubsub">
|
<ul class="subsubsub">
|
||||||
<?php foreach ( $sections as $section_id => $section ) : ?>
|
<?php foreach ( $sections as $section_id => $section ) : ?>
|
||||||
<li><a class="<?php echo $current_section === $section_id ? 'current' : ''; ?>" href="<?php echo admin_url( 'admin.php?page=wc-addons§ion=' . esc_attr( $section_id ) ); ?>"><?php echo esc_html( $section->title ); ?></a><?php if ( $section_id !== end( $section_keys ) ) echo ' |'; ?></li>
|
<li><a class="<?php echo $current_section === $section_id ? 'current' : ''; ?>" href="<?php echo admin_url( 'admin.php?page=wc-addons§ion=' . esc_attr( $section_id ) ); ?>"><?php echo esc_html( $section->title ); ?></a><?php if ( end( $section_keys ) !== $section_id ) echo ' |'; ?></li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
|
|
|
@ -55,7 +55,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
|
||||||
$report = $reports[ $current_tab ]['reports'][ $current_report ];
|
$report = $reports[ $current_tab ]['reports'][ $current_report ];
|
||||||
|
|
||||||
if ( ! isset( $report['hide_title'] ) || $report['hide_title'] != true ) {
|
if ( ! isset( $report['hide_title'] ) || true != $report['hide_title'] ) {
|
||||||
echo '<h1>' . esc_html( $report['title'] ) . '</h1>';
|
echo '<h1>' . esc_html( $report['title'] ) . '</h1>';
|
||||||
} else {
|
} else {
|
||||||
echo '<h1 class="screen-reader-text">' . esc_html( $report['title'] ) . '</h1>';
|
echo '<h1 class="screen-reader-text">' . esc_html( $report['title'] ) . '</h1>';
|
||||||
|
|
|
@ -352,7 +352,7 @@ $pages = $system_status->get_pages();
|
||||||
$version_string = ' – <strong style="color:red;">' . esc_html( sprintf( _x( '%s is available', 'Version info', 'woocommerce' ), $plugin['version_latest'] ) ) . '</strong>';
|
$version_string = ' – <strong style="color:red;">' . esc_html( sprintf( _x( '%s is available', 'Version info', 'woocommerce' ), $plugin['version_latest'] ) ) . '</strong>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $plugin['network_activated'] != false ) {
|
if ( false != $plugin['network_activated'] ) {
|
||||||
$network_string = ' – <strong style="color:black;">' . __( 'Network enabled', 'woocommerce' ) . '</strong>';
|
$network_string = ' – <strong style="color:black;">' . __( 'Network enabled', 'woocommerce' ) . '</strong>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,7 @@ $pages = $system_status->get_pages();
|
||||||
} else {
|
} else {
|
||||||
echo esc_html( $override['file'] );
|
echo esc_html( $override['file'] );
|
||||||
}
|
}
|
||||||
if ( $i !== ( count( $theme['overrides'] ) - 1 ) ) {
|
if ( ( count( $theme['overrides'] ) - 1 ) !== $i ) {
|
||||||
echo ', ';
|
echo ', ';
|
||||||
}
|
}
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
|
|
|
@ -26,7 +26,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
echo '<li class="' . ( $current_range == $range ? 'active' : '' ) . '"><a href="' . esc_url( remove_query_arg( array( 'start_date', 'end_date' ), add_query_arg( 'range', $range ) ) ) . '">' . $name . '</a></li>';
|
echo '<li class="' . ( $current_range == $range ? 'active' : '' ) . '"><a href="' . esc_url( remove_query_arg( array( 'start_date', 'end_date' ), add_query_arg( 'range', $range ) ) ) . '">' . $name . '</a></li>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<li class="custom <?php echo $current_range == 'custom' ? 'active' : ''; ?>">
|
<li class="custom <?php echo ( 'custom' === $current_range ) ? 'active' : ''; ?>">
|
||||||
<?php _e( 'Custom:', 'woocommerce' ); ?>
|
<?php _e( 'Custom:', 'woocommerce' ); ?>
|
||||||
<form method="GET">
|
<form method="GET">
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -36,10 +36,10 @@ class WC_REST_Authentication {
|
||||||
$rest_prefix = trailingslashit( rest_get_url_prefix() );
|
$rest_prefix = trailingslashit( rest_get_url_prefix() );
|
||||||
|
|
||||||
// Check if our endpoint.
|
// Check if our endpoint.
|
||||||
$woocommerce = false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix . 'wc/' );
|
$woocommerce = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix . 'wc/' ) );
|
||||||
|
|
||||||
// Allow third party plugins use our authentication methods.
|
// Allow third party plugins use our authentication methods.
|
||||||
$third_party = false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix . 'wc-' );
|
$third_party = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix . 'wc-' ) );
|
||||||
|
|
||||||
return apply_filters( 'woocommerce_rest_is_request_to_rest_api', $woocommerce || $third_party );
|
return apply_filters( 'woocommerce_rest_is_request_to_rest_api', $woocommerce || $third_party );
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,7 @@ class WC_REST_Authentication {
|
||||||
$query_string = implode( '%26', $query_parameters ); // Join with ampersand.
|
$query_string = implode( '%26', $query_parameters ); // Join with ampersand.
|
||||||
$string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string;
|
$string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string;
|
||||||
|
|
||||||
if ( $params['oauth_signature_method'] !== 'HMAC-SHA1' && $params['oauth_signature_method'] !== 'HMAC-SHA256' ) {
|
if ( 'HMAC-SHA1' !== $params['oauth_signature_method'] && 'HMAC-SHA256' !== $params['oauth_signature_method'] ) {
|
||||||
return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid Signature - signature method is invalid.', 'woocommerce' ), array( 'status' => 401 ) );
|
return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid Signature - signature method is invalid.', 'woocommerce' ), array( 'status' => 401 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -315,7 +315,7 @@ class WC_REST_Coupons_Controller extends WC_REST_Posts_Controller {
|
||||||
try {
|
try {
|
||||||
$post_id = (int) $request['id'];
|
$post_id = (int) $request['id'];
|
||||||
|
|
||||||
if ( empty( $post_id ) || $this->post_type !== get_post_type( $post_id ) ) {
|
if ( empty( $post_id ) || get_post_type( $post_id ) !== $this->post_type ) {
|
||||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
|
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -725,7 +725,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
|
||||||
try {
|
try {
|
||||||
$post_id = (int) $request['id'];
|
$post_id = (int) $request['id'];
|
||||||
|
|
||||||
if ( empty( $post_id ) || $this->post_type !== get_post_type( $post_id ) ) {
|
if ( empty( $post_id ) || get_post_type( $post_id ) !== $this->post_type ) {
|
||||||
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
|
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1494,7 +1494,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
|
||||||
|
|
||||||
// Tax class.
|
// Tax class.
|
||||||
if ( isset( $variation['tax_class'] ) ) {
|
if ( isset( $variation['tax_class'] ) ) {
|
||||||
if ( $variation['tax_class'] !== 'parent' ) {
|
if ( 'parent' !== $variation['tax_class'] ) {
|
||||||
update_post_meta( $variation_id, '_tax_class', wc_clean( $variation['tax_class'] ) );
|
update_post_meta( $variation_id, '_tax_class', wc_clean( $variation['tax_class'] ) );
|
||||||
} else {
|
} else {
|
||||||
delete_post_meta( $variation_id, '_tax_class' );
|
delete_post_meta( $variation_id, '_tax_class' );
|
||||||
|
|
|
@ -414,7 +414,7 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
|
||||||
if ( isset( $tools[ $tool ]['callback'] ) ) {
|
if ( isset( $tools[ $tool ]['callback'] ) ) {
|
||||||
$callback = $tools[ $tool ]['callback'];
|
$callback = $tools[ $tool ]['callback'];
|
||||||
$return = call_user_func( $callback );
|
$return = call_user_func( $callback );
|
||||||
if ( $return === false ) {
|
if ( false === $return ) {
|
||||||
$callback_string = is_array( $callback ) ? get_class( $callback[0] ) . '::' . $callback[1] : $callback;
|
$callback_string = is_array( $callback ) ? get_class( $callback[0] ) . '::' . $callback[1] : $callback;
|
||||||
$ran = false;
|
$ran = false;
|
||||||
$message = sprintf( __( 'There was an error calling %s', 'woocommerce' ), $callback_string );
|
$message = sprintf( __( 'There was an error calling %s', 'woocommerce' ), $callback_string );
|
||||||
|
|
|
@ -261,7 +261,7 @@ class WC_API_Authentication {
|
||||||
|
|
||||||
$string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string;
|
$string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string;
|
||||||
|
|
||||||
if ( $params['oauth_signature_method'] !== 'HMAC-SHA1' && $params['oauth_signature_method'] !== 'HMAC-SHA256' ) {
|
if ( 'HMAC-SHA1' !== $params['oauth_signature_method'] && 'HMAC-SHA256' !== $params['oauth_signature_method'] ) {
|
||||||
throw new Exception( __( 'Invalid Signature - signature method is invalid', 'woocommerce' ), 401 );
|
throw new Exception( __( 'Invalid Signature - signature method is invalid', 'woocommerce' ), 401 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -261,7 +261,7 @@ class WC_API_Authentication {
|
||||||
|
|
||||||
$string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string;
|
$string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string;
|
||||||
|
|
||||||
if ( $params['oauth_signature_method'] !== 'HMAC-SHA1' && $params['oauth_signature_method'] !== 'HMAC-SHA256' ) {
|
if ( 'HMAC-SHA1' !== $params['oauth_signature_method'] && 'HMAC-SHA256' !== $params['oauth_signature_method'] ) {
|
||||||
throw new Exception( __( 'Invalid Signature - signature method is invalid', 'woocommerce' ), 401 );
|
throw new Exception( __( 'Invalid Signature - signature method is invalid', 'woocommerce' ), 401 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -559,7 +559,7 @@ class WC_API_Customers extends WC_API_Resource {
|
||||||
|
|
||||||
// Limit number of users returned
|
// Limit number of users returned
|
||||||
if ( ! empty( $args['limit'] ) ) {
|
if ( ! empty( $args['limit'] ) ) {
|
||||||
if ( $args['limit'] == -1 ) {
|
if ( -1 == $args['limit'] ) {
|
||||||
unset( $query_args['number'] );
|
unset( $query_args['number'] );
|
||||||
} else {
|
} else {
|
||||||
$query_args['number'] = absint( $args['limit'] );
|
$query_args['number'] = absint( $args['limit'] );
|
||||||
|
@ -606,7 +606,7 @@ class WC_API_Customers extends WC_API_Resource {
|
||||||
$query = new WP_User_Query( $query_args );
|
$query = new WP_User_Query( $query_args );
|
||||||
|
|
||||||
// Helper members for pagination headers
|
// Helper members for pagination headers
|
||||||
$query->total_pages = ( $args['limit'] == -1 ) ? 1 : ceil( $query->get_total() / $users_per_page );
|
$query->total_pages = ( -1 == $args['limit'] ) ? 1 : ceil( $query->get_total() / $users_per_page );
|
||||||
$query->page = $page;
|
$query->page = $page;
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
|
|
|
@ -214,7 +214,7 @@ class WC_API_Orders extends WC_API_Resource {
|
||||||
// add line items
|
// add line items
|
||||||
foreach ( $order->get_items() as $item_id => $item ) {
|
foreach ( $order->get_items() as $item_id => $item ) {
|
||||||
$product = $item->get_product();
|
$product = $item->get_product();
|
||||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
$hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_';
|
||||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||||
|
|
||||||
foreach ( $item_meta as $key => $values ) {
|
foreach ( $item_meta as $key => $values ) {
|
||||||
|
@ -301,7 +301,7 @@ class WC_API_Orders extends WC_API_Resource {
|
||||||
|
|
||||||
if ( ! empty( $status ) ) {
|
if ( ! empty( $status ) ) {
|
||||||
|
|
||||||
if ( $status == 'any' ) {
|
if ( 'any' === $status ) {
|
||||||
|
|
||||||
$order_statuses = array();
|
$order_statuses = array();
|
||||||
|
|
||||||
|
@ -1506,7 +1506,7 @@ class WC_API_Orders extends WC_API_Resource {
|
||||||
// Add line items
|
// Add line items
|
||||||
foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) {
|
foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) {
|
||||||
$product = $item->get_product();
|
$product = $item->get_product();
|
||||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
$hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_';
|
||||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||||
|
|
||||||
foreach ( $item_meta as $key => $values ) {
|
foreach ( $item_meta as $key => $values ) {
|
||||||
|
|
|
@ -1021,7 +1021,7 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
|
|
||||||
// Update parent if grouped so price sorting works and stays in sync with the cheapest child
|
// Update parent if grouped so price sorting works and stays in sync with the cheapest child
|
||||||
$_product = wc_get_product( $product_id );
|
$_product = wc_get_product( $product_id );
|
||||||
if ( $_product->post->post_parent > 0 || $product_type == 'grouped' ) {
|
if ( $_product->post->post_parent > 0 || 'grouped' === $product_type ) {
|
||||||
|
|
||||||
$clear_parent_ids = array();
|
$clear_parent_ids = array();
|
||||||
|
|
||||||
|
@ -1029,7 +1029,7 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
$clear_parent_ids[] = $_product->post->post_parent;
|
$clear_parent_ids[] = $_product->post->post_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $product_type == 'grouped' ) {
|
if ( 'grouped' === $product_type ) {
|
||||||
$clear_parent_ids[] = $product_id;
|
$clear_parent_ids[] = $product_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1216,7 +1216,7 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Product url
|
// Product url
|
||||||
if ( $product_type == 'external' ) {
|
if ( 'external' === $product_type ) {
|
||||||
if ( isset( $data['product_url'] ) ) {
|
if ( isset( $data['product_url'] ) ) {
|
||||||
update_post_meta( $product_id, '_product_url', wc_clean( $data['product_url'] ) );
|
update_post_meta( $product_id, '_product_url', wc_clean( $data['product_url'] ) );
|
||||||
}
|
}
|
||||||
|
@ -1319,7 +1319,7 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
if ( isset( $variation['image'] ) && is_array( $variation['image'] ) ) {
|
if ( isset( $variation['image'] ) && is_array( $variation['image'] ) ) {
|
||||||
$image = current( $variation['image'] );
|
$image = current( $variation['image'] );
|
||||||
if ( $image && is_array( $image ) ) {
|
if ( $image && is_array( $image ) ) {
|
||||||
if ( isset( $image['position'] ) && isset( $image['src'] ) && $image['position'] == 0 ) {
|
if ( isset( $image['position'] ) && isset( $image['src'] ) && 0 == $image['position'] ) {
|
||||||
$upload = $this->upload_product_image( wc_clean( $image['src'] ) );
|
$upload = $this->upload_product_image( wc_clean( $image['src'] ) );
|
||||||
if ( is_wp_error( $upload ) ) {
|
if ( is_wp_error( $upload ) ) {
|
||||||
throw new WC_API_Exception( 'woocommerce_api_cannot_upload_product_image', $upload->get_error_message(), 400 );
|
throw new WC_API_Exception( 'woocommerce_api_cannot_upload_product_image', $upload->get_error_message(), 400 );
|
||||||
|
@ -1419,7 +1419,7 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
|
|
||||||
// Tax class
|
// Tax class
|
||||||
if ( isset( $variation['tax_class'] ) ) {
|
if ( isset( $variation['tax_class'] ) ) {
|
||||||
if ( $variation['tax_class'] !== 'parent' ) {
|
if ( 'parent' !== $variation['tax_class'] ) {
|
||||||
update_post_meta( $variation_id, '_tax_class', wc_clean( $variation['tax_class'] ) );
|
update_post_meta( $variation_id, '_tax_class', wc_clean( $variation['tax_class'] ) );
|
||||||
} else {
|
} else {
|
||||||
delete_post_meta( $variation_id, '_tax_class' );
|
delete_post_meta( $variation_id, '_tax_class' );
|
||||||
|
@ -1752,7 +1752,7 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
$gallery = array();
|
$gallery = array();
|
||||||
|
|
||||||
foreach ( $images as $image ) {
|
foreach ( $images as $image ) {
|
||||||
if ( isset( $image['position'] ) && $image['position'] == 0 ) {
|
if ( isset( $image['position'] ) && 0 == $image['position'] ) {
|
||||||
$attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0;
|
$attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0;
|
||||||
|
|
||||||
if ( 0 === $attachment_id && isset( $image['src'] ) ) {
|
if ( 0 === $attachment_id && isset( $image['src'] ) ) {
|
||||||
|
|
|
@ -257,7 +257,7 @@ class WC_API_Authentication {
|
||||||
|
|
||||||
$string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string;
|
$string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string;
|
||||||
|
|
||||||
if ( $params['oauth_signature_method'] !== 'HMAC-SHA1' && $params['oauth_signature_method'] !== 'HMAC-SHA256' ) {
|
if ( 'HMAC-SHA1' !== $params['oauth_signature_method'] && 'HMAC-SHA256' !== $params['oauth_signature_method'] ) {
|
||||||
throw new Exception( __( 'Invalid Signature - signature method is invalid', 'woocommerce' ), 401 );
|
throw new Exception( __( 'Invalid Signature - signature method is invalid', 'woocommerce' ), 401 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -548,7 +548,7 @@ class WC_API_Customers extends WC_API_Resource {
|
||||||
|
|
||||||
// Limit number of users returned
|
// Limit number of users returned
|
||||||
if ( ! empty( $args['limit'] ) ) {
|
if ( ! empty( $args['limit'] ) ) {
|
||||||
if ( $args['limit'] == -1 ) {
|
if ( -1 == $args['limit'] ) {
|
||||||
unset( $query_args['number'] );
|
unset( $query_args['number'] );
|
||||||
} else {
|
} else {
|
||||||
$query_args['number'] = absint( $args['limit'] );
|
$query_args['number'] = absint( $args['limit'] );
|
||||||
|
@ -595,7 +595,7 @@ class WC_API_Customers extends WC_API_Resource {
|
||||||
$query = new WP_User_Query( $query_args );
|
$query = new WP_User_Query( $query_args );
|
||||||
|
|
||||||
// Helper members for pagination headers
|
// Helper members for pagination headers
|
||||||
$query->total_pages = ( $args['limit'] == -1 ) ? 1 : ceil( $query->get_total() / $users_per_page );
|
$query->total_pages = ( -1 == $args['limit'] ) ? 1 : ceil( $query->get_total() / $users_per_page );
|
||||||
$query->page = $page;
|
$query->page = $page;
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
|
|
|
@ -220,7 +220,7 @@ class WC_API_Orders extends WC_API_Resource {
|
||||||
// Add line items.
|
// Add line items.
|
||||||
foreach ( $order->get_items() as $item_id => $item ) {
|
foreach ( $order->get_items() as $item_id => $item ) {
|
||||||
$product = $item->get_product();
|
$product = $item->get_product();
|
||||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
$hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_';
|
||||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||||
|
|
||||||
foreach ( $item_meta as $key => $values ) {
|
foreach ( $item_meta as $key => $values ) {
|
||||||
|
@ -337,7 +337,7 @@ class WC_API_Orders extends WC_API_Resource {
|
||||||
|
|
||||||
if ( ! empty( $status ) ) {
|
if ( ! empty( $status ) ) {
|
||||||
|
|
||||||
if ( $status == 'any' ) {
|
if ( 'any' === $status ) {
|
||||||
|
|
||||||
$order_statuses = array();
|
$order_statuses = array();
|
||||||
|
|
||||||
|
@ -1551,7 +1551,7 @@ class WC_API_Orders extends WC_API_Resource {
|
||||||
// Add line items
|
// Add line items
|
||||||
foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) {
|
foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) {
|
||||||
$product = $item->get_product();
|
$product = $item->get_product();
|
||||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
$hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_';
|
||||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||||
|
|
||||||
foreach ( $item_meta as $key => $values ) {
|
foreach ( $item_meta as $key => $values ) {
|
||||||
|
|
|
@ -1506,7 +1506,7 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
|
|
||||||
// Update parent if grouped so price sorting works and stays in sync with the cheapest child.
|
// Update parent if grouped so price sorting works and stays in sync with the cheapest child.
|
||||||
$_product = wc_get_product( $product_id );
|
$_product = wc_get_product( $product_id );
|
||||||
if ( $_product->post->post_parent > 0 || $product_type == 'grouped' ) {
|
if ( $_product->post->post_parent > 0 || 'grouped' === $product_type ) {
|
||||||
|
|
||||||
$clear_parent_ids = array();
|
$clear_parent_ids = array();
|
||||||
|
|
||||||
|
@ -1514,7 +1514,7 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
$clear_parent_ids[] = $_product->post->post_parent;
|
$clear_parent_ids[] = $_product->post->post_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $product_type == 'grouped' ) {
|
if ( 'grouped' === $product_type ) {
|
||||||
$clear_parent_ids[] = $product_id;
|
$clear_parent_ids[] = $product_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1706,7 +1706,7 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Product url.
|
// Product url.
|
||||||
if ( $product_type == 'external' ) {
|
if ( 'external' === $product_type ) {
|
||||||
if ( isset( $data['product_url'] ) ) {
|
if ( isset( $data['product_url'] ) ) {
|
||||||
update_post_meta( $product_id, '_product_url', wc_clean( $data['product_url'] ) );
|
update_post_meta( $product_id, '_product_url', wc_clean( $data['product_url'] ) );
|
||||||
}
|
}
|
||||||
|
@ -1814,7 +1814,7 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
if ( isset( $variation['image'] ) && is_array( $variation['image'] ) ) {
|
if ( isset( $variation['image'] ) && is_array( $variation['image'] ) ) {
|
||||||
$image = current( $variation['image'] );
|
$image = current( $variation['image'] );
|
||||||
if ( $image && is_array( $image ) ) {
|
if ( $image && is_array( $image ) ) {
|
||||||
if ( isset( $image['position'] ) && $image['position'] == 0 ) {
|
if ( isset( $image['position'] ) && 0 == $image['position'] ) {
|
||||||
if ( isset( $image['src'] ) ) {
|
if ( isset( $image['src'] ) ) {
|
||||||
$upload = $this->upload_product_image( wc_clean( $image['src'] ) );
|
$upload = $this->upload_product_image( wc_clean( $image['src'] ) );
|
||||||
|
|
||||||
|
@ -1936,7 +1936,7 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
|
|
||||||
// Tax class
|
// Tax class
|
||||||
if ( isset( $variation['tax_class'] ) ) {
|
if ( isset( $variation['tax_class'] ) ) {
|
||||||
if ( $variation['tax_class'] !== 'parent' ) {
|
if ( 'parent' !== $variation['tax_class'] ) {
|
||||||
update_post_meta( $variation_id, '_tax_class', wc_clean( $variation['tax_class'] ) );
|
update_post_meta( $variation_id, '_tax_class', wc_clean( $variation['tax_class'] ) );
|
||||||
} else {
|
} else {
|
||||||
delete_post_meta( $variation_id, '_tax_class' );
|
delete_post_meta( $variation_id, '_tax_class' );
|
||||||
|
@ -2274,7 +2274,7 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
$gallery = array();
|
$gallery = array();
|
||||||
|
|
||||||
foreach ( $images as $image ) {
|
foreach ( $images as $image ) {
|
||||||
if ( isset( $image['position'] ) && $image['position'] == 0 ) {
|
if ( isset( $image['position'] ) && 0 == $image['position'] ) {
|
||||||
$attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0;
|
$attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0;
|
||||||
|
|
||||||
if ( 0 === $attachment_id && isset( $image['src'] ) ) {
|
if ( 0 === $attachment_id && isset( $image['src'] ) ) {
|
||||||
|
|
|
@ -582,7 +582,7 @@ class WC_API_Server {
|
||||||
$page = 1;
|
$page = 1;
|
||||||
$total_pages = 1;
|
$total_pages = 1;
|
||||||
}
|
}
|
||||||
} else if ( is_a( $query, 'stdClass' ) ) {
|
} elseif ( is_a( $query, 'stdClass' ) ) {
|
||||||
$page = $query->page;
|
$page = $query->page;
|
||||||
$single = $query->is_single;
|
$single = $query->is_single;
|
||||||
$total = $query->total;
|
$total = $query->total;
|
||||||
|
|
|
@ -1294,7 +1294,7 @@ class WC_CLI_Product extends WC_CLI_Command {
|
||||||
|
|
||||||
// Update parent if grouped so price sorting works and stays in sync with the cheapest child
|
// Update parent if grouped so price sorting works and stays in sync with the cheapest child
|
||||||
$_product = wc_get_product( $product_id );
|
$_product = wc_get_product( $product_id );
|
||||||
if ( $_product && $_product->post->post_parent > 0 || $product_type == 'grouped' ) {
|
if ( $_product && $_product->post->post_parent > 0 || 'grouped' === $product_type ) {
|
||||||
|
|
||||||
$clear_parent_ids = array();
|
$clear_parent_ids = array();
|
||||||
|
|
||||||
|
@ -1302,7 +1302,7 @@ class WC_CLI_Product extends WC_CLI_Command {
|
||||||
$clear_parent_ids[] = $_product->post->post_parent;
|
$clear_parent_ids[] = $_product->post->post_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $product_type == 'grouped' ) {
|
if ( 'grouped' === $product_type ) {
|
||||||
$clear_parent_ids[] = $product_id;
|
$clear_parent_ids[] = $product_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1487,7 +1487,7 @@ class WC_CLI_Product extends WC_CLI_Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Product url
|
// Product url
|
||||||
if ( $product_type == 'external' ) {
|
if ( 'external' === $product_type ) {
|
||||||
if ( isset( $data['product_url'] ) ) {
|
if ( isset( $data['product_url'] ) ) {
|
||||||
update_post_meta( $product_id, '_product_url', wc_clean( $data['product_url'] ) );
|
update_post_meta( $product_id, '_product_url', wc_clean( $data['product_url'] ) );
|
||||||
}
|
}
|
||||||
|
@ -1590,7 +1590,7 @@ class WC_CLI_Product extends WC_CLI_Command {
|
||||||
if ( isset( $variation['image'] ) && is_array( $variation['image'] ) ) {
|
if ( isset( $variation['image'] ) && is_array( $variation['image'] ) ) {
|
||||||
$image = current( $variation['image'] );
|
$image = current( $variation['image'] );
|
||||||
if ( $image && is_array( $image ) ) {
|
if ( $image && is_array( $image ) ) {
|
||||||
if ( isset( $image['position'] ) && isset( $image['src'] ) && $image['position'] == 0 ) {
|
if ( isset( $image['position'] ) && isset( $image['src'] ) && 0 == $image['position'] ) {
|
||||||
$upload = $this->upload_product_image( wc_clean( $image['src'] ) );
|
$upload = $this->upload_product_image( wc_clean( $image['src'] ) );
|
||||||
if ( is_wp_error( $upload ) ) {
|
if ( is_wp_error( $upload ) ) {
|
||||||
throw new WC_CLI_Exception( 'woocommerce_cli_cannot_upload_product_image', $upload->get_error_message() );
|
throw new WC_CLI_Exception( 'woocommerce_cli_cannot_upload_product_image', $upload->get_error_message() );
|
||||||
|
@ -1710,7 +1710,7 @@ class WC_CLI_Product extends WC_CLI_Command {
|
||||||
|
|
||||||
// Tax class
|
// Tax class
|
||||||
if ( isset( $variation['tax_class'] ) ) {
|
if ( isset( $variation['tax_class'] ) ) {
|
||||||
if ( $variation['tax_class'] !== 'parent' ) {
|
if ( 'parent' !== $variation['tax_class'] ) {
|
||||||
update_post_meta( $variation_id, '_tax_class', wc_clean( $variation['tax_class'] ) );
|
update_post_meta( $variation_id, '_tax_class', wc_clean( $variation['tax_class'] ) );
|
||||||
} else {
|
} else {
|
||||||
delete_post_meta( $variation_id, '_tax_class' );
|
delete_post_meta( $variation_id, '_tax_class' );
|
||||||
|
@ -1836,7 +1836,7 @@ class WC_CLI_Product extends WC_CLI_Command {
|
||||||
$gallery = array();
|
$gallery = array();
|
||||||
|
|
||||||
foreach ( $images as $image ) {
|
foreach ( $images as $image ) {
|
||||||
if ( isset( $image['position'] ) && $image['position'] == 0 ) {
|
if ( isset( $image['position'] ) && 0 == $image['position'] ) {
|
||||||
$attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0;
|
$attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0;
|
||||||
|
|
||||||
if ( 0 === $attachment_id && isset( $image['src'] ) ) {
|
if ( 0 === $attachment_id && isset( $image['src'] ) ) {
|
||||||
|
|
|
@ -582,7 +582,7 @@ class WC_Email extends WC_Settings_API {
|
||||||
if ( is_writeable( $file ) ) {
|
if ( is_writeable( $file ) ) {
|
||||||
$f = fopen( $file, 'w+' );
|
$f = fopen( $file, 'w+' );
|
||||||
|
|
||||||
if ( $f !== false ) {
|
if ( false !== $f ) {
|
||||||
fwrite( $f, $code );
|
fwrite( $f, $code );
|
||||||
fclose( $f );
|
fclose( $f );
|
||||||
$saved = true;
|
$saved = true;
|
||||||
|
|
|
@ -57,8 +57,8 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway_CC {
|
||||||
$this->mode = $this->get_option( 'mode', 'standard' );
|
$this->mode = $this->get_option( 'mode', 'standard' );
|
||||||
$this->modal_color = $this->get_option( 'modal_color', '#a46497' );
|
$this->modal_color = $this->get_option( 'modal_color', '#a46497' );
|
||||||
$this->sandbox = $this->get_option( 'sandbox' );
|
$this->sandbox = $this->get_option( 'sandbox' );
|
||||||
$this->public_key = $this->sandbox == 'no' ? $this->get_option( 'public_key' ) : $this->get_option( 'sandbox_public_key' );
|
$this->public_key = ( 'no' === $this->sandbox ) ? $this->get_option( 'public_key' ) : $this->get_option( 'sandbox_public_key' );
|
||||||
$this->private_key = $this->sandbox == 'no' ? $this->get_option( 'private_key' ) : $this->get_option( 'sandbox_private_key' );
|
$this->private_key = ( 'no' === $this->sandbox ) ? $this->get_option( 'private_key' ) : $this->get_option( 'sandbox_private_key' );
|
||||||
|
|
||||||
$this->init_simplify_sdk();
|
$this->init_simplify_sdk();
|
||||||
|
|
||||||
|
|
|
@ -121,10 +121,10 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
|
||||||
// find out if we're currently at the beginning of a number/variable/function/parenthesis/operand
|
// find out if we're currently at the beginning of a number/variable/function/parenthesis/operand
|
||||||
$ex = preg_match( '/^([A-Za-z]\w*\(?|\d+(?:\.\d*)?|\.\d+|\()/', substr( $expr, $index ), $match );
|
$ex = preg_match( '/^([A-Za-z]\w*\(?|\d+(?:\.\d*)?|\.\d+|\()/', substr( $expr, $index ), $match );
|
||||||
// ===============
|
// ===============
|
||||||
if ( $op == '-' and ! $expecting_op ) { // is it a negation instead of a minus?
|
if ( '-' === $op and ! $expecting_op ) { // is it a negation instead of a minus?
|
||||||
$stack->push( '_' ); // put a negation on the stack
|
$stack->push( '_' ); // put a negation on the stack
|
||||||
$index++;
|
$index++;
|
||||||
} elseif ( $op == '_' ) { // we have to explicitly deny this, because it's legal on the stack
|
} elseif ( '_' === $op ) { // we have to explicitly deny this, because it's legal on the stack
|
||||||
return self::trigger( "illegal character '_'" ); // but not in the input expression
|
return self::trigger( "illegal character '_'" ); // but not in the input expression
|
||||||
// ===============
|
// ===============
|
||||||
} elseif ( ( in_array( $op, $ops ) or $ex ) and $expecting_op ) { // are we putting an operator on the stack?
|
} elseif ( ( in_array( $op, $ops ) or $ex ) and $expecting_op ) { // are we putting an operator on the stack?
|
||||||
|
@ -141,10 +141,13 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
|
||||||
$index++;
|
$index++;
|
||||||
$expecting_op = false;
|
$expecting_op = false;
|
||||||
// ===============
|
// ===============
|
||||||
} elseif ( $op == ')' and $expecting_op ) { // ready to close a parenthesis?
|
} elseif ( ')' === $op && $expecting_op ) { // ready to close a parenthesis?
|
||||||
while ( ( $o2 = $stack->pop() ) != '(' ) { // pop off the stack back to the last (
|
while ( ( $o2 = $stack->pop() ) != '(' ) { // pop off the stack back to the last (
|
||||||
if ( is_null( $o2 ) ) return self::trigger( "unexpected ')'" );
|
if ( is_null( $o2 ) ) {
|
||||||
else $output[] = $o2;
|
return self::trigger( "unexpected ')'" );
|
||||||
|
} else {
|
||||||
|
$output[] = $o2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( preg_match( "/^([A-Za-z]\w*)\($/", $stack->last( 2 ), $matches ) ) { // did we just close a function?
|
if ( preg_match( "/^([A-Za-z]\w*)\($/", $stack->last( 2 ), $matches ) ) { // did we just close a function?
|
||||||
$fnn = $matches[1]; // get the function name
|
$fnn = $matches[1]; // get the function name
|
||||||
|
@ -154,7 +157,7 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
|
||||||
if ( $arg_count > 1 )
|
if ( $arg_count > 1 )
|
||||||
return self::trigger( "too many arguments ($arg_count given, 1 expected)" );
|
return self::trigger( "too many arguments ($arg_count given, 1 expected)" );
|
||||||
} elseif ( array_key_exists( $fnn, self::$f ) ) {
|
} elseif ( array_key_exists( $fnn, self::$f ) ) {
|
||||||
if ( $arg_count != count( self::$f[ $fnn ]['args'] ) )
|
if ( count( self::$f[ $fnn ]['args'] ) != $arg_count )
|
||||||
return self::trigger( "wrong number of arguments ($arg_count given, " . count( self::$f[ $fnn ]['args'] ) . " expected)" );
|
return self::trigger( "wrong number of arguments ($arg_count given, " . count( self::$f[ $fnn ]['args'] ) . " expected)" );
|
||||||
} else { // did we somehow push a non-function on the stack? this should never happen
|
} else { // did we somehow push a non-function on the stack? this should never happen
|
||||||
return self::trigger( "internal error" );
|
return self::trigger( "internal error" );
|
||||||
|
@ -162,10 +165,13 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
|
||||||
}
|
}
|
||||||
$index++;
|
$index++;
|
||||||
// ===============
|
// ===============
|
||||||
} elseif ( $op == ',' and $expecting_op ) { // did we just finish a function argument?
|
} elseif ( ',' === $op and $expecting_op ) { // did we just finish a function argument?
|
||||||
while ( ( $o2 = $stack->pop() ) != '(' ) {
|
while ( ( $o2 = $stack->pop() ) != '(' ) {
|
||||||
if ( is_null( $o2 ) ) return self::trigger( "unexpected ','" ); // oops, never had a (
|
if ( is_null( $o2 ) ) {
|
||||||
else $output[] = $o2; // pop the argument expression stuff and push onto the output
|
return self::trigger( "unexpected ','" ); // oops, never had a (
|
||||||
|
} else {
|
||||||
|
$output[] = $o2; // pop the argument expression stuff and push onto the output
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// make sure there was a function
|
// make sure there was a function
|
||||||
if ( ! preg_match( "/^([A-Za-z]\w*)\($/", $stack->last( 2 ), $matches ) )
|
if ( ! preg_match( "/^([A-Za-z]\w*)\($/", $stack->last( 2 ), $matches ) )
|
||||||
|
@ -175,7 +181,7 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
|
||||||
$index++;
|
$index++;
|
||||||
$expecting_op = false;
|
$expecting_op = false;
|
||||||
// ===============
|
// ===============
|
||||||
} elseif ( $op == '(' and ! $expecting_op ) {
|
} elseif ( '(' === $op and ! $expecting_op ) {
|
||||||
$stack->push( '(' ); // that was easy
|
$stack->push( '(' ); // that was easy
|
||||||
$index++;
|
$index++;
|
||||||
// ===============
|
// ===============
|
||||||
|
@ -197,14 +203,14 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
|
||||||
}
|
}
|
||||||
$index += strlen( $val );
|
$index += strlen( $val );
|
||||||
// ===============
|
// ===============
|
||||||
} elseif ( $op == ')' ) { // miscellaneous error checking
|
} elseif ( ')' === $op ) { // miscellaneous error checking
|
||||||
return self::trigger( "unexpected ')'" );
|
return self::trigger( "unexpected ')'" );
|
||||||
} elseif ( in_array( $op, $ops ) and ! $expecting_op ) {
|
} elseif ( in_array( $op, $ops ) and ! $expecting_op ) {
|
||||||
return self::trigger( "unexpected operator '$op'" );
|
return self::trigger( "unexpected operator '$op'" );
|
||||||
} else { // I don't even want to know what you did to get here
|
} else { // I don't even want to know what you did to get here
|
||||||
return self::trigger( "an unexpected error occured" );
|
return self::trigger( "an unexpected error occured" );
|
||||||
}
|
}
|
||||||
if ( $index == strlen( $expr ) ) {
|
if ( strlen( $expr ) == $index ) {
|
||||||
if ( in_array( $op, $ops ) ) { // did we end with an operator? bad.
|
if ( in_array( $op, $ops ) ) { // did we end with an operator? bad.
|
||||||
return self::trigger( "operator '$op' lacks operand" );
|
return self::trigger( "operator '$op' lacks operand" );
|
||||||
} else {
|
} else {
|
||||||
|
@ -216,7 +222,9 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ( ! is_null( $op = $stack->pop() ) ) { // pop everything off the stack and push onto output
|
while ( ! is_null( $op = $stack->pop() ) ) { // pop everything off the stack and push onto output
|
||||||
if ( $op == '(' ) return self::trigger( "expecting ')'" ); // if there are (s on the stack, ()s were unbalanced
|
if ( '(' === $op ) {
|
||||||
|
return self::trigger( "expecting ')'" ); // if there are (s on the stack, ()s were unbalanced
|
||||||
|
}
|
||||||
$output[] = $op;
|
$output[] = $op;
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
|
@ -231,7 +239,9 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private static function pfx( $tokens, $vars = array() ) {
|
private static function pfx( $tokens, $vars = array() ) {
|
||||||
if ( $tokens == false ) return false;
|
if ( false == $tokens ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$stack = new WC_Eval_Math_Stack;
|
$stack = new WC_Eval_Math_Stack;
|
||||||
|
|
||||||
foreach ( $tokens as $token ) { // nice and easy
|
foreach ( $tokens as $token ) { // nice and easy
|
||||||
|
@ -250,7 +260,9 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
|
||||||
$stack->push( $op1 * $op2 );
|
$stack->push( $op1 * $op2 );
|
||||||
break;
|
break;
|
||||||
case '/':
|
case '/':
|
||||||
if ( $op2 == 0 ) return self::trigger( "division by zero" );
|
if ( 0 == $op2 ) {
|
||||||
|
return self::trigger( 'division by zero' );
|
||||||
|
}
|
||||||
$stack->push( $op1 / $op2 );
|
$stack->push( $op1 / $op2 );
|
||||||
break;
|
break;
|
||||||
case '^':
|
case '^':
|
||||||
|
@ -258,7 +270,7 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if the token is a unary operator, pop one value off the stack, do the operation, and push it back on
|
// if the token is a unary operator, pop one value off the stack, do the operation, and push it back on
|
||||||
} elseif ( $token == "_" ) {
|
} elseif ( '_' === $token ) {
|
||||||
$stack->push( -1 * $stack->pop() );
|
$stack->push( -1 * $stack->pop() );
|
||||||
// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
|
// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
|
||||||
} elseif ( ! preg_match( "/^([a-z]\w*)\($/", $token, $matches ) ) {
|
} elseif ( ! preg_match( "/^([a-z]\w*)\($/", $token, $matches ) ) {
|
||||||
|
@ -274,7 +286,9 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// when we're out of tokens, the stack should have a single element, the final result
|
// when we're out of tokens, the stack should have a single element, the final result
|
||||||
if ( $stack->count != 1 ) return self::trigger( "internal error" );
|
if ( 1 != $stack->count ) {
|
||||||
|
return self::trigger( "internal error" );
|
||||||
|
}
|
||||||
return $stack->pop();
|
return $stack->pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
|
||||||
$has_costs = false; // True when a cost is set. False if all costs are blank strings.
|
$has_costs = false; // True when a cost is set. False if all costs are blank strings.
|
||||||
$cost = $this->get_option( 'cost' );
|
$cost = $this->get_option( 'cost' );
|
||||||
|
|
||||||
if ( $cost !== '' ) {
|
if ( '' !== $cost ) {
|
||||||
$has_costs = true;
|
$has_costs = true;
|
||||||
$rate['cost'] = $this->evaluate_cost( $cost, array(
|
$rate['cost'] = $this->evaluate_cost( $cost, array(
|
||||||
'qty' => $this->get_package_item_qty( $package ),
|
'qty' => $this->get_package_item_qty( $package ),
|
||||||
|
@ -153,7 +153,7 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
|
||||||
$shipping_class_term = get_term_by( 'slug', $shipping_class, 'product_shipping_class' );
|
$shipping_class_term = get_term_by( 'slug', $shipping_class, 'product_shipping_class' );
|
||||||
$class_cost_string = $shipping_class_term && $shipping_class_term->term_id ? $this->get_option( 'class_cost_' . $shipping_class_term->term_id, $this->get_option( 'class_cost_' . $shipping_class, '' ) ) : $this->get_option( 'no_class_cost', '' );
|
$class_cost_string = $shipping_class_term && $shipping_class_term->term_id ? $this->get_option( 'class_cost_' . $shipping_class_term->term_id, $this->get_option( 'class_cost_' . $shipping_class, '' ) ) : $this->get_option( 'no_class_cost', '' );
|
||||||
|
|
||||||
if ( $class_cost_string === '' ) {
|
if ( '' === $class_cost_string ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,14 +163,14 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
|
||||||
'cost' => array_sum( wp_list_pluck( $products, 'line_total' ) ),
|
'cost' => array_sum( wp_list_pluck( $products, 'line_total' ) ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
if ( $this->type === 'class' ) {
|
if ( 'class' === $this->type ) {
|
||||||
$rate['cost'] += $class_cost;
|
$rate['cost'] += $class_cost;
|
||||||
} else {
|
} else {
|
||||||
$highest_class_cost = $class_cost > $highest_class_cost ? $class_cost : $highest_class_cost;
|
$highest_class_cost = $class_cost > $highest_class_cost ? $class_cost : $highest_class_cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->type === 'order' && $highest_class_cost ) {
|
if ( 'order' === $this->type && $highest_class_cost ) {
|
||||||
$rate['cost'] += $highest_class_cost;
|
$rate['cost'] += $highest_class_cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ class WC_Shipping_Legacy_Flat_Rate extends WC_Shipping_Method {
|
||||||
$has_costs = false; // True when a cost is set. False if all costs are blank strings.
|
$has_costs = false; // True when a cost is set. False if all costs are blank strings.
|
||||||
$cost = $this->get_option( 'cost' );
|
$cost = $this->get_option( 'cost' );
|
||||||
|
|
||||||
if ( $cost !== '' ) {
|
if ( '' !== $cost ) {
|
||||||
$has_costs = true;
|
$has_costs = true;
|
||||||
$rate['cost'] = $this->evaluate_cost( $cost, array(
|
$rate['cost'] = $this->evaluate_cost( $cost, array(
|
||||||
'qty' => $this->get_package_item_qty( $package ),
|
'qty' => $this->get_package_item_qty( $package ),
|
||||||
|
@ -179,7 +179,7 @@ class WC_Shipping_Legacy_Flat_Rate extends WC_Shipping_Method {
|
||||||
$shipping_class_term = get_term_by( 'slug', $shipping_class, 'product_shipping_class' );
|
$shipping_class_term = get_term_by( 'slug', $shipping_class, 'product_shipping_class' );
|
||||||
$class_cost_string = $shipping_class_term && $shipping_class_term->term_id ? $this->get_option( 'class_cost_' . $shipping_class_term->term_id, $this->get_option( 'class_cost_' . $shipping_class, '' ) ) : $this->get_option( 'no_class_cost', '' );
|
$class_cost_string = $shipping_class_term && $shipping_class_term->term_id ? $this->get_option( 'class_cost_' . $shipping_class_term->term_id, $this->get_option( 'class_cost_' . $shipping_class, '' ) ) : $this->get_option( 'no_class_cost', '' );
|
||||||
|
|
||||||
if ( $class_cost_string === '' ) {
|
if ( '' === $class_cost_string ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,14 +189,14 @@ class WC_Shipping_Legacy_Flat_Rate extends WC_Shipping_Method {
|
||||||
'cost' => array_sum( wp_list_pluck( $products, 'line_total' ) ),
|
'cost' => array_sum( wp_list_pluck( $products, 'line_total' ) ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
if ( $this->type === 'class' ) {
|
if ( 'class' === $this->type ) {
|
||||||
$rate['cost'] += $class_cost;
|
$rate['cost'] += $class_cost;
|
||||||
} else {
|
} else {
|
||||||
$highest_class_cost = $class_cost > $highest_class_cost ? $class_cost : $highest_class_cost;
|
$highest_class_cost = $class_cost > $highest_class_cost ? $class_cost : $highest_class_cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->type === 'order' && $highest_class_cost ) {
|
if ( 'order' === $this->type && $highest_class_cost ) {
|
||||||
$rate['cost'] += $highest_class_cost;
|
$rate['cost'] += $highest_class_cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ class WC_Shipping_Legacy_Local_Pickup extends WC_Shipping_Method {
|
||||||
public function get_valid_postcodes() {
|
public function get_valid_postcodes() {
|
||||||
$codes = array();
|
$codes = array();
|
||||||
|
|
||||||
if ( $this->codes != '' ) {
|
if ( '' !== $this->codes ) {
|
||||||
foreach ( explode( ',', $this->codes ) as $code ) {
|
foreach ( explode( ',', $this->codes ) as $code ) {
|
||||||
$codes[] = strtoupper( trim( $code ) );
|
$codes[] = strtoupper( trim( $code ) );
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ class WC_Shipping_Legacy_Local_Pickup extends WC_Shipping_Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $is_available ) {
|
if ( $is_available ) {
|
||||||
if ( $this->availability === 'specific' ) {
|
if ( 'specific' === $this->availability ) {
|
||||||
$ship_to_countries = $this->countries;
|
$ship_to_countries = $this->countries;
|
||||||
} else {
|
} else {
|
||||||
$ship_to_countries = array_keys( WC()->countries->get_shipping_countries() );
|
$ship_to_countries = array_keys( WC()->countries->get_shipping_countries() );
|
||||||
|
|
|
@ -54,7 +54,7 @@ class WC_Product_Cat_Dropdown_Walker extends Walker {
|
||||||
}
|
}
|
||||||
|
|
||||||
$cat_name = apply_filters( 'list_product_cats', $cat->name, $cat );
|
$cat_name = apply_filters( 'list_product_cats', $cat->name, $cat );
|
||||||
$value = isset( $args['value'] ) && $args['value'] == 'id' ? $cat->term_id : $cat->slug;
|
$value = ( isset( $args['value'] ) && 'id' === $args['value'] ) ? $cat->term_id : $cat->slug;
|
||||||
$output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $value ) . "\"";
|
$output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $value ) . "\"";
|
||||||
|
|
||||||
if ( $value === $args['selected'] || ( is_array( $args['selected'] ) && in_array( $value, $args['selected'] ) ) ) {
|
if ( $value === $args['selected'] || ( is_array( $args['selected'] ) && in_array( $value, $args['selected'] ) ) ) {
|
||||||
|
|
|
@ -441,7 +441,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
||||||
$link = add_query_arg( $filter_name, implode( ',', $current_filter ), $link );
|
$link = add_query_arg( $filter_name, implode( ',', $current_filter ), $link );
|
||||||
|
|
||||||
// Add Query type Arg to URL
|
// Add Query type Arg to URL
|
||||||
if ( $query_type === 'or' && ! ( 1 === sizeof( $current_filter ) && $option_is_set ) ) {
|
if ( 'or' === $query_type && ! ( 1 === sizeof( $current_filter ) && $option_is_set ) ) {
|
||||||
$link = add_query_arg( 'query_type_' . sanitize_title( str_replace( 'pa_', '', $taxonomy ) ), 'or', $link );
|
$link = add_query_arg( 'query_type_' . sanitize_title( str_replace( 'pa_', '', $taxonomy ) ), 'or', $link );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ class WC_Widget_Product_Categories extends WC_Widget {
|
||||||
|
|
||||||
// Menu Order
|
// Menu Order
|
||||||
$list_args['menu_order'] = false;
|
$list_args['menu_order'] = false;
|
||||||
if ( $orderby == 'order' ) {
|
if ( 'order' === $orderby ) {
|
||||||
$list_args['menu_order'] = 'asc';
|
$list_args['menu_order'] = 'asc';
|
||||||
} else {
|
} else {
|
||||||
$list_args['orderby'] = 'title';
|
$list_args['orderby'] = 'title';
|
||||||
|
|
|
@ -170,7 +170,7 @@ class WC_Widget_Rating_Filter extends WC_Widget {
|
||||||
$link = $this->get_page_base_url();
|
$link = $this->get_page_base_url();
|
||||||
$link = $min_rating !== $rating ? add_query_arg( 'min_rating', $rating, $link ) : $link;
|
$link = $min_rating !== $rating ? add_query_arg( 'min_rating', $rating, $link ) : $link;
|
||||||
|
|
||||||
echo '<li class="wc-layered-nav-rating ' . ( ! empty( $_GET['min_rating'] ) && $rating === absint( $_GET['min_rating'] ) ? 'chosen' : '' ) . '">';
|
echo '<li class="wc-layered-nav-rating ' . ( ( ! empty( $_GET['min_rating'] ) && absint( $_GET['min_rating'] ) === $rating ) ? 'chosen' : '' ) . '">';
|
||||||
|
|
||||||
echo '<a href="' . esc_url( apply_filters( 'woocommerce_rating_filter_link', $link ) ) . '">';
|
echo '<a href="' . esc_url( apply_filters( 'woocommerce_rating_filter_link', $link ) ) . '">';
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,8 @@ do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plai
|
||||||
foreach ( $totals as $total ) {
|
foreach ( $totals as $total ) {
|
||||||
$i++;
|
$i++;
|
||||||
?><tr>
|
?><tr>
|
||||||
<th class="td" scope="row" colspan="2" style="text-align:left; <?php if ( $i === 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
|
<th class="td" scope="row" colspan="2" style="text-align:left; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo $total['label']; ?></th>
|
||||||
<td class="td" style="text-align:left; <?php if ( $i === 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
|
<td class="td" style="text-align:left; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo $total['value']; ?></td>
|
||||||
</tr><?php
|
</tr><?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$page_title = ( $load_address === 'billing' ) ? __( 'Billing Address', 'woocommerce' ) : __( 'Shipping Address', 'woocommerce' );
|
$page_title = ( 'billing' === $load_address ) ? __( 'Billing Address', 'woocommerce' ) : __( 'Shipping Address', 'woocommerce' );
|
||||||
|
|
||||||
do_action( 'woocommerce_before_edit_account_address_form' ); ?>
|
do_action( 'woocommerce_before_edit_account_address_form' ); ?>
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ do_action( 'woocommerce_before_account_orders', $has_orders ); ?>
|
||||||
<a class="woocommerce-Button woocommerce-Button--previous button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page - 1 ) ); ?>"><?php _e( 'Previous', 'woocommerce' ); ?></a>
|
<a class="woocommerce-Button woocommerce-Button--previous button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page - 1 ) ); ?>"><?php _e( 'Previous', 'woocommerce' ); ?></a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ( $current_page !== intval( $customer_orders->max_num_pages ) ) : ?>
|
<?php if ( intval( $customer_orders->max_num_pages ) !== $current_page ) : ?>
|
||||||
<a class="woocommerce-Button woocommerce-Button--next button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page + 1 ) ); ?>"><?php _e( 'Next', 'woocommerce' ); ?></a>
|
<a class="woocommerce-Button woocommerce-Button--next button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page + 1 ) ); ?>"><?php _e( 'Next', 'woocommerce' ); ?></a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -34,11 +34,11 @@ if ( $attachment_ids ) {
|
||||||
|
|
||||||
$classes = array( 'zoom' );
|
$classes = array( 'zoom' );
|
||||||
|
|
||||||
if ( $loop === 0 || $loop % $columns === 0 ) {
|
if ( 0 === $loop || 0 === $loop % $columns ) {
|
||||||
$classes[] = 'first';
|
$classes[] = 'first';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( $loop + 1 ) % $columns === 0 ) {
|
if ( 0 === ( $loop + 1 ) % $columns ) {
|
||||||
$classes[] = 'last';
|
$classes[] = 'last';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue