Fixed coding standards

This commit is contained in:
Claudio Sanches 2016-09-13 19:04:33 -03:00
parent c5c1e9ecbe
commit 089b5e93f2
1 changed files with 20 additions and 18 deletions

View File

@ -446,18 +446,18 @@ class WC_Checkout {
// Get Value // Get Value
switch ( $field['type'] ) { switch ( $field['type'] ) {
case "checkbox" : case 'checkbox' :
$this->posted[ $key ] = isset( $_POST[ $key ] ) ? 1 : 0; $this->posted[ $key ] = (int) isset( $_POST[ $key ] );
break; break;
case "multiselect" : case 'multiselect' :
$this->posted[ $key ] = isset( $_POST[ $key ] ) ? implode( ', ', array_map( 'wc_clean', $_POST[ $key ] ) ) : ''; $this->posted[ $key ] = isset( $_POST[ $key ] ) ? implode( ', ', array_map( 'wc_clean', $_POST[ $key ] ) ) : '';
break; break;
case "textarea" : case 'textarea' :
$this->posted[ $key ] = isset( $_POST[ $key ] ) ? wp_strip_all_tags( wp_check_invalid_utf8( stripslashes( $_POST[ $key ] ) ) ) : ''; $this->posted[ $key ] = isset( $_POST[ $key ] ) ? wp_strip_all_tags( wp_check_invalid_utf8( stripslashes( $_POST[ $key ] ) ) ) : '';
break; break;
default : default :
$this->posted[ $key ] = isset( $_POST[ $key ] ) ? ( is_array( $_POST[ $key ] ) ? array_map( 'wc_clean', $_POST[ $key ] ) : wc_clean( $_POST[ $key ] ) ) : ''; $this->posted[ $key ] = isset( $_POST[ $key ] ) ? ( is_array( $_POST[ $key ] ) ? array_map( 'wc_clean', $_POST[ $key ] ) : wc_clean( $_POST[ $key ] ) ) : '';
break; break;
} }
// Hooks to allow modification of value // Hooks to allow modification of value
@ -489,24 +489,26 @@ class WC_Checkout {
case 'postcode' : case 'postcode' :
$this->posted[ $key ] = strtoupper( str_replace( ' ', '', $this->posted[ $key ] ) ); $this->posted[ $key ] = strtoupper( str_replace( ' ', '', $this->posted[ $key ] ) );
if ( ! WC_Validation::is_postcode( $this->posted[ $key ], $_POST[ $fieldset_key . '_country' ] ) ) : if ( ! WC_Validation::is_postcode( $this->posted[ $key ], $_POST[ $fieldset_key . '_country' ] ) ) {
wc_add_notice( __( 'Please enter a valid postcode/ZIP.', 'woocommerce' ), 'error' ); wc_add_notice( __( 'Please enter a valid postcode/ZIP.', 'woocommerce' ), 'error' );
else : } else {
$this->posted[ $key ] = wc_format_postcode( $this->posted[ $key ], $_POST[ $fieldset_key . '_country' ] ); $this->posted[ $key ] = wc_format_postcode( $this->posted[ $key ], $_POST[ $fieldset_key . '_country' ] );
endif; }
break; break;
case 'phone' : case 'phone' :
$this->posted[ $key ] = wc_format_phone_number( $this->posted[ $key ] ); $this->posted[ $key ] = wc_format_phone_number( $this->posted[ $key ] );
if ( ! WC_Validation::is_phone( $this->posted[ $key ] ) ) if ( ! WC_Validation::is_phone( $this->posted[ $key ] ) ) {
wc_add_notice( '<strong>' . $field['label'] . '</strong> ' . __( 'is not a valid phone number.', 'woocommerce' ), 'error' ); wc_add_notice( '<strong>' . $field['label'] . '</strong> ' . __( 'is not a valid phone number.', 'woocommerce' ), 'error' );
break; }
break;
case 'email' : case 'email' :
$this->posted[ $key ] = strtolower( $this->posted[ $key ] ); $this->posted[ $key ] = strtolower( $this->posted[ $key ] );
if ( ! is_email( $this->posted[ $key ] ) ) if ( ! is_email( $this->posted[ $key ] ) ) {
wc_add_notice( '<strong>' . $field['label'] . '</strong> ' . __( 'is not a valid email address.', 'woocommerce' ), 'error' ); wc_add_notice( '<strong>' . $field['label'] . '</strong> ' . __( 'is not a valid email address.', 'woocommerce' ), 'error' );
break; }
break;
case 'state' : case 'state' :
// Get valid states // Get valid states
$valid_states = WC()->countries->get_states( isset( $_POST[ $fieldset_key . '_country' ] ) ? $_POST[ $fieldset_key . '_country' ] : ( 'billing' === $fieldset_key ? WC()->customer->get_country() : WC()->customer->get_shipping_country() ) ); $valid_states = WC()->countries->get_states( isset( $_POST[ $fieldset_key . '_country' ] ) ? $_POST[ $fieldset_key . '_country' ] : ( 'billing' === $fieldset_key ? WC()->customer->get_country() : WC()->customer->get_shipping_country() ) );
@ -516,7 +518,7 @@ class WC_Checkout {
// Convert value to key if set // Convert value to key if set
if ( isset( $valid_state_values[ strtolower( $this->posted[ $key ] ) ] ) ) { if ( isset( $valid_state_values[ strtolower( $this->posted[ $key ] ) ] ) ) {
$this->posted[ $key ] = $valid_state_values[ strtolower( $this->posted[ $key ] ) ]; $this->posted[ $key ] = $valid_state_values[ strtolower( $this->posted[ $key ] ) ];
} }
} }
@ -526,7 +528,7 @@ class WC_Checkout {
wc_add_notice( '<strong>' . $field['label'] . '</strong> ' . __( 'is not valid. Please enter one of the following:', 'woocommerce' ) . ' ' . implode( ', ', $valid_states ), 'error' ); wc_add_notice( '<strong>' . $field['label'] . '</strong> ' . __( 'is not valid. Please enter one of the following:', 'woocommerce' ) . ' ' . implode( ', ', $valid_states ), 'error' );
} }
} }
break; break;
} }
} }
} }