WordPress.PHP.YodaConditions.NotYoda

This commit is contained in:
Aristeides Stathopoulos 2016-09-09 03:14:28 +03:00
parent 734f284fa4
commit 9668247b95
51 changed files with 135 additions and 127 deletions

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

@ -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

@ -1494,7 +1494,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

@ -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

@ -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

@ -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

@ -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';
}