PATH:
home
/
centosnipponia
/
public_html
/
nipponiacar
/
wp-content
/
plugins
/
ninja-forms
/
includes
/
Fields
<?php if ( ! defined( 'ABSPATH' ) ) exit; /** * Class NF_Fields_Recaptcha */ class NF_Fields_Recaptcha extends NF_Abstracts_Field { protected $_name = 'recaptcha'; protected $_type = 'recaptcha'; protected $_section = 'misc'; protected $_icon = 'filter'; protected $_templates = 'recaptcha'; protected $_test_value = ''; protected $_settings = array( 'label', 'classes' ); public function __construct() { parent::__construct(); $this->_nicename = esc_html__( 'Recaptcha v2', 'ninja-forms' ); $this->_settings[ 'size '] = array( 'name' => 'size', 'type' => 'select', 'label' => esc_html__( 'Visibility', 'ninja-forms' ), 'options' => array( array( 'label' => esc_html__( 'Visible', 'ninja-forms' ), 'value' => 'visible' ), array( 'label' => esc_html__( 'Invisible', 'ninja-forms' ), 'value' => 'invisible' ), ), 'width' => 'one-half', 'group' => 'primary', 'value' => 'visible', 'help' => esc_html__( 'Select whether to display a "I\'m not a robot" field or to detect if the user is a robot in the background.', 'ninja-forms' ), ); add_filter( 'nf_sub_hidden_field_types', array( $this, 'hide_field_type' ) ); } public function localize_settings( $settings, $form ) { $settings['site_key'] = !empty(Ninja_Forms()->get_setting( 'recaptcha_site_key' )) ? Ninja_Forms()->get_setting( 'recaptcha_site_key' ) : Ninja_Forms()->get_setting( 'recaptcha_site_key_v3' ); $settings['theme'] = Ninja_Forms()->get_setting( 'recaptcha_theme' ); $settings['theme'] = ( $settings['theme'] ) ? $settings['theme'] : 'light'; $settings['lang'] = Ninja_Forms()->get_setting( 'recaptcha_lang' ); return $settings; } public function validate( $field, $data ) { if ( empty( $field['value'] ) ) { return esc_html__( 'Please complete the recaptcha', 'ninja-forms' ); } $secret_key = !empty(Ninja_Forms()->get_setting( 'recaptcha_secret_key' )) ? Ninja_Forms()->get_setting( 'recaptcha_secret_key' ) : Ninja_Forms()->get_setting( 'recaptcha_secret_key_v3' ); $url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . $secret_key . '&response='.sanitize_text_field( $field['value'] ); $resp = wp_remote_get( esc_url_raw( $url ) ); if ( !is_wp_error( $resp ) ) { $body = wp_remote_retrieve_body( $resp ); $response = json_decode( $body ); if ( $response->success === false ) { if ( !empty( $response->{'error-codes'} ) && $response->{'error-codes'} != 'missing-input-response' ) { return array( esc_html__( 'Please make sure you have entered your Site & Secret keys correctly', 'ninja-forms' ) ); }else { return array( esc_html__( 'Captcha mismatch. Please enter the correct value in captcha field', 'ninja-forms' ) ); } } } } function hide_field_type( $field_types ) { $field_types[] = $this->_name; return $field_types; } }
[+]
..
[-] Address2.php
[edit]
[-] Address.php
[edit]
[-] Button.php
[edit]
[-] Checkbox.php
[edit]
[-] City.php
[edit]
[-] Color.php
[edit]
[-] Confirm.php
[edit]
[-] CreditCardCVC.php
[edit]
[-] CreditCardExpiration.php
[edit]
[-] CreditCardFullName.php
[edit]
[-] CreditCardNumber.php
[edit]
[-] CreditCard.php
[edit]
[-] CreditCardZip.php
[edit]
[-] Date.php
[edit]
[-] Email.php
[edit]
[-] FirstName.php
[edit]
[-] Hcaptcha.php
[edit]
[-] Hidden.php
[edit]
[-] hr.php
[edit]
[-] HTML.php
[edit]
[-] LastName.php
[edit]
[-] ListCheckbox.php
[edit]
[-] ListCountry.php
[edit]
[-] ListImage.php
[edit]
[-] ListModifier.php
[edit]
[-] ListMultiSelect.php
[edit]
[-] ListRadio.php
[edit]
[-] ListSelect.php
[edit]
[-] ListState.php
[edit]
[-] Note.php
[edit]
[-] Number.php
[edit]
[-] PasswordConfirm.php
[edit]
[-] Password.php
[edit]
[-] Phone.php
[edit]
[-] Product.php
[edit]
[-] Quantity.php
[edit]
[-] Recaptcha.php
[edit]
[-] RecaptchaV3.php
[edit]
[-] Repeater.php
[edit]
[-] Shipping.php
[edit]
[-] Signature.php
[edit]
[-] Spam.php
[edit]
[-] StarRating.php
[edit]
[-] Submit.php
[edit]
[-] Terms.php
[edit]
[-] Textarea.php
[edit]
[-] Textbox.php
[edit]
[-] TimedSubmit.php
[edit]
[-] Total.php
[edit]
[-] Turnstile.php
[edit]
[-] Unknown.php
[edit]
[-] Zip.php
[edit]
[-] .htaccess.disabled
[edit]