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

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