diff --git a/includes/admin/class-wc-admin-settings.php b/includes/admin/class-wc-admin-settings.php index 85eed5bafd3..ece655447c7 100644 --- a/includes/admin/class-wc-admin-settings.php +++ b/includes/admin/class-wc-admin-settings.php @@ -501,11 +501,11 @@ class WC_Admin_Settings { // Image width settings case 'image_width' : - $image_size = str_replace( '_image_size', '', $value[ 'id' ] ); + $image_size = str_replace( '_image_size', '', $value['id'] ); $size = wc_get_image_size( $image_size ); - $width = isset( $size[ 'width' ] ) ? $size[ 'width' ] : $value[ 'default' ][ 'width' ]; - $height = isset( $size[ 'height' ] ) ? $size[ 'height' ] : $value[ 'default' ][ 'height' ]; - $crop = isset( $size[ 'crop' ] ) ? $size[ 'crop' ] : $value[ 'default' ][ 'crop' ]; + $width = isset( $size['width'] ) ? $size['width'] : $value['default']['width']; + $height = isset( $size['height'] ) ? $size['height'] : $value['default']['height']; + $crop = isset( $size['crop'] ) ? $size['crop'] : $value['default']['crop']; $disabled_attr = ''; $disabled_message = ''; diff --git a/includes/admin/class-wc-admin-status.php b/includes/admin/class-wc-admin-status.php index 79f4dd8a5b6..1946a4a9868 100644 --- a/includes/admin/class-wc-admin-status.php +++ b/includes/admin/class-wc-admin-status.php @@ -88,7 +88,7 @@ class WC_Admin_Status { $handle = ! empty( $viewed_log ) ? self::get_log_file_handle( $viewed_log ) : ''; - if ( ! empty( $_REQUEST[ 'handle' ] ) ) { + if ( ! empty( $_REQUEST['handle'] ) ) { self::remove_log(); } @@ -244,13 +244,13 @@ class WC_Admin_Status { * Remove/delete the chosen file. */ public static function remove_log() { - if ( empty( $_REQUEST[ '_wpnonce' ] ) || ! wp_verify_nonce( $_REQUEST[ '_wpnonce' ], 'remove_log' ) ) { + if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'remove_log' ) ) { wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) ); } - if ( ! empty( $_REQUEST[ 'handle' ] ) ) { + if ( ! empty( $_REQUEST['handle'] ) ) { $logger = wc_get_logger(); - $logger->remove( $_REQUEST[ 'handle' ] ); + $logger->remove( $_REQUEST['handle'] ); } wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=wc-status&tab=logs' ) ) ); diff --git a/includes/admin/meta-boxes/class-wc-meta-box-order-data.php b/includes/admin/meta-boxes/class-wc-meta-box-order-data.php index a440118db12..1b76cfc5ea4 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-order-data.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-order-data.php @@ -454,7 +454,7 @@ class WC_Meta_Box_Order_Data { } if ( isset( $_POST['_transaction_id'] ) ) { - update_post_meta( $post_id, '_transaction_id', wc_clean( $_POST[ '_transaction_id' ] ) ); + update_post_meta( $post_id, '_transaction_id', wc_clean( $_POST['_transaction_id'] ) ); } // Payment method handling diff --git a/includes/admin/reports/class-wc-report-coupon-usage.php b/includes/admin/reports/class-wc-report-coupon-usage.php index 89e7754b717..5d57b23b2df 100644 --- a/includes/admin/reports/class-wc-report-coupon-usage.php +++ b/includes/admin/reports/class-wc-report-coupon-usage.php @@ -112,7 +112,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report { $legend[] = array( 'title' => sprintf( __( '%s coupons used in total', 'woocommerce' ), '' . $total_coupons . '' ), - 'color' => $this->chart_colours['coupon_count' ], + 'color' => $this->chart_colours['coupon_count'], 'highlight_series' => 0, ); @@ -458,8 +458,8 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report { { label: "", data: order_data.order_coupon_counts, - color: 'chart_colours['coupon_count' ]; ?>', - bars: { fillColor: 'chart_colours['coupon_count' ]; ?>', fill: true, show: true, lineWidth: 0, barWidth: barwidth; ?> * 0.5, align: 'center' }, + color: 'chart_colours['coupon_count']; ?>', + bars: { fillColor: 'chart_colours['coupon_count']; ?>', fill: true, show: true, lineWidth: 0, barWidth: barwidth; ?> * 0.5, align: 'center' }, shadowSize: 0, hoverable: false }, diff --git a/includes/admin/reports/class-wc-report-sales-by-category.php b/includes/admin/reports/class-wc-report-sales-by-category.php index a8d725029a4..ac0e6b57240 100644 --- a/includes/admin/reports/class-wc-report-sales-by-category.php +++ b/includes/admin/reports/class-wc-report-sales-by-category.php @@ -94,7 +94,7 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report { $legend[] = array( 'title' => sprintf( __( '%s sales in %s', 'woocommerce' ), '' . wc_price( $total ) . '', $category->name ), - 'color' => isset( $this->chart_colours[ $index ] ) ? $this->chart_colours[ $index ] : $this->chart_colours[ 0 ], + 'color' => isset( $this->chart_colours[ $index ] ) ? $this->chart_colours[ $index ] : $this->chart_colours[0], 'highlight_series' => $index, ); diff --git a/includes/admin/views/html-admin-page-reports.php b/includes/admin/views/html-admin-page-reports.php index 8510c91a878..2c362fff1fa 100644 --- a/includes/admin/views/html-admin-page-reports.php +++ b/includes/admin/views/html-admin-page-reports.php @@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) { if ( $current_tab == $key ) { echo 'nav-tab-active'; } - echo '">' . esc_html( $report_group[ 'title' ] ) . ''; + echo '">' . esc_html( $report_group['title'] ) . ''; } do_action( 'wc_reports_tabs' ); @@ -51,9 +51,9 @@ if ( ! defined( 'ABSPATH' ) ) { ' . esc_html( $report['title'] ) . ''; diff --git a/includes/api/class-wc-rest-authentication.php b/includes/api/class-wc-rest-authentication.php index d28bb787b74..562cbb01784 100644 --- a/includes/api/class-wc-rest-authentication.php +++ b/includes/api/class-wc-rest-authentication.php @@ -154,7 +154,7 @@ class WC_REST_Authentication { // From OAuth PHP library, used under MIT license. $params = array(); if ( preg_match_all( '/(oauth_[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches ) ) { - foreach ( $matches[ 1 ] as $i => $h ) { + foreach ( $matches[1] as $i => $h ) { $params[ $h ] = urldecode( empty( $matches[3][ $i ] ) ? $matches[4][ $i ] : $matches[3][ $i ] ); } if ( isset( $params['realm'] ) ) { diff --git a/includes/api/class-wc-rest-orders-controller.php b/includes/api/class-wc-rest-orders-controller.php index 5a0efd2a339..b43c202b105 100644 --- a/includes/api/class-wc-rest-orders-controller.php +++ b/includes/api/class-wc-rest-orders-controller.php @@ -458,7 +458,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller { } // If items have changed, recalculate order totals. - if ( isset( $request[ 'billing' ], $request[ 'shipping' ], $request[ 'line_items' ], $request[ 'shipping' ], $request[ 'fee' ], $request[ 'coupon' ] ) ) { + if ( isset( $request['billing'], $request['shipping'], $request['line_items'], $request['shipping'], $request['fee'], $request['coupon'] ) ) { $order->calculate_totals(); } diff --git a/includes/class-wc-form-handler.php b/includes/class-wc-form-handler.php index ba676e32f48..8f217f89d05 100644 --- a/includes/class-wc-form-handler.php +++ b/includes/class-wc-form-handler.php @@ -156,11 +156,11 @@ class WC_Form_Handler { */ public static function save_account_details() { - if ( 'POST' !== strtoupper( $_SERVER[ 'REQUEST_METHOD' ] ) ) { + if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) { return; } - if ( empty( $_POST[ 'action' ] ) || 'save_account_details' !== $_POST[ 'action' ] || empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'save_account_details' ) ) { + if ( empty( $_POST['action'] ) || 'save_account_details' !== $_POST['action'] || empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'save_account_details' ) ) { return; } @@ -174,12 +174,12 @@ class WC_Form_Handler { return; } - $account_first_name = ! empty( $_POST[ 'account_first_name' ] ) ? wc_clean( $_POST[ 'account_first_name' ] ) : ''; - $account_last_name = ! empty( $_POST[ 'account_last_name' ] ) ? wc_clean( $_POST[ 'account_last_name' ] ) : ''; - $account_email = ! empty( $_POST[ 'account_email' ] ) ? sanitize_email( $_POST[ 'account_email' ] ) : ''; - $pass_cur = ! empty( $_POST[ 'password_current' ] ) ? $_POST[ 'password_current' ] : ''; - $pass1 = ! empty( $_POST[ 'password_1' ] ) ? $_POST[ 'password_1' ] : ''; - $pass2 = ! empty( $_POST[ 'password_2' ] ) ? $_POST[ 'password_2' ] : ''; + $account_first_name = ! empty( $_POST['account_first_name'] ) ? wc_clean( $_POST['account_first_name'] ) : ''; + $account_last_name = ! empty( $_POST['account_last_name'] ) ? wc_clean( $_POST['account_last_name'] ) : ''; + $account_email = ! empty( $_POST['account_email'] ) ? sanitize_email( $_POST['account_email'] ) : ''; + $pass_cur = ! empty( $_POST['password_current'] ) ? $_POST['password_current'] : ''; + $pass1 = ! empty( $_POST['password_1'] ) ? $_POST['password_1'] : ''; + $pass2 = ! empty( $_POST['password_2'] ) ? $_POST['password_2'] : ''; $save_pass = true; $user->first_name = $account_first_name; @@ -983,7 +983,7 @@ class WC_Form_Handler { wc_add_notice( __( 'Please enter your password.', 'woocommerce' ), 'error' ); } - if ( $posted_fields[ 'password_1' ] !== $posted_fields[ 'password_2' ] ) { + if ( $posted_fields['password_1'] !== $posted_fields['password_2'] ) { wc_add_notice( __( 'Passwords do not match.', 'woocommerce' ), 'error' ); } diff --git a/includes/class-wc-product-variation.php b/includes/class-wc-product-variation.php index 10a35a9f412..3463de45f54 100644 --- a/includes/class-wc-product-variation.php +++ b/includes/class-wc-product-variation.php @@ -635,18 +635,18 @@ class WC_Product_Variation extends WC_Product { foreach ( $attributes as $attribute ) { // Only deal with attributes that are variations - if ( ! $attribute[ 'is_variation' ] ) { + if ( ! $attribute['is_variation'] ) { continue; } - $variation_selected_value = isset( $variation_data[ 'attribute_' . sanitize_title( $attribute[ 'name' ] ) ] ) ? $variation_data[ 'attribute_' . sanitize_title( $attribute[ 'name' ] ) ] : ''; - $description_name = esc_html( wc_attribute_label( $attribute[ 'name' ] ) ); + $variation_selected_value = isset( $variation_data[ 'attribute_' . sanitize_title( $attribute['name'] ) ] ) ? $variation_data[ 'attribute_' . sanitize_title( $attribute['name'] ) ] : ''; + $description_name = esc_html( wc_attribute_label( $attribute['name'] ) ); $description_value = __( 'Any', 'woocommerce' ); // Get terms for attribute taxonomy or value if its a custom attribute - if ( $attribute[ 'is_taxonomy' ] ) { + if ( $attribute['is_taxonomy'] ) { - $post_terms = get_the_terms( $this->id, $attribute[ 'name' ] ); + $post_terms = get_the_terms( $this->id, $attribute['name'] ); foreach ( $post_terms as $term ) { if ( $variation_selected_value === $term->slug ) { @@ -656,7 +656,7 @@ class WC_Product_Variation extends WC_Product { } else { - $options = wc_get_text_attributes( $attribute[ 'value' ] ); + $options = wc_get_text_attributes( $attribute['value'] ); foreach ( $options as $option ) { diff --git a/includes/class-wc-query.php b/includes/class-wc-query.php index bfd806fa342..79f2c19b3f5 100644 --- a/includes/class-wc-query.php +++ b/includes/class-wc-query.php @@ -666,7 +666,7 @@ class WC_Query { } if ( ! empty( $args['product_cat'] ) ) { - $tax_query[ 'product_cat' ] = array( + $tax_query['product_cat'] = array( 'taxonomy' => 'product_cat', 'terms' => array( $args['product_cat'] ), 'field' => 'slug', @@ -674,7 +674,7 @@ class WC_Query { } if ( ! empty( $args['product_tag'] ) ) { - $tax_query[ 'product_tag' ] = array( + $tax_query['product_tag'] = array( 'taxonomy' => 'product_tag', 'terms' => array( $args['product_tag'] ), 'field' => 'slug', diff --git a/includes/class-wc-shipping-zone.php b/includes/class-wc-shipping-zone.php index 27850584238..ad31e6a3c20 100644 --- a/includes/class-wc-shipping-zone.php +++ b/includes/class-wc-shipping-zone.php @@ -211,7 +211,7 @@ class WC_Shipping_Zone extends WC_Data { foreach ( $states as $location ) { $location_codes = explode( ':', $location->code ); - $location_parts[] = $all_states[ $location_codes[ 0 ] ][ $location_codes[ 1 ] ]; + $location_parts[] = $all_states[ $location_codes[0] ][ $location_codes[1] ]; } foreach ( $postcodes as $location ) { diff --git a/includes/shipping/flat-rate/includes/settings-flat-rate.php b/includes/shipping/flat-rate/includes/settings-flat-rate.php index 2be85592dc3..96ea076c9bf 100644 --- a/includes/shipping/flat-rate/includes/settings-flat-rate.php +++ b/includes/shipping/flat-rate/includes/settings-flat-rate.php @@ -40,7 +40,7 @@ $settings = array( $shipping_classes = WC()->shipping->get_shipping_classes(); if ( ! empty( $shipping_classes ) ) { - $settings[ 'class_costs' ] = array( + $settings['class_costs'] = array( 'title' => __( 'Shipping Class Costs', 'woocommerce' ), 'type' => 'title', 'default' => '', @@ -59,7 +59,7 @@ if ( ! empty( $shipping_classes ) ) { 'desc_tip' => true, ); } - $settings[ 'no_class_cost' ] = array( + $settings['no_class_cost'] = array( 'title' => __( 'No Shipping Class Cost', 'woocommerce' ), 'type' => 'text', 'placeholder' => __( 'N/A', 'woocommerce' ), @@ -67,7 +67,7 @@ if ( ! empty( $shipping_classes ) ) { 'default' => '', 'desc_tip' => true, ); - $settings[ 'type' ] = array( + $settings['type'] = array( 'title' => __( 'Calculation Type', 'woocommerce' ), 'type' => 'select', 'class' => 'wc-enhanced-select', diff --git a/includes/shipping/legacy-flat-rate/class-wc-shipping-legacy-flat-rate.php b/includes/shipping/legacy-flat-rate/class-wc-shipping-legacy-flat-rate.php index 0a7aabb721a..82468526cad 100644 --- a/includes/shipping/legacy-flat-rate/class-wc-shipping-legacy-flat-rate.php +++ b/includes/shipping/legacy-flat-rate/class-wc-shipping-legacy-flat-rate.php @@ -37,7 +37,7 @@ class WC_Shipping_Legacy_Flat_Rate extends WC_Shipping_Method { public function process_admin_options() { parent::process_admin_options(); - if ( 'no' === $this->settings[ 'enabled' ] ) { + if ( 'no' === $this->settings['enabled'] ) { wp_redirect( admin_url( 'admin.php?page=wc-settings&tab=shipping§ion=options' ) ); exit; } diff --git a/includes/shipping/legacy-flat-rate/includes/settings-flat-rate.php b/includes/shipping/legacy-flat-rate/includes/settings-flat-rate.php index 3746053e2a0..53f87c2a41a 100644 --- a/includes/shipping/legacy-flat-rate/includes/settings-flat-rate.php +++ b/includes/shipping/legacy-flat-rate/includes/settings-flat-rate.php @@ -67,7 +67,7 @@ $settings = array( $shipping_classes = WC()->shipping->get_shipping_classes(); if ( ! empty( $shipping_classes ) ) { - $settings[ 'class_costs' ] = array( + $settings['class_costs'] = array( 'title' => __( 'Shipping Class Costs', 'woocommerce' ), 'type' => 'title', 'default' => '', @@ -86,7 +86,7 @@ if ( ! empty( $shipping_classes ) ) { 'desc_tip' => true, ); } - $settings[ 'no_class_cost' ] = array( + $settings['no_class_cost'] = array( 'title' => __( 'No Shipping Class Cost', 'woocommerce' ), 'type' => 'text', 'placeholder' => __( 'N/A', 'woocommerce' ), @@ -94,7 +94,7 @@ if ( ! empty( $shipping_classes ) ) { 'default' => '', 'desc_tip' => true, ); - $settings[ 'type' ] = array( + $settings['type'] = array( 'title' => __( 'Calculation Type', 'woocommerce' ), 'type' => 'select', 'class' => 'wc-enhanced-select', @@ -107,7 +107,7 @@ if ( ! empty( $shipping_classes ) ) { } if ( apply_filters( 'woocommerce_enable_deprecated_additional_flat_rates', $this->get_option( 'options', false ) ) ) { - $settings[ 'additional_rates' ] = array( + $settings['additional_rates'] = array( 'title' => __( 'Additional Rates', 'woocommerce' ), 'type' => 'title', 'default' => '', diff --git a/includes/shipping/legacy-free-shipping/class-wc-shipping-legacy-free-shipping.php b/includes/shipping/legacy-free-shipping/class-wc-shipping-legacy-free-shipping.php index 33956b4a157..997375390a9 100644 --- a/includes/shipping/legacy-free-shipping/class-wc-shipping-legacy-free-shipping.php +++ b/includes/shipping/legacy-free-shipping/class-wc-shipping-legacy-free-shipping.php @@ -38,7 +38,7 @@ class WC_Shipping_Legacy_Free_Shipping extends WC_Shipping_Method { public function process_admin_options() { parent::process_admin_options(); - if ( 'no' === $this->settings[ 'enabled' ] ) { + if ( 'no' === $this->settings['enabled'] ) { wp_redirect( admin_url( 'admin.php?page=wc-settings&tab=shipping§ion=options' ) ); exit; } diff --git a/includes/shipping/legacy-local-delivery/class-wc-shipping-legacy-local-delivery.php b/includes/shipping/legacy-local-delivery/class-wc-shipping-legacy-local-delivery.php index eb95a89213b..f3e71cc2d2d 100644 --- a/includes/shipping/legacy-local-delivery/class-wc-shipping-legacy-local-delivery.php +++ b/includes/shipping/legacy-local-delivery/class-wc-shipping-legacy-local-delivery.php @@ -32,7 +32,7 @@ class WC_Shipping_Legacy_Local_Delivery extends WC_Shipping_Local_Pickup { public function process_admin_options() { parent::process_admin_options(); - if ( 'no' === $this->settings[ 'enabled' ] ) { + if ( 'no' === $this->settings['enabled'] ) { wp_redirect( admin_url( 'admin.php?page=wc-settings&tab=shipping§ion=options' ) ); exit; } diff --git a/includes/shipping/legacy-local-pickup/class-wc-shipping-legacy-local-pickup.php b/includes/shipping/legacy-local-pickup/class-wc-shipping-legacy-local-pickup.php index da0f3ec99b1..eed0fbcd358 100644 --- a/includes/shipping/legacy-local-pickup/class-wc-shipping-legacy-local-pickup.php +++ b/includes/shipping/legacy-local-pickup/class-wc-shipping-legacy-local-pickup.php @@ -32,7 +32,7 @@ class WC_Shipping_Legacy_Local_Pickup extends WC_Shipping_Method { public function process_admin_options() { parent::process_admin_options(); - if ( 'no' === $this->settings[ 'enabled' ] ) { + if ( 'no' === $this->settings['enabled'] ) { wp_redirect( admin_url( 'admin.php?page=wc-settings&tab=shipping§ion=options' ) ); exit; } diff --git a/includes/shortcodes/class-wc-shortcode-checkout.php b/includes/shortcodes/class-wc-shortcode-checkout.php index ace6592e274..6978bc457c8 100644 --- a/includes/shortcodes/class-wc-shortcode-checkout.php +++ b/includes/shortcodes/class-wc-shortcode-checkout.php @@ -82,7 +82,7 @@ class WC_Shortcode_Checkout { if ( isset( $_GET['pay_for_order'] ) && isset( $_GET['key'] ) && $order_id ) { // Pay for existing order - $order_key = $_GET[ 'key' ]; + $order_key = $_GET['key']; $order = wc_get_order( $order_id ); if ( ! current_user_can( 'pay_for_order', $order_id ) ) { diff --git a/includes/wc-order-functions.php b/includes/wc-order-functions.php index 453f6a8cdee..8a0d029d2ff 100644 --- a/includes/wc-order-functions.php +++ b/includes/wc-order-functions.php @@ -113,7 +113,7 @@ function wc_get_orders( $args ) { $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); } - if ( ! $args['paginate' ] ) { + if ( ! $args['paginate'] ) { $wp_query_args['no_found_rows'] = true; } @@ -126,7 +126,7 @@ function wc_get_orders( $args ) { $return = $orders->posts; } - if ( $args['paginate' ] ) { + if ( $args['paginate'] ) { return (object) array( 'orders' => $return, 'total' => $orders->found_posts, diff --git a/includes/wc-update-functions.php b/includes/wc-update-functions.php index d3143961be5..79369b55083 100644 --- a/includes/wc-update-functions.php +++ b/includes/wc-update-functions.php @@ -634,7 +634,7 @@ function wc_update_240_shipping_methods() { foreach ( WC()->shipping->get_shipping_classes() as $shipping_class ) { $rate_key = 'class_cost_' . $shipping_class->slug; - $math_cost_strings[ $rate_key ] = $math_cost_strings[ 'no_class_cost' ]; + $math_cost_strings[ $rate_key ] = $math_cost_strings['no_class_cost']; } if ( $flat_rates = array_filter( (array) get_option( $flat_rate_option_key, array() ) ) ) { @@ -658,7 +658,7 @@ function wc_update_240_shipping_methods() { } } - $math_cost_strings[ 'cost' ][] = $shipping_method->get_option( 'cost_per_order' ); + $math_cost_strings['cost'][] = $shipping_method->get_option( 'cost_per_order' ); // Save settings foreach ( $math_cost_strings as $option_id => $math_cost_string ) { diff --git a/includes/wc-user-functions.php b/includes/wc-user-functions.php index 6f687c9ecc0..3c87ebde360 100644 --- a/includes/wc-user-functions.php +++ b/includes/wc-user-functions.php @@ -316,7 +316,7 @@ add_filter( 'user_has_cap', 'wc_customer_has_capability', 10, 3 ); */ function wc_modify_editable_roles( $roles ){ if ( ! current_user_can( 'administrator' ) ) { - unset( $roles[ 'administrator' ] ); + unset( $roles['administrator'] ); } return $roles; }