PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.32.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.32.1
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / models / FrmRecaptchaSettings.php

FrmRecaptchaSettings.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.32.1, at classes/models/FrmRecaptchaSettings.php

144 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 /**
7 * @since 6.8.4
8 */
9 class FrmRecaptchaSettings extends FrmFieldCaptchaSettings {
10
11 /**
12 * @since 6.8.4
13 *
14 * @return void
15 */
16 protected function set_endpoint() {
17 $this->endpoint = 'https://www.google.com/recaptcha/api/siteverify';
18 }
19
20 /**
21 * @since 6.11.1
22 *
23 * @return string
24 */
25 public function get_name() {
26 return 'reCAPTCHA';
27 }
28
29 /**
30 * @since 6.8.4
31 *
32 * @return string
33 */
34 public function get_element_class_name() {
35 return 'g-recaptcha';
36 }
37
38 /**
39 * @since 6.8.4
40 *
41 * @return string
42 */
43 public function get_documentation_url() {
44 return 'https://www.google.com/recaptcha/';
45 }
46
47 /**
48 * @since 6.8.4
49 *
50 * @return string
51 */
52 public function get_site_key_tooltip() {
53 return __( 'reCAPTCHA is a free, accessible CAPTCHA service that helps to digitize books while blocking spam on your blog. reCAPTCHA asks commenters to retype two words scanned from a book to prove that they are a human. This verifies that they are not a spambot.', 'formidable' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
54 }
55
56 /**
57 * Add additional element attributes for reCAPTCHA.
58 *
59 * @since 6.8.4
60 *
61 * @param array $attributes
62 * @param array $field
63 *
64 * @return array
65 */
66 public function add_front_end_element_attributes( $attributes, $field ) {
67 $attributes = parent::add_front_end_element_attributes( $attributes, $field );
68 $captcha_size = $attributes['data-size'];
69
70 if ( $captcha_size === 'invisible' && ! $this->frm_settings->re_multi ) {
71 $attributes['data-callback'] = 'frmAfterRecaptcha';
72 }
73
74 return $attributes;
75 }
76
77 /**
78 * @since 6.8.4
79 *
80 * @param array $field
81 *
82 * @return string
83 */
84 protected function get_captcha_size( $field ) {
85 if ( $this->captcha_is_invisible() ) {
86 return 'invisible';
87 }
88 return parent::get_captcha_size( $field );
89 }
90
91 /**
92 * Show the Captcha field size setting if the captcha is visible.
93 *
94 * @since 6.8.4
95 *
96 * @return bool
97 */
98 public function should_show_captcha_size() {
99 return ! $this->captcha_is_invisible();
100 }
101
102 /**
103 * @since 6.8.4
104 *
105 * @return bool
106 */
107 public function should_show_captcha_theme() {
108 return ! $this->captcha_is_invisible();
109 }
110
111 /**
112 * @since 6.8.4
113 *
114 * @return bool
115 */
116 private function captcha_is_invisible() {
117 return in_array( $this->frm_settings->re_type, array( 'invisible', 'v3' ), true );
118 }
119
120 /**
121 * Only add the "frm-" prefix if multiple reCAPTCHA fields are allowed.
122 *
123 * @since 6.25.1
124 *
125 * @param bool $allow_multiple
126 *
127 * @return string
128 */
129 public function get_class_prefix( $allow_multiple ) {
130 return $allow_multiple ? 'frm-' : '';
131 }
132
133 /**
134 * @since 6.8.4
135 * @deprecated 6.11.1
136 *
137 * @return string
138 */
139 public function getName() {
140 _deprecated_function( __METHOD__, '6.11.1' );
141 return $this->get_name();
142 }
143 }
144