WordPress.Arrays.ArrayKeySpacingRestrictions.SpacesAroundArrayKeys

This commit is contained in:
Aristeides Stathopoulos 2016-08-27 06:23:21 +03:00
parent ff852038c9
commit 6c30f84fa2
22 changed files with 53 additions and 53 deletions

View File

@ -501,11 +501,11 @@ class WC_Admin_Settings {
// Image width settings // Image width settings
case 'image_width' : 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 ); $size = wc_get_image_size( $image_size );
$width = isset( $size[ 'width' ] ) ? $size[ 'width' ] : $value[ 'default' ][ 'width' ]; $width = isset( $size['width'] ) ? $size['width'] : $value['default']['width'];
$height = isset( $size[ 'height' ] ) ? $size[ 'height' ] : $value[ 'default' ][ 'height' ]; $height = isset( $size['height'] ) ? $size['height'] : $value['default']['height'];
$crop = isset( $size[ 'crop' ] ) ? $size[ 'crop' ] : $value[ 'default' ][ 'crop' ]; $crop = isset( $size['crop'] ) ? $size['crop'] : $value['default']['crop'];
$disabled_attr = ''; $disabled_attr = '';
$disabled_message = ''; $disabled_message = '';

View File

@ -88,7 +88,7 @@ class WC_Admin_Status {
$handle = ! empty( $viewed_log ) ? self::get_log_file_handle( $viewed_log ) : ''; $handle = ! empty( $viewed_log ) ? self::get_log_file_handle( $viewed_log ) : '';
if ( ! empty( $_REQUEST[ 'handle' ] ) ) { if ( ! empty( $_REQUEST['handle'] ) ) {
self::remove_log(); self::remove_log();
} }
@ -244,13 +244,13 @@ class WC_Admin_Status {
* Remove/delete the chosen file. * Remove/delete the chosen file.
*/ */
public static function remove_log() { 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' ) ); wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
} }
if ( ! empty( $_REQUEST[ 'handle' ] ) ) { if ( ! empty( $_REQUEST['handle'] ) ) {
$logger = wc_get_logger(); $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' ) ) ); wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=wc-status&tab=logs' ) ) );

View File

