Removed obvious boolean results

This commit is contained in:
Claudio Sanches 2018-03-21 19:57:10 -03:00
parent dc7aa30694
commit 0660a50e07
14 changed files with 16 additions and 16 deletions

View File

@ -1876,7 +1876,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* @return bool * @return bool
*/ */
public function has_status( $status ) { public function has_status( $status ) {
return apply_filters( 'woocommerce_order_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status ? true : false, $this, $status ); return apply_filters( 'woocommerce_order_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status, $this, $status );
} }
/** /**

View File

@ -273,7 +273,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
* @return bool * @return bool
*/ */
public function has_fields() { public function has_fields() {
return $this->has_fields ? true : false; return (bool) $this->has_fields;
} }
/** /**
@ -385,7 +385,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
* @since 1.5.7 * @since 1.5.7
*/ */
public function supports( $feature ) { public function supports( $feature ) {
return apply_filters( 'woocommerce_payment_gateway_supports', in_array( $feature, $this->supports ) ? true : false, $feature, $this ); return apply_filters( 'woocommerce_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this );
} }
/** /**

View File

@ -1360,7 +1360,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* @since 2.5.0 * @since 2.5.0
*/ */
public function supports( $feature ) { public function supports( $feature ) {
return apply_filters( 'woocommerce_product_supports', in_array( $feature, $this->supports ) ? true : false, $feature, $this ); return apply_filters( 'woocommerce_product_supports', in_array( $feature, $this->supports ), $feature, $this );
} }
/** /**
@ -1577,7 +1577,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
return true; return true;
} }
return $this->managing_stock() && $this->backorders_allowed() && ( $this->get_stock_quantity() - $qty_in_cart ) < 0 ? true : false; return $this->managing_stock() && $this->backorders_allowed() && ( $this->get_stock_quantity() - $qty_in_cart ) < 0;
} }
/** /**

View File

@ -603,7 +603,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'site_url' => get_option( 'siteurl' ), 'site_url' => get_option( 'siteurl' ),
'version' => WC()->version, 'version' => WC()->version,
'log_directory' => WC_LOG_DIR, 'log_directory' => WC_LOG_DIR,
'log_directory_writable' => ( @fopen( WC_LOG_DIR . 'test-log.log', 'a' ) ? true : false ), 'log_directory_writable' => (bool) @fopen( WC_LOG_DIR . 'test-log.log', 'a' ),
'wp_version' => get_bloginfo( 'version' ), 'wp_version' => get_bloginfo( 'version' ),
'wp_multisite' => is_multisite(), 'wp_multisite' => is_multisite(),
'wp_memory_limit' => $wp_memory_limit, 'wp_memory_limit' => $wp_memory_limit,

View File

@ -337,7 +337,7 @@ class WC_API_Orders extends WC_API_Resource {
'id' => $note->comment_ID, 'id' => $note->comment_ID,
'created_at' => $this->server->format_datetime( $note->comment_date_gmt ), 'created_at' => $this->server->format_datetime( $note->comment_date_gmt ),
'note' => $note->comment_content, 'note' => $note->comment_content,
'customer_note' => get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? true : false, 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ),
); );
} }

View File

@ -1269,7 +1269,7 @@ class WC_API_Orders extends WC_API_Resource {
'id' => $note->comment_ID, 'id' => $note->comment_ID,
'created_at' => $this->server->format_datetime( $note->comment_date_gmt ), 'created_at' => $this->server->format_datetime( $note->comment_date_gmt ),
'note' => $note->comment_content, 'note' => $note->comment_content,
'customer_note' => get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? true : false, 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ),
); );
return array( 'order_note' => apply_filters( 'woocommerce_api_order_note_response', $order_note, $id, $fields, $note, $order_id, $this ) ); return array( 'order_note' => apply_filters( 'woocommerce_api_order_note_response', $order_note, $id, $fields, $note, $order_id, $this ) );

View File

@ -1316,7 +1316,7 @@ class WC_API_Orders extends WC_API_Resource {
'id' => $note->comment_ID, 'id' => $note->comment_ID,
'created_at' => $this->server->format_datetime( $note->comment_date_gmt ), 'created_at' => $this->server->format_datetime( $note->comment_date_gmt ),
'note' => $note->comment_content, 'note' => $note->comment_content,
'customer_note' => get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? true : false, 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ),
); );
return array( 'order_note' => apply_filters( 'woocommerce_api_order_note_response', $order_note, $id, $fields, $note, $order_id, $this ) ); return array( 'order_note' => apply_filters( 'woocommerce_api_order_note_response', $order_note, $id, $fields, $note, $order_id, $this ) );

View File

@ -603,7 +603,7 @@ class WC_Tax {
$compound = $key_or_rate->tax_rate_compound; $compound = $key_or_rate->tax_rate_compound;
} else { } else {
$key = $key_or_rate; $key = $key_or_rate;
$compound = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_compound FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) ) ? true : false; $compound = (bool) $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_compound FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) );
} }
return (bool) apply_filters( 'woocommerce_rate_compound', $compound, $key ); return (bool) apply_filters( 'woocommerce_rate_compound', $compound, $key );

View File

@ -181,7 +181,7 @@ class WC_CLI_Runner {
'name' => $name, 'name' => $name,
'type' => 'assoc', 'type' => 'assoc',
'description' => ! empty( $args['description'] ) ? $args['description'] : '', 'description' => ! empty( $args['description'] ) ? $args['description'] : '',
'optional' => empty( $args['required'] ) ? true : false, 'optional' => empty( $args['required'] ),
); );
} }
} }

View File

@ -37,7 +37,7 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
$this->description = $this->get_option( 'description' ); $this->description = $this->get_option( 'description' );
$this->instructions = $this->get_option( 'instructions' ); $this->instructions = $this->get_option( 'instructions' );
$this->enable_for_methods = $this->get_option( 'enable_for_methods', array() ); $this->enable_for_methods = $this->get_option( 'enable_for_methods', array() );
$this->enable_for_virtual = $this->get_option( 'enable_for_virtual', 'yes' ) === 'yes' ? true : false; $this->enable_for_virtual = $this->get_option( 'enable_for_virtual', 'yes' ) === 'yes';
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) ); add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) );

View File

@ -65,7 +65,7 @@ abstract class WC_Legacy_Coupon extends WC_Data {
$value = $this->get_id(); $value = $this->get_id();
break; break;
case 'exists' : case 'exists' :
$value = ( $this->get_id() > 0 ) ? true : false; $value = $this->get_id() > 0;
break; break;
case 'coupon_custom_fields' : case 'coupon_custom_fields' :
$legacy_custom_fields = array(); $legacy_custom_fields = array();

View File

@ -241,7 +241,7 @@ class WC_Shortcode_Checkout {
} else { } else {
$non_js_checkout = ! empty( $_POST['woocommerce_checkout_update_totals'] ) ? true : false; // WPCS: input var ok, CSRF ok. $non_js_checkout = ! empty( $_POST['woocommerce_checkout_update_totals'] ); // WPCS: input var ok, CSRF ok.
if ( wc_notice_count( 'error' ) === 0 && $non_js_checkout ) { if ( wc_notice_count( 'error' ) === 0 && $non_js_checkout ) {
wc_add_notice( __( 'The order totals have been updated. Please confirm your order by pressing the "Place order" button at the bottom of the page.', 'woocommerce' ) ); wc_add_notice( __( 'The order totals have been updated. Please confirm your order by pressing the "Place order" button at the bottom of the page.', 'woocommerce' ) );

View File

@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* @return bool * @return bool
*/ */
function is_woocommerce() { function is_woocommerce() {
return apply_filters( 'is_woocommerce', ( is_shop() || is_product_taxonomy() || is_product() ) ? true : false ); return apply_filters( 'is_woocommerce', is_shop() || is_product_taxonomy() || is_product() );
} }
if ( ! function_exists( 'is_shop' ) ) { if ( ! function_exists( 'is_shop' ) ) {

View File

@ -2456,7 +2456,7 @@ if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) {
$name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title( $attribute ); $name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title( $attribute );
$id = $args['id'] ? $args['id'] : sanitize_title( $attribute ); $id = $args['id'] ? $args['id'] : sanitize_title( $attribute );
$class = $args['class']; $class = $args['class'];
$show_option_none = $args['show_option_none'] ? true : false; $show_option_none = (bool) $args['show_option_none'];
$show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __( 'Choose an option', 'woocommerce' ); // We'll do our best to hide the placeholder, but we'll need to show something when resetting options. $show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __( 'Choose an option', 'woocommerce' ); // We'll do our best to hide the placeholder, but we'll need to show something when resetting options.
if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) { if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) {