verify = new Verify();
}
protected static function get_adcaptcha_name() {
return 'adCAPTCHA';
}
public static function get_setup_message() {
return esc_html__( 'Please enter your adCAPTCHA API Key and Placement ID in the adCAPTCHA settings.', 'elementor-pro' );
}
public function setup() {
add_filter( 'elementor_pro/forms/field_types', [ $this, 'add_field_type' ] );
add_filter( 'elementor_pro/forms/render/item', [ $this, 'filter_field_item' ] );
add_action( 'elementor_pro/forms/render_field/' . static::get_adcaptcha_name(), [ $this, 'render_field' ], 10, 3 );
add_action(
'elementor/element/form/section_form_fields/after_section_end',
[ $this, 'update_controls' ],
10,
2
);
add_action( 'wp_enqueue_scripts', [ AdCaptcha::class, 'enqueue_scripts' ], 9 );
add_action( 'wp_enqueue_scripts', [ $this, 'reset_captcha_script' ], 9 );
add_action( 'elementor/preview/enqueue_scripts', [ AdCaptcha::class, 'enqueue_scripts' ] );
add_action( 'wp_enqueue_scripts', [ Verify::class, 'get_success_token' ] );
add_action( 'elementor_pro/forms/validation', [ $this, 'verify' ], 10, 2 );
if ( \is_admin() ) {
add_action( 'elementor/admin/after_create_settings/' . 'elementor', [ $this, 'register_admin_fields' ] );
}
}
public function register_admin_fields() {
ElementorPlugin::$instance->settings->add_section(
'integrations',
static::get_adcaptcha_name(),
[
'label' => esc_html__( static::get_adcaptcha_name(), 'adcaptcha' ),
'callback' => function () {
echo sprintf(
esc_html__( '%1$sadCAPTCHA%2$s is the first CAPTCHA product which combines technical security features with a brands own media to block Bots and identify human verified users.', 'elementor-pro' ) . '
',
'',
''
);
echo sprintf(
'%2$s',
esc_url('/adcaptcha/wp-admin/options-general.php?page=adcaptcha'),
esc_html__('Click to configure adCAPTCHA', 'elementor-pro')
);
},
]
);
}
public function reset_captcha_script() {
wp_add_inline_script( 'adcaptcha-script', 'document.addEventListener("submit", function(event) { ' . AdCaptcha::setupScript() . ' window.adcap.successToken = ""; }, false);' );
}
public function render_field( $item, $item_index, $widget ) {
$html = '