Update strict comparission and update to Yoda condition

In order to follow one of the best practices from the Wordpress
handbook:

- https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#yoda-conditions
This commit is contained in:
mitogh 2015-11-14 20:35:29 -06:00
parent 4d86d8a6ad
commit f8f70f294a
13 changed files with 21 additions and 21 deletions

View File

@ -64,8 +64,8 @@ if ( ! defined( 'ABSPATH' ) ) {
</tr>
<?php endforeach; ?>
<?php if ( wc_tax_enabled() && WC()->cart->tax_display_cart == 'excl' ) : ?>
<?php if ( get_option( 'woocommerce_tax_total_display' ) == 'itemized' ) : ?>
<?php if ( wc_tax_enabled() && 'excl' === WC()->cart->tax_display_cart ) : ?>
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : ?>
<tr class="tax-rate tax-rate-<?php echo sanitize_title( $code ); ?>">
<th><?php echo esc_html( $tax->label ); ?></th>

View File

@ -23,7 +23,7 @@ global $product, $woocommerce_loop;
$crosssells = WC()->cart->get_cross_sells();
if ( sizeof( $crosssells ) == 0 ) return;
if ( 0 === sizeof( $crosssells ) ) return;
$meta_query = WC()->query->get_meta_query();

View File

@ -19,7 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( get_option( 'woocommerce_enable_shipping_calc' ) === 'no' || ! WC()->cart->needs_shipping() ) {
if ( 'no' === get_option( 'woocommerce_enable_shipping_calc' ) || ! WC()->cart->needs_shipping() ) {
return;
}

View File

@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<div class="woocommerce-shipping-fields">
<?php if ( WC()->cart->needs_shipping_address() === true ) : ?>
<?php if ( true === WC()->cart->needs_shipping_address() ) : ?>
<?php
if ( empty( $_POST ) ) {

View File

@ -83,8 +83,8 @@ if ( ! defined( 'ABSPATH' ) ) {
</tr>
<?php endforeach; ?>
<?php if ( wc_tax_enabled() && WC()->cart->tax_display_cart === 'excl' ) : ?>
<?php if ( get_option( 'woocommerce_tax_total_display' ) === 'itemized' ) : ?>
<?php if ( wc_tax_enabled() && 'excl' === WC()->cart->tax_display_cart ) : ?>
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : ?>
<tr class="tax-rate tax-rate-<?php echo sanitize_title( $code ); ?>">
<th><?php echo esc_html( $tax->label ); ?></th>

View File

@ -42,8 +42,8 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
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 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>
</tr><?php
}
}

View File

@ -47,8 +47,8 @@ if ( ! defined( 'ABSPATH' ) ) {
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 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>
</tr><?php
}
}

View File

@ -63,8 +63,8 @@ if ( ! defined( 'ABSPATH' ) ) {
foreach ( $totals as $total ) {
$i++;
?><tr>
<td class="td" colspan="2" style="text-align:left; <?php if ( $i == 1 ) echo 'border-top-width: 4px !important;'; ?>"><?php echo $total['label']; ?></td>
<td class="td" style="text-align:left; <?php if ( $i == 1 ) echo 'border-top-width: 4px !important;'; ?>"><?php echo $total['value']; ?></td>
<td class="td" colspan="2" style="text-align:left; <?php if ( $i === 1 ) echo 'border-top-width: 4px !important;'; ?>"><?php echo $total['label']; ?></td>
<td class="td" style="text-align:left; <?php if ( $i === 1 ) echo 'border-top-width: 4px !important;'; ?>"><?php echo $total['value']; ?></td>
</tr><?php
}
}

View File

@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<p><?php printf( __( "Thanks for creating an account on %s. Your username is <strong>%s</strong>.", 'woocommerce' ), esc_html( $blogname ), esc_html( $user_login ) ); ?></p>
<?php if ( get_option( 'woocommerce_registration_generate_password' ) == 'yes' && $password_generated ) : ?>
<?php if ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) && $password_generated ) : ?>
<p><?php printf( __( "Your password has been automatically generated: <strong>%s</strong>", 'woocommerce' ), esc_html( $user_pass ) ); ?></p>

View File

@ -51,8 +51,8 @@ if ( ! defined( 'ABSPATH' ) ) {
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 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>
</tr><?php
}
}

View File

@ -47,8 +47,8 @@ if ( ! defined( 'ABSPATH' ) ) {
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 if ( 1 === $i ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
<td class="td" style="text-align:left; <?php if ( 1 === $i ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
</tr><?php
}
}

View File

@ -64,8 +64,8 @@ if ( ! defined( 'ABSPATH' ) ) {
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 if ( 1 === $i ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
<td class="td" style="text-align:left; <?php if ( 1 === $i ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
</tr><?php
}
}

View File

@ -23,7 +23,7 @@ echo "= " . $email_heading . " =\n\n";
echo sprintf( __( "Thanks for creating an account on %s. Your username is <strong>%s</strong>.", 'woocommerce' ), $blogname, $user_login ) . "\n\n";
if ( get_option( 'woocommerce_registration_generate_password' ) === 'yes' && $password_generated )
if ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) && $password_generated )
echo sprintf( __( "Your password is <strong>%s</strong>.", 'woocommerce' ), $user_pass ) . "\n\n";
echo sprintf( __( 'You can access your account area to view your orders and change your password here: %s.', 'woocommerce' ), wc_get_page_permalink( 'myaccount' ) ) . "\n\n";