From 27ff97be8fcc0a5da0b21591aacc2e0f00408ac3 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 10 Oct 2017 12:58:45 -0400 Subject: [PATCH] Update the functions file for reCaptcha. Save captcha in session. This will allow someone to have submit errors then be able to pass the reCaptcha test next time they submit. --- functions.php | 26 ++++++++++++++++++++++++++ style.css | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index 2392978..4935ba2 100755 --- a/functions.php +++ b/functions.php @@ -314,4 +314,30 @@ function custom_wc_checkout_fields( $fields ) { } add_filter( 'woocommerce_checkout_fields' , 'custom_wc_checkout_fields' ); + +// Dissable captch if it has been solved once using session +// safely start a session +function my_session_start( ) { + $sid = session_id(); + if ( empty( $sid ) ) { + session_start(); + } +} +add_action('init','my_session_start',1); + +// don't requiere captcha, if session says so +function my_wp_recaptcha_required( $is_required ) { + if ( isset( $_SESSION['recaptcha_solved'] ) && $_SESSION['recaptcha_solved'] ) + return false; + return $is_required; +} +add_filter('wp_recaptcha_required' , 'my_wp_recaptcha_required'); + +// store in session if captcha solved +function my_wp_recaptcha_checked( $check_successful ) { + if ( $check_successful ) + $_SESSION['recaptcha_solved'] = true; +} +add_action('wp_recaptcha_checked','my_wp_recaptcha_checked'); + ?> diff --git a/style.css b/style.css index 89eea28..cbc8f17 100755 --- a/style.css +++ b/style.css @@ -3,5 +3,5 @@ Theme Name: Tom's Mom's Cookies Author: Gaslight Media Author URI: http://www.gaslightmedia.com Description: A theme made for Tom's Mom's Cookies. -Version: 1.0.20 +Version: 1.0.21 */ -- 2.17.1