diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index 331d94b9a14..1c1c6206beb 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -330,7 +330,9 @@ class WC_Checkout { * @return void */ public function process_checkout() { - wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-process_checkout' ); + if ( ! wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-process_checkout' ) ) { + return; + } if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) define( 'WOOCOMMERCE_CHECKOUT', true ); diff --git a/includes/class-wc-form-handler.php b/includes/class-wc-form-handler.php index 6cf793f61be..3173af843f7 100644 --- a/includes/class-wc-form-handler.php +++ b/includes/class-wc-form-handler.php @@ -48,7 +48,9 @@ class WC_Form_Handler { return; } - wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-edit_address' ); + if ( ! wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-edit_address' ) ) { + return; + } $user_id = get_current_user_id(); @@ -143,12 +145,10 @@ class WC_Form_Handler { return; } - if ( empty( $_POST[ 'action' ] ) || ( 'save_account_details' !== $_POST[ 'action' ] ) || empty( $_POST['_wpnonce'] ) ) { + if ( empty( $_POST[ 'action' ] ) || ( 'save_account_details' !== $_POST[ 'action' ] ) || empty( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'save_account_details' ) ) { return; } - wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-save_account_details' ); - $update = true; $errors = new WP_Error(); $user = new stdClass(); @@ -733,9 +733,7 @@ class WC_Form_Handler { * Process the login form. */ public static function process_login() { - if ( ! empty( $_POST['login'] ) && ! empty( $_POST['_wpnonce'] ) ) { - - wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-login' ); + if ( ! empty( $_POST['login'] ) && ! empty( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-login' ) ) { try { $creds = array(); @@ -809,14 +807,13 @@ class WC_Form_Handler { } // process lost password form - if ( isset( $_POST['user_login'] ) && isset( $_POST['_wpnonce'] ) ) { - wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-lost_password' ); + if ( isset( $_POST['user_login'] ) && isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'lost_password' ) ) { WC_Shortcode_My_Account::retrieve_password(); } // process reset password form - if ( isset( $_POST['password_1'] ) && isset( $_POST['password_2'] ) && isset( $_POST['reset_key'] ) && isset( $_POST['reset_login'] ) && isset( $_POST['_wpnonce'] ) ) { + if ( isset( $_POST['password_1'] ) && isset( $_POST['password_2'] ) && isset( $_POST['reset_key'] ) && isset( $_POST['reset_login'] ) && isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'reset_password' ) ) { // verify reset key again $user = WC_Shortcode_My_Account::check_password_reset_key( $_POST['reset_key'], $_POST['reset_login'] ); @@ -827,8 +824,6 @@ class WC_Form_Handler { $args['key'] = wc_clean( $_POST['reset_key'] ); $args['login'] = wc_clean( $_POST['reset_login'] ); - wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-reset_password' ); - if ( empty( $_POST['password_1'] ) || empty( $_POST['password_2'] ) ) { wc_add_notice( __( 'Please enter your password.', 'woocommerce' ), 'error' ); $args['form'] = 'reset_password'; @@ -865,9 +860,7 @@ class WC_Form_Handler { * Process the registration form. */ public static function process_registration() { - if ( ! empty( $_POST['register'] ) ) { - - wp_verify_nonce( $_POST['register'], 'woocommerce-register' ); + if ( ! empty( $_POST['register'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-register' ) ) { if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) { $_username = $_POST['username']; diff --git a/includes/class-wc-product-variation.php b/includes/class-wc-product-variation.php index 00bc751ddf0..e4c49799074 100644 --- a/includes/class-wc-product-variation.php +++ b/includes/class-wc-product-variation.php @@ -276,6 +276,27 @@ class WC_Product_Variation extends WC_Product { return $this->variation_data; } + /** + * Check if all variation's attributes are set + * + * @return boolean + */ + public function has_all_attributes_set() { + + $set = true; + + // undefined attributes have null strings as array values + foreach( $this->get_variation_attributes() as $att ){ + if( ! $att ){ + $set = false; + break; + } + } + + return $set; + + } + /** * Get variation price HTML. Prices are not inherited from parents. * diff --git a/includes/gateways/bacs/class-wc-gateway-bacs.php b/includes/gateways/bacs/class-wc-gateway-bacs.php index 319b3ddf636..3922a74f70a 100644 --- a/includes/gateways/bacs/class-wc-gateway-bacs.php +++ b/includes/gateways/bacs/class-wc-gateway-bacs.php @@ -9,18 +9,18 @@ if ( ! defined( 'ABSPATH' ) ) { * * Provides a Bank Transfer Payment Gateway. Based on code by Mike Pepper. * - * @class WC_Gateway_BACS - * @extends WC_Payment_Gateway - * @version 2.1.0 - * @package WooCommerce/Classes/Payment - * @author WooThemes + * @class WC_Gateway_BACS + * @extends WC_Payment_Gateway + * @version 2.1.0 + * @package WooCommerce/Classes/Payment + * @author WooThemes */ class WC_Gateway_BACS extends WC_Payment_Gateway { - /** - * Constructor for the gateway. - */ - public function __construct() { + /** + * Constructor for the gateway. + */ + public function __construct() { $this->id = 'bacs'; $this->icon = apply_filters('woocommerce_bacs_icon', ''); $this->has_fields = false; @@ -31,7 +31,7 @@ class WC_Gateway_BACS extends WC_Payment_Gateway { $this->init_form_fields(); $this->init_settings(); - // Define user set variables + // Define user set variables $this->title = $this->get_option( 'title' ); $this->description = $this->get_option( 'description' ); $this->instructions = $this->get_option( 'instructions', $this->description ); @@ -53,17 +53,17 @@ class WC_Gateway_BACS extends WC_Payment_Gateway { // Actions add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'save_account_details' ) ); - add_action( 'woocommerce_thankyou_bacs', array( $this, 'thankyou_page' ) ); + add_action( 'woocommerce_thankyou_bacs', array( $this, 'thankyou_page' ) ); - // Customer Emails - add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); - } + // Customer Emails + add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); + } - /** - * Initialise Gateway Settings Form Fields - */ - public function init_form_fields() { - $this->form_fields = array( + /** + * Initialise Gateway Settings Form Fields + */ + public function init_form_fields() { + $this->form_fields = array( 'enabled' => array( 'title' => __( 'Enable/Disable', 'woocommerce' ), 'type' => 'checkbox', @@ -95,88 +95,88 @@ class WC_Gateway_BACS extends WC_Payment_Gateway { 'type' => 'account_details' ), ); - } + } - /** - * generate_account_details_html function. - */ - public function generate_account_details_html() { - ob_start(); - ?> -