public_key = $site_key;
$this->private_key = $secret_key;
$this->acl_gcaptcha_theme = $acl_gcaptcha_theme;
// adds the captcha to the login form
add_action( 'login_form', array( $this, 'captcha_display' ) );
// authenticate the captcha answer
add_action( 'wp_authenticate_user', array( $this, 'validate_captcha_field' ), 10, 2 );
}
/** Output the ACL_gcaptcha form field. */
public function captcha_display() {
if($this->acl_gcaptcha_theme=="yes"){
$acl_gcaptcha_theme="light";
} else {
$acl_gcaptcha_theme="dark";
}
?>
success && $response1->score ){
if($response1->success!=false && $response1->score < 0.5){
//var_dump($response1);
return new WP_Error( 'empty_captcha', 'ERROR:You are a robot' );
}else{
return $user;
}
}else{
return new WP_Error( 'empty_captcha', 'ERROR: Please Enter the reCaptcha valid Key' );
}
}
}
/**
* Send a GET request to verify captcha challenge
*
* @return bool
*/
public static function captcha_verification() {
$response = isset( $_POST['g-recaptcha-response'] ) ? esc_attr( $_POST['g-recaptcha-response'] ) : '';
$remote_ip = $_SERVER["REMOTE_ADDR"];
// make a GET request to the Google reCAPTCHA Server
$g_page = unserialize(get_option('Admin_custome_login_gcaptcha'));
if(isset($g_page['site_key']) && isset($g_page['secret_key'])){
$site_key = $g_page['site_key'];
$secret_key = $g_page['secret_key'];
} else {
$site_key = '';
$secret_key = '';
}
$request = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret_key.'&response='.$response.'');
// get the request response body
echo('');
$return = json_decode( $request );
return $return;
}
}
new ACL_gcaptcha_Login_Form();
?>