From e1fea55cb619af9ba2518da8a598cbaf5da85569 Mon Sep 17 00:00:00 2001 From: Khan M Rashedun-Naby Date: Thu, 26 Apr 2018 09:40:58 +0600 Subject: [PATCH] get_value method refactored --- includes/class-wc-checkout.php | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index e0ec3d204d1..6d2a0c60e9d 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -1058,24 +1058,24 @@ class WC_Checkout { * @return string */ public function get_value( $input ) { - if ( ! empty( $_POST[ $input ] ) ) { // WPCS: input var ok, CSRF OK. - return wc_clean( wp_unslash( $_POST[ $input ] ) ); // WPCS: input var ok, CSRF OK. - - } else { - - $value = apply_filters( 'woocommerce_checkout_get_value', null, $input ); - - if ( null !== $value ) { - return $value; - } - - if ( is_callable( array( WC()->customer, "get_$input" ) ) ) { - $value = WC()->customer->{"get_$input"}() ? WC()->customer->{"get_$input"}() : null; - } elseif ( WC()->customer->meta_exists( $input ) ) { - $value = WC()->customer->get_meta( $input, true ); - } - - return apply_filters( 'default_checkout_' . $input, $value, $input ); + // WPCS: input var ok, CSRF OK. + if ( ! empty( $_POST[ $input ] ) ) { + // WPCS: input var ok, CSRF OK. + return wc_clean( wp_unslash( $_POST[ $input ] ) ); } + + $value = apply_filters( 'woocommerce_checkout_get_value', null, $input ); + + if ( null !== $value ) { + return $value; + } + + if ( is_callable( array( WC()->customer, "get_$input" ) ) ) { + $value = WC()->customer->{"get_$input"}() ? WC()->customer->{"get_$input"}() : null; + } elseif ( WC()->customer->meta_exists( $input ) ) { + $value = WC()->customer->get_meta( $input, true ); + } + + return apply_filters( 'default_checkout_' . $input, $value, $input ); } }