| Server IP : 172.67.162.67 / Your IP : 216.73.216.222 Web Server : Apache System : Linux vps42439 6.8.0-136-generic #136~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 3 16:29:11 UTC x86_64 User : dh_7hi3h9 ( 6349477) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/dh_7hi3h9/regalflower.com/wp-content/themes/temp_thestory/lib/ |
Upload File : |
<?php
class PexetoRecaptcha{
protected static $initialized = false;
public static function init(){
if(!self::$initialized){
add_action('wp_enqueue_scripts', array('PexetoRecaptcha', 'load_scripts'));
add_action('admin_init', array('PexetoRecaptcha', 'show_notice'));
self::$initialized = true;
}
}
public static function is_enabled(){
return pexeto_option('captcha') === true && self::are_api_keys_set();
}
public static function are_api_keys_set(){
$keys = self::get_api_keys();
if(empty($keys['site']) || empty($keys['secret'])){
return false;
}
return true;
}
public static function get_api_keys(){
return array(
'site' => pexeto_option('captcha_v2_site_key'),
'secret' => pexeto_option('captcha_v2_secret_key')
);
}
public static function load_scripts(){
if(is_page_template('template-contact.php') && self::is_enabled()){
$url = 'https://www.google.com/recaptcha/api.js';
$language = pexeto_option('captcha_v2_language_code');
if(!empty($language)){
$url.='?hl='.$language;
}
wp_enqueue_script('pexeto_recaptcha', $url);
}
}
/**
* Shows a notice to notify the users about the new version of captcha in case they
* are using captcha but don't have the v2 API keys enabled
*/
public static function show_notice(){
if(pexeto_option('captcha') === true && !self::are_api_keys_set()){
$v1_public_key = pexeto_option('captcha_public_key');
if(!empty($v1_public_key)){
$content = 'The contact form reCaptcha has been updated to version 2, which requires generating new API keys.
Please go to <strong>'.PEXETO_THEMENAME.' Options » General Settings
» Contact Form</strong> and enter your new reCaptcha version 2 API keys
in order to continue using captcha in your contact form.
<br>For more information please refer to the <a href="http://pexetothemes.com/docs/story/#contact">Contact form section</a> of the documentation.';
PexetoNotice::create('alert', $content, 'captchakeys');
}
}
}
public static function validate_response(){
if (self::is_enabled() && !(isset($_POST['widget']) && $_POST['widget']=='true') && empty($_POST['g-recaptcha-response'])){
return false;
}
return true;
}
}
PexetoRecaptcha::init();