Done !
| Server IP : 46.105.57.169 / Your IP : 216.73.216.67 Web Server : Apache System : Linux webm002.cluster120.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : verseaumee ( 152031) PHP Version : 8.5.7 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/verseaumee/blueversion/wp-content/plugins/wp-freeio/includes/ |
Upload File : |
<?php
/**
* Recaptcha
*
* @package wp-freeio
* @author Habq
* @license GNU General Public License, version 3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class WP_Freeio_Recaptcha {
public static function init() {
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue' ) );
}
public static function enqueue() {
if ( self::is_recaptcha_enabled() ) {
wp_enqueue_script( 'recaptcha', '//www.google.com/recaptcha/api.js', array( 'jquery' ), false, true );
}
}
public static function validate_fields( $return ) {
if ( self::is_recaptcha_enabled() ) {
$is_recaptcha_valid = array_key_exists( 'g-recaptcha-response', $_POST ) ? self::is_recaptcha_valid( sanitize_text_field( $_POST['g-recaptcha-response'] ) ) : false;
if ( !$is_recaptcha_valid ) {
return new WP_Error( 'validation-error', esc_html__( 'reCAPTCHA is a required field', 'wp-freeio' ) );
}
}
return $return;
}
/**
* Checks if reCAPTCHA is enabled
*
* @access public
* @return bool
*/
public static function is_recaptcha_enabled() {
$site_key = wp_freeio_get_option( 'recaptcha_site_key' );
$secret_key = wp_freeio_get_option( 'recaptcha_secret_key' );
if ( ! empty( $site_key ) && ! empty( $secret_key ) ) {
return true;
}
return false;
}
/**
* Checks if reCAPTCHA is valid
*
* @access public
* @param $recaptcha_response string
* @return bool
*/
public static function is_recaptcha_valid( $recaptcha_response ) {
$response = wp_remote_get(
add_query_arg(
array(
'secret' => wp_freeio_get_option( 'recaptcha_secret_key' ),
'response' => $recaptcha_response
),
'https://www.google.com/recaptcha/api/siteverify'
)
);
if ( is_wp_error( $response ) || empty( $response['body'] ) ) {
return false;
}
$json = json_decode( $response['body'] );
if ( ! $json || ! $json->success ) {
return false;
}
return true;
}
}
WP_Freeio_Recaptcha::init();