PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.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 / helpers / FrmEntriesHelper.php

FrmEntriesHelper.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.1, at classes/helpers/FrmEntriesHelper.php

727 lines 23.6 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 class FrmEntriesHelper {
7
8 public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9 remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
10
11 $values = array(
12 'name' => '',
13 'description' => '',
14 'item_key' => '',
15 );
16
17 $values['fields'] = array();
18 if ( empty( $fields ) ) {
19 return apply_filters( 'frm_setup_new_entry', $values );
20 }
21
22 foreach ( (array) $fields as $field ) {
23 $original_default = $field->default_value;
24 self::prepare_field_default_value( $field );
25 $new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
26
27 $field_array = FrmAppHelper::start_field_array( $field );
28 $field_array['value'] = $new_value;
29 $field_array['type'] = apply_filters( 'frm_field_type', $field->type, $field, $new_value );
30 $field_array['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
31 $field_array['reset_value'] = $reset;
32 $field_array['in_embed_form'] = isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0';
33 $field_array['original_default'] = $original_default;
34
35 FrmFieldsHelper::prepare_new_front_field( $field_array, $field, $args );
36
37 if ( ! is_array( $field->field_options ) ) {
38 $field->field_options = array();
39 }
40
41 $field_array = array_merge( $field->field_options, $field_array );
42
43 $values['fields'][] = $field_array;
44
45 if ( ! $form || ! isset( $form->id ) ) {
46 $form = FrmForm::getOne( $field->form_id );
47 }
48 }
49
50 FrmAppHelper::unserialize_or_decode( $form->options );
51 if ( is_array( $form->options ) ) {
52 $values = array_merge( $values, $form->options );
53 }
54
55 $form_defaults = FrmFormsHelper::get_default_opts();
56 $form_defaults['custom_style'] = FrmAppHelper::custom_style_value( array() );
57
58 $values = array_merge( $form_defaults, $values );
59
60 return apply_filters( 'frm_setup_new_entry', $values );
61 }
62
63 /**
64 * @since 2.05
65 *
66 * @param object $field
67 */
68 private static function prepare_field_default_value( &$field ) {
69 //If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
70 $return_array = FrmField::is_field_with_multiple_values( $field );
71
72 /**
73 * Do any shortcodes in default value and allow customization of default value.
74 * Calls FrmProFieldsHelper::get_default_value
75 */
76 $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array );
77
78 if ( isset( $field->field_options['placeholder'] ) ) {
79 $field->field_options['placeholder'] = apply_filters( 'frm_get_default_value', $field->field_options['placeholder'], $field, false, false );
80 }
81 }
82
83 /**
84 * Set the value for each field
85 * This function is used when the form is first loaded and on all page turns *for a new entry*
86 *
87 * @since 2.0.13
88 *
89 * @param object $field - this is passed by reference since it is an object
90 * @param boolean $reset
91 * @param array $args
92 *
93 * @return string|array $new_value
94 */
95 private static function get_field_value_for_new_entry( $field, $reset, $args ) {
96 $new_value = $field->default_value;
97
98 if ( ! $reset && self::value_is_posted( $field, $args ) ) {
99 self::get_posted_value( $field, $new_value, $args );
100 }
101
102 if ( ! is_array( $new_value ) ) {
103 $new_value = str_replace( '"', '&quot;', $new_value );
104 }
105
106 return $new_value;
107 }
108
109 /**
110 * Check if a field has a posted value
111 *
112 * @since 2.01.0
113 *
114 * @param object $field
115 * @param array $args
116 *
117 * @return boolean $value_is_posted
118 */
119 public static function value_is_posted( $field, $args ) {
120 $value_is_posted = false;
121 if ( $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
122 $repeating = isset( $args['repeating'] ) && $args['repeating'];
123 if ( $repeating ) {
124 if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
125 $value_is_posted = true;
126 }
127 } elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
128 $value_is_posted = true;
129 }
130 }
131
132 return $value_is_posted;
133 }
134
135 public static function setup_edit_vars( $values, $record ) {
136 remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
137
138 $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
139 $values['form_id'] = $record->form_id;
140 $values['is_draft'] = $record->is_draft;
141
142 return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
143 }
144
145 public static function replace_default_message( $message, $atts ) {
146 if ( strpos( $message, '[default-message' ) === false &&
147 strpos( $message, '[default_message' ) === false &&
148 ! empty( $message ) ) {
149 return $message;
150 }
151
152 if ( empty( $message ) ) {
153 $message = '[default-message]';
154 }
155
156 preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
157
158 foreach ( $shortcodes[0] as $short_key => $tag ) {
159 $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
160 if ( ! empty( $add_atts ) ) {
161 $this_atts = array_merge( $atts, $add_atts );
162 } else {
163 $this_atts = $atts;
164 }
165
166 $default = FrmEntriesController::show_entry_shortcode( $this_atts );
167
168 // Add the default message.
169 $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
170 }
171
172 return $message;
173 }
174
175 public static function prepare_display_value( $entry, $field, $atts ) {
176 $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
177
178 if ( FrmAppHelper::pro_is_installed() ) {
179 $empty = empty( $field_value );
180 FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
181 if ( $empty && ! empty( $field_value ) ) {
182 // We've got an entry id, so switch it to a value.
183 $atts['force_id'] = true;
184 }
185 }
186
187 if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
188 return self::display_value( $field_value, $field, $atts );
189 }
190
191 // This is an embeded form.
192 $val = '';
193
194 if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
195 // This is a repeating section.
196 $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
197 } else {
198 // Get all values for this field.
199 $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
200
201 if ( $child_values ) {
202 $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
203 }
204 }
205
206 $field_value = array();
207
208 if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209 return $val;
210 }
211
212 foreach ( $child_entries as $child_entry ) {
213 $atts['item_id'] = $child_entry->id;
214 $atts['post_id'] = $child_entry->post_id;
215
216 // Fet the value for this field -- check for post values as well.
217 $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
218
219 if ( $entry_val || '0' === $entry_val ) {
220 // foreach entry get display_value.
221 $field_value[] = self::display_value( $entry_val, $field, $atts );
222 }
223
224 unset( $child_entry );
225 }
226
227 $sep = ', ';
228 if ( strpos( implode( ' ', (array) $field_value ), '<img' ) !== false ) {
229 $sep = '<br/>';
230 }
231 $val = implode( $sep, (array) $field_value );
232
233 return FrmAppHelper::kses( $val, 'all' );
234 }
235
236 /**
237 * Prepare the saved value for display
238 *
239 * @param array|string $value
240 * @param object $field
241 * @param array $atts
242 *
243 * @return string
244 */
245 public static function display_value( $value, $field, $atts = array() ) {
246
247 $defaults = array(
248 'type' => '',
249 'html' => false,
250 'show_filename' => true,
251 'truncate' => false,
252 'sep' => ', ',
253 'post_id' => 0,
254 'form_id' => $field->form_id,
255 'field' => $field,
256 'keepjs' => 0,
257 'return_array' => false,
258 );
259
260 $atts = wp_parse_args( $atts, $defaults );
261
262 if ( FrmField::is_image( $field ) || $field->type == 'star' ) {
263 $atts['truncate'] = false;
264 $atts['html'] = true;
265 }
266
267 $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
268
269 if ( ! isset( $field->field_options['post_field'] ) ) {
270 $field->field_options['post_field'] = '';
271 }
272
273 if ( ! isset( $field->field_options['custom_field'] ) ) {
274 $field->field_options['custom_field'] = '';
275 }
276
277 if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
278 $atts['pre_truncate'] = $atts['truncate'];
279 $atts['truncate'] = true;
280 $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
281
282 $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
283 $atts['truncate'] = $atts['pre_truncate'];
284 }
285
286 if ( $value == '' ) {
287 return $value;
288 }
289
290 $unfiltered_value = $value;
291 FrmAppHelper::unserialize_or_decode( $unfiltered_value );
292
293 $value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts );
294 $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
295
296 if ( $value == $unfiltered_value ) {
297 $value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
298 }
299
300 if ( $atts['truncate'] && $atts['type'] != 'url' ) {
301 $value = FrmAppHelper::truncate( $value, 50 );
302 }
303
304 if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
305 $value = FrmAppHelper::kses( $value, 'all' );
306 }
307
308 return apply_filters( 'frm_display_value', $value, $field, $atts );
309 }
310
311 public static function set_posted_value( $field, $value, $args ) {
312 // If validating a field with "other" opt, set back to prev value now.
313 if ( isset( $args['other'] ) && $args['other'] ) {
314 $value = $args['temp_value'];
315 }
316 if ( empty( $args['parent_field_id'] ) ) {
317 $_POST['item_meta'][ $field->id ] = $value;
318 } else {
319 self::set_parent_field_posted_value( $field, $value, $args );
320 }
321 }
322
323 /**
324 * Init arrays if necessary, else we get fatal error.
325 *
326 * @since 4.01
327 */
328 private static function set_parent_field_posted_value( $field, $value, $args ) {
329 if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) && is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
330 if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) || ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
331 $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
332 }
333 } else {
334 // All of the section was probably removed.
335 $_POST['item_meta'][ $args['parent_field_id'] ] = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
336 $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
337 }
338
339 $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; // phpcs:ignore WordPress.Security.NonceVerification.Missing
340 }
341
342 public static function get_posted_value( $field, &$value, $args ) {
343 if ( is_array( $field ) ) {
344 $field_id = $field['id'];
345 $field_obj = FrmFieldFactory::get_field_object( $field['id'] );
346 } elseif ( is_object( $field ) ) {
347 $field_id = $field->id;
348 $field_obj = FrmFieldFactory::get_field_object( $field );
349 } elseif ( is_numeric( $field ) ) {
350 $field_id = $field;
351 $field_obj = FrmFieldFactory::get_field_object( $field );
352 } else {
353 $value = self::get_posted_meta( $field, $args );
354 FrmAppHelper::sanitize_value( 'sanitize_text_field', $value );
355 return;
356 }
357
358 $value = self::get_posted_meta( $field_id, $args );
359
360 $field_obj->sanitize_value( $value );
361 }
362
363 /**
364 * @since 4.02.04
365 */
366 private static function get_posted_meta( $field_id, $args ) {
367 if ( empty( $args['parent_field_id'] ) ) {
368 // Sanitizing is done next.
369 $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
370 } else {
371 $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
372 }
373 return $value;
374 }
375
376 /**
377 * Check if field has an "Other" option and if any other values are posted
378 *
379 * @since 2.0
380 *
381 * @param object $field
382 * @param string|array $value
383 * @param array $args
384 */
385 public static function maybe_set_other_validation( $field, &$value, &$args ) {
386 $args['other'] = false;
387 if ( ! $value || ! FrmAppHelper::pro_is_installed() ) {
388 return;
389 }
390
391 // Trim excess values if selection limit is exceeded for checkbox. Necessary to do here
392 // as the value set here will be used later in this class's set_posted_value() method.
393 if ( FrmField::is_checkbox( $field ) ) {
394 $field_obj = FrmFieldFactory::get_field_object( $field );
395 $field_obj->maybe_trim_excess_values( $value );
396 }
397
398 // Get other value for fields in repeating section.
399 self::set_other_repeating_vals( $field, $value, $args );
400
401 // Check if there are any posted "Other" values.
402 if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
403
404 // Save original value.
405 $args['temp_value'] = $value;
406 $args['other'] = true;
407
408 // Sanitizing is done next.
409 $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
410 FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
411
412 // Set the validation value now
413 self::set_other_validation_val( $value, $other_vals, $field, $args );
414 }
415 }
416
417 /**
418 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
419 *
420 * @since 2.0
421 *
422 * @param object $field
423 * @param string|array $value
424 * @param array $args
425 */
426 public static function set_other_repeating_vals( $field, &$value, &$args ) {
427 if ( ! $args['parent_field_id'] ) {
428 return;
429 }
430
431 // Check if there are any other posted "other" values for this field.
432 if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
433 // Save original value
434 $args['temp_value'] = $value;
435 $args['other'] = true;
436
437 $other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
438 FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
439
440 // Set the validation value now.
441 self::set_other_validation_val( $value, $other_vals, $field, $args );
442 }
443 }
444
445 /**
446 * Modify value used for validation
447 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
448 * It also adds any text from the free text fields to the value
449 *
450 * Needs to accommodate for times when other opt is selected, but no other free text is entered
451 *
452 * @since 2.0
453 *
454 * @param string|array $value
455 * @param string|array $other_vals (usually of posted values)
456 * @param object $field
457 * @param array $args
458 */
459 public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
460 // Checkboxes and multi-select dropdowns.
461 if ( is_array( $value ) && $field->type === 'checkbox' ) {
462 // Combine "Other" values with checked values. "Other" values will override checked box values.
463 foreach ( $other_vals as $k => $v ) {
464 if ( isset( $value[ $k ] ) && trim( $v ) === '' ) {
465 // If the other box is checked, but doesn't have a value.
466 $value = '';
467 break;
468 }
469 }
470
471 if ( is_array( $value ) && ! empty( $value ) ) {
472 $value = array_merge( $value, $other_vals );
473 }
474 } else {
475 // Radio and dropdowns.
476 $other_key = array_filter( array_keys( $field->options ), 'is_string' );
477 $other_key = reset( $other_key );
478
479 // Multi-select dropdown.
480 if ( is_array( $value ) ) {
481 $o_key = array_search( $field->options[ $other_key ], $value );
482
483 if ( $o_key !== false ) {
484 // Modify the original value so other key will be preserved.
485 $value[ $other_key ] = $value[ $o_key ];
486
487 // By default, the array keys will be numeric for multi-select dropdowns.
488 // If going backwards and forwards between pages, the array key will match the other key.
489 if ( $o_key !== $other_key ) {
490 unset( $value[ $o_key ] );
491 }
492
493 $args['temp_value'] = $value;
494 $value[ $other_key ] = reset( $other_vals );
495 if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
496 unset( $value[ $other_key ] );
497 }
498 }
499 } elseif ( $field->options[ $other_key ] == $value ) {
500 $value = $other_vals;
501 }
502 }
503 }
504
505 /**
506 * Add submitted values to a string for spam checking.
507 *
508 * @param array $values
509 * @return string
510 */
511 public static function entry_array_to_string( $values ) {
512 $content = '';
513 foreach ( $values['item_meta'] as $val ) {
514 if ( $content != '' ) {
515 $content .= "\n\n";
516 }
517
518 if ( is_array( $val ) ) {
519 $val = FrmAppHelper::array_flatten( $val );
520 $val = implode( ', ', $val );
521 }
522
523 $content .= $val;
524 }
525
526 return $content;
527 }
528
529 /**
530 * Get the browser from the user agent
531 *
532 * @since 2.04
533 *
534 * @param string $u_agent
535 *
536 * @return string
537 */
538 public static function get_browser( $u_agent ) {
539 $bname = __( 'Unknown', 'formidable' );
540 $platform = __( 'Unknown', 'formidable' );
541 $ub = '';
542
543 // Get the operating system
544 if ( preg_match( '/windows|win32/i', $u_agent ) ) {
545 $platform = 'Windows';
546 } elseif ( preg_match( '/android/i', $u_agent ) ) {
547 $platform = 'Android';
548 } elseif ( preg_match( '/linux/i', $u_agent ) ) {
549 $platform = 'Linux';
550 } elseif ( preg_match( '/macintosh|mac os x/i', $u_agent ) ) {
551 $platform = 'OS X';
552 }
553
554 $agent_options = array(
555 'Chrome' => 'Google Chrome',
556 'Safari' => 'Apple Safari',
557 'Opera' => 'Opera',
558 'Netscape' => 'Netscape',
559 'Firefox' => 'Mozilla Firefox',
560 );
561
562 // Next get the name of the useragent yes seperately and for good reason
563 if ( strpos( $u_agent, 'MSIE' ) !== false && strpos( $u_agent, 'Opera' ) === false ) {
564 $bname = 'Internet Explorer';
565 $ub = 'MSIE';
566 } else {
567 foreach ( $agent_options as $agent_key => $agent_name ) {
568 if ( strpos( $u_agent, $agent_key ) !== false ) {
569 $bname = $agent_name;
570 $ub = $agent_key;
571 break;
572 }
573 }
574 }
575
576 // finally get the correct version number
577 $known = array( 'Version', $ub, 'other' );
578 $pattern = '#(?<browser>' . join( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
579 preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
580
581 // see how many we have
582 $i = count( $matches['browser'] );
583
584 if ( $i > 1 ) {
585 //we will have two since we are not using 'other' argument yet
586 //see if version is before or after the name
587 if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) {
588 $version = $matches['version'][0];
589 } else {
590 $version = $matches['version'][1];
591 }
592 } elseif ( $i === 1 ) {
593 $version = $matches['version'][0];
594 } else {
595 $version = '';
596 }
597
598 // check if we have a number
599 if ( $version == '' ) {
600 $version = '?';
601 }
602
603 return $bname . ' ' . $version . ' / ' . $platform;
604 }
605
606 /**
607 * @since 3.0
608 */
609 public static function actions_dropdown( $atts ) {
610 $id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
611 $links = self::get_action_links( $id, $atts['entry'] );
612
613 foreach ( $links as $link ) {
614 ?>
615 <div class="misc-pub-section">
616 <a href="<?php echo esc_url( $link['url'] ); ?>"
617 <?php
618 if ( isset( $link['data'] ) ) {
619 foreach ( $link['data'] as $data => $value ) {
620 echo 'data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '" ';
621 }
622 }
623 if ( isset( $link['class'] ) ) {
624 echo 'class="' . esc_attr( $link['class'] ) . '" ';
625 }
626 if ( isset( $link['id'] ) ) {
627 echo 'id="' . esc_attr( $link['id'] ) . '" ';
628 }
629 ?>
630 >
631 <?php FrmAppHelper::icon_by_class( $link['icon'], array( 'aria-hidden' => 'true' ) ); ?>
632 <span class="frm_link_label"><?php echo esc_html( $link['label'] ); ?></span>
633 </a>
634 </div>
635 <?php
636 }
637 }
638
639 /**
640 * @since 3.0
641 */
642 private static function get_action_links( $id, $entry ) {
643 $page = FrmAppHelper::get_param( 'frm_action' );
644 $actions = array();
645
646 if ( $page != 'show' ) {
647 $actions['frm_view'] = array(
648 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=show&id=' . $id . '&form=' . $entry->form_id ),
649 'label' => __( 'View Entry', 'formidable' ),
650 'icon' => 'frm_icon_font frm_save_icon',
651 );
652 }
653
654 if ( current_user_can( 'frm_delete_entries' ) ) {
655 $actions['frm_delete'] = array(
656 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ) ),
657 'label' => __( 'Delete Entry', 'formidable' ),
658 'icon' => 'frm_icon_font frm_delete_icon',
659 'data' => array(
660 'frmverify' => __( 'Delete this form entry?', 'formidable' ),
661 ),
662 );
663 }
664
665 if ( $page == 'show' ) {
666 $actions['frm_print'] = array(
667 'url' => '#',
668 'label' => __( 'Print Entry', 'formidable' ),
669 'data' => array(
670 'frmprint' => '1',
671 ),
672 'icon' => 'frm_icon_font frm_printer_icon',
673 );
674 }
675
676 $actions['frm_resend'] = array(
677 'url' => '#',
678 'label' => __( 'Resend Emails', 'formidable' ),
679 'class' => 'frm_noallow',
680 'data' => array(
681 'upgrade' => __( 'Resend Emails', 'formidable' ),
682 'medium' => 'resend-email',
683 'content' => 'entry',
684 ),
685 'icon' => 'frm_icon_font frm_email_icon',
686 );
687
688 $actions['frm_edit'] = array(
689 'url' => '#',
690 'label' => __( 'Edit Entry', 'formidable' ),
691 'class' => 'frm_noallow',
692 'data' => array(
693 'upgrade' => __( 'Entry edits', 'formidable' ),
694 'medium' => 'edit-entries',
695 'content' => 'entry',
696 ),
697 'icon' => 'frm_icon_font frm_pencil_icon',
698 );
699
700 return apply_filters( 'frm_entry_actions_dropdown', $actions, compact( 'id', 'entry' ) );
701 }
702
703 /**
704 * @since 5.0.15
705 *
706 * @param string|int $entry_id
707 * @return void
708 */
709 public static function maybe_render_captcha_score( $entry_id ) {
710 $query = array(
711 'item_id' => (int) $entry_id,
712 'field_id' => 0,
713 );
714 $metas_without_a_field = (array) FrmEntryMeta::getAll( $query, ' ORDER BY it.created_at DESC', '', true );
715 foreach ( $metas_without_a_field as $meta ) {
716 if ( ! empty( $meta->meta_value['captcha_score'] ) ) {
717 echo '<div class="misc-pub-section">';
718 FrmAppHelper::icon_by_class( 'frm_icon_font frm_shield_check_icon', array( 'aria-hidden' => 'true' ) );
719 echo ' ' . esc_html__( 'reCAPTCHA Score', 'formidable' ) . ': ';
720 echo '<b>' . esc_html( $meta->meta_value['captcha_score'] ) . '</b>';
721 echo '</div>';
722 return;
723 }
724 }
725 }
726 }
727