PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.5.2
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.5.2
3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / includes / fields / class-evf-field-captcha.php
everest-forms / includes / fields Last commit date
class-evf-field-address.php 1 year ago class-evf-field-ai.php 1 year ago class-evf-field-captcha.php 4 weeks ago class-evf-field-checkbox.php 2 months ago class-evf-field-color.php 4 weeks ago class-evf-field-country.php 2 months ago class-evf-field-credit-card.php 4 weeks ago class-evf-field-date-time.php 4 weeks ago class-evf-field-divider.php 2 years ago class-evf-field-email.php 1 year ago class-evf-field-file-upload.php 1 year ago class-evf-field-first-name.php 1 year ago class-evf-field-hcaptcha.php 4 months ago class-evf-field-hidden.php 1 year ago class-evf-field-html.php 9 months ago class-evf-field-image-upload.php 1 year ago class-evf-field-last-name.php 1 year ago class-evf-field-likert.php 1 year ago class-evf-field-lookup.php 4 weeks ago class-evf-field-number.php 1 year ago class-evf-field-password.php 4 weeks ago class-evf-field-payment-authorize-net.php 4 weeks ago class-evf-field-payment-checkbox.php 4 weeks ago class-evf-field-payment-coupon.php 4 weeks ago class-evf-field-payment-gateway-selector.php 4 weeks ago class-evf-field-payment-quantity.php 4 weeks ago class-evf-field-payment-radio.php 4 weeks ago class-evf-field-payment-single.php 4 weeks ago class-evf-field-payment-square.php 1 year ago class-evf-field-payment-subscription-plan.php 4 weeks ago class-evf-field-payment-subtotal.php 4 weeks ago class-evf-field-payment-total.php 4 weeks ago class-evf-field-phone.php 1 year ago class-evf-field-privacy-policy.php 2 months ago class-evf-field-private-note.php 1 year ago class-evf-field-progress.php 4 weeks ago class-evf-field-radio.php 2 months ago class-evf-field-range-slider.php 4 weeks ago class-evf-field-rating.php 2 months ago class-evf-field-recaptcha.php 4 months ago class-evf-field-repeater.php 4 weeks ago class-evf-field-reset.php 4 weeks ago class-evf-field-scale-rating.php 1 year ago class-evf-field-select.php 1 year ago class-evf-field-signature.php 4 weeks ago class-evf-field-text.php 1 year ago class-evf-field-textarea.php 1 year ago class-evf-field-title.php 2 years ago class-evf-field-turnstile.php 4 months ago class-evf-field-url.php 1 year ago class-evf-field-wysiwyg.php 2 months ago class-evf-field-yes-no.php 1 year ago payment-amount-helpers.php 4 weeks ago
class-evf-field-captcha.php
206 lines
1 <?php
2 /**
3 * Captcha field
4 *
5 * @package EverestForms\Fields
6 * @since 1.6.5
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * EVF_Field_Captcha Class.
13 */
14 class EVF_Field_Captcha extends EVF_Form_Fields {
15
16 /**
17 * Math equation and operators.
18 *
19 * @var array
20 */
21 public $math;
22
23 /**
24 * Captcha questions to ask for.
25 *
26 * @var array
27 */
28 public $questions;
29
30 /**
31 * Constructor.
32 */
33 public function __construct() {
34 $this->name = esc_html__( 'Math Captcha', 'everest-forms' );
35 $this->type = 'captcha';
36 $this->icon = 'evf-icon evf-icon-captcha';
37 $this->order = 255;
38 $this->group = 'advanced';
39 $this->is_pro = true;
40 $this->plan = 'personal agency themegrill-agency';
41 $this->addon = 'everest-forms-captcha';
42 $this->links = array(
43 'image_id' => '',
44 'vedio_id' => 'obScswjZ24Q',
45 );
46 $this->settings = array(
47 'basic-options' => array(
48 'field_options' => array(
49 'label',
50 'captcha',
51 'description',
52 ),
53 ),
54 'advanced-options' => array(
55 'field_options' => array(
56 'placeholder',
57 'label_hide',
58 'css',
59 ),
60 ),
61 );
62
63 // Allow customizing math captcha.
64 $this->math = apply_filters(
65 'everest_forms_math_captcha',
66 array(
67 'min' => 1,
68 'max' => 15,
69 'cal' => array( '+', '*' ),
70 )
71 );
72
73 // Allow for additional questions or customizing captcha questions.
74 $this->questions = apply_filters(
75 'everest_forms_default_captcha_questions',
76 array(
77 1 => array(
78 'question' => esc_html__( 'What is 2+3?', 'everest-forms' ),
79 'answer' => esc_html__( '5', 'everest-forms' ),
80 ),
81 )
82 );
83
84 parent::__construct();
85 }
86
87 /**
88 * Captcha Format and questions.
89 *
90 * @param array $field Field Data.
91 */
92 public function captcha( $field ) {
93 $format = ! empty( $field['format'] ) ? esc_attr( $field['format'] ) : 'math';
94 $questions = ! empty( $field['questions'] ) ? $field['questions'] : $this->questions;
95
96 // Field is always required.
97 $this->field_element(
98 'text',
99 $field,
100 array(
101 'type' => 'hidden',
102 'slug' => 'required',
103 'value' => '1',
104 )
105 );
106
107 // Format.
108 $format_label = $this->field_element(
109 'label',
110 $field,
111 array(
112 'slug' => 'format',
113 'value' => esc_html__( 'Format', 'everest-forms' ),
114 'tooltip' => sprintf( esc_html__( 'Choose a captcha format to be displayed on frontend.', 'everest-forms' ) ),
115 ),
116 false
117 );
118 $format_select = $this->field_element(
119 'select',
120 $field,
121 array(
122 'slug' => 'format',
123 'value' => $format,
124 'options' => array(
125 'math' => esc_html__( 'Math', 'everest-forms' ),
126 'question' => esc_html__( 'Question and Answer', 'everest-forms' ),
127 ),
128 ),
129 false
130 );
131
132 $this->field_element(
133 'row',
134 $field,
135 array(
136 'slug' => 'format',
137 'content' => $format_label . $format_select,
138 )
139 );
140
141 // Questions.
142 $questions_label = $this->field_element(
143 'label',
144 $field,
145 array(
146 'slug' => 'questions',
147 'value' => esc_html__( 'Questions and Answers', 'everest-forms' ),
148 'tooltip' => sprintf( esc_html__( 'Add multiple questions below to ask the user. We will select questions randomly.', 'everest-forms' ) ),
149 ),
150 false
151 );
152 $questions_field = sprintf(
153 '<ul data-next-id="%s" class="evf-questions-list" data-field-id="%s" data-field-type="%s">',
154 max( array_keys( $questions ) ) + 1,
155 esc_attr( $field['id'] ),
156 esc_attr( $this->type )
157 );
158 foreach ( $questions as $key => $value ) {
159 $questions_field .= '<li data-key="' . absint( $key ) . '">';
160 $questions_field .= sprintf( '<div class="question-wrap"><input type="text" name="form_fields[%s][questions][%s][question]" value="%s" class="question" placeholder="%s"><a class="add" href="#"><i class="dashicons dashicons-plus"></i></a></div>', $field['id'], $key, esc_attr( $value['question'] ), esc_html__( 'Question', 'everest-forms' ) );
161 $questions_field .= sprintf( '<div class="answer-wrap"><input type="text" name="form_fields[%s][questions][%s][answer]" value="%s" class="answer" placeholder="%s"><a class="remove" href="#"><i class="dashicons dashicons-minus"></i></a></div>', $field['id'], $key, esc_attr( $value['answer'] ), esc_html__( 'Answer', 'everest-forms' ) );
162 $questions_field .= '</li>';
163 }
164 $questions_field .= '</ul>';
165
166 $this->field_element(
167 'row',
168 $field,
169 array(
170 'slug' => 'questions',
171 'content' => $questions_label . $questions_field,
172 'class' => 'math' === $format ? 'everest-forms-hidden' : '',
173 )
174 );
175 }
176
177 /**
178 * Field preview inside the builder.
179 *
180 * @param array $field Field data and settings.
181 */
182 public function field_preview( $field ) {
183 $placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
184 $format = ! empty( $field['format'] ) ? $field['format'] : 'math';
185 $number1 = wp_rand( $this->math['min'], $this->math['max'] );
186 $number2 = wp_rand( $this->math['min'], $this->math['max'] );
187 $cal = $this->math['cal'][ wp_rand( 0, count( $this->math['cal'] ) - 1 ) ];
188 $questions = ! empty( $field['questions'] ) ? $field['questions'] : $this->questions;
189 $question = current( $questions );
190
191 // Label.
192 $this->field_preview_option( 'label', $field );
193 ?>
194 <div class="format-selected format-selected-<?php echo esc_attr( $format ); ?>">
195 <span class="everest-forms-equation">
196 <?php printf( '%s %s %s = ', $number1, $cal, $number2 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
197 </span>
198 <p class="everest-forms-question"><?php echo esc_html( $question['question'] ); ?></p>
199 <input type="text" placeholder="<?php echo esc_attr( $placeholder ); ?>" class="widefat" disabled>
200 </div>
201 <?php
202 // Description.
203 $this->field_preview_option( 'description', $field );
204 }
205 }
206