Merge branch 'pr/11883'

# Conflicts:
#	includes/class-wc-shortcodes.php
This commit is contained in:
Mike Jolley 2016-09-12 14:53:04 +01:00
commit f9b2ed88c2
94 changed files with 372 additions and 345 deletions

View File

@ -50,10 +50,11 @@ script:
# -n flag: Do not print warnings. (shortcut for --warning-severity=0)
# --standard: Use WordPress as the standard.
# --extensions: Only sniff PHP files.
- /tmp/phpcs/scripts/phpcs -p -s -v -n ./*.php --standard=./phpcs.ruleset.xml --extensions=php
- /tmp/phpcs/scripts/phpcs -p -s -v -n ./**/*.php --standard=./phpcs.ruleset.xml --extensions=php --ignore=./vendor/*.php
- /tmp/phpcs/scripts/phpcs -p -s -v -n ./**/**/*.php --standard=./phpcs.ruleset.xml --extensions=php --ignore=./vendor/**/*.php
- /tmp/phpcs/scripts/phpcs -p -s -v -n ./**/**/**/*.php --standard=./phpcs.ruleset.xml --extensions=php --ignore=./vendor/**/**/*.php
- /tmp/phpcs/scripts/phpcs -p -s -n ./*.php --standard=./phpcs.ruleset.xml --extensions=php
- /tmp/phpcs/scripts/phpcs -p -s -n ./**/*.php --standard=./phpcs.ruleset.xml --extensions=php --ignore=./vendor/*.php
- /tmp/phpcs/scripts/phpcs -p -s -n ./**/**/*.php --standard=./phpcs.ruleset.xml --extensions=php --ignore=./vendor/**/*.php
- /tmp/phpcs/scripts/phpcs -p -s -n ./**/**/**/*.php --standard=./phpcs.ruleset.xml --extensions=php --ignore=./vendor/**/**/*.php
- /tmp/phpcs/scripts/phpcs -p -s -n ./**/**/**/**/*.php --standard=./phpcs.ruleset.xml --extensions=php --ignore=./vendor/**/**/*.php
after_script:
- bash tests/bin/travis.sh after

View File

@ -12,9 +12,11 @@ class WC_HookFinder {
private static function get_files( $pattern, $flags = 0, $path = '' ) {
if ( ! $path && ( $dir = dirname( $pattern ) ) != '.' ) {
if ( ! $path && ( $dir = dirname( $pattern ) ) != '.' ) {
if ( $dir == '\\' || $dir == '/' ) { $dir = ''; } // End IF Statement
if ( '\\' == $dir || '/' == $dir ) {
$dir = '';
}
return self::get_files( basename( $pattern ), $flags, $dir . '/' );
@ -102,15 +104,16 @@ class WC_HookFinder {
foreach ( $tokens as $index => $token ) {
if ( is_array( $token ) ) {
if ( $token[0] == T_CLASS ) {
$trimmed_token_1 = trim( $token[1] );
if ( T_CLASS == $token[0] ) {
$token_type = 'class';
} elseif ( $token[0] == T_FUNCTION ) {
} elseif ( T_FUNCTION == $token[0] ) {
$token_type = 'function';
} elseif ( $token[1] === 'do_action' ) {
} elseif ( 'do_action' === $token[1] ) {
$token_type = 'action';
} elseif ( $token[1] === 'apply_filters' ) {
} elseif ( 'apply_filters' === $token[1] ) {
$token_type = 'filter';
} elseif ( $token_type && ! empty( trim( $token[1] ) ) ) {
} elseif ( $token_type && ! empty( $trimmed_token_1 ) ) {
switch ( $token_type ) {
case 'class' :
$current_class = $token[1];

View File

@ -1493,7 +1493,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
if ( $this->get_shipping_total() != 0 ) {
if ( $tax_display == 'excl' ) {
if ( 'excl' === $tax_display ) {
// Show shipping excluding tax.
$shipping = wc_price( $this->get_shipping_total(), array( 'currency' => $this->get_currency() ) );

View File

@ -241,11 +241,11 @@ class WC_Product {
*/
public function check_stock_status() {
if ( ! $this->backorders_allowed() && $this->get_total_stock() <= get_option( 'woocommerce_notify_no_stock_amount' ) ) {
if ( $this->stock_status !== 'outofstock' ) {
if ( 'outofstock' !== $this->stock_status ) {
$this->set_stock_status( 'outofstock' );
}
} elseif ( $this->backorders_allowed() || $this->get_total_stock() > get_option( 'woocommerce_notify_no_stock_amount' ) ) {
if ( $this->stock_status !== 'instock' ) {
if ( 'instock' !== $this->stock_status ) {
$this->set_stock_status( 'instock' );
}
}
@ -367,7 +367,7 @@ class WC_Product {
* @return bool
*/
public function is_downloadable() {
return $this->downloadable == 'yes' ? true : false;
return ( 'yes' === $this->downloadable );
}
/**
@ -464,7 +464,7 @@ class WC_Product {
* @return bool
*/
public function is_virtual() {
return apply_filters( 'woocommerce_is_virtual', $this->virtual == 'yes' ? true : false, $this );
return apply_filters( 'woocommerce_is_virtual', ( 'yes' === $this->virtual ), $this );
}
/**
@ -599,7 +599,7 @@ class WC_Product {
* @return bool
*/
public function managing_stock() {
return ( ! isset( $this->manage_stock ) || $this->manage_stock == 'no' || get_option( 'woocommerce_manage_stock' ) !== 'yes' ) ? false : true;
return ( ! isset( $this->manage_stock ) || 'no' === $this->manage_stock || 'yes' !== get_option( 'woocommerce_manage_stock' ) ) ? false : true;
}
/**
@ -608,7 +608,7 @@ class WC_Product {
* @return bool
*/
public function is_in_stock() {
return apply_filters( 'woocommerce_product_is_in_stock', $this->stock_status === 'instock', $this );
return apply_filters( 'woocommerce_product_is_in_stock', ( 'instock' === $this->stock_status ), $this );
}
/**
@ -617,7 +617,7 @@ class WC_Product {
* @return bool
*/
public function backorders_allowed() {
return apply_filters( 'woocommerce_product_backorders_allowed', $this->backorders === 'yes' || $this->backorders === 'notify' ? true : false, $this->id, $this );
return apply_filters( 'woocommerce_product_backorders_allowed', ( 'yes' === $this->backorders || 'notify' === $this->backorders ), $this->id, $this );
}
/**
@ -626,7 +626,7 @@ class WC_Product {
* @return bool
*/
public function backorders_require_notification() {
return apply_filters( 'woocommerce_product_backorders_require_notification', $this->managing_stock() && $this->backorders === 'notify' ? true : false, $this );
return apply_filters( 'woocommerce_product_backorders_require_notification', ( $this->managing_stock() && 'notify' === $this->backorders ), $this );
}
/**
@ -731,7 +731,7 @@ class WC_Product {
* @return bool
*/
public function is_featured() {
return $this->featured === 'yes' ? true : false;
return ( 'yes' === $this->featured ) ? true : false;
}
/**
@ -744,7 +744,7 @@ class WC_Product {
$visible = false;
// Published/private
} elseif ( $this->post->post_status !== 'publish' && ! current_user_can( 'edit_post', $this->id ) ) {
} elseif ( 'publish' !== $this->post->post_status && ! current_user_can( 'edit_post', $this->id ) ) {
$visible = false;
// Out of stock visibility
@ -794,7 +794,7 @@ class WC_Product {
$purchasable = false;
// Check the product is published
} elseif ( $this->post->post_status !== 'publish' && ! current_user_can( 'edit_post', $this->id ) ) {
} elseif ( 'publish' !== $this->post->post_status && ! current_user_can( 'edit_post', $this->id ) ) {
$purchasable = false;
}
@ -855,7 +855,7 @@ class WC_Product {
*/
public function get_price_including_tax( $qty = 1, $price = '' ) {
if ( $price === '' ) {
if ( '' === $price ) {
$price = $this->get_price();
}
@ -913,7 +913,7 @@ class WC_Product {
*/
public function get_price_excluding_tax( $qty = 1, $price = '' ) {
if ( $price === '' ) {
if ( '' === $price ) {
$price = $this->get_price();
}
@ -937,12 +937,12 @@ class WC_Product {
*/
public function get_display_price( $price = '', $qty = 1 ) {
if ( $price === '' ) {
if ( '' === $price ) {
$price = $this->get_price();
}
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
$display_price = $tax_display_mode == 'incl' ? $this->get_price_including_tax( $qty, $price ) : $this->get_price_excluding_tax( $qty, $price );
$display_price = ( 'incl' === $tax_display_mode ) ? $this->get_price_including_tax( $qty, $price ) : $this->get_price_excluding_tax( $qty, $price );
return $display_price;
}
@ -956,7 +956,7 @@ class WC_Product {
*/
public function get_price_suffix( $price = '', $qty = 1 ) {
if ( $price === '' ) {
if ( '' === $price ) {
$price = $this->get_price();
}

View File

@ -307,7 +307,7 @@ abstract class WC_Settings_API {
* @return string
*/
public function get_tooltip_html( $data ) {
if ( $data['desc_tip'] === true ) {
if ( true === $data['desc_tip'] ) {
$tip = $data['description'];
} elseif ( ! empty( $data['desc_tip'] ) ) {
$tip = $data['desc_tip'];
@ -325,7 +325,7 @@ abstract class WC_Settings_API {
* @return string
*/
public function get_description_html( $data ) {
if ( $data['desc_tip'] === true ) {
if ( true === $data['desc_tip'] ) {
$description = '';
} elseif ( ! empty( $data['desc_tip'] ) ) {
$description = $data['description'];
@ -797,7 +797,7 @@ abstract class WC_Settings_API {
*/
public function validate_price_field( $key, $value ) {
$value = is_null( $value ) ? '' : $value;
return $value === '' ? '' : wc_format_decimal( trim( stripslashes( $value ) ) );
return ( '' === $value ) ? '' : wc_format_decimal( trim( stripslashes( $value ) ) );
}
/**
@ -811,7 +811,7 @@ abstract class WC_Settings_API {
*/
public function validate_decimal_field( $key, $value ) {
$value = is_null( $value ) ? '' : $value;
return $value === '' ? '' : wc_format_decimal( trim( stripslashes( $value ) ) );
return ( '' === $value ) ? '' : wc_format_decimal( trim( stripslashes( $value ) ) );
}
/**

View File

@ -253,7 +253,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
$taxes = $args['taxes'];
// Taxes - if not an array and not set to false, calc tax based on cost and passed calc_tax variable. This saves shipping methods having to do complex tax calculations.
if ( ! is_array( $taxes ) && $taxes !== false && $total_cost > 0 && $this->is_taxable() ) {
if ( ! is_array( $taxes ) && false !== $taxes && $total_cost > 0 && $this->is_taxable() ) {
$taxes = 'per_item' === $args['calc_tax'] ? $this->get_taxes_per_item( $args['cost'] ) : WC_Tax::calc_shipping_tax( $total_cost, WC_Tax::get_shipping_tax_rates() );
}

View File

@ -306,7 +306,7 @@ class WC_Admin_Assets {
}
// Product sorting - only when sorting by menu order on the products page
if ( current_user_can( 'edit_others_pages' ) && $screen_id == 'edit-product' && isset( $wp_query->query['orderby'] ) && $wp_query->query['orderby'] == 'menu_order title' ) {
if ( current_user_can( 'edit_others_pages' ) && 'edit-product' === $screen_id && isset( $wp_query->query['orderby'] ) && 'menu_order title' === $wp_query->query['orderby'] ) {
wp_register_script( 'woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array( 'jquery-ui-sortable' ), WC_VERSION, true );
wp_enqueue_script( 'woocommerce_product_ordering' );
}

View File

@ -39,7 +39,7 @@ class WC_Admin_Duplicate_Product {
return $actions;
}
if ( $post->post_type != 'product' ) {
if ( 'product' !== $post->post_type ) {
return $actions;
}
@ -63,7 +63,7 @@ class WC_Admin_Duplicate_Product {
return;
}
if ( $post->post_type != 'product' ) {
if ( 'product' !== $post->post_type ) {
return;
}

View File

@ -239,7 +239,7 @@ class WC_Admin_Notices {
$theme_file = get_template_directory() . '/woocommerce/' . $file;
}
if ( $theme_file !== false ) {
if ( false !== $theme_file ) {
$core_version = WC_Admin_Status::get_file_version( WC()->plugin_path() . '/templates/' . $file );
$theme_version = WC_Admin_Status::get_file_version( $theme_file );

View File

@ -710,7 +710,7 @@ class WC_Admin_Post_Types {
$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>';
} 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>';
@ -931,7 +931,7 @@ class WC_Admin_Post_Types {
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 = add_query_arg( 'orderby', urlencode( 'menu_order title' ), $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 ( 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 );
} else {
$new_regular_price = null;
}
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 );
} else {
$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_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 );
} else {
update_post_meta( $post_id, '_price', $new_regular_price );
@ -1254,7 +1254,7 @@ class WC_Admin_Post_Types {
// 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' );
} else {
update_post_meta( $post_id, '_sold_individually', '' );
@ -1386,7 +1386,7 @@ class WC_Admin_Post_Types {
if ( ! empty( $_REQUEST['_manage_stock'] ) ) {
if ( $_REQUEST['_manage_stock'] == 'yes' ) {
if ( 'yes' === $_REQUEST['_manage_stock'] ) {
update_post_meta( $post_id, '_manage_stock', 'yes' );
} else {
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 ) {
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;
}
@ -1537,7 +1537,7 @@ class WC_Admin_Post_Types {
return $query;
}
if ( $typenow != 'shop_order' ) {
if ( 'shop_order' !== $typenow ) {
return $query;
}

View File

@ -206,7 +206,7 @@ class WC_Admin_Settings {
$option_value = stripslashes( $option_value );
}
return $option_value === null ? $default : $option_value;
return ( null === $option_value ) ? $default : $option_value;
}
/**
@ -297,7 +297,7 @@ class WC_Admin_Settings {
$type = $value['type'];
$option_value = self::get_option( $value['id'], $value['default'] );
if ( $value['type'] == 'color' ) {
if ( 'color' === $value['type'] ) {
$type = 'text';
$value['class'] .= 'colorpick';
$description .= '<div id="colorPickerDiv_' . esc_attr( $value['id'] ) . '" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>';
@ -366,7 +366,7 @@ class WC_Admin_Settings {
</th>
<td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
<select
name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>"
name="<?php echo esc_attr( $value['id'] ); ?><?php echo ( 'multiselect' === $value['type'] ) ? '[]' : ''; ?>"
id="<?php echo esc_attr( $value['id'] ); ?>"
style="<?php echo esc_attr( $value['css'] ); ?>"
class="<?php echo esc_attr( $value['class'] ); ?>"

View File

@ -112,7 +112,7 @@ class WC_Tax_Rate_Importer extends WP_Importer {
* @return string
*/
public function format_data_from_csv( $data, $enc ) {
return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
return ( 'UTF-8' === $enc ) ? $data : utf8_encode( $data );
}
/**

View File

@ -302,7 +302,7 @@ class WC_Meta_Box_Order_Data {
$found_method = false;
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>';
if ( $payment_method == $gateway->id ) {
$found_method = true;

View File

@ -47,7 +47,7 @@ class WC_Meta_Box_Order_Notes {
$note_classes = array( '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 );
?>
<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>
<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>
<?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>
</p>
</li>

View File

@ -865,7 +865,7 @@ class WC_Meta_Box_Product_Data {
}
// 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' );
// Unique SKU
@ -1422,7 +1422,7 @@ class WC_Meta_Box_Product_Data {
// 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 ] );
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 ] ) );
} else {
delete_post_meta( $variation_id, '_tax_class' );

View File

@ -259,7 +259,7 @@ class WC_Admin_Report {
$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'] ) ) {
$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' ) {
if ( $id ) {
$meta_key = $type == 'sales' ? '_line_total' : '_qty';
$meta_key = ( 'sales' === $type ) ? '_line_total' : '_qty';
$data = $this->get_order_report_data( array(
'data' => array(
@ -479,7 +479,7 @@ class WC_Admin_Report {
$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 );
} 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 );
@ -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' ) );
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>';
}
/**

View File

@ -506,7 +506,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
position: "bottom",
tickColor: 'transparent',
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 ) ) ?>,
tickLength: 1,
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],

View File

@ -375,7 +375,7 @@ class WC_Report_Customers extends WC_Admin_Report {
position: "bottom",
tickColor: 'transparent',
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 ) ) ?>,
tickLength: 1,
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],

View File

@ -396,7 +396,7 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
position: "bottom",
tickColor: 'transparent',
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 ) ); ?>,
tickLength: 1,
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],

View File

@ -674,7 +674,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
position: "bottom",
tickColor: 'transparent',
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 ) ) ?>,
tickLength: 1,
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],

View File

@ -539,7 +539,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
position: "bottom",
tickColor: 'transparent',
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 ) ) ?>,
tickLength: 1,
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],

View File

@ -51,7 +51,7 @@ class WC_Report_Stock extends WP_List_Table {
*/
public function display_tablenav( $position ) {
if ( $position != 'top' ) {
if ( 'top' !== $position ) {
parent::display_tablenav( $position );
}
}

View File

@ -128,7 +128,7 @@ class WC_Report_Taxes_By_Date extends WC_Admin_Report {
$tax_rows = array();
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 ]->tax_amount += $tax_row->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 ) {
$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 ]->tax_amount += $tax_row->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;
?>
<tr>
<th scope="row"><?php
if ( $this->chart_groupby == 'month' )
echo date_i18n( 'F', strtotime( $date . '01' ) );
else
echo date_i18n( get_option( 'date_format' ), strtotime( $date ) );
?></th>
<th scope="row">
<?php echo ( 'month' === $this->chart_groupby ) ? date_i18n( 'F', strtotime( $date . '01' ) ) : 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 wc_price( $gross ); ?></td>
<td class="total_row"><?php echo wc_price( $tax_row->total_shipping ); ?></td>

View File

@ -135,7 +135,7 @@ class WC_Settings_Rest_API extends WC_Settings_Page {
if ( 'webhooks' == $current_section ) {
WC_Admin_Webhooks::page_output();
} else if ( 'keys' == $current_section ) {
} elseif ( 'keys' === $current_section ) {
WC_Admin_API_Keys::page_output();
} else {
$settings = $this->get_settings( $current_section );

View File

@ -325,12 +325,7 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
case 'status' :
echo '<td class="status">';
if ( $gateway->enabled == 'yes' )
echo '<span class="status-enabled tips" data-tip="' . __( 'Yes', 'woocommerce' ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
else
echo '-';
echo ( 'yes' === $gateway->enabled ) ? '<span class="status-enabled tips" data-tip="' . __( 'Yes', 'woocommerce' ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>' : '-';
echo '</td>';
break;

View File

@ -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() ) ) ) ) {
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 );
}
}

View File

@ -90,7 +90,7 @@ class WC_Settings_Tax extends WC_Settings_Page {
$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();
} else {
$settings = $this->get_settings();
@ -260,7 +260,7 @@ class WC_Settings_Tax extends WC_Settings_Page {
// Loop posted fields
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 );
if ( 'insert' === $mode ) {

View File

@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php if ( $sections ) : ?>
<ul class="subsubsub">
<?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&section=' . 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&section=' . esc_attr( $section_id ) ); ?>"><?php echo esc_html( $section->title ); ?></a><?php if ( end( $section_keys ) !== $section_id ) echo ' |'; ?></li>
<?php endforeach; ?>
</ul>
<br class="clear" />

View File

@ -55,7 +55,7 @@ if ( ! defined( 'ABSPATH' ) ) {
$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>';
} else {
echo '<h1 class="screen-reader-text">' . esc_html( $report['title'] ) . '</h1>';

View File

@ -352,7 +352,7 @@ $pages = $system_status->get_pages();
$version_string = ' &ndash; <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 = ' &ndash; <strong style="color:black;">' . __( 'Network enabled', 'woocommerce' ) . '</strong>';
}
}
@ -570,7 +570,7 @@ $pages = $system_status->get_pages();
} else {
echo esc_html( $override['file'] );
}
if ( $i !== ( count( $theme['overrides'] ) - 1 ) ) {
if ( ( count( $theme['overrides'] ) - 1 ) !== $i ) {
echo ', ';
}
echo '<br />';

View File

@ -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>';
}
?>
<li class="custom <?php echo $current_range == 'custom' ? 'active' : ''; ?>">
<li class="custom <?php echo ( 'custom' === $current_range ) ? 'active' : ''; ?>">
<?php _e( 'Custom:', 'woocommerce' ); ?>
<form method="GET">
<div>

View File

@ -36,10 +36,10 @@ class WC_REST_Authentication {
$rest_prefix = trailingslashit( rest_get_url_prefix() );
// 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.
$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 );
}
@ -356,7 +356,7 @@ class WC_REST_Authentication {
$query_string = implode( '%26', $query_parameters ); // Join with ampersand.
$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 ) );
}

View File

@ -315,7 +315,7 @@ class WC_REST_Coupons_Controller extends WC_REST_Posts_Controller {
try {
$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 ) );
}

View File

@ -725,7 +725,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
try {
$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 ) );
}

View File

@ -1495,7 +1495,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
// 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'] ) );
} else {
delete_post_meta( $variation_id, '_tax_class' );

View File

@ -368,7 +368,7 @@ class WC_REST_Settings_Options_Controller extends WC_REST_Controller {
if ( isset( $setting[ $key ] ) ) {
$setting[ $key ]['width'] = intval( $setting[ $key ]['width'] );
$setting[ $key ]['height'] = intval( $setting[ $key ]['height'] );
$setting[ $key ]['crop'] = (bool) $setting[ $key ]['crop'];
$setting[ $key ]['crop'] = (bool) $setting[ $key ]['crop'];
}
}
return $setting;

View File

@ -414,7 +414,7 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
if ( isset( $tools[ $tool ]['callback'] ) ) {
$callback = $tools[ $tool ]['callback'];
$return = call_user_func( $callback );
if ( $return === false ) {
if ( false === $return ) {
$callback_string = is_array( $callback ) ? get_class( $callback[0] ) . '::' . $callback[1] : $callback;
$ran = false;
$message = sprintf( __( 'There was an error calling %s', 'woocommerce' ), $callback_string );

View File

@ -261,7 +261,7 @@ class WC_API_Authentication {
$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 );
}

View File

@ -261,7 +261,7 @@ class WC_API_Authentication {
$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 );
}

View File

@ -559,7 +559,7 @@ class WC_API_Customers extends WC_API_Resource {
// Limit number of users returned
if ( ! empty( $args['limit'] ) ) {
if ( $args['limit'] == -1 ) {
if ( -1 == $args['limit'] ) {
unset( $query_args['number'] );
} else {
$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 );
// 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;
return $query;

View File

@ -214,7 +214,7 @@ class WC_API_Orders extends WC_API_Resource {
// add line items
foreach ( $order->get_items() as $item_id => $item ) {
$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 );
foreach ( $item_meta as $key => $values ) {
@ -301,7 +301,7 @@ class WC_API_Orders extends WC_API_Resource {
if ( ! empty( $status ) ) {
if ( $status == 'any' ) {
if ( 'any' === $status ) {
$order_statuses = array();
@ -1506,7 +1506,7 @@ class WC_API_Orders extends WC_API_Resource {
// Add line items
foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) {
$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 );
foreach ( $item_meta as $key => $values ) {

View File

@ -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
$_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();
@ -1029,7 +1029,7 @@ class WC_API_Products extends WC_API_Resource {
$clear_parent_ids[] = $_product->post->post_parent;
}
if ( $product_type == 'grouped' ) {
if ( 'grouped' === $product_type ) {
$clear_parent_ids[] = $product_id;
}
@ -1216,7 +1216,7 @@ class WC_API_Products extends WC_API_Resource {
}
// Product url
if ( $product_type == 'external' ) {
if ( 'external' === $product_type ) {
if ( isset( $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'] ) ) {
$image = current( $variation['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'] ) );
if ( is_wp_error( $upload ) ) {
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
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'] ) );
} else {
delete_post_meta( $variation_id, '_tax_class' );
@ -1752,7 +1752,7 @@ class WC_API_Products extends WC_API_Resource {
$gallery = array();
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;
if ( 0 === $attachment_id && isset( $image['src'] ) ) {

View File

@ -257,7 +257,7 @@ class WC_API_Authentication {
$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 );
}

View File

@ -548,7 +548,7 @@ class WC_API_Customers extends WC_API_Resource {
// Limit number of users returned
if ( ! empty( $args['limit'] ) ) {
if ( $args['limit'] == -1 ) {
if ( -1 == $args['limit'] ) {
unset( $query_args['number'] );
} else {
$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 );
// 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;
return $query;

View File

@ -220,7 +220,7 @@ class WC_API_Orders extends WC_API_Resource {
// Add line items.
foreach ( $order->get_items() as $item_id => $item ) {
$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 );
foreach ( $item_meta as $key => $values ) {
@ -337,7 +337,7 @@ class WC_API_Orders extends WC_API_Resource {
if ( ! empty( $status ) ) {
if ( $status == 'any' ) {
if ( 'any' === $status ) {
$order_statuses = array();
@ -1551,7 +1551,7 @@ class WC_API_Orders extends WC_API_Resource {
// Add line items
foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) {
$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 );
foreach ( $item_meta as $key => $values ) {

View File

@ -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.
$_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();
@ -1514,7 +1514,7 @@ class WC_API_Products extends WC_API_Resource {
$clear_parent_ids[] = $_product->post->post_parent;
}
if ( $product_type == 'grouped' ) {
if ( 'grouped' === $product_type ) {
$clear_parent_ids[] = $product_id;
}
@ -1706,7 +1706,7 @@ class WC_API_Products extends WC_API_Resource {
}
// Product url.
if ( $product_type == 'external' ) {
if ( 'external' === $product_type ) {
if ( isset( $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'] ) ) {
$image = current( $variation['image'] );
if ( $image && is_array( $image ) ) {
if ( isset( $image['position'] ) && $image['position'] == 0 ) {
if ( isset( $image['position'] ) && 0 == $image['position'] ) {
if ( isset( $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
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'] ) );
} else {
delete_post_meta( $variation_id, '_tax_class' );
@ -2274,7 +2274,7 @@ class WC_API_Products extends WC_API_Resource {
$gallery = array();
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;
if ( 0 === $attachment_id && isset( $image['src'] ) ) {

View File

@ -582,7 +582,7 @@ class WC_API_Server {
$page = 1;
$total_pages = 1;
}
} else if ( is_a( $query, 'stdClass' ) ) {
} elseif ( is_a( $query, 'stdClass' ) ) {
$page = $query->page;
$single = $query->is_single;
$total = $query->total;

View File

@ -1459,7 +1459,7 @@ class WC_AJAX {
$note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
$note_type = $_POST['note_type'];
$is_customer_note = $note_type == 'customer' ? 1 : 0;
$is_customer_note = ( 'customer' === $note_type ) ? 1 : 0;
if ( $post_id > 0 ) {
$order = wc_get_order( $post_id );
@ -1918,8 +1918,8 @@ class WC_AJAX {
$line_item_qtys = json_decode( sanitize_text_field( stripslashes( $_POST['line_item_qtys'] ) ), true );
$line_item_totals = json_decode( sanitize_text_field( stripslashes( $_POST['line_item_totals'] ) ), true );
$line_item_tax_totals = json_decode( sanitize_text_field( stripslashes( $_POST['line_item_tax_totals'] ) ), true );
$api_refund = $_POST['api_refund'] === 'true' ? true : false;
$restock_refunded_items = $_POST['restock_refunded_items'] === 'true' ? true : false;
$api_refund = ( 'true' === $_POST['api_refund'] ) ? true : false;
$restock_refunded_items = ( 'true' === $_POST['restock_refunded_items'] ) ? true : false;
$refund = false;
$response_data = array();
@ -2338,7 +2338,7 @@ class WC_AJAX {
$product_type_terms = wp_get_object_terms( $product_id, 'product_type' );
// If the product type hasn't been set or it has changed, update it before saving variations
if ( empty( $product_type_terms ) || $product_type !== sanitize_title( current( $product_type_terms )->name ) ) {
if ( empty( $product_type_terms ) || sanitize_title( current( $product_type_terms )->name ) !== $product_type ) {
wp_set_object_terms( $product_id, $product_type, 'product_type' );
}

View File

@ -134,7 +134,7 @@ class WC_Cart {
break;
case 'display_totals_ex_tax' :
case 'display_cart_ex_tax' :
return $this->tax_display_cart === 'excl';
return 'excl' === $this->tax_display_cart;
break;
case 'cart_contents_weight' :
return $this->get_cart_contents_weight();
@ -760,7 +760,7 @@ class WC_Cart {
foreach ( $taxes as $key => $tax ) {
$code = WC_Tax::get_rate_code( $key );
if ( $code || $key === apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) ) {
if ( $code || apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) === $key ) {
if ( ! isset( $tax_totals[ $code ] ) ) {
$tax_totals[ $code ] = new stdClass();
$tax_totals[ $code ]->amount = 0;
@ -830,7 +830,7 @@ class WC_Cart {
* @return string cart item key
*/
public function find_product_in_cart( $cart_id = false ) {
if ( $cart_id !== false ) {
if ( false !== $cart_id ) {
if ( is_array( $this->cart_contents ) && isset( $this->cart_contents[ $cart_id ] ) ) {
return $cart_id;
}
@ -1057,7 +1057,7 @@ class WC_Cart {
* @return bool
*/
public function set_quantity( $cart_item_key, $quantity = 1, $refresh_totals = true ) {
if ( $quantity == 0 || $quantity < 0 ) {
if ( 0 == $quantity || $quantity < 0 ) {
do_action( 'woocommerce_before_cart_item_quantity_zero', $cart_item_key );
unset( $this->cart_contents[ $cart_item_key ] );
} else {
@ -1593,7 +1593,7 @@ class WC_Cart {
if ( $this->shipping_total > 0 ) {
// Display varies depending on settings
if ( $this->tax_display_cart == 'excl' ) {
if ( 'excl' === $this->tax_display_cart ) {
$return = wc_price( $this->shipping_total );
@ -1859,7 +1859,7 @@ class WC_Cart {
$coupon_code = apply_filters( 'woocommerce_coupon_code', $coupon_code );
$position = array_search( $coupon_code, $this->applied_coupons );
if ( $position !== false ) {
if ( false !== $position ) {
unset( $this->applied_coupons[ $position ] );
}
@ -2090,7 +2090,7 @@ class WC_Cart {
} else {
// Display varies depending on settings
if ( $this->tax_display_cart == 'excl' ) {
if ( 'excl' === $this->tax_display_cart ) {
$cart_subtotal = wc_price( $this->subtotal_ex_tax );
@ -2117,7 +2117,7 @@ class WC_Cart {
* @return string formatted price
*/
public function get_product_price( $_product ) {
if ( $this->tax_display_cart == 'excl' ) {
if ( 'excl' === $this->tax_display_cart ) {
$product_price = $_product->get_price_excluding_tax();
} else {
$product_price = $_product->get_price_including_tax();
@ -2145,7 +2145,7 @@ class WC_Cart {
// Taxable
if ( $taxable ) {
if ( $this->tax_display_cart == 'excl' ) {
if ( 'excl' === $this->tax_display_cart ) {
$row_price = $_product->get_price_excluding_tax( $quantity );
$product_subtotal = wc_price( $row_price );

View File

@ -292,7 +292,7 @@ class WC_Checkout {
// Store tax rows
foreach ( array_keys( WC()->cart->taxes + WC()->cart->shipping_taxes ) as $tax_rate_id ) {
if ( $tax_rate_id && $tax_rate_id !== apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) ) {
if ( $tax_rate_id && apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) !== $tax_rate_id ) {
$order->add_item( new WC_Order_Item_Tax( array(
'rate_id' => $tax_rate_id,
'tax_total' => WC()->cart->get_tax_amount( $tax_rate_id ),
@ -428,7 +428,7 @@ class WC_Checkout {
foreach ( $this->checkout_fields as $fieldset_key => $fieldset ) {
// Skip shipping if not needed
if ( $fieldset_key == 'shipping' && ( $this->posted['ship_to_different_address'] == false || ! WC()->cart->needs_shipping_address() ) ) {
if ( 'shipping' === $fieldset_key && ( false == $this->posted['ship_to_different_address'] || ! WC()->cart->needs_shipping_address() ) ) {
$skipped_shipping = true;
continue;
}
@ -790,7 +790,7 @@ class WC_Checkout {
$value = apply_filters( 'woocommerce_checkout_get_value', null, $input );
if ( $value !== null ) {
if ( null !== $value ) {
return $value;
}
@ -806,7 +806,7 @@ class WC_Checkout {
return $meta;
}
if ( $input == 'billing_email' ) {
if ( 'billing_email' === $input ) {
return $current_user->user_email;
}
}

View File

@ -388,7 +388,7 @@ class WC_Countries {
echo '</optgroup>';
else :
echo '<option';
if ( $selected_country == $key && $selected_state == '*' ) {
if ( $selected_country == $key && '*' == $selected_state ) {
echo ' selected="selected"';
}
echo ' value="' . esc_attr( $key ) . '">' . ( $escape ? esc_js( $value ) : $value ) . '</option>';
@ -1010,7 +1010,7 @@ class WC_Countries {
$address_fields[ $type . $key ] = $value;
// Add email and phone after company or last
if ( 'billing_' === $type && ( 'company' === $key || ( ! array_key_exists( 'company', $fields ) && $key === end( $keys ) ) ) ) {
if ( 'billing_' === $type && ( 'company' === $key || ( ! array_key_exists( 'company', $fields ) && end( $keys ) === $key ) ) ) {
$address_fields['billing_email'] = array(
'label' => __( 'Email Address', 'woocommerce' ),
'required' => true,

View File

@ -1233,7 +1233,7 @@ class WC_Customer extends WC_Legacy_Customer {
}
$data[ $session_key ] = $this->{"get_$function_key"}();
}
if ( $data !== WC()->session->get( 'customer' ) ) {
if ( WC()->session->get( 'customer' ) !== $data ) {
WC()->session->set( 'customer', $data );
}
}

View File

@ -372,7 +372,7 @@ class WC_Form_Handler {
if ( wc_notice_count( 'wc_errors' ) == 0 ) {
$result = $available_gateways[ $payment_method ]->add_payment_method();
// Redirect to success/confirmation/payment page
if ( $result['result'] == 'success' ) {
if ( 'success' === $result['result'] ) {
wc_add_notice( __( 'Payment method added.', 'woocommerce' ) );
wp_redirect( $result['redirect'] );
exit();

View File

@ -1214,7 +1214,7 @@ class WC_Geo_IP {
$delim = @shmop_read( $this->shmid, $offset, 3 );
$offset += 3;
if ( $delim == ( chr( 255 ) . chr( 255 ) . chr( 255 ) ) ) {
if ( ( chr( 255 ) . chr( 255 ) . chr( 255 ) ) == $delim ) {
$this->databaseType = ord( @shmop_read( $this->shmid, $offset, 1 ) );
if ( $this->databaseType >= 106 ) {
@ -1223,28 +1223,28 @@ class WC_Geo_IP {
$offset++;
if ( $this->databaseType == self::GEOIP_REGION_EDITION_REV0 ) {
if ( self::GEOIP_REGION_EDITION_REV0 == $this->databaseType ) {
$this->databaseSegments = self::GEOIP_STATE_BEGIN_REV0;
} elseif ( $this->databaseType == self::GEOIP_REGION_EDITION_REV1 ) {
} elseif ( self::GEOIP_REGION_EDITION_REV1 == $this->databaseType ) {
$this->databaseSegments = self::GEOIP_STATE_BEGIN_REV1;
} elseif ( ( $this->databaseType == self::GEOIP_CITY_EDITION_REV0 )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV1 )
|| ( $this->databaseType == self::GEOIP_ORG_EDITION )
|| ( $this->databaseType == self::GEOIP_ORG_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_USERTYPE_EDITION )
|| ( $this->databaseType == self::GEOIP_USERTYPE_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_LOCATIONA_EDITION )
|| ( $this->databaseType == self::GEOIP_ACCURACYRADIUS_EDITION )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV0_V6 )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV1_V6 )
|| ( $this->databaseType == self::GEOIP_NETSPEED_EDITION_REV1 )
|| ( $this->databaseType == self::GEOIP_NETSPEED_EDITION_REV1_V6 )
|| ( $this->databaseType == self::GEOIP_ASNUM_EDITION )
|| ( $this->databaseType == self::GEOIP_ASNUM_EDITION_V6 )
} elseif ( ( self::GEOIP_CITY_EDITION_REV0 == $this->databaseType )
|| ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType )
|| ( self::GEOIP_ORG_EDITION == $this->databaseType )
|| ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
|| ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_ISP_EDITION == $this->databaseType )
|| ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_USERTYPE_EDITION == $this->databaseType )
|| ( self::GEOIP_USERTYPE_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_LOCATIONA_EDITION == $this->databaseType )
|| ( self::GEOIP_ACCURACYRADIUS_EDITION == $this->databaseType )
|| ( self::GEOIP_CITY_EDITION_REV0_V6 == $this->databaseType )
|| ( self::GEOIP_CITY_EDITION_REV1_V6 == $this->databaseType )
|| ( self::GEOIP_NETSPEED_EDITION_REV1 == $this->databaseType )
|| ( self::GEOIP_NETSPEED_EDITION_REV1_V6 == $this->databaseType )
|| ( self::GEOIP_ASNUM_EDITION == $this->databaseType )
|| ( self::GEOIP_ASNUM_EDITION_V6 == $this->databaseType )
) {
$this->databaseSegments = 0;
$buf = @shmop_read( $this->shmid, $offset, self::SEGMENT_RECORD_LENGTH );
@ -1253,12 +1253,12 @@ class WC_Geo_IP {
$this->databaseSegments += ( ord( $buf[ $j ] ) << ( $j * 8 ) );
}
if ( ( $this->databaseType == self::GEOIP_ORG_EDITION )
|| ( $this->databaseType == self::GEOIP_ORG_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION_V6 )
if ( ( self::GEOIP_ORG_EDITION == $this->databaseType )
|| ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
|| ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_ISP_EDITION == $this->databaseType )
|| ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType )
) {
$this->record_length = self::ORG_RECORD_LENGTH;
}
@ -1269,10 +1269,10 @@ class WC_Geo_IP {
$offset -= 4;
}
}
if ( ( $this->databaseType == self::GEOIP_COUNTRY_EDITION )
|| ( $this->databaseType == self::GEOIP_COUNTRY_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_PROXY_EDITION )
|| ( $this->databaseType == self::GEOIP_NETSPEED_EDITION )
if ( ( self::GEOIP_COUNTRY_EDITION == $this->databaseType )
|| ( self::GEOIP_COUNTRY_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_PROXY_EDITION == $this->databaseType )
|| ( self::GEOIP_NETSPEED_EDITION == $this->databaseType )
) {
$this->databaseSegments = self::GEOIP_COUNTRY_BEGIN;
}
@ -1283,35 +1283,35 @@ class WC_Geo_IP {
for ( $i = 0; $i < self::STRUCTURE_INFO_MAX_SIZE; $i++ ) {
$delim = fread( $this->filehandle, 3 );
if ( $delim == ( chr( 255 ) . chr( 255 ) . chr( 255 ) ) ) {
if ( ( chr( 255 ) . chr( 255 ) . chr( 255 ) ) == $delim ) {
$this->databaseType = ord( fread( $this->filehandle, 1 ) );
if ( $this->databaseType >= 106 ) {
$this->databaseType -= 105;
}
if ( $this->databaseType == self::GEOIP_REGION_EDITION_REV0 ) {
if ( self::GEOIP_REGION_EDITION_REV0 == $this->databaseType ) {
$this->databaseSegments = self::GEOIP_STATE_BEGIN_REV0;
} elseif ( $this->databaseType == self::GEOIP_REGION_EDITION_REV1 ) {
} elseif ( self::GEOIP_REGION_EDITION_REV1 == $this->databaseType ) {
$this->databaseSegments = self::GEOIP_STATE_BEGIN_REV1;
} elseif ( ( $this->databaseType == self::GEOIP_CITY_EDITION_REV0 )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV1 )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV0_V6 )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV1_V6 )
|| ( $this->databaseType == self::GEOIP_ORG_EDITION )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION )
|| ( $this->databaseType == self::GEOIP_ORG_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_LOCATIONA_EDITION )
|| ( $this->databaseType == self::GEOIP_ACCURACYRADIUS_EDITION )
|| ( $this->databaseType == self::GEOIP_NETSPEED_EDITION_REV1 )
|| ( $this->databaseType == self::GEOIP_NETSPEED_EDITION_REV1_V6 )
|| ( $this->databaseType == self::GEOIP_USERTYPE_EDITION )
|| ( $this->databaseType == self::GEOIP_USERTYPE_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_ASNUM_EDITION )
|| ( $this->databaseType == self::GEOIP_ASNUM_EDITION_V6 )
} elseif ( ( self::GEOIP_CITY_EDITION_REV0 == $this->databaseType )
|| ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType )
|| ( self::GEOIP_CITY_EDITION_REV0_V6 == $this->databaseType )
|| ( self::GEOIP_CITY_EDITION_REV1_V6 == $this->databaseType )
|| ( self::GEOIP_ORG_EDITION == $this->databaseType )
|| ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
|| ( self::GEOIP_ISP_EDITION == $this->databaseType )
|| ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_LOCATIONA_EDITION == $this->databaseType )
|| ( self::GEOIP_ACCURACYRADIUS_EDITION == $this->databaseType )
|| ( self::GEOIP_NETSPEED_EDITION_REV1 == $this->databaseType )
|| ( self::GEOIP_NETSPEED_EDITION_REV1_V6 == $this->databaseType )
|| ( self::GEOIP_USERTYPE_EDITION == $this->databaseType )
|| ( self::GEOIP_USERTYPE_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_ASNUM_EDITION == $this->databaseType )
|| ( self::GEOIP_ASNUM_EDITION_V6 == $this->databaseType )
) {
$this->databaseSegments = 0;
$buf = fread( $this->filehandle, self::SEGMENT_RECORD_LENGTH );
@ -1320,12 +1320,12 @@ class WC_Geo_IP {
$this->databaseSegments += ( ord( $buf[ $j ] ) << ( $j * 8 ) );
}
if ( ( $this->databaseType == self::GEOIP_ORG_EDITION )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION )
|| ( $this->databaseType == self::GEOIP_ORG_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION_V6 )
if ( ( self::GEOIP_ORG_EDITION == $this->databaseType )
|| ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
|| ( self::GEOIP_ISP_EDITION == $this->databaseType )
|| ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType )
) {
$this->record_length = self::ORG_RECORD_LENGTH;
}
@ -1337,10 +1337,10 @@ class WC_Geo_IP {
}
}
if ( ( $this->databaseType == self::GEOIP_COUNTRY_EDITION )
|| ( $this->databaseType == self::GEOIP_COUNTRY_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_PROXY_EDITION )
|| ( $this->databaseType == self::GEOIP_NETSPEED_EDITION )
if ( ( self::GEOIP_COUNTRY_EDITION == $this->databaseType )
|| ( self::GEOIP_COUNTRY_EDITION_V6 == $this->databaseType )
|| ( self::GEOIP_PROXY_EDITION == $this->databaseType )
|| ( self::GEOIP_NETSPEED_EDITION == $this->databaseType )
) {
$this->databaseSegments = self::GEOIP_COUNTRY_BEGIN;
}
@ -1403,7 +1403,7 @@ class WC_Geo_IP {
// Get region
$char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) );
while ( $char != 0 ) {
while ( 0 != $char ) {
$str_length++;
$char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) );
}
@ -1417,7 +1417,7 @@ class WC_Geo_IP {
// Get city
$char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) );
while ( $char != 0 ) {
while ( 0 != $char ) {
$str_length++;
$char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) );
}
@ -1431,7 +1431,7 @@ class WC_Geo_IP {
// Get postal code
$char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) );
while ( $char != 0 ) {
while ( 0 != $char ) {
$str_length++;
$char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) );
}
@ -1461,7 +1461,7 @@ class WC_Geo_IP {
if ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType ) {
$metroarea_combo = 0;
if ( $record->country_code == "US" ) {
if ( 'US' === $record->country_code ) {
for ( $j = 0; $j < 3; ++$j ) {
$char = ord( substr( $record_buf, $record_buf_pos++, 1 ) );
$metroarea_combo += ( $char << ( $j * 8 ) );
@ -1617,7 +1617,7 @@ class WC_Geo_IP {
* @return int
*/
public function geoip_record_by_addr( $addr ) {
if ( $addr == null ) {
if ( null == $addr ) {
return 0;
}
@ -1655,7 +1655,7 @@ class WC_Geo_IP {
*/
public function geoip_country_code_by_addr_v6( $addr ) {
$country_id = $this->geoip_country_id_by_addr_v6( $addr );
if ( $country_id !== false && isset( $this->GEOIP_COUNTRY_CODES[ $country_id ] ) ) {
if ( false !== $country_id && isset( $this->GEOIP_COUNTRY_CODES[ $country_id ] ) ) {
return $this->GEOIP_COUNTRY_CODES[ $country_id ];
}
@ -1669,14 +1669,14 @@ class WC_Geo_IP {
* @return string
*/
public function geoip_country_code_by_addr( $addr ) {
if ( $this->databaseType == self::GEOIP_CITY_EDITION_REV1 ) {
if ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType ) {
$record = $this->geoip_record_by_addr( $addr );
if ( $record !== false ) {
if ( false !== $record ) {
return $record->country_code;
}
} else {
$country_id = $this->geoip_country_id_by_addr( $addr );
if ( $country_id !== false && isset( $this->GEOIP_COUNTRY_CODES[ $country_id ] ) ) {
if ( false !== $country_id && isset( $this->GEOIP_COUNTRY_CODES[ $country_id ] ) ) {
return $this->GEOIP_COUNTRY_CODES[ $country_id ];
}
}

View File

@ -277,7 +277,7 @@ class WC_Install {
$held_duration = get_option( 'woocommerce_hold_stock_minutes', '60' );
if ( $held_duration != '' ) {
if ( '' != $held_duration ) {
wp_schedule_single_event( time() + ( absint( $held_duration ) * 60 ), 'woocommerce_cancel_unpaid_orders' );
}
@ -854,7 +854,7 @@ CREATE TABLE {$wpdb->prefix}woocommerce_termmeta (
* @return array
*/
public static function plugin_row_meta( $links, $file ) {
if ( $file == WC_PLUGIN_BASENAME ) {
if ( WC_PLUGIN_BASENAME == $file ) {
$row_meta = array(
'docs' => '<a href="' . esc_url( apply_filters( 'woocommerce_docs_url', 'https://docs.woocommerce.com/documentation/plugins/woocommerce/' ) ) . '" title="' . esc_attr( __( 'View WooCommerce Documentation', 'woocommerce' ) ) . '">' . __( 'Docs', 'woocommerce' ) . '</a>',
'apidocs' => '<a href="' . esc_url( apply_filters( 'woocommerce_apidocs_url', 'https://docs.woocommerce.com/wc-apidocs/' ) ) . '" title="' . esc_attr( __( 'View WooCommerce API Docs', 'woocommerce' ) ) . '">' . __( 'API Docs', 'woocommerce' ) . '</a>',

View File

@ -97,7 +97,7 @@ class WC_Legacy_API {
// Legacy v1 API request.
if ( 1 === WC_API_REQUEST_VERSION ) {
$this->handle_v1_rest_api_request();
} else if ( 2 === WC_API_REQUEST_VERSION ) {
} elseif ( 2 === WC_API_REQUEST_VERSION ) {
$this->handle_v2_rest_api_request();
} else {
$this->includes();

View File

@ -154,9 +154,9 @@ class WC_Payment_Gateways {
if ( $gateway->is_available() ) {
if ( ! is_add_payment_method_page() ) {
$_available_gateways[ $gateway->id ] = $gateway;
} else if ( $gateway->supports( 'add_payment_method' ) ) {
} elseif ( $gateway->supports( 'add_payment_method' ) ) {
$_available_gateways[ $gateway->id ] = $gateway;
} else if ( $gateway->supports( 'tokenization' ) ) {
} elseif ( $gateway->supports( 'tokenization' ) ) {
$_available_gateways[ $gateway->id ] = $gateway;
}
}

View File

@ -95,7 +95,7 @@ class WC_Product_Grouped extends WC_Product {
foreach ( $this->get_children() as $child_id ) {
$sale_price = get_post_meta( $child_id, '_sale_price', true );
if ( $sale_price !== "" && $sale_price >= 0 ) {
if ( '' !== $sale_price && $sale_price >= 0 ) {
$is_on_sale = true;
}
}
@ -148,7 +148,7 @@ class WC_Product_Grouped extends WC_Product {
if ( '' !== $min_price ) {
$price = $min_price !== $max_price ? sprintf( _x( '%1$s&ndash;%2$s', 'Price range: from-to', 'woocommerce' ), wc_price( $min_price ), wc_price( $max_price ) ) : wc_price( $min_price );
$is_free = $min_price == 0 && $max_price == 0;
$is_free = ( 0 == $min_price && 0 == $max_price );
if ( $is_free ) {
$price = apply_filters( 'woocommerce_grouped_free_price_html', __( 'Free!', 'woocommerce' ), $this );

View File

@ -272,7 +272,7 @@ class WC_Product_Variable extends WC_Product {
$transient_cached_prices_array = array_filter( (array) json_decode( strval( get_transient( $transient_name ) ), true ) );
// If the product version has changed since the transient was last saved, reset the transient cache.
if ( empty( $transient_cached_prices_array['version'] ) || $transient_cached_prices_array['version'] !== WC_Cache_Helper::get_transient_version( 'product' ) ) {
if ( empty( $transient_cached_prices_array['version'] ) || WC_Cache_Helper::get_transient_version( 'product' ) !== $transient_cached_prices_array['version'] ) {
$transient_cached_prices_array = array( 'version' => WC_Cache_Helper::get_transient_version( 'product' ) );
}
@ -356,7 +356,7 @@ class WC_Product_Variable extends WC_Product {
$min_price = current( $prices['price'] );
$max_price = end( $prices['price'] );
$price = $min_price !== $max_price ? sprintf( _x( '%1$s&ndash;%2$s', 'Price range: from-to', 'woocommerce' ), wc_price( $min_price ), wc_price( $max_price ) ) : wc_price( $min_price );
$is_free = $min_price == 0 && $max_price == 0;
$is_free = 0 == $min_price && 0 == $max_price;
if ( $this->is_on_sale() ) {
$min_regular_price = current( $prices['regular_price'] );
@ -528,7 +528,7 @@ class WC_Product_Variable extends WC_Product {
* Fallback is here because there are cases where data will be 'synced' but the product version will remain the same. @see WC_Product_Variable::sync_attributes.
*/
} elseif ( version_compare( get_post_meta( $this->id, '_product_version', true ), '2.4.0', '<' ) ) {
return $match_attributes === array_map( 'sanitize_title', $match_attributes ) ? 0 : $this->get_matching_variation( array_map( 'sanitize_title', $match_attributes ) );
return ( array_map( 'sanitize_title', $match_attributes ) === $match_attributes ) ? 0 : $this->get_matching_variation( array_map( 'sanitize_title', $match_attributes ) );
} else {
return 0;
@ -710,7 +710,7 @@ class WC_Product_Variable extends WC_Product {
}
if ( sanitize_title( $value[0] ) === $value[0] ) {
foreach ( $parent_attributes as $attribute ) {
if ( $name !== 'attribute_' . sanitize_title( $attribute['name'] ) ) {
if ( 'attribute_' . sanitize_title( $attribute['name'] ) !== $name ) {
continue;
}
$text_attributes = wc_get_text_attributes( $attribute['value'] );
@ -819,14 +819,14 @@ class WC_Product_Variable extends WC_Product {
$child_price = get_post_meta( $child_id, '_' . $price_type, true );
// Skip non-priced variations
if ( $child_price === '' ) {
if ( '' === $child_price ) {
continue;
}
// Skip hidden variations
if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
$stock = get_post_meta( $child_id, '_stock', true );
if ( $stock !== "" && $stock <= get_option( 'woocommerce_notify_no_stock_amount' ) ) {
if ( '' !== $stock && $stock <= get_option( 'woocommerce_notify_no_stock_amount' ) ) {
continue;
}
}

View File

@ -428,7 +428,7 @@ class WC_Product_Variation extends WC_Product {
* @return bool
*/
public function is_in_stock() {
return apply_filters( 'woocommerce_variation_is_in_stock', $this->stock_status === 'instock', $this );
return apply_filters( 'woocommerce_variation_is_in_stock', 'instock' === $this->stock_status, $this );
}
/**
@ -660,7 +660,7 @@ class WC_Product_Variation extends WC_Product {
foreach ( $options as $option ) {
if ( sanitize_title( $variation_selected_value ) === $variation_selected_value ) {
if ( $variation_selected_value !== sanitize_title( $option ) ) {
if ( sanitize_title( $option ) !== $variation_selected_value ) {
continue;
}
} else {

View File

@ -443,39 +443,39 @@ class WC_Query {
// default - menu_order
$args['orderby'] = 'menu_order title';
$args['order'] = $order == 'DESC' ? 'DESC' : 'ASC';
$args['order'] = ( 'DESC' === $order ) ? 'DESC' : 'ASC';
$args['meta_key'] = '';
switch ( $orderby ) {
case 'rand' :
$args['orderby'] = 'rand';
break;
break;
case 'date' :
$args['orderby'] = 'date ID';
$args['order'] = $order == 'ASC' ? 'ASC' : 'DESC';
break;
$args['order'] = ( 'ASC' === $order ) ? 'ASC' : 'DESC';
break;
case 'price' :
$args['orderby'] = "meta_value_num ID";
$args['order'] = $order == 'DESC' ? 'DESC' : 'ASC';
$args['order'] = ( 'DESC' === $order ) ? 'DESC' : 'ASC';
$args['meta_key'] = '_price';
break;
break;
case 'popularity' :
$args['meta_key'] = 'total_sales';
// Sorting handled later though a hook
add_filter( 'posts_clauses', array( $this, 'order_by_popularity_post_clauses' ) );
break;
break;
case 'rating' :
$args['meta_key'] = '_wc_average_rating';
$args['orderby'] = array(
'meta_value_num' => 'DESC',
'ID' => 'ASC',
);
break;
break;
case 'title' :
$args['orderby'] = 'title';
$args['order'] = $order == 'DESC' ? 'DESC' : 'ASC';
break;
$args['orderby'] = 'title';
$args['order'] = ( 'DESC' === $order ) ? 'DESC' : 'ASC';
break;
}
return apply_filters( 'woocommerce_get_catalog_ordering_args', $args );

View File

@ -28,7 +28,7 @@ class WC_Register_WP_Admin_Settings {
if ( 'page' === $type ) {
add_filter( 'woocommerce_settings_groups', array( $this, 'register_page_group' ) );
add_filter( 'woocommerce_settings-' . $this->object->get_id(), array( $this, 'register_page_settings' ) );
} else if ( 'email' === $type ) {
} elseif ( 'email' === $type ) {
add_filter( 'woocommerce_settings_groups', array( $this, 'register_email_group' ) );
add_filter( 'woocommerce_settings-email_' . $this->object->id, array( $this, 'register_email_settings' ) );
}
@ -135,9 +135,9 @@ class WC_Register_WP_Admin_Settings {
}
$description = '';
if ( ! empty ( $setting['desc'] ) ) {
if ( ! empty( $setting['desc'] ) ) {
$description = $setting['desc'];
} else if ( ! empty( $setting['description'] ) ) {
} elseif ( ! empty( $setting['description'] ) ) {
$description = $setting['description'];
}
@ -158,7 +158,7 @@ class WC_Register_WP_Admin_Settings {
if ( isset( $setting['desc_tip'] ) ) {
if ( true === $setting['desc_tip'] ) {
$new_setting['tip'] = $description;
} else if ( ! empty( $setting['desc_tip'] ) ) {
} elseif ( ! empty( $setting['desc_tip'] ) ) {
$new_setting['tip'] = $setting['desc_tip'];
}
}

View File

@ -288,7 +288,7 @@ class WC_Shipping {
if ( sizeof( $package['rates'] ) > 0 ) {
// If not set, not available, or available methods have changed, set to the DEFAULT option
if ( empty( $chosen_method ) || ! isset( $package['rates'][ $chosen_method ] ) || $method_count !== sizeof( $package['rates'] ) ) {
if ( empty( $chosen_method ) || ! isset( $package['rates'][ $chosen_method ] ) || sizeof( $package['rates'] ) !== $method_count ) {
$chosen_method = apply_filters( 'woocommerce_shipping_chosen_method', $this->get_default_method( $package['rates'], false ), $package['rates'], $chosen_method );
$chosen_methods[ $i ] = $chosen_method;
$method_counts[ $i ] = sizeof( $package['rates'] );

View File

@ -232,7 +232,7 @@ class WC_Shortcodes {
), $atts, 'product_categories' );
$ids = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) );
$hide_empty = ( $atts['hide_empty'] == true || $atts['hide_empty'] == 1 ) ? 1 : 0;
$hide_empty = ( true === $atts['hide_empty'] || 'true' === $atts['hide_empty'] || 1 === $atts['hide_empty'] || '1' === $atts['hide_empty'] ) ? 1 : 0;
// get terms and workaround WP bug with parents/pad counts
$args = array(
@ -252,7 +252,7 @@ class WC_Shortcodes {
if ( $hide_empty ) {
foreach ( $product_categories as $key => $category ) {
if ( $category->count == 0 ) {
if ( 0 == $category->count ) {
unset( $product_categories[ $key ] );
}
}
@ -690,7 +690,7 @@ class WC_Shortcodes {
$preselected_id = '0';
// check if sku is a variation
if ( isset( $atts['sku'] ) && $single_product->have_posts() && $single_product->post->post_type === 'product_variation' ) {
if ( isset( $atts['sku'] ) && $single_product->have_posts() && 'product_variation' === $single_product->post->post_type ) {
$variation = new WC_Product_Variation( $single_product->post->ID );
$attributes = $variation->get_variation_attributes();

View File

@ -148,11 +148,13 @@ class WC_Tax {
$regular_tax_rates = $compound_tax_rates = 0;
foreach ( $rates as $key => $rate )
if ( $rate['compound'] == 'yes' )
foreach ( $rates as $key => $rate ) {
if ( 'yes' === $rate['compound'] ) {
$compound_tax_rates = $compound_tax_rates + $rate['rate'];
else
} else {
$regular_tax_rates = $regular_tax_rates + $rate['rate'];
}
}
$regular_tax_rate = 1 + ( $regular_tax_rates / 100 );
$compound_tax_rate = 1 + ( $compound_tax_rates / 100 );
@ -164,7 +166,7 @@ class WC_Tax {
$the_rate = $rate['rate'] / 100;
if ( $rate['compound'] == 'yes' ) {
if ( 'yes' === $rate['compound'] ) {
$the_price = $price;
$the_rate = $the_rate / $compound_tax_rate;
} else {
@ -194,8 +196,9 @@ class WC_Tax {
// Multiple taxes
foreach ( $rates as $key => $rate ) {
if ( $rate['compound'] == 'yes' )
if ( 'yes' === $rate['compound'] ) {
continue;
}
$tax_amount = $price * ( $rate['rate'] / 100 );
@ -214,8 +217,9 @@ class WC_Tax {
// Compound taxes
foreach ( $rates as $key => $rate ) {
if ( $rate['compound'] == 'no' )
if ( 'no' === $rate['compound'] ) {
continue;
}
$the_price_inc_tax = $price + ( $pre_compound_total );
@ -225,10 +229,11 @@ class WC_Tax {
$tax_amount = apply_filters( 'woocommerce_price_ex_tax_amount', $tax_amount, $key, $rate, $price, $the_price_inc_tax, $pre_compound_total );
// Add rate
if ( ! isset( $taxes[ $key ] ) )
if ( ! isset( $taxes[ $key ] ) ) {
$taxes[ $key ] = $tax_amount;
else
} else {
$taxes[ $key ] += $tax_amount;
}
}
}
@ -706,7 +711,7 @@ class WC_Tax {
*/
private static function format_tax_rate_state( $state ) {
$state = strtoupper( $state );
return $state === '*' ? '' : $state;
return ( '*' === $state ) ? '' : $state;
}
/**
@ -716,7 +721,7 @@ class WC_Tax {
*/
private static function format_tax_rate_country( $country ) {
$country = strtoupper( $country );
return $country === '*' ? '' : $country;
return ( '*' === $country ) ? '' : $country;
}
/**
@ -757,7 +762,7 @@ class WC_Tax {
if ( ! in_array( $class, $sanitized_classes ) ) {
$class = '';
}
return $class === 'standard' ? '' : $class;
return ( 'standard' === $class ) ? '' : $class;
}
/**

View File

@ -309,7 +309,7 @@ class WC_Tracker {
$active_gateways = array();
$gateways = WC()->payment_gateways->payment_gateways();
foreach ( $gateways as $id => $gateway ) {
if ( isset( $gateway->enabled ) && $gateway->enabled == 'yes' ) {
if ( isset( $gateway->enabled ) && 'yes' === $gateway->enabled ) {
$active_gateways[ $id ] = array( 'title' => $gateway->title, 'supports' => $gateway->supports );
}
}
@ -325,7 +325,7 @@ class WC_Tracker {
$active_methods = array();
$shipping_methods = WC()->shipping->get_shipping_methods();
foreach ( $shipping_methods as $id => $shipping_method ) {
if ( isset( $shipping_method->enabled ) && $shipping_method->enabled == 'yes' ) {
if ( isset( $shipping_method->enabled ) && 'yes' === $shipping_method->enabled ) {
$active_methods[ $id ] = array( 'title' => $shipping_method->title, 'tax_status' => $shipping_method->tax_status );
}
}
@ -388,7 +388,7 @@ class WC_Tracker {
$theme_file = false;
}
if ( $theme_file !== false ) {
if ( false !== $theme_file ) {
$override_data[] = basename( $theme_file );
}
}

View File

@ -242,6 +242,9 @@ class WC_CLI_Coupon extends WC_CLI_Command {
}
$coupon_post = get_post( $coupon->get_id() );
$coupon_usage_limit = $coupon->get_usage_limit();
$coupon_usage_limit_per_user = $coupon->get_usage_limit_per_user();
$coupon_date_expires = $coupon->get_date_expires();
$coupon_data = array(
'id' => $coupon->get_id(),
'code' => $coupon->get_code(),
@ -252,11 +255,11 @@ class WC_CLI_Coupon extends WC_CLI_Command {
'individual_use' => $coupon->get_individual_use(),
'product_ids' => implode( ', ', $coupon->get_product_ids() ),
'exclude_product_ids' => implode( ', ', $coupon->get_excluded_product_ids() ),
'usage_limit' => ( ! empty( $coupon->get_usage_limit() ) ) ? $coupon->get_usage_limit() : null,
'usage_limit_per_user' => ( ! empty( $coupon->get_usage_limit_per_user() ) ) ? $coupon->get_usage_limit_per_user() : null,
'usage_limit' => ( ! empty( $coupon_usage_limit ) ) ? $coupon_usage_limit : null,
'usage_limit_per_user' => ( ! empty( $coupon_usage_limit_per_user ) ) ? $coupon_usage_limit_per_user : null,
'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(),
'usage_count' => (int) $coupon->get_usage_count(),
'expiry_date' => ( ! empty( $coupon->get_date_expires() ) ) ? $this->format_datetime( $coupon->get_date_expires() ) : null,
'expiry_date' => ( ! empty( $coupon_date_expires ) ) ? $this->format_datetime( $coupon_date_expires ) : null,
'enable_free_shipping' => $coupon->get_free_shipping(),
'product_category_ids' => implode( ', ', $coupon->get_product_categories() ),
'exclude_product_category_ids' => implode( ', ', $coupon->get_excluded_product_categories() ),
@ -577,6 +580,9 @@ class WC_CLI_Coupon extends WC_CLI_Command {
foreach ( $posts as $post ) {
$coupon = new WC_Coupon;
$coupon->read( $post->ID );
$coupon_usage_limit = $coupon->get_usage_limit();
$coupon_usage_limit_per_user = $coupon->get_usage_limit_per_user();
$coupon_date_expires = $coupon->get_date_expires();
$items[] = array(
'id' => $post->ID,
'code' => $post->post_title,
@ -587,11 +593,11 @@ class WC_CLI_Coupon extends WC_CLI_Command {
'individual_use' => $coupon->get_individual_use(),
'product_ids' => implode( ', ', is_array( $coupon->get_product_ids() ) ? $coupon->get_product_ids() : array() ),
'exclude_product_ids' => implode( ', ', is_array( $coupon->get_excluded_product_ids() ) ? $coupon->get_excluded_product_ids() : array() ),
'usage_limit' => ( ! empty( $coupon->get_usage_limit() ) ) ? $coupon->get_usage_limit() : null,
'usage_limit_per_user' => ( ! empty( $coupon->get_usage_limit_per_user() ) ) ? $coupon->get_usage_limit_per_user() : null,
'usage_limit' => ( ! empty( $coupon_usage_limit ) ) ? $coupon_usage_limit : null,
'usage_limit_per_user' => ( ! empty( $coupon_usage_limit_per_user ) ) ? $coupon_usage_limit_per_user : null,
'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(),
'usage_count' => (int) $coupon->get_usage_count(),
'expiry_date' => ( ! empty( $coupon->get_date_expires() ) ) ? $this->format_datetime( $coupon->get_date_expires() ) : null,
'expiry_date' => ( ! empty( $coupon_date_expires ) ) ? $this->format_datetime( $coupon_date_expires ) : null,
'free_shipping' => $coupon->get_free_shipping(),
'product_category_ids' => implode( ', ', is_array( $coupon->get_product_categories() ) ? $coupon->get_product_categories() : array() ),
'exclude_product_category_ids' => implode( ', ', is_array( $coupon->get_excluded_product_categories() ) ? $coupon->get_excluded_product_categories() : array() ),

View File

@ -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
$_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();
@ -1302,7 +1302,7 @@ class WC_CLI_Product extends WC_CLI_Command {
$clear_parent_ids[] = $_product->post->post_parent;
}
if ( $product_type == 'grouped' ) {
if ( 'grouped' === $product_type ) {
$clear_parent_ids[] = $product_id;
}
@ -1487,7 +1487,7 @@ class WC_CLI_Product extends WC_CLI_Command {
}
// Product url
if ( $product_type == 'external' ) {
if ( 'external' === $product_type ) {
if ( isset( $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'] ) ) {
$image = current( $variation['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'] ) );
if ( is_wp_error( $upload ) ) {
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
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'] ) );
} else {
delete_post_meta( $variation_id, '_tax_class' );
@ -1836,7 +1836,7 @@ class WC_CLI_Product extends WC_CLI_Command {
$gallery = array();
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;
if ( 0 === $attachment_id && isset( $image['src'] ) ) {

View File

@ -582,7 +582,7 @@ class WC_Email extends WC_Settings_API {
if ( is_writeable( $file ) ) {
$f = fopen( $file, 'w+' );
if ( $f !== false ) {
if ( false !== $f ) {
fwrite( $f, $code );
fclose( $f );
$saved = true;

View File

@ -57,8 +57,8 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway_CC {
$this->mode = $this->get_option( 'mode', 'standard' );
$this->modal_color = $this->get_option( 'modal_color', '#a46497' );
$this->sandbox = $this->get_option( 'sandbox' );
$this->public_key = $this->sandbox == 'no' ? $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->public_key = ( 'no' === $this->sandbox ) ? $this->get_option( 'public_key' ) : $this->get_option( 'sandbox_public_key' );
$this->private_key = ( 'no' === $this->sandbox ) ? $this->get_option( 'private_key' ) : $this->get_option( 'sandbox_private_key' );
$this->init_simplify_sdk();

View File

@ -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
$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
$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
// ===============
} 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++;
$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 (
if ( is_null( $o2 ) ) return self::trigger( "unexpected ')'" );
else $output[] = $o2;
if ( is_null( $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?
$fnn = $matches[1]; // get the function name
@ -154,7 +157,7 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
if ( $arg_count > 1 )
return self::trigger( "too many arguments ($arg_count given, 1 expected)" );
} 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)" );
} else { // did we somehow push a non-function on the stack? this should never happen
return self::trigger( "internal error" );
@ -162,10 +165,13 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
}
$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() ) != '(' ) {
if ( is_null( $o2 ) ) return self::trigger( "unexpected ','" ); // oops, never had a (
else $output[] = $o2; // pop the argument expression stuff and push onto the output
if ( is_null( $o2 ) ) {
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
if ( ! preg_match( "/^([A-Za-z]\w*)\($/", $stack->last( 2 ), $matches ) )
@ -175,7 +181,7 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
$index++;
$expecting_op = false;
// ===============
} elseif ( $op == '(' and ! $expecting_op ) {
} elseif ( '(' === $op and ! $expecting_op ) {
$stack->push( '(' ); // that was easy
$index++;
// ===============
@ -197,14 +203,14 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
}
$index += strlen( $val );
// ===============
} elseif ( $op == ')' ) { // miscellaneous error checking
} elseif ( ')' === $op ) { // miscellaneous error checking
return self::trigger( "unexpected ')'" );
} elseif ( in_array( $op, $ops ) and ! $expecting_op ) {
return self::trigger( "unexpected operator '$op'" );
} else { // I don't even want to know what you did to get here
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.
return self::trigger( "operator '$op' lacks operand" );
} 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
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;
}
return $output;
@ -231,7 +239,9 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
* @return mixed
*/
private static function pfx( $tokens, $vars = array() ) {
if ( $tokens == false ) return false;
if ( false == $tokens ) {
return false;
}
$stack = new WC_Eval_Math_Stack;
foreach ( $tokens as $token ) { // nice and easy
@ -250,7 +260,9 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
$stack->push( $op1 * $op2 );
break;
case '/':
if ( $op2 == 0 ) return self::trigger( "division by zero" );
if ( 0 == $op2 ) {
return self::trigger( 'division by zero' );
}
$stack->push( $op1 / $op2 );
break;
case '^':
@ -258,7 +270,7 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
break;
}
// 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() );
// 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 ) ) {
@ -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
if ( $stack->count != 1 ) return self::trigger( "internal error" );
if ( 1 != $stack->count ) {
return self::trigger( "internal error" );
}
return $stack->pop();
}

View File

@ -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.
$cost = $this->get_option( 'cost' );
if ( $cost !== '' ) {
if ( '' !== $cost ) {
$has_costs = true;
$rate['cost'] = $this->evaluate_cost( $cost, array(
'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' );
$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;
}
@ -163,14 +163,14 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
'cost' => array_sum( wp_list_pluck( $products, 'line_total' ) ),
) );
if ( $this->type === 'class' ) {
if ( 'class' === $this->type ) {
$rate['cost'] += $class_cost;
} else {
$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;
}

View File

@ -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.
$cost = $this->get_option( 'cost' );
if ( $cost !== '' ) {
if ( '' !== $cost ) {
$has_costs = true;
$rate['cost'] = $this->evaluate_cost( $cost, array(
'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' );
$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;
}
@ -189,14 +189,14 @@ class WC_Shipping_Legacy_Flat_Rate extends WC_Shipping_Method {
'cost' => array_sum( wp_list_pluck( $products, 'line_total' ) ),
) );
if ( $this->type === 'class' ) {
if ( 'class' === $this->type ) {
$rate['cost'] += $class_cost;
} else {
$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;
}

View File

@ -136,7 +136,7 @@ class WC_Shipping_Legacy_Local_Pickup extends WC_Shipping_Method {
public function get_valid_postcodes() {
$codes = array();
if ( $this->codes != '' ) {
if ( '' !== $this->codes ) {
foreach ( explode( ',', $this->codes ) as $code ) {
$codes[] = strtoupper( trim( $code ) );
}
@ -196,7 +196,7 @@ class WC_Shipping_Legacy_Local_Pickup extends WC_Shipping_Method {
}
if ( $is_available ) {
if ( $this->availability === 'specific' ) {
if ( 'specific' === $this->availability ) {
$ship_to_countries = $this->countries;
} else {
$ship_to_countries = array_keys( WC()->countries->get_shipping_countries() );

View File

@ -54,7 +54,7 @@ class WC_Product_Cat_Dropdown_Walker extends Walker {
}
$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 ) . "\"";
if ( $value === $args['selected'] || ( is_array( $args['selected'] ) && in_array( $value, $args['selected'] ) ) ) {

View File

@ -136,9 +136,9 @@ function wc_format_list_of_items( $items ) {
foreach ( $items as $key => $item ) {
$item_string .= $item;
if ( $key + 2 === sizeof( $items ) ) {
if ( sizeof( $items ) === $key + 2 ) {
$item_string .= ' ' . __( 'and', 'woocommerce' ) . ' ';
} elseif ( $key + 1 !== sizeof( $items ) ) {
} elseif ( sizeof( $items ) !== $key + 1 ) {
$item_string .= ', ';
}
}

View File

@ -126,7 +126,7 @@ if ( ! function_exists( 'is_wc_endpoint_url' ) ) {
$wc_endpoints = WC()->query->get_query_vars();
if ( $endpoint !== false ) {
if ( false !== $endpoint ) {
if ( ! isset( $wc_endpoints[ $endpoint ] ) ) {
return false;
} else {

View File

@ -995,7 +995,7 @@ if ( ! function_exists( 'hash_equals' ) ) :
*/
function hash_equals( $a, $b ) {
$a_length = strlen( $a );
if ( $a_length !== strlen( $b ) ) {
if ( strlen( $b ) !== $a_length ) {
return false;
}
$result = 0;
@ -1005,7 +1005,7 @@ if ( ! function_exists( 'hash_equals' ) ) :
$result |= ord( $a[ $i ] ) ^ ord( $b[ $i ] );
}
return $result === 0;
return 0 === $result;
}
endif;

View File

@ -92,7 +92,7 @@ function woocommerce_get_formatted_product_name( $product ) {
* @access public
*/
function woocommerce_legacy_paypal_ipn() {
if ( ! empty( $_GET['paypalListener'] ) && $_GET['paypalListener'] == 'paypal_standard_IPN' ) {
if ( ! empty( $_GET['paypalListener'] ) && 'paypal_standard_IPN' === $_GET['paypalListener'] ) {
WC()->payment_gateways();

View File

@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* @return bool
*/
function wc_string_to_bool( $string ) {
return is_bool( $string ) ? $string : ( $string === 'yes' || $string === 1 || $string === '1' );
return is_bool( $string ) ? $string : ( 'yes' === $string || 1 === $string || '1' === $string );
}
/**
@ -245,8 +245,8 @@ function wc_format_decimal( $number, $dp = false, $trim_zeros = false ) {
$number = wc_clean( str_replace( $decimals, '.', $number ) );
}
if ( $dp !== false ) {
$dp = intval( $dp == "" ? wc_get_price_decimals() : $dp );
if ( false !== $dp ) {
$dp = intval( '' == $dp ? wc_get_price_decimals() : $dp );
$number = number_format( floatval( $number ), $dp, '.', '' );
// DP is false - don't use number format, just return a string in our format

View File

@ -45,12 +45,12 @@ add_filter( 'the_title', 'wc_page_endpoint_title' );
*/
function wc_get_page_id( $page ) {
if ( $page == 'pay' || $page == 'thanks' ) {
if ( 'pay' == $page || 'thanks' == $page ) {
_deprecated_argument( __FUNCTION__, '2.1', 'The "pay" and "thanks" pages are no-longer used - an endpoint is added to the checkout instead. To get a valid link use the WC_Order::get_checkout_payment_url() or WC_Order::get_checkout_order_received_url() methods instead.' );
$page = 'checkout';
}
if ( $page == 'change_password' || $page == 'edit_address' || $page == 'lost_password' ) {
if ( 'change_password' === $page || 'edit_address' === $page || 'lost_password' === $page ) {
_deprecated_argument( __FUNCTION__, '2.1', 'The "change_password", "edit_address" and "lost_password" pages are no-longer used - an endpoint is added to the my-account instead. To get a valid link use the wc_customer_edit_account_url() function instead.' );
$page = 'myaccount';

View File

@ -215,7 +215,7 @@ function wc_get_featured_product_ids() {
*/
function wc_product_post_type_link( $permalink, $post ) {
// Abort if post is not a product.
if ( $post->post_type !== 'product' ) {
if ( 'product' !== $post->post_type ) {
return $permalink;
}
@ -596,7 +596,7 @@ function wc_get_product_id_by_sku( $sku ) {
function _wc_save_product_price( $product_id, $regular_price, $sale_price = '', $date_from = '', $date_to = '' ) {
$product_id = absint( $product_id );
$regular_price = wc_format_decimal( $regular_price );
$sale_price = $sale_price === '' ? '' : wc_format_decimal( $sale_price );
$sale_price = '' === $sale_price ? '' : wc_format_decimal( $sale_price );
$date_from = wc_clean( $date_from );
$date_to = wc_clean( $date_to );
@ -668,7 +668,7 @@ function wc_get_product_variation_attributes( $variation_id ) {
*/
if ( sanitize_title( $value[0] ) === $value[0] && version_compare( get_post_meta( $parent_id, '_product_version', true ), '2.4.0', '<' ) ) {
foreach ( $parent_attributes as $attribute ) {
if ( $name !== 'attribute_' . sanitize_title( $attribute['name'] ) ) {
if ( 'attribute_' . sanitize_title( $attribute['name'] ) !== $name ) {
continue;
}
$text_attributes = wc_get_text_attributes( $attribute['value'] );

View File

@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
function wc_template_redirect() {
global $wp_query, $wp;
if ( ! empty( $_GET['page_id'] ) && '' === get_option( 'permalink_structure' ) && $_GET['page_id'] == wc_get_page_id( 'shop' ) ) {
if ( ! empty( $_GET['page_id'] ) && '' === get_option( 'permalink_structure' ) && wc_get_page_id( 'shop' ) == $_GET['page_id'] ) {
// When default permalinks are enabled, redirect shop page to post type archive url
wp_safe_redirect( get_post_type_archive_link( 'product' ) );

View File

@ -65,7 +65,7 @@ function wc_get_product_terms( $product_id, $taxonomy, $args = array() ) {
$terms = wp_list_pluck( $terms, 'slug' );
break;
}
} elseif ( ! empty( $args['orderby'] ) && $args['orderby'] === 'menu_order' ) {
} elseif ( ! empty( $args['orderby'] ) && 'menu_order' === $args['orderby'] ) {
// wp_get_post_terms doesn't let us use custom sort order
$args['include'] = wp_get_post_terms( $product_id, $taxonomy, array( 'fields' => 'ids' ) );
@ -81,7 +81,7 @@ function wc_get_product_terms( $product_id, $taxonomy, $args = array() ) {
$args['fields'] = isset( $args['fields'] ) ? $args['fields'] : 'names';
// Ensure slugs is valid for get_terms - slugs isn't supported
$args['fields'] = $args['fields'] === 'slugs' ? 'id=>slug' : $args['fields'];
$args['fields'] = ( 'slugs' === $args['fields'] ) ? 'id=>slug' : $args['fields'];
$terms = get_terms( $taxonomy, $args );
}
} else {
@ -152,7 +152,7 @@ function wc_product_dropdown_categories( $args = array(), $deprecated_hierarchic
$args = wp_parse_args( $args, $defaults );
if ( $args['orderby'] == 'order' ) {
if ( 'order' === $args['orderby'] ) {
$args['menu_order'] = 'asc';
$args['orderby'] = 'name';
}
@ -417,12 +417,12 @@ function wc_terms_clauses( $clauses, $taxonomies, $args ) {
global $wpdb;
// No sorting when menu_order is false.
if ( isset( $args['menu_order'] ) && $args['menu_order'] == false ) {
if ( isset( $args['menu_order'] ) && false == $args['menu_order'] ) {
return $clauses;
}
// No sorting when orderby is non default.
if ( isset( $args['orderby'] ) && $args['orderby'] != 'name' ) {
if ( isset( $args['orderby'] ) && 'name' !== $args['orderby'] ) {
return $clauses;
}
@ -638,7 +638,7 @@ function wc_change_term_counts( $terms, $taxonomies ) {
if ( is_object( $term ) ) {
$term_counts[ $term->term_id ] = isset( $term_counts[ $term->term_id ] ) ? $term_counts[ $term->term_id ] : get_woocommerce_term_meta( $term->term_id, 'product_count_' . $taxonomies[0] , true );
if ( $term_counts[ $term->term_id ] !== '' ) {
if ( '' !== $term_counts[ $term->term_id ] ) {
$term->count = absint( $term_counts[ $term->term_id ] );
}
}

View File

@ -110,8 +110,9 @@ function wc_update_200_taxrates() {
foreach ( $states as $state ) {
if ( $state == '*' )
if ( '*' == $state ) {
$state = '';
}
$wpdb->insert(
$wpdb->prefix . "woocommerce_tax_rates",
@ -121,8 +122,8 @@ function wc_update_200_taxrates() {
'tax_rate' => $tax_rate['rate'],
'tax_rate_name' => $tax_rate['label'],
'tax_rate_priority' => 1,
'tax_rate_compound' => $tax_rate['compound'] == 'yes' ? 1 : 0,
'tax_rate_shipping' => $tax_rate['shipping'] == 'yes' ? 1 : 0,
'tax_rate_compound' => ( 'yes' === $tax_rate['compound'] ) ? 1 : 0,
'tax_rate_shipping' => ( 'yes' === $tax_rate['shipping'] ) ? 1 : 0,
'tax_rate_order' => $loop,
'tax_rate_class' => $tax_rate['class'],
)
@ -138,10 +139,11 @@ function wc_update_200_taxrates() {
if ( $local_tax_rates )
foreach ( $local_tax_rates as $tax_rate ) {
$location_type = $tax_rate['location_type'] == 'postcode' ? 'postcode' : 'city';
$location_type = ( 'postcode' === $tax_rate['location_type'] ) ? 'postcode' : 'city';
if ( $tax_rate['state'] == '*' )
if ( '*' == $tax_rate['state'] ) {
$tax_rate['state'] = '';
}
$wpdb->insert(
$wpdb->prefix . "woocommerce_tax_rates",
@ -151,8 +153,8 @@ function wc_update_200_taxrates() {
'tax_rate' => $tax_rate['rate'],
'tax_rate_name' => $tax_rate['label'],
'tax_rate_priority' => 2,
'tax_rate_compound' => $tax_rate['compound'] == 'yes' ? 1 : 0,
'tax_rate_shipping' => $tax_rate['shipping'] == 'yes' ? 1 : 0,
'tax_rate_compound' => ( 'yes' === $tax_rate['compound'] ) ? 1 : 0,
'tax_rate_shipping' => ( 'yes' === $tax_rate['shipping'] ) ? 1 : 0,
'tax_rate_order' => $loop,
'tax_rate_class' => $tax_rate['class'],
)

View File

@ -441,7 +441,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
$link = add_query_arg( $filter_name, implode( ',', $current_filter ), $link );
// 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 );
}
}

View File

@ -104,7 +104,7 @@ class WC_Widget_Product_Categories extends WC_Widget {
// Menu Order
$list_args['menu_order'] = false;
if ( $orderby == 'order' ) {
if ( 'order' === $orderby ) {
$list_args['menu_order'] = 'asc';
} else {
$list_args['orderby'] = 'title';

View File

@ -170,7 +170,7 @@ class WC_Widget_Rating_Filter extends WC_Widget {
$link = $this->get_page_base_url();
$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 ) ) . '">';

View File

@ -118,6 +118,7 @@
<exclude name="WordPress.Functions.DontExtract.extract" />
<exclude name="WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid" />
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid" />
<exclude name="WordPress.NamingConventions.ValidHookName.UseUnderscores" />
<exclude name="WordPress.NamingConventions.ValidVariableName.MemberNotSnakeCase" />
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCase" />
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar" />
@ -126,8 +127,9 @@
<exclude name="WordPress.PHP.DiscouragedFunctions.DiscouragedWithAlternative" />
<exclude name="WordPress.PHP.StrictComparisons.LooseComparison" />
<exclude name="WordPress.PHP.StrictInArray.MissingTrueStrict" />
<exclude name="WordPress.PHP.YodaConditions.NotYoda" />
<!-- <exclude name="WordPress.PHP.YodaConditions.NotYoda" /> -->
<exclude name="WordPress.VIP.AdminBarRemoval.RemovalDetected" />
<exclude name="WordPress.VIP.CronInterval.ChangeDetected" />
<exclude name="WordPress.VIP.DirectDatabaseQuery.DirectQuery" />
<exclude name="WordPress.VIP.DirectDatabaseQuery.NoCaching" />
<exclude name="WordPress.VIP.DirectDatabaseQuery.SchemaChange" />

View File

@ -52,8 +52,8 @@ do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plai
foreach ( $totals as $total ) {
$i++;
?><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>
<td class="td" style="text-align:left; <?php if ( $i === 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
<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 echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo $total['value']; ?></td>
</tr><?php
}
}

View File

@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
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' ); ?>

View File

@ -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>
<?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>
<?php endif; ?>
</div>

View File

@ -34,11 +34,11 @@ if ( $attachment_ids ) {
$classes = array( 'zoom' );
if ( $loop === 0 || $loop % $columns === 0 ) {
if ( 0 === $loop || 0 === $loop % $columns ) {
$classes[] = 'first';
}
if ( ( $loop + 1 ) % $columns === 0 ) {
if ( 0 === ( $loop + 1 ) % $columns ) {
$classes[] = 'last';
}

View File

@ -190,7 +190,7 @@ class Payment_Gateways extends WC_REST_Unit_Test_Case {
$request->set_body_params( array(
'settings' => array(
'paymentaction' => 'afasfasf',
)
),
) );
$response = $this->server->dispatch( $request );
$this->assertEquals( 400, $response->get_status() );
@ -199,7 +199,7 @@ class Payment_Gateways extends WC_REST_Unit_Test_Case {
$request->set_body_params( array(
'settings' => array(
'paymentaction' => 'authorization',
)
),
) );
$response = $this->server->dispatch( $request );
$paypal = $response->get_data();