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-lookup.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-lookup.php
316 lines
1 <?php
2 /**
3 * Lookup field
4 *
5 * @package EverestForms\Fields
6 * @since 1.6.7.1
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * EVF_Field_Lookup Class.
13 *
14 * Builder-scope (read-only) version shipped in the free plugin so the field can
15 * be shown LOCKED — with its real preview and readable settings — for the AI
16 * upsell. The full functional implementation (front-end display, validation,
17 * AJAX filters, entry processing) lives in Everest Forms Pro, whose class loads
18 * in place of this one when the plugin is active (this file is only autoloaded
19 * when that class is not already defined). Keep `is_pro = true` so the field
20 * stays locked.
21 */
22 class EVF_Field_Lookup extends EVF_Form_Fields {
23
24 /**
25 * Constructor.
26 */
27 public function __construct() {
28 $this->name = esc_html__( 'Lookup', 'everest-forms' );
29 $this->type = 'lookup';
30 $this->icon = 'evf-icon evf-icon-lookup';
31 $this->order = 250;
32 $this->group = 'advanced';
33 $this->is_pro = true;
34 $this->links = array(
35 'image_id' => '',
36 'vedio_id' => '8hFSI5-Gf_U',
37 );
38 $this->settings = array(
39 'basic-options' => array(
40 'field_options' => array(
41 'label',
42 'description',
43 'required',
44 'required_field_message_setting',
45 'required_field_message',
46 'choose_lookup_format',
47 ),
48 ),
49 'advanced-options' => array(
50 'field_options' => array(
51 'meta',
52 'lookup_options',
53 'placeholder',
54 'label_hide',
55 'css',
56 'field_visiblity',
57 ),
58 ),
59 );
60 parent::__construct();
61 }
62
63 /**
64 * Lookup field format option.
65 *
66 * @since 1.6.7.1
67 * @param array $field Field Data.
68 */
69 public function choose_lookup_format( $field ) {
70 $format = ! empty( $field['lookup_format'] ) ? esc_attr( $field['lookup_format'] ) : 'dropdown';
71 $format_label = $this->field_element(
72 'label',
73 $field,
74 array(
75 'slug' => 'lookup_format',
76 'value' => __( 'Lookup Format', 'everest-forms' ),
77 'tooltip' => __( 'Select a format to display the lookup data.', 'everest-forms' ),
78 ),
79 false
80 );
81 $format_select = $this->field_element(
82 'select',
83 $field,
84 array(
85 'slug' => 'lookup_format',
86 'value' => $format,
87 'options' => array(
88 'dropdown' => __( 'Dropdown', 'everest-forms' ),
89 ),
90 ),
91 false
92 );
93 $args = array(
94 'slug' => 'lookup_format',
95 'content' => $format_label . $format_select,
96 );
97 $this->field_element( 'row', $field, $args );
98 }
99
100 /**
101 * To get form list.
102 */
103 private function evf_form_list() {
104 $current_form_id = isset( $_REQUEST['form_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['form_id'] ) ) : '';// phpcs:ignore WordPress.Security.NonceVerification
105 $args = array(
106 'post_type' => 'everest_form',
107 );
108
109 $posts = get_posts( $args );
110 $form_list = array( 'none' => esc_html__( '---Select Form---', 'everest-forms' ) );
111
112 foreach ( $posts as $post ) {
113 if ( $current_form_id == $post->ID ) {
114 continue;
115 }
116 $form_list[ $post->ID ] = $post->post_title;
117 }
118
119 return $form_list;
120 }
121
122 /**
123 * Form's field list.
124 *
125 * @param int $form_id form id.
126 */
127 private function get_form_fields( $form_id ) {
128 $lookup_field_name_option_list = array(
129 'none' => __( '---Select Field---', 'everest-forms' ),
130 );
131 if ( ! empty( $form_id ) && 'none' !== $form_id ) {
132 $form = json_decode( get_post_field( 'post_content', $form_id ) );
133 $exclude_field = array( 'image-upload', 'signature' );
134 $form_arr = isset( $form->form_fields ) ? (array) $form->form_fields : array();
135 foreach ( $form_arr as $key => $value ) {
136 if ( in_array( $value->type, $exclude_field, true ) ) {
137 continue;
138 }
139 $lookup_field_name_option_list[ $key ] = $value->label;
140 }
141 }
142 return $lookup_field_name_option_list;
143 }
144
145 /**
146 * Lookup Options.
147 *
148 * @since 1.6.7.1
149 * @param array $field Field Data.
150 */
151 public function lookup_options( $field ) {
152
153 $lookup_options_label = $this->field_element(
154 'label',
155 $field,
156 array(
157 'slug' => 'lookup_options',
158 'value' => __( 'Lookup Options', 'everest-forms' ),
159 'tooltip' => __( 'Select the form and field for lookup the data.', 'everest-forms' ),
160 ),
161 false
162 );
163
164 $args = array(
165 'slug' => 'lookup_option_lists`',
166 'content' => $lookup_options_label,
167 );
168 $this->field_element( 'row', $field, $args );
169 // select form.
170 echo '<div class="format-selected-lookup format-selected">';
171 echo '<div class="everest-forms-border-container everest-forms-lookup">';
172 echo '<h4 class="everest-forms-border-container-title">' . esc_html__( 'Lookup Options', 'everest-forms' ) . '</h4>'; // phpcs:ignore WordPress.Security.NonceVerification
173 $lookup_form_name = ! empty( $field['lookup_form_name'] ) ? esc_attr( $field['lookup_form_name'] ) : '';
174 $lookup_form_name_option_label = $this->field_element(
175 'label',
176 $field,
177 array(
178 'slug' => 'lookup_form_name_option',
179 'value' => __( 'Select Form', 'everest-forms' ),
180 'class' => 'evf-lookup-form-name-label',
181 'tooltip' => __( 'Select the form for lookup the data.', 'everest-forms' ),
182 ),
183 false
184 );
185 $lookup_form_name_option_select = $this->field_element(
186 'select',
187 $field,
188 array(
189 'slug' => 'lookup_form_name',
190 'value' => $lookup_form_name,
191 'class' => 'evf-lookup-form-name-select',
192 'options' => self::evf_form_list(),
193 ),
194 false
195 );
196
197 // Select field.
198 $lookup_field_name = ! empty( $field['lookup_field_name'] ) ? esc_attr( $field['lookup_field_name'] ) : array( 'none' );
199 $lookup_field_name_option_list = self::get_form_fields( $lookup_form_name );
200 $lookup_field_name_option_label = $this->field_element(
201 'label',
202 $field,
203 array(
204 'slug' => 'lookup_form_field_option',
205 'value' => __( 'Select Field', 'everest-forms' ),
206 'class' => 'evf-lookup-field-name-label',
207 'tooltip' => __( 'Select the field for lookup the data.', 'everest-forms' ),
208 ),
209 false
210 );
211 $lookup_field_name_option_select = $this->field_element(
212 'select',
213 $field,
214 array(
215 'slug' => 'lookup_field_name',
216 'value' => $lookup_field_name,
217 'class' => 'evf-lookup-field-name-select',
218 'options' => $lookup_field_name_option_list,
219 ),
220 false
221 );
222
223 // Lookup filter by field.
224 $lookup_filter_by_field = isset( $field['lookup_filter_by_field_name'] ) ? $field['lookup_filter_by_field_name'] : array();
225 $lookup_filter_by_fields = array();
226 if ( isset( $_REQUEST['form_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
227 $form_id = sanitize_text_field( wp_unslash( $_REQUEST['form_id'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
228 $form = json_decode( get_post_field( 'post_content', $form_id ) );
229 $form_arr = (array) $form->form_fields;
230 foreach ( $form_arr as $key => $value ) {
231 if ( $field['id'] === $key ) {
232 continue;
233 }
234 if ( 'lookup' === $value->type ) {
235 $lookup_filter_by_fields[ $key ] = $value->label;
236 }
237 }
238 }
239 $lookup_filter_by_field_option_label = $this->field_element(
240 'label',
241 $field,
242 array(
243 'slug' => 'lookup_filter_by_field_option',
244 'value' => __( 'Filter By Lookup Field', 'everest-forms' ),
245 'tooltip' => __( 'Select the fields to filter the lookup the data.', 'everest-forms' ),
246 ),
247 false
248 );
249 $lookup_filter_by_field_option_select = $this->field_element(
250 'select',
251 $field,
252 array(
253 'slug' => 'lookup_filter_by_field_name',
254 'value' => $lookup_filter_by_field,
255 'multiple' => true,
256 'class' => 'evf-enhanced-select evf-lookup-filter-by-field-select',
257 'options' => $lookup_filter_by_fields,
258 ),
259 false
260 );
261 // multi select.
262 $lookup_multiple_select_option = isset( $field['lookup_multiple_select'] ) ? $field['lookup_multiple_select'] : false;
263 $lookup_multi_select_checkbox = $this->field_element(
264 'toggle',
265 $field,
266 array(
267 'slug' => 'lookup_multiple_select',
268 'value' => evf_string_to_bool( $lookup_multiple_select_option ),
269 'desc' => __( 'Enable Multiple Select', 'everest-forms' ),
270 'tooltip' => __( 'Check to enable the multiple select option.', 'everest-forms' ),
271
272 ),
273 false
274 );
275
276 $args = array(
277 'slug' => 'lookup_option_lists',
278 'content' => $lookup_form_name_option_label . $lookup_form_name_option_select . $lookup_field_name_option_label . $lookup_field_name_option_select . $lookup_filter_by_field_option_label . $lookup_filter_by_field_option_select . $lookup_multi_select_checkbox,
279 );
280 $this->field_element( 'row', $field, $args );
281 echo '</div>';
282 echo '</div>';
283 }
284
285 /**
286 * Field preview inside the builder.
287 *
288 * @since 1.6.7.1
289 *
290 * @param array $field Field data and settings.
291 */
292 public function field_preview( $field ) {
293
294 // Define data.
295 $placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
296 $field_type = ! empty( $field['type'] ) ? esc_attr( $field['type'] ) : '';
297 $display_format = ! empty( $field['lookup_format'] ) ? esc_attr( $field['lookup_format'] ) : 'dropdown';
298 // Label.
299 $this->field_preview_option( 'label', $field );
300
301 // Primary input.
302 switch ( $display_format ) {
303 case 'dropdown':
304 echo '<select data-field-type="' . esc_attr( $field_type ) . '" placeholder="' . esc_attr( $placeholder ) . '" class="widefat primary-input" disabled>';
305 echo '<option value="option1">' . esc_html__( 'Option 1', 'everest-forms' ) . '</option>';
306 echo '<option value="option1">' . esc_html__( 'Option 1', 'everest-forms' ) . '</option>';
307 echo '<option value="option1">' . esc_html__( 'Option 1', 'everest-forms' ) . '</option>';
308 echo '</select>';
309 break;
310 }
311
312 // Description.
313 $this->field_preview_option( 'description', $field );
314 }
315 }
316