diff --git a/includes/admin/class-wc-admin-status.php b/includes/admin/class-wc-admin-status.php
index 227e7e504502e..c65b590347fcc 100644
--- a/includes/admin/class-wc-admin-status.php
+++ b/includes/admin/class-wc-admin-status.php
@@ -278,7 +278,7 @@ public static function scan_log_files() {
$files = @scandir( WC_LOG_DIR );
$result = array();
- if ( $files ) {
+ if ( ! empty( $files ) ) {
foreach ( $files as $key => $value ) {
diff --git a/includes/admin/views/html-admin-page-status-report.php b/includes/admin/views/html-admin-page-status-report.php
index db281ad002b75..aa988d1040a32 100644
--- a/includes/admin/views/html-admin-page-status-report.php
+++ b/includes/admin/views/html-admin-page-status-report.php
@@ -762,7 +762,7 @@
}
}
- if ( $found_files ) {
+ if ( ! empty( $found_files ) ) {
foreach ( $found_files as $plugin_name => $found_plugin_files ) {
?>
diff --git a/includes/admin/views/html-bulk-edit-product.php b/includes/admin/views/html-bulk-edit-product.php
index 2911cfd6e71cb..a98b2a569298a 100644
--- a/includes/admin/views/html-bulk-edit-product.php
+++ b/includes/admin/views/html-bulk-edit-product.php
@@ -97,7 +97,7 @@
$tax_classes = WC_Tax::get_tax_classes();
- if ( $tax_classes )
+ if ( ! empty( $tax_classes ) )
foreach ( $tax_classes as $class ) {
$options[ sanitize_title( $class ) ] = esc_html( $class );
}
diff --git a/includes/admin/views/html-quick-edit-product.php b/includes/admin/views/html-quick-edit-product.php
index 25d98f26a3d04..782aa8c1e1492 100644
--- a/includes/admin/views/html-quick-edit-product.php
+++ b/includes/admin/views/html-quick-edit-product.php
@@ -75,7 +75,7 @@
$tax_classes = WC_Tax::get_tax_classes();
- if ( $tax_classes )
+ if ( ! empty( $tax_classes ) )
foreach ( $tax_classes as $class ) {
$options[ sanitize_title( $class ) ] = esc_html( $class );
}
diff --git a/includes/api/class-wc-rest-products-controller.php b/includes/api/class-wc-rest-products-controller.php
index 7e4aeb7616f38..0043d0238c8b7 100644
--- a/includes/api/class-wc-rest-products-controller.php
+++ b/includes/api/class-wc-rest-products-controller.php
@@ -970,7 +970,7 @@ protected function save_product_meta( $product, $request ) {
wp_set_object_terms( $product->id, $values, $attribute_name );
}
- if ( $values ) {
+ if ( ! empty( $values ) ) {
// Add attribute to array, but don't set values.
$attributes[ $attribute_name ] = array(
'name' => $attribute_name,
@@ -1071,7 +1071,7 @@ protected function save_product_meta( $product, $request ) {
$clear_parent_ids[] = $product->id;
}
- if ( $clear_parent_ids ) {
+ if ( ! empty( $clear_parent_ids ) ) {
foreach ( $clear_parent_ids as $clear_id ) {
$children_by_price = get_posts( array(
diff --git a/includes/api/legacy/v2/class-wc-api-products.php b/includes/api/legacy/v2/class-wc-api-products.php
index d2dd9da7431b2..550ab49a8c384 100644
--- a/includes/api/legacy/v2/class-wc-api-products.php
+++ b/includes/api/legacy/v2/class-wc-api-products.php
@@ -907,7 +907,7 @@ protected function save_product_meta( $product_id, $data ) {
wp_set_object_terms( $product_id, $values, $taxonomy );
}
- if ( $values ) {
+ if ( ! empty( $values ) ) {
// Add attribute to array, but don't set values
$attributes[ $taxonomy ] = array(
'name' => $taxonomy,
@@ -1009,7 +1009,7 @@ protected function save_product_meta( $product_id, $data ) {
$clear_parent_ids[] = $product_id;
}
- if ( $clear_parent_ids ) {
+ if ( ! empty( $clear_parent_ids ) ) {
foreach ( $clear_parent_ids as $clear_id ) {
$children_by_price = get_posts( array(
diff --git a/includes/api/legacy/v3/class-wc-api-products.php b/includes/api/legacy/v3/class-wc-api-products.php
index c4f2d407f0686..c1caa19d7a3a9 100644
--- a/includes/api/legacy/v3/class-wc-api-products.php
+++ b/includes/api/legacy/v3/class-wc-api-products.php
@@ -1392,7 +1392,7 @@ protected function save_product_meta( $product_id, $data ) {
wp_set_object_terms( $product_id, $values, $taxonomy );
}
- if ( $values ) {
+ if ( ! empty( $values ) ) {
// Add attribute to array, but don't set values.
$attributes[ $taxonomy ] = array(
'name' => $taxonomy,
@@ -1494,7 +1494,7 @@ protected function save_product_meta( $product_id, $data ) {
$clear_parent_ids[] = $product_id;
}
- if ( $clear_parent_ids ) {
+ if ( ! empty( $clear_parent_ids ) ) {
foreach ( $clear_parent_ids as $clear_id ) {
$children_by_price = get_posts( array(
diff --git a/includes/class-wc-ajax.php b/includes/class-wc-ajax.php
index f4e46beb2313f..d74d21e838cb5 100644
--- a/includes/class-wc-ajax.php
+++ b/includes/class-wc-ajax.php
@@ -716,7 +716,7 @@ public static function save_attributes() {
wp_set_object_terms( $post_id, $values, $attribute_names[ $i ] );
}
- if ( $values ) {
+ if ( ! empty( $values ) ) {
// Add attribute to array, but don't set values
$attributes[ sanitize_title( $attribute_names[ $i ] ) ] = array(
'name' => wc_clean( $attribute_names[ $i ] ),
@@ -1065,7 +1065,7 @@ public static function grant_access_to_download() {
die();
}
- if ( $files ) {
+ if ( ! empty( $files ) ) {
foreach ( $files as $download_id => $file ) {
if ( $inserted_id = wc_downloadable_file_permission( $download_id, $product_id, $order ) ) {
diff --git a/includes/class-wc-api.php b/includes/class-wc-api.php
index 0808df8f77b29..488a2576cc0c0 100644
--- a/includes/class-wc-api.php
+++ b/includes/class-wc-api.php
@@ -45,9 +45,7 @@ class WC_API {
/**
* Setup class.
- *
* @since 2.0
- * @return WC_API
*/
public function __construct() {
// Add query vars.
diff --git a/includes/class-wc-cart.php b/includes/class-wc-cart.php
index c9ac0ca82f232..5563396eb9fec 100644
--- a/includes/class-wc-cart.php
+++ b/includes/class-wc-cart.php
@@ -1517,7 +1517,7 @@ public function needs_shipping() {
$needs_shipping = false;
- if ( $this->cart_contents ) {
+ if ( ! empty( $this->cart_contents ) ) {
foreach ( $this->cart_contents as $cart_item_key => $values ) {
$_product = $values['data'];
if ( $_product->needs_shipping() ) {
diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php
index e73c56c96c1bb..2d0af6202c6b5 100644
--- a/includes/class-wc-checkout.php
+++ b/includes/class-wc-checkout.php
@@ -414,7 +414,7 @@ public function process_checkout() {
}
// Skip account if not needed
- if ( $fieldset_key == 'account' && ( is_user_logged_in() || ( $this->must_create_account == false && empty( $this->posted['createaccount'] ) ) ) ) {
+ if ( 'account' === $fieldset_key && ( is_user_logged_in() || ( false === $this->must_create_account && empty( $this->posted['createaccount'] ) ) ) ) {
continue;
}
diff --git a/includes/class-wc-countries.php b/includes/class-wc-countries.php
index 7343fba44f89c..f0798302b8aaa 100644
--- a/includes/class-wc-countries.php
+++ b/includes/class-wc-countries.php
@@ -116,7 +116,7 @@ public function load_country_states() {
// Load only the state files the shop owner wants/needs.
$allowed = array_merge( $this->get_allowed_countries(), $this->get_shipping_countries() );
- if ( $allowed ) {
+ if ( ! empty( $allowed ) ) {
foreach ( $allowed as $code => $country ) {
if ( ! isset( $states[ $code ] ) && file_exists( WC()->plugin_path() . '/i18n/states/' . $code . '.php' ) ) {
include( WC()->plugin_path() . '/i18n/states/' . $code . '.php' );
@@ -401,7 +401,7 @@ public function country_dropdown_options( $selected_country = '', $selected_stat
* @return array
*/
public function get_address_formats() {
- if ( ! $this->address_formats ) :
+ if ( empty( $this->address_formats ) ) {
// Common formats
$postcode_before_city = "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}";
@@ -442,7 +442,7 @@ public function get_address_formats() {
'US' => "{name}\n{company}\n{address_1}\n{address_2}\n{city}, {state_code} {postcode}\n{country}",
'VN' => "{name}\n{company}\n{address_1}\n{city}\n{country}",
));
- endif;
+ }
return $this->address_formats;
}
@@ -628,7 +628,7 @@ public function get_country_locale_field_selectors() {
* @todo [2.4] Check select2 4.0.0 compatibility with `placeholder` attribute and uncomment relevant lines. https://github.com/woothemes/woocommerce/issues/7729
*/
public function get_country_locale() {
- if ( ! $this->locale ) {
+ if ( empty( $this->locale ) ) {
// Locale information used by the checkout
$this->locale = apply_filters( 'woocommerce_get_country_locale', array(
diff --git a/includes/class-wc-form-handler.php b/includes/class-wc-form-handler.php
index 5592e2cc77199..03172bb8f4a47 100644
--- a/includes/class-wc-form-handler.php
+++ b/includes/class-wc-form-handler.php
@@ -833,7 +833,7 @@ private static function add_to_cart_handler_variable( $product_id ) {
}
}
- if ( $missing_attributes ) {
+ if ( ! empty( $missing_attributes ) ) {
wc_add_notice( sprintf( _n( '%s is a required field', '%s are required fields', sizeof( $missing_attributes ), 'woocommerce' ), wc_format_list_of_items( $missing_attributes ) ), 'error' );
} elseif ( empty( $variation_id ) ) {
wc_add_notice( __( 'Please choose product options…', 'woocommerce' ), 'error' );
diff --git a/includes/class-wc-order-item-meta.php b/includes/class-wc-order-item-meta.php
index 941b728e07df1..aef65beaddf93 100644
--- a/includes/class-wc-order-item-meta.php
+++ b/includes/class-wc-order-item-meta.php
@@ -33,7 +33,6 @@ class WC_Order_Item_Meta {
*
* @param array $item defaults to array()
* @param \WC_Product $product defaults to null
- * @return \WC_Order_Item_Meta instance
*/
public function __construct( $item = array(), $product = null ) {
// Backwards (pre 2.4) compat
diff --git a/includes/class-wc-shipping-zones.php b/includes/class-wc-shipping-zones.php
index 3820b17a79755..e9113852cbe75 100644
--- a/includes/class-wc-shipping-zones.php
+++ b/includes/class-wc-shipping-zones.php
@@ -143,7 +143,7 @@ public static function get_zone_matching_package( $package ) {
$matches = wc_postcode_location_matcher( $postcode, $postcode_locations, 'zone_id', 'location_code' );
$do_not_match = array_unique( array_diff( $zone_ids_with_postcode_rules, array_keys( $matches ) ) );
- if ( $do_not_match ) {
+ if ( ! empty( $do_not_match ) ) {
$criteria[] = "AND zones.zone_id NOT IN (" . implode( ',', $do_not_match ) . ")";
}
}
diff --git a/includes/class-wc-shipping.php b/includes/class-wc-shipping.php
index dbb1c69832115..093d3037be554 100644
--- a/includes/class-wc-shipping.php
+++ b/includes/class-wc-shipping.php
@@ -131,7 +131,7 @@ public function get_shipping_method_class_names() {
* @return array
*/
public function load_shipping_methods( $package = array() ) {
- if ( $package ) {
+ if ( ! empty( $package ) ) {
$shipping_zone = WC_Shipping_Zones::get_zone_matching_package( $package );
$this->shipping_methods = $shipping_zone->get_shipping_methods( true );
} else {
@@ -317,7 +317,7 @@ public function calculate_shipping( $packages = array() ) {
* @return array
*/
public function calculate_shipping_for_package( $package = array(), $package_key = 0 ) {
- if ( ! $this->enabled || ! $package ) {
+ if ( ! $this->enabled || empty( $package ) ) {
return false;
}
diff --git a/includes/class-wc-tax.php b/includes/class-wc-tax.php
index dc76bab0e3de7..bf32528b3a3cc 100644
--- a/includes/class-wc-tax.php
+++ b/includes/class-wc-tax.php
@@ -167,7 +167,7 @@ public static function calc_inclusive_tax( $price, $rates ) {
public static function calc_exclusive_tax( $price, $rates ) {
$taxes = array();
- if ( $rates ) {
+ if ( ! empty( $rates ) ) {
// Multiple taxes
foreach ( $rates as $key => $rate ) {
diff --git a/includes/class-wc-webhook.php b/includes/class-wc-webhook.php
index 2714233b0670a..8d28f62076fb9 100644
--- a/includes/class-wc-webhook.php
+++ b/includes/class-wc-webhook.php
@@ -28,7 +28,6 @@ class WC_Webhook {
*
* @since 2.2
* @param string|int $id
- * @return \WC_Webhook
*/
public function __construct( $id ) {
diff --git a/includes/cli/class-wc-cli-product.php b/includes/cli/class-wc-cli-product.php
index 02619c1b55196..1c2e5ed2c949c 100644
--- a/includes/cli/class-wc-cli-product.php
+++ b/includes/cli/class-wc-cli-product.php
@@ -1184,7 +1184,7 @@ private function save_product_meta( $product_id, $data ) {
wp_set_object_terms( $product_id, $values, $taxonomy );
}
- if ( $values ) {
+ if ( ! empty( $values ) ) {
// Add attribute to array, but don't set values
$attributes[ $taxonomy ] = array(
'name' => $taxonomy,
@@ -1309,7 +1309,7 @@ private function save_product_meta( $product_id, $data ) {
$clear_parent_ids[] = $product_id;
}
- if ( $clear_parent_ids ) {
+ if ( ! empty( $clear_parent_ids ) ) {
foreach ( $clear_parent_ids as $clear_id ) {
$children_by_price = get_posts( array(
diff --git a/includes/emails/class-wc-email-customer-note.php b/includes/emails/class-wc-email-customer-note.php
index c697b50d7ae26..b74391d4cc2f8 100644
--- a/includes/emails/class-wc-email-customer-note.php
+++ b/includes/emails/class-wc-email-customer-note.php
@@ -56,7 +56,7 @@ public function __construct() {
*/
public function trigger( $args ) {
- if ( $args ) {
+ if ( ! empty( $args ) ) {
$defaults = array(
'order_id' => '',
diff --git a/includes/gateways/bacs/class-wc-gateway-bacs.php b/includes/gateways/bacs/class-wc-gateway-bacs.php
index 7645afe6c80b3..2c031740eaafe 100644
--- a/includes/gateways/bacs/class-wc-gateway-bacs.php
+++ b/includes/gateways/bacs/class-wc-gateway-bacs.php
@@ -357,7 +357,7 @@ public function process_payment( $order_id ) {
*/
public function get_country_locale() {
- if ( ! $this->locale ) {
+ if ( empty( $this->locale ) ) {
// Locale information to be used - only those that are not 'Sort Code'
$this->locale = apply_filters( 'woocommerce_get_bacs_locale', array(
diff --git a/includes/vendor/class-wp-rest-controller.php b/includes/vendor/class-wp-rest-controller.php
index c5c5113f7d1e5..97cfb58e1d524 100644
--- a/includes/vendor/class-wp-rest-controller.php
+++ b/includes/vendor/class-wp-rest-controller.php
@@ -418,7 +418,7 @@ protected function get_additional_fields( $object_type = null ) {
protected function get_object_type() {
$schema = $this->get_item_schema();
- if ( ! $schema || ! isset( $schema['title'] ) ) {
+ if ( empty( $schema ) || ! isset( $schema['title'] ) ) {
return null;
}
diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php
index acfb801eff316..252b6186ba26a 100644
--- a/includes/wc-core-functions.php
+++ b/includes/wc-core-functions.php
@@ -184,7 +184,7 @@ function wc_get_template_part( $slug, $name = '' ) {
* @param string $default_path (default: '')
*/
function wc_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
- if ( $args && is_array( $args ) ) {
+ if ( ! empty( $args ) && is_array( $args ) ) {
extract( $args );
}
diff --git a/includes/wc-term-functions.php b/includes/wc-term-functions.php
index 27d973e25918d..fd9f52af10b8b 100644
--- a/includes/wc-term-functions.php
+++ b/includes/wc-term-functions.php
@@ -159,7 +159,7 @@ function wc_product_dropdown_categories( $args = array(), $deprecated_hierarchic
$terms = get_terms( 'product_cat', apply_filters( 'wc_product_dropdown_categories_get_terms_args', $args ) );
- if ( ! $terms ) {
+ if ( empty( $terms ) ) {
return;
}
@@ -538,7 +538,7 @@ function _wc_term_recount( $terms, $taxonomy, $callback = true, $terms_are_term_
}
// Exit if we have no terms to count
- if ( ! $terms ) {
+ if ( empty( $terms ) ) {
return;
}
diff --git a/includes/wc-update-functions.php b/includes/wc-update-functions.php
index d4acb85a758ed..b59bfd0357436 100644
--- a/includes/wc-update-functions.php
+++ b/includes/wc-update-functions.php
@@ -274,7 +274,7 @@ function wc_update_200_line_items() {
$order_taxes = (array) maybe_unserialize( $order_tax_row->meta_value );
- if ( $order_taxes ) {
+ if ( ! empty( $order_taxes ) ) {
foreach( $order_taxes as $order_tax ) {
if ( ! isset( $order_tax['label'] ) || ! isset( $order_tax['cart_tax'] ) || ! isset( $order_tax['shipping_tax'] ) )
diff --git a/includes/widgets/class-wc-widget-layered-nav-filters.php b/includes/widgets/class-wc-widget-layered-nav-filters.php
index 197f667a1cbdc..f7532bee6b462 100644
--- a/includes/widgets/class-wc-widget-layered-nav-filters.php
+++ b/includes/widgets/class-wc-widget-layered-nav-filters.php
@@ -59,7 +59,7 @@ public function widget( $args, $instance ) {
echo '';
// Attributes
- if ( $_chosen_attributes ) {
+ if ( ! empty( $_chosen_attributes ) ) {
foreach ( $_chosen_attributes as $taxonomy => $data ) {
foreach ( $data['terms'] as $term_slug ) {
if ( ! $term = get_term_by( 'slug', $term_slug, $taxonomy ) ) {
diff --git a/includes/widgets/class-wc-widget-product-categories.php b/includes/widgets/class-wc-widget-product-categories.php
index e8ea2de29db63..c47a406339503 100644
--- a/includes/widgets/class-wc-widget-product-categories.php
+++ b/includes/widgets/class-wc-widget-product-categories.php
@@ -123,7 +123,7 @@ public function widget( $args, $instance ) {
$product_category = wc_get_product_terms( $post->ID, 'product_cat', apply_filters( 'woocommerce_product_categories_widget_product_terms_args', array( 'orderby' => 'parent' ) ) );
- if ( $product_category ) {
+ if ( ! empty( $product_category ) ) {
$this->current_cat = end( $product_category );
$this->cat_ancestors = get_ancestors( $this->current_cat->term_id, 'product_cat' );
}
diff --git a/templates/checkout/form-coupon.php b/templates/checkout/form-coupon.php
index d48c279ca7b5f..1e856bd3c70aa 100644
--- a/templates/checkout/form-coupon.php
+++ b/templates/checkout/form-coupon.php
@@ -24,7 +24,7 @@
return;
}
-if ( ! WC()->cart->applied_coupons ) {
+if ( empty( WC()->cart->applied_coupons ) ) {
$info_message = apply_filters( 'woocommerce_checkout_coupon_message', __( 'Have a coupon?', 'woocommerce' ) . ' ' . __( 'Click here to enter your code', 'woocommerce' ) . '' );
wc_print_notice( $info_message, 'notice' );
}