Skip to content

Commit

Permalink
re-apply WC Reg-Form fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mcguffin committed Oct 19, 2017
1 parent b9c49d0 commit ef2533b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions inc/class-wp_recaptcha_woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,16 @@ function init() {
add_filter('woocommerce_process_login_errors', array( &$this , 'login_errors' ) , 10 , 3 );
}
if ( $enable_signup ) {
// displaying the captcha at hook 'registration_form' already done by core plugin
// Injects recaptcha in Register for WooCommerce >= 3.0
// For WooCommerce < 3.0 displaying the captcha at hook 'registration_form' already done by core plugin
if ( class_exists( 'WooCommerce' ) ) {
global $woocommerce;
if ( version_compare( $woocommerce->version, '3.0', ">=" ) ) {
add_action('woocommerce_register_form' , array($wp_recaptcha,'print_recaptcha_html'),10,0);
}
}


add_filter('woocommerce_registration_errors', array( &$this , 'login_errors' ) , 10 , 3 );
// if ( ! $enable_order )
// add_filter('woocommerce_checkout_fields', array( &$this , 'checkout_fields' ) , 10 , 3 );
Expand Down Expand Up @@ -146,20 +155,20 @@ function checkout_fields( $checkout_fields ) {
* hooks into action `woocommerce_checkout_process`
*/
function recaptcha_check() {
if ( ! WP_reCaptcha::instance()->recaptcha_check() )
if ( ! WP_reCaptcha::instance()->recaptcha_check() )
wc_add_notice( __("<strong>Error:</strong> the Captcha didn’t verify.",'wp-recaptcha-integration'), 'error' );
}

/**
* WooCommerce recaptcha Check
* hooks into actions `woocommerce_process_login_errors` and `woocommerce_registration_errors`
*/
function login_errors( $validation_error ) {
if ( ! WP_reCaptcha::instance()->recaptcha_check() )
if ( ! WP_reCaptcha::instance()->recaptcha_check() )
$validation_error->add( 'captcha_error' , __("<strong>Error:</strong> the Captcha didn’t verify.",'wp-recaptcha-integration') );
return $validation_error;
}

/**
* WooCommerce recaptcha Check
* hooks into actions `woocommerce_process_login_errors` and `woocommerce_registration_errors`
Expand All @@ -170,5 +179,3 @@ function disable_on_checkout( $enabled ) {
return $enabled;
}
}


0 comments on commit ef2533b

Please sign in to comment.