PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.09.08
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.09.08
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 4.09.08, at classes/helpers/FrmEntriesHelper.php

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