@ -454,7 +454,7 @@ class WC_Meta_Box_Order_Data {
} }
if ( isset( $_POST['_transaction_id'] ) ) { 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 // Payment method handling

View File

@ -112,7 +112,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
$legend[] = array( $legend[] = array(
'title' => sprintf( __( '%s coupons used in total', 'woocommerce' ), '<strong>' . $total_coupons . '</strong>' ), 'title' => sprintf( __( '%s coupons used in total', 'woocommerce' ), '<strong>' . $total_coupons . '</strong>' ),
'color' => $this->chart_colours['coupon_count' ], 'color' => $this->chart_colours['coupon_count'],
'highlight_series' => 0, 'highlight_series' => 0,
); );
@ -458,8 +458,8 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
{ {
label: "<?php echo esc_js( __( 'Number of coupons used', 'woocommerce' ) ) ?>", label: "<?php echo esc_js( __( 'Number of coupons used', 'woocommerce' ) ) ?>",
data: order_data.order_coupon_counts, data: order_data.order_coupon_counts,
color: '<?php echo $this->chart_colours['coupon_count' ]; ?>', color: '<?php echo $this->chart_colours['coupon_count']; ?>',
bars: { fillColor: '<?php echo $this->chart_colours['coupon_count' ]; ?>', fill: true, show: true, lineWidth: 0, barWidth: <?php echo $this->barwidth; ?> * 0.5, align: 'center' }, bars: { fillColor: '<?php echo $this->chart_colours['coupon_count']; ?>', fill: true, show: true, lineWidth: 0, barWidth: <?php echo $this->barwidth; ?> * 0.5, align: 'center' },
shadowSize: 0, shadowSize: 0,
hoverable: false hoverable: false
}, },

View File

@ -94,7 +94,7 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
$legend[] = array( $legend[] = array(
'title' => sprintf( __( '%s sales in %s', 'woocommerce' ), '<strong>' . wc_price( $total ) . '</strong>', $category->name ), 'title' => sprintf( __( '%s sales in %s', 'woocommerce' ), '<strong>' . wc_price( $total ) . '</strong>', $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, 'highlight_series' => $index,
); );

View File

@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
if ( $current_tab == $key ) { if ( $current_tab == $key ) {
echo 'nav-tab-active'; echo 'nav-tab-active';
} }
echo '">' . esc_html( $report_group[ 'title' ] ) . '</a>'; echo '">' . esc_html( $report_group['title'] ) . '</a>';
} }
do_action( 'wc_reports_tabs' ); do_action( 'wc_reports_tabs' );
@ -51,9 +51,9 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php <?php
} }
if ( isset( $reports[ $current_tab ][ 'reports' ][ $current_report ] ) ) { if ( isset( $reports[ $current_tab ]['reports'][ $current_report ] ) ) {
$report = $reports[ $current_tab ][ 'reports' ][ $current_report ]; $report = $reports[ $current_tab ]['reports'][ $current_report ];
if ( ! isset( $report['hide_title'] ) || $report['hide_title'] != true ) { if ( ! isset( $report['hide_title'] ) || $report['hide_title'] != true ) {
echo '<h1>' . esc_html( $report['title'] ) . '</h1>'; echo '<h1>' . esc_html( $report['title'] ) . '</h1>';

View File

@ -154,7 +154,7 @@ class WC_REST_Authentication {
// From OAuth PHP library, used under MIT license. // From OAuth PHP library, used under MIT license.
$params = array(); $params = array();
if ( preg_match_all( '/(oauth_[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches ) ) { 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 ] ); $params[ $h ] = urldecode( empty( $matches[3][ $i ] ) ? $matches[4][ $i ] : $matches[3][ $i ] );
} }
if ( isset( $params['realm'] ) ) { if ( isset( $params['realm'] ) ) {

View File

@ -458,7 +458,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
} }
// If items have changed, recalculate order totals. // 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(); $order->calculate_totals();
} }

View File

@ -156,11 +156,11 @@ class WC_Form_Handler {
*/ */
public static function save_account_details() { public static function save_account_details() {
if ( 'POST' !== strtoupper( $_SERVER[ 'REQUEST_METHOD' ] ) ) { if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
return; 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; return;
} }
@ -174,12 +174,12 @@ class WC_Form_Handler {
return; return;
} }
$account_first_name = ! empty( $_POST[ 'account_first_name' ] ) ? wc_clean( $_POST[ 'account_first_name' ] ) : ''; $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_last_name = ! empty( $_POST['account_last_name'] ) ? wc_clean( $_POST['account_last_name'] ) : '';
$account_email = ! empty( $_POST[ 'account_email' ] ) ? sanitize_email( $_POST[ 'account_email' ] ) : ''; $account_email = ! empty( $_POST['account_email'] ) ? sanitize_email( $_POST['account_email'] ) : '';
$pass_cur = ! empty( $_POST[ 'password_current' ] ) ? $_POST[ 'password_current' ] : ''; $pass_cur = ! empty( $_POST['password_current'] ) ? $_POST['password_current'] : '';
$pass1 = ! empty( $_POST[ 'password_1' ] ) ? $_POST[ 'password_1' ] : ''; $pass1 = ! empty( $_POST['password_1'] ) ? $_POST['password_1'] : '';
$pass2 = ! empty( $_POST[ 'password_2' ] ) ? $_POST[ 'password_2' ] : ''; $pass2 = ! empty( $_POST['password_2'] ) ? $_POST['password_2'] : '';
$save_pass = true; $save_pass = true;
$user->first_name = $account_first_name; $user->first_name = $account_first_name;
@ -983,7 +983,7 @@ class WC_Form_Handler {
wc_add_notice( __( 'Please enter your password.', 'woocommerce' ), 'error' ); 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' ); wc_add_notice( __( 'Passwords do not match.', 'woocommerce' ), 'error' );
} }

View File

@ -635,18 +635,18 @@ class WC_Product_Variation extends WC_Product {
foreach ( $attributes as $attribute ) { foreach ( $attributes as $attribute ) {
// Only deal with attributes that are variations // Only deal with attributes that are variations
if ( ! $attribute[ 'is_variation' ] ) { if ( ! $attribute['is_variation'] ) {
continue; continue;
} }
$variation_selected_value = isset( $variation_data[ 'attribute_' . sanitize_title( $attribute[ 'name' ] ) ] ) ? $variation_data[ 'attribute_' . sanitize_title( $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_name = esc_html( wc_attribute_label( $attribute['name'] ) );
$description_value = __( 'Any', 'woocommerce' ); $description_value = __( 'Any', 'woocommerce' );
// Get terms for attribute taxonomy or value if its a custom attribute // 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 ) { foreach ( $post_terms as $term ) {
if ( $variation_selected_value === $term->slug ) { if ( $variation_selected_value === $term->slug ) {
@ -656,7 +656,7 @@ class WC_Product_Variation extends WC_Product {
} else { } else {
$options = wc_get_text_attributes( $attribute[ 'value' ] ); $options = wc_get_text_attributes( $attribute['value'] );
foreach ( $options as $option ) { foreach ( $options as $option ) {

View File

@ -666,7 +666,7 @@ class WC_Query {
} }
if ( ! empty( $args['product_cat'] ) ) { if ( ! empty( $args['product_cat'] ) ) {
$tax_query[ 'product_cat' ] = array( $tax_query['product_cat'] = array(
'taxonomy' => 'product_cat', 'taxonomy' => 'product_cat',
'terms' => array( $args['product_cat'] ), 'terms' => array( $args['product_cat'] ),
'field' => 'slug', 'field' => 'slug',
@ -674,7 +674,7 @@ class WC_Query {
} }
if ( ! empty( $args['product_tag'] ) ) { if ( ! empty( $args['product_tag'] ) ) {
$tax_query[ 'product_tag' ] = array( $tax_query['product_tag'] = array(
'taxonomy' => 'product_tag', 'taxonomy' => 'product_tag',
'terms' => array( $args['product_tag'] ), 'terms' => array( $args['product_tag'] ),
'field' => 'slug', 'field' => 'slug',

View File

@ -211,7 +211,7 @@ class WC_Shipping_Zone extends WC_Data {
foreach ( $states as $location ) { foreach ( $states as $location ) {
$location_codes = explode( ':', $location->code ); $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 ) { foreach ( $postcodes as $location ) {

View File

@ -40,7 +40,7 @@ $settings = array(
$shipping_classes = WC()->shipping->get_shipping_classes(); $shipping_classes = WC()->shipping->get_shipping_classes();
if ( ! empty( $shipping_classes ) ) { if ( ! empty( $shipping_classes ) ) {
$settings[ 'class_costs' ] = array( $settings['class_costs'] = array(
'title' => __( 'Shipping Class Costs', 'woocommerce' ), 'title' => __( 'Shipping Class Costs', 'woocommerce' ),
'type' => 'title', 'type' => 'title',
'default' => '', 'default' => '',
@ -59,7 +59,7 @@ if ( ! empty( $shipping_classes ) ) {
'desc_tip' => true, 'desc_tip' => true,
); );
} }
$settings[ 'no_class_cost' ] = array( $settings['no_class_cost'] = array(
'title' => __( 'No Shipping Class Cost', 'woocommerce' ), 'title' => __( 'No Shipping Class Cost', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'placeholder' => __( 'N/A', 'woocommerce' ), 'placeholder' => __( 'N/A', 'woocommerce' ),
@ -67,7 +67,7 @@ if ( ! empty( $shipping_classes ) ) {
'default' => '', 'default' => '',
'desc_tip' => true, 'desc_tip' => true,
); );
$settings[ 'type' ] = array( $settings['type'] = array(
'title' => __( 'Calculation Type', 'woocommerce' ), 'title' => __( 'Calculation Type', 'woocommerce' ),
'type' => 'select', 'type' => 'select',
'class' => 'wc-enhanced-select', 'class' => 'wc-enhanced-select',

View File

@ -37,7 +37,7 @@ class WC_Shipping_Legacy_Flat_Rate extends WC_Shipping_Method {
public function process_admin_options() { public function process_admin_options() {
parent::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&section=options' ) ); wp_redirect( admin_url( 'admin.php?page=wc-settings&tab=shipping&section=options' ) );
exit; exit;
} }

View File

@ -67,7 +67,7 @@ $settings = array(
$shipping_classes = WC()->shipping->get_shipping_classes(); $shipping_classes = WC()->shipping->get_shipping_classes();
if ( ! empty( $shipping_classes ) ) { if ( ! empty( $shipping_classes ) ) {
$settings[ 'class_costs' ] = array( $settings['class_costs'] = array(
'title' => __( 'Shipping Class Costs', 'woocommerce' ), 'title' => __( 'Shipping Class Costs', 'woocommerce' ),
'type' => 'title', 'type' => 'title',
'default' => '', 'default' => '',
@ -86,7 +86,7 @@ if ( ! empty( $shipping_classes ) ) {
'desc_tip' => true, 'desc_tip' => true,
); );
} }
$settings[ 'no_class_cost' ] = array( $settings['no_class_cost'] = array(
'title' => __( 'No Shipping Class Cost', 'woocommerce' ), 'title' => __( 'No Shipping Class Cost', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'placeholder' => __( 'N/A', 'woocommerce' ), 'placeholder' => __( 'N/A', 'woocommerce' ),
@ -94,7 +94,7 @@ if ( ! empty( $shipping_classes ) ) {
'default' => '', 'default' => '',
'desc_tip' => true, 'desc_tip' => true,
); );
$settings[ 'type' ] = array( $settings['type'] = array(
'title' => __( 'Calculation Type', 'woocommerce' ), 'title' => __( 'Calculation Type', 'woocommerce' ),
'type' => 'select', 'type' => 'select',
'class' => 'wc-enhanced-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 ) ) ) { 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' ), 'title' => __( 'Additional Rates', 'woocommerce' ),
'type' => 'title', 'type' => 'title',
'default' => '', 'default' => '',

View File

@ -38,7 +38,7 @@ class WC_Shipping_Legacy_Free_Shipping extends WC_Shipping_Method {
public function process_admin_options() { public function process_admin_options() {
parent::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&section=options' ) ); wp_redirect( admin_url( 'admin.php?page=wc-settings&tab=shipping&section=options' ) );
exit; exit;
} }

View File

@ -32,7 +32,7 @@ class WC_Shipping_Legacy_Local_Delivery extends WC_Shipping_Local_Pickup {
public function process_admin_options() { public function process_admin_options() {
parent::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&section=options' ) ); wp_redirect( admin_url( 'admin.php?page=wc-settings&tab=shipping&section=options' ) );
exit; exit;
} }

View File

@ -32,7 +32,7 @@ class WC_Shipping_Legacy_Local_Pickup extends WC_Shipping_Method {
public function process_admin_options() { public function process_admin_options() {
parent::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&section=options' ) ); wp_redirect( admin_url( 'admin.php?page=wc-settings&tab=shipping&section=options' ) );
exit; exit;
} }

View File

@ -82,7 +82,7 @@ class WC_Shortcode_Checkout {
if ( isset( $_GET['pay_for_order'] ) && isset( $_GET['key'] ) && $order_id ) { if ( isset( $_GET['pay_for_order'] ) && isset( $_GET['key'] ) && $order_id ) {
// Pay for existing order // Pay for existing order
$order_key = $_GET[ 'key' ]; $order_key = $_GET['key'];
$order = wc_get_order( $order_id ); $order = wc_get_order( $order_id );
if ( ! current_user_can( 'pay_for_order', $order_id ) ) { if ( ! current_user_can( 'pay_for_order', $order_id ) ) {

View File

@ -113,7 +113,7 @@ function wc_get_orders( $args ) {
$wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] );
} }
if ( ! $args['paginate' ] ) { if ( ! $args['paginate'] ) {
$wp_query_args['no_found_rows'] = true; $wp_query_args['no_found_rows'] = true;
} }
@ -126,7 +126,7 @@ function wc_get_orders( $args ) {
$return = $orders->posts; $return = $orders->posts;
} }
if ( $args['paginate' ] ) { if ( $args['paginate'] ) {
return (object) array( return (object) array(
'orders' => $return, 'orders' => $return,
'total' => $orders->found_posts, 'total' => $orders->found_posts,

View File

@ -634,7 +634,7 @@ function wc_update_240_shipping_methods() {
foreach ( WC()->shipping->get_shipping_classes() as $shipping_class ) { foreach ( WC()->shipping->get_shipping_classes() as $shipping_class ) {
$rate_key = 'class_cost_' . $shipping_class->slug; $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() ) ) ) { 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 // Save settings
foreach ( $math_cost_strings as $option_id => $math_cost_string ) { foreach ( $math_cost_strings as $option_id => $math_cost_string ) {

View File

@ -316,7 +316,7 @@ add_filter( 'user_has_cap', 'wc_customer_has_capability', 10, 3 );
*/ */
function wc_modify_editable_roles( $roles ){ function wc_modify_editable_roles( $roles ){
if ( ! current_user_can( 'administrator' ) ) { if ( ! current_user_can( 'administrator' ) ) {
unset( $roles[ 'administrator' ] ); unset( $roles['administrator'] );
} }
return $roles; return $roles;
} }