PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.9
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.9
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 / controllers / FrmEntriesController.php

FrmEntriesController.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.9, at classes/controllers/FrmEntriesController.php

728 lines 20.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 FrmEntriesController {
7
8 public static function menu() {
9 FrmAppHelper::force_capability( 'frm_view_entries' );
10
11 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
12
13 $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed();
14 if ( ! $views_installed ) {
15 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Views', 'formidable' ), __( 'Views', 'formidable' ), 'frm_view_entries', 'formidable-views', 'FrmFormsController::no_views' );
16 }
17
18 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
19 self::load_manage_entries_hooks();
20 }
21 }
22
23 /**
24 * @since 2.05.07
25 */
26 private static function load_manage_entries_hooks() {
27 if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new', 'duplicate' ), true ) ) {
28 $menu_name = FrmAppHelper::get_menu_name();
29 $base = self::base_column_key( $menu_name );
30
31 add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' );
32 add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' );
33 add_filter( 'manage_' . $base . '_sortable_columns', 'FrmEntriesController::sortable_columns' );
34 } else {
35 add_filter( 'screen_options_show_screen', __CLASS__ . '::remove_screen_options', 10, 2 );
36 }
37 }
38
39 /**
40 * Display in Back End.
41 */
42 public static function route() {
43 $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
44 FrmAppHelper::include_svg();
45
46 switch ( $action ) {
47 case 'show':
48 case 'destroy':
49 return self::$action();
50
51 default:
52 do_action( 'frm_entry_action_route', $action );
53 if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
54 return;
55 }
56
57 return self::display_list();
58 }
59 }
60
61 /**
62 * Prevent the "screen options" tab from showing when
63 * editing or creating an entry
64 *
65 * @since 3.0
66 */
67 public static function remove_screen_options( $show_screen, $screen ) {
68 $menu_name = sanitize_title( FrmAppHelper::get_menu_name() );
69 if ( $screen->id == $menu_name . '_page_formidable-entries' ) {
70 $show_screen = false;
71 }
72
73 return $show_screen;
74 }
75
76 public static function manage_columns( $columns ) {
77 global $frm_vars;
78 $form_id = FrmForm::get_current_form_id();
79
80 $columns[ $form_id . '_id' ] = 'ID';
81 $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
82
83 if ( $form_id ) {
84 self::get_columns_for_form( $form_id, $columns );
85 } else {
86 $columns[ $form_id . '_form_id' ] = esc_html__( 'Form', 'formidable' );
87 $columns[ $form_id . '_name' ] = esc_html__( 'Entry Name', 'formidable' );
88 $columns[ $form_id . '_user_id' ] = esc_html__( 'Created By', 'formidable' );
89 }
90
91 $columns[ $form_id . '_is_draft' ] = esc_html__( 'Entry Status', 'formidable' );
92 $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
93 $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
94 self::maybe_add_ip_col( $form_id, $columns );
95
96 $frm_vars['cols'] = $columns;
97
98 $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
99 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
100 add_screen_option(
101 'per_page',
102 array(
103 'label' => esc_html__( 'Entries', 'formidable' ),
104 'default' => 20,
105 'option' => 'formidable_page_formidable_entries_per_page',
106 )
107 );
108 }
109
110 return $columns;
111 }
112
113 private static function get_columns_for_form( $form_id, &$columns ) {
114 $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
115
116 /**
117 * Allows changing fields in the Entries list table heading.
118 *
119 * @since 5.0.04
120 *
121 * @param array $fields Array of fields.
122 * @param array $args The arguments. Contains `form_id`.
123 */
124 $form_cols = apply_filters( 'frm_fields_in_entries_list_table', $form_cols, compact( 'form_id' ) );
125
126 foreach ( $form_cols as $form_col ) {
127 if ( FrmField::is_no_save_field( $form_col->type ) ) {
128 continue;
129 }
130
131 $has_child_fields = $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] );
132 if ( $has_child_fields ) {
133 self::add_subform_cols( $form_col, $form_id, $columns );
134 } else {
135 self::add_field_cols( $form_col, $form_id, $columns );
136 }
137 }
138 }
139
140 /**
141 * @since 3.01
142 */
143 private static function add_subform_cols( $field, $form_id, &$columns ) {
144 $sub_form_cols = FrmField::get_all_for_form( $field->field_options['form_select'] );
145 if ( empty( $sub_form_cols ) ) {
146 return;
147 }
148
149 foreach ( $sub_form_cols as $k => $sub_form_col ) {
150 if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
151 unset( $sub_form_cols[ $k ] );
152 continue;
153 }
154 $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $field->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
155 unset( $sub_form_col );
156 }
157 }
158
159 /**
160 * @since 3.01
161 */
162 private static function add_field_cols( $field, $form_id, &$columns ) {
163 $col_id = $field->field_key;
164 if ( $field->form_id != $form_id ) {
165 $col_id .= '-_-form' . $field->form_id;
166 }
167
168 $has_separate_value = ! FrmField::is_option_empty( $field, 'separate_value' );
169 $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] == 'post_status';
170 if ( $has_separate_value && ! $is_post_status ) {
171 $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 );
172 }
173
174 $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 );
175 }
176
177 private static function maybe_add_ip_col( $form_id, &$columns ) {
178 if ( FrmAppHelper::ips_saved() ) {
179 $columns[ $form_id . '_ip' ] = 'IP';
180 }
181 }
182
183 public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
184 $this_page_name = self::hidden_column_key();
185 if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
186 return $check;
187 }
188
189 if ( empty( $prev_value ) ) {
190 $prev_value = get_metadata( 'user', $object_id, $meta_key, true );
191 }
192
193 global $frm_vars;
194 // Add a check so we don't create a loop.
195 $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
196
197 return $check;
198 }
199
200 /**
201 * Add hidden columns back from other forms
202 */
203 public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
204 $this_page_name = self::hidden_column_key();
205 if ( $meta_key != $this_page_name ) {
206 return;
207 }
208
209 global $frm_vars;
210 if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
211 // Don't continue if there's no previous value.
212 return;
213 }
214
215 foreach ( $meta_value as $mk => $mv ) {
216 // Remove blank values.
217 if ( empty( $mv ) ) {
218 unset( $meta_value[ $mk ] );
219 }
220 }
221
222 $cur_form_prefix = reset( $meta_value );
223 $cur_form_prefix = explode( '_', $cur_form_prefix );
224 $cur_form_prefix = $cur_form_prefix[0];
225 $save = false;
226
227 foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
228 if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
229 // Don't add blank cols or process included cols.
230 continue;
231 }
232
233 $form_prefix = explode( '_', $prev_hidden );
234 $form_prefix = $form_prefix[0];
235 if ( $form_prefix == $cur_form_prefix ) {
236 // Don't add back columns that are meant to be hidden.
237 continue;
238 }
239
240 $meta_value[] = $prev_hidden;
241 $save = true;
242 unset( $form_prefix );
243 }
244
245 if ( $save ) {
246 $user_id = get_current_user_id();
247 update_user_option( $user_id, $this_page_name, $meta_value, true );
248 }
249 }
250
251 /**
252 * @since 2.05.07
253 */
254 private static function hidden_column_key( $menu_name = '' ) {
255 $base = self::base_column_key( $menu_name );
256
257 return 'manage' . $base . 'columnshidden';
258 }
259
260 /**
261 * @since 2.05.07
262 */
263 private static function base_column_key( $menu_name = '' ) {
264 if ( empty( $menu_name ) ) {
265 $menu_name = FrmAppHelper::get_menu_name();
266 }
267
268 return sanitize_title( $menu_name ) . '_page_formidable-entries';
269 }
270
271 public static function save_per_page( $save, $option, $value ) {
272 if ( $option == 'formidable_page_formidable_entries_per_page' ) {
273 $save = (int) $value;
274 }
275
276 return $save;
277 }
278
279 public static function sortable_columns() {
280 $form_id = FrmForm::get_current_form_id();
281 $fields = FrmField::get_all_for_form( $form_id );
282
283 $columns = array(
284 $form_id . '_id' => 'id',
285 $form_id . '_created_at' => 'created_at',
286 $form_id . '_updated_at' => 'updated_at',
287 $form_id . '_ip' => 'ip',
288 $form_id . '_item_key' => 'item_key',
289 $form_id . '_is_draft' => 'is_draft',
290 );
291
292 if ( ! $form_id ) {
293 $columns[ $form_id . '_user_id' ] = 'user_id';
294 $columns[ $form_id . '_name' ] = 'name';
295 $columns[ $form_id . '_form_id' ] = 'form_id';
296 }
297
298 foreach ( $fields as $field ) {
299 if ( self::field_supports_sorting( $field ) ) {
300 $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
301 }
302 }
303
304 return $columns;
305 }
306
307 /**
308 * Can't sort on checkboxes because they are sorted serialized.
309 * Some post content can be sorted but not everything.
310 *
311 * @param stdClass $field
312 * @return bool
313 */
314 private static function field_supports_sorting( $field ) {
315 $is_sortable = 'checkbox' !== $field->type && empty( $field->field_options['post_field'] );
316 return apply_filters( 'frm_field_column_is_sortable', $is_sortable, $field );
317 }
318
319 /**
320 * @param mixed $result Option value from database for hidden columns in entries table.
321 * @return array
322 */
323 public static function hidden_columns( $result ) {
324 if ( ! is_array( $result ) ) {
325 // Force an unexpected value to be an array.
326 // Since $result is a filtered option and gets saved to the database, it's possible it could be a string.
327 // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error.
328 $result = array();
329 }
330
331 $form_id = FrmForm::get_current_form_id();
332
333 $hidden = self::user_hidden_columns_for_form( $form_id, $result );
334
335 global $frm_vars;
336 $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
337
338 if ( ! empty( $hidden ) ) {
339 $result = $hidden;
340 $i = $i - count( $result );
341 $max_columns = 11;
342 } else {
343 $max_columns = 8;
344 }
345
346 if ( $i <= $max_columns ) {
347 return $result;
348 }
349
350 self::remove_excess_cols( compact( 'i', 'max_columns', 'form_id' ), $result );
351
352 return $result;
353 }
354
355 /**
356 * @since 2.05.07
357 */
358 private static function user_hidden_columns_for_form( $form_id, $result ) {
359 $hidden = array();
360 foreach ( (array) $result as $r ) {
361 if ( ! empty( $r ) ) {
362 list( $form_prefix, $field_key ) = explode( '_', $r );
363
364 if ( (int) $form_prefix == (int) $form_id ) {
365 $hidden[] = $r;
366 }
367
368 unset( $form_prefix );
369 }
370 }
371
372 return $hidden;
373 }
374
375 /**
376 * Remove some columns by default when there are too many
377 *
378 * @since 2.05.07
379 */
380 private static function remove_excess_cols( $atts, &$result ) {
381 global $frm_vars;
382
383 $remove_first = array(
384 $atts['form_id'] . '_item_key' => '',
385 $atts['form_id'] . '_id' => '',
386 );
387 $cols = $remove_first + array_reverse( $frm_vars['cols'], true );
388
389 $i = $atts['i'];
390
391 foreach ( $cols as $col_key => $col ) {
392 if ( $i <= $atts['max_columns'] ) {
393 break;
394 }
395
396 if ( empty( $result ) || ! in_array( $col_key, $result, true ) ) {
397 $result[] = $col_key;
398 --$i;
399 }
400
401 unset( $col_key, $col );
402 }
403 }
404
405 public static function display_list( $message = '', $errors = array() ) {
406 global $wpdb, $frm_vars;
407
408 $form = FrmForm::maybe_get_current_form();
409 $params = FrmForm::get_admin_params( $form );
410
411 if ( $form ) {
412 $params['form'] = $form->id;
413 $frm_vars['current_form'] = $form;
414
415 self::get_delete_form_time( $form, $errors );
416 }
417
418 $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
419
420 $wp_list_table = new $table_class( array( 'params' => $params ) );
421
422 $pagenum = $wp_list_table->get_pagenum();
423
424 $wp_list_table->prepare_items();
425
426 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
427 if ( $pagenum > $total_pages && $total_pages > 0 ) {
428 $url = add_query_arg( 'paged', $total_pages );
429 if ( headers_sent() ) {
430 FrmAppHelper::js_redirect( $url, true );
431 } else {
432 wp_redirect( esc_url_raw( $url ) );
433 }
434 die();
435 }
436
437 if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
438 $message = __( 'Your import is complete', 'formidable' );
439 }
440
441 require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php';
442 }
443
444 private static function get_delete_form_time( $form, &$errors ) {
445 if ( 'trash' == $form->status ) {
446 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
447 $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
448
449 /* translators: %1$s: Time string */
450 $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
451 }
452 }
453
454 /**
455 * Back End CRUD.
456 */
457 public static function show( $id = 0 ) {
458 FrmAppHelper::permission_check( 'frm_view_entries' );
459
460 if ( ! $id ) {
461 $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
462
463 if ( ! $id ) {
464 $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
465 }
466 }
467
468 $entry = FrmEntry::getOne( $id, true );
469 if ( ! $entry ) {
470 echo '<div id="form_show_entry_page" class="wrap">' .
471 esc_html__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
472 '</div>';
473
474 return;
475 }
476
477 $data = $entry->description;
478 if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
479 $data = array( 'referrer' => $data );
480 }
481
482 $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
483 $form = FrmForm::getOne( $entry->form_id );
484
485 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php';
486 }
487
488 /**
489 * Destroy an entry from the admin page.
490 * This is triggered from the entries list from the "Delete" row action, and also from the "Delete Entry" trigger in the view/edit entry sidebar.
491 *
492 * @return void
493 */
494 public static function destroy() {
495 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_entries', '_wpnonce', -1 );
496 if ( false !== $permission_error ) {
497 $error_args = array(
498 'title' => __( 'Verification failed', 'formidable' ),
499 'body' => $permission_error,
500 'cancel_url' => admin_url( 'admin.php?page=formidable-entries' ),
501 );
502 FrmAppController::show_error_modal( $error_args );
503 return;
504 }
505
506 $params = FrmForm::get_admin_params();
507
508 if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
509 self::unlink_post( $params['id'] );
510 }
511
512 $message = '';
513 if ( FrmEntry::destroy( $params['id'] ) ) {
514 $message = __( 'Entry was successfully deleted', 'formidable' );
515 }
516
517 self::display_list( $message );
518 }
519
520 /**
521 * @deprecated 4.02.04 - Moved to Pro since it was unused in Lite.
522 */
523 public static function destroy_all() {
524 _deprecated_function( __METHOD__, '4.02.04', 'FrmProEntriesController::destroy_all' );
525 if ( is_callable( 'FrmProEntriesController::destroy_all' ) ) {
526 FrmProEntriesController::destroy_all();
527 }
528 }
529
530 public static function process_entry( $errors = '', $ajax = false ) {
531 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
532 if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
533 return;
534 }
535
536 global $frm_vars;
537
538 $form = FrmForm::getOne( $form_id );
539 if ( ! $form ) {
540 return;
541 }
542
543 $params = FrmForm::get_params( $form );
544
545 if ( ! isset( $frm_vars['form_params'] ) ) {
546 $frm_vars['form_params'] = array();
547 }
548 $frm_vars['form_params'][ $form->id ] = $params;
549
550 if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
551 return;
552 }
553
554 if ( $errors == '' && ! $ajax ) {
555 $errors = FrmEntryValidate::validate( wp_unslash( $_POST ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
556 }
557
558 /**
559 * Use this filter to add trigger actions and add errors after
560 * all other errors have been processed
561 *
562 * @since 2.0.6
563 */
564 $errors = apply_filters( 'frm_entries_before_create', $errors, $form );
565
566 $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
567
568 if ( empty( $errors ) ) {
569 $_POST['frm_skip_cookie'] = 1;
570 $do_success = false;
571 if ( $params['action'] === 'create' ) {
572 if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
573 $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
574
575 $params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id'];
576 $do_success = true;
577 }
578 }
579
580 do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
581 if ( $do_success ) {
582 FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) );
583 }
584 unset( $_POST['frm_skip_cookie'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
585 }
586 }
587
588 /**
589 * Escape url entities before redirect
590 *
591 * @since 3.0
592 *
593 * @param string $url
594 *
595 * @return string
596 */
597 public static function prepare_redirect_url( $url ) {
598 return str_replace( array( ' ', '[', ']', '|', '@' ), array( '%20', '%5B', '%5D', '%7C', '%40' ), $url );
599 }
600
601 public static function delete_entry_before_redirect( $url, $form, $atts ) {
602 self::_delete_entry( $atts['id'], $form );
603
604 return $url;
605 }
606
607 /**
608 * Delete entry if not redirected.
609 *
610 * @param array $atts
611 */
612 public static function delete_entry_after_save( $atts ) {
613 self::_delete_entry( $atts['entry_id'], $atts['form'] );
614 }
615
616 private static function _delete_entry( $entry_id, $form ) {
617 if ( ! $form ) {
618 return;
619 }
620
621 FrmAppHelper::unserialize_or_decode( $form->options );
622 if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
623 self::unlink_post( $entry_id );
624 FrmEntry::destroy( $entry_id );
625 }
626 }
627
628 /**
629 * Unlink entry from post
630 */
631 private static function unlink_post( $entry_id ) {
632 global $wpdb;
633 $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $entry_id ) );
634 FrmEntry::clear_cache();
635 }
636
637 /**
638 * @param array $atts
639 *
640 * @return array|string
641 */
642 public static function show_entry_shortcode( $atts ) {
643 $defaults = array(
644 'id' => false,
645 'entry' => false,
646 'fields' => false,
647 'plain_text' => false,
648 'user_info' => false,
649 'include_blank' => false,
650 'default_email' => false,
651 'form_id' => false,
652 'format' => 'text',
653 'array_key' => 'key',
654 'direction' => 'ltr',
655 'font_size' => '',
656 'text_color' => '',
657 'border_width' => '',
658 'border_color' => '',
659 'bg_color' => '',
660 'alt_bg_color' => '',
661 'class' => '',
662 'clickable' => false,
663 'exclude_fields' => '',
664 'include_fields' => '',
665 'include_extras' => '',
666 'inline_style' => 1,
667 // Return embedded fields as nested array.
668 'child_array' => false,
669 'line_breaks' => true,
670 'array_separator' => ', ',
671 );
672 $defaults = apply_filters( 'frm_show_entry_defaults', $defaults );
673
674 $atts = shortcode_atts( $defaults, $atts );
675
676 if ( $atts['default_email'] ) {
677 $shortcode_atts = array(
678 'format' => $atts['format'],
679 'plain_text' => $atts['plain_text'],
680 );
681
682 $entry_formatter = FrmEntryFactory::entry_shortcode_formatter_instance( $atts['form_id'], $shortcode_atts );
683 $formatted_entry = $entry_formatter->content();
684
685 } else {
686
687 $entry_formatter = FrmEntryFactory::entry_formatter_instance( $atts );
688 $formatted_entry = $entry_formatter->get_formatted_entry_values();
689
690 }
691
692 return $formatted_entry;
693 }
694
695 public static function entry_sidebar( $entry = false ) {
696 $data = array();
697 $id = 0;
698
699 $date_format = get_option( 'date_format' );
700 $time_format = get_option( 'time_format' );
701
702 if ( $entry ) {
703 $id = $entry->id;
704 $data = $entry->description;
705 if ( isset( $data['browser'] ) ) {
706 $browser = FrmEntriesHelper::get_browser( $data['browser'] );
707 }
708 /**
709 * Add or remove information in the entry sidebar.
710 *
711 * @since 5.5.2
712 * @param array $data
713 */
714 $data = apply_filters( 'frm_sidebar_data', $data, compact( 'entry' ) );
715 }
716
717 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php';
718 }
719
720 /**
721 * @deprecated 4.0
722 */
723 public static function contextual_help( $help, $screen_id, $screen ) {
724 _deprecated_function( __METHOD__, '4.0' );
725 return $help;
726 }
727 }
728