Completed
Push — master ( 1e40cc...84ba55 )
by Stephanie
02:21
created

FrmEntriesController::remove_excess_cols()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 14
nc 4
nop 2
dl 0
loc 24
rs 8.6845
c 0
b 0
f 0
1
<?php
2
3
class FrmEntriesController {
4
5
	public static function menu() {
6
		FrmAppHelper::force_capability( 'frm_view_entries' );
7
8
		add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9
10
		self::load_manage_entries_hooks();
11
	}
12
13
	/**
14
	 * @since 2.05.07
15
	 */
16
	private static function load_manage_entries_hooks() {
17
		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
18
			$menu_name = FrmAppHelper::get_menu_name();
19
			$base = self::base_column_key( $menu_name );
20
21
			add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' );
22
			add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' );
23
			add_filter( 'manage_' . $base . '_sortable_columns', 'FrmEntriesController::sortable_columns' );
24
		}
25
	}
26
27
    /* Display in Back End */
28
    public static function route() {
29
		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
30
31
        switch ( $action ) {
32
            case 'show':
33
            case 'destroy':
34
            case 'destroy_all':
35
                return self::$action();
36
37
            default:
38
                do_action( 'frm_entry_action_route', $action );
39
                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
40
                    return;
41
                }
42
43
                return self::display_list();
44
        }
45
    }
46
47
	public static function contextual_help( $help, $screen_id, $screen ) {
48
        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
49
        if ( ! method_exists( $screen, 'add_help_tab' ) ) {
50
            return $help;
51
        }
52
53
		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
54
		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
55
		if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) {
56
            return $help;
57
        }
58
59
		unset( $action, $page );
60
61
        $screen->add_help_tab( array(
62
            'id'      => 'formidable-entries-tab',
63
            'title'   => __( 'Overview', 'formidable' ),
64
			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
65
        ));
66
67
        $screen->set_help_sidebar(
68
			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
69
			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
70
			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
71
    	);
72
73
        return $help;
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' ] = __( 'Form', 'formidable' );
87
			$columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
88
			$columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
89
		}
90
91
		$columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
92
		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
93
		self::maybe_add_ip_col( $form_id, $columns );
94
95
        $frm_vars['cols'] = $columns;
96
97
		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
98
		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
99
			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
100
        }
101
102
        return $columns;
103
    }
104
105
	private static function get_columns_for_form( $form_id, &$columns ) {
106
		$form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
107
108
		foreach ( $form_cols as $form_col ) {
109
			if ( FrmField::is_no_save_field( $form_col->type ) ) {
110
				continue;
111
			}
112
113
			if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
114
				$sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] );
115
116
				if ( $sub_form_cols ) {
117
					foreach ( $sub_form_cols as $k => $sub_form_col ) {
118
						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
119
							unset( $sub_form_cols[ $k ] );
120
							continue;
121
						}
122
						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
123
						unset($sub_form_col);
124
					}
125
				}
126
				unset($sub_form_cols);
127
			} else {
128
				$col_id = $form_col->field_key;
129
				if ( $form_col->form_id != $form_id ) {
130
					$col_id .= '-_-form' . $form_col->form_id;
131
				}
132
				
133
				$has_separate_value = ! FrmField::is_option_empty( $form_col, 'separate_value' );
134
				$is_post_status     = FrmField::is_option_true( $form_col, 'post_field' ) && $form_col->field_options['post_field'] == 'post_status';
135
				if ( $has_separate_value && ! $is_post_status ) {
136
					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
137
				}
138
				$columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
139
			}
140
		}
141
	}
142
143
	private static function maybe_add_ip_col( $form_id, &$columns ) {
144
		if ( FrmAppHelper::ips_saved() ) {
145
			$columns[ $form_id . '_ip' ] = 'IP';
146
		}
147
	}
148
149
	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
150
		$this_page_name = self::hidden_column_key();
151
		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
152
            return $check;
153
        }
154
155
		if ( empty( $prev_value ) ) {
156
			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
157
		}
158
159
        global $frm_vars;
160
        //add a check so we don't create a loop
161
        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
162
163
        return $check;
164
    }
165
166
    //add hidden columns back from other forms
167
	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
168
		$this_page_name = self::hidden_column_key();
169
		if ( $meta_key != $this_page_name ) {
170
            return;
171
        }
172
173
        global $frm_vars;
174
        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
175
            return; //don't continue if there's no previous value
176
        }
177
178
        foreach ( $meta_value as $mk => $mv ) {
179
            //remove blank values
180
            if ( empty( $mv ) ) {
181
                unset( $meta_value[ $mk ] );
182
            }
183
        }
184
185
        $cur_form_prefix = reset($meta_value);
186
        $cur_form_prefix = explode('_', $cur_form_prefix);
187
        $cur_form_prefix = $cur_form_prefix[0];
188
        $save = false;
189
190
        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
191
			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
192
                //don't add blank cols or process included cols
193
                continue;
194
            }
195
196
			$form_prefix = explode( '_', $prev_hidden );
197
            $form_prefix = $form_prefix[0];
198
            if ( $form_prefix == $cur_form_prefix ) {
199
                //don't add back columns that are meant to be hidden
200
                continue;
201
            }
202
203
            $meta_value[] = $prev_hidden;
204
            $save = true;
205
            unset($form_prefix);
206
        }
207
208
		if ( $save ) {
209
			$user_id = get_current_user_id();
210
			update_user_option( $user_id, $this_page_name, $meta_value, true );
211
        }
212
    }
213
214
	/**
215
	 * @since 2.05.07
216
	 */
217
	private static function hidden_column_key( $menu_name = '' ) {
218
		$base = self::base_column_key( $menu_name );
219
		return 'manage' . $base . 'columnshidden';
220
	}
221
222
	/**
223
	 * @since 2.05.07
224
	 */
225
	private static function base_column_key( $menu_name = '' ) {
226
		if ( empty( $menu_name ) ) {
227
			$menu_name = FrmAppHelper::get_menu_name();
228
		}
229
		return sanitize_title( $menu_name ) . '_page_formidable-entries';
230
	}
231
232
	public static function save_per_page( $save, $option, $value ) {
233
        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
234
            $save = (int) $value;
235
        }
236
        return $save;
237
    }
238
239
	public static function sortable_columns() {
240
		$form_id = FrmForm::get_current_form_id();
241
		$fields = FrmField::get_all_for_form( $form_id );
242
243
		$columns = array(
244
			$form_id . '_id'         => 'id',
245
			$form_id . '_created_at' => 'created_at',
246
			$form_id . '_updated_at' => 'updated_at',
247
			$form_id . '_ip'         => 'ip',
248
			$form_id . '_item_key'   => 'item_key',
249
			$form_id . '_is_draft'   => 'is_draft',
250
		);
251
252
		foreach ( $fields as $field ) {
253
			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
254
				// Can't sort on checkboxes because they are stored serialized, or post fields
255
				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
256
			}
257
		}
258
259
		return $columns;
260
	}
261
262
	public static function hidden_columns( $result ) {
263
		$form_id = FrmForm::get_current_form_id();
264
265
		$hidden = self::user_hidden_columns_for_form( $form_id, $result );
266
267
		global $frm_vars;
268
		$i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
269
270
		if ( ! empty( $hidden ) ) {
271
			$result = $hidden;
272
			$i = $i - count( $result );
273
			$max_columns = 11;
274
		} else {
275
			$max_columns = 8;
276
		}
277
278
		if ( $i <= $max_columns ) {
279
			return $result;
280
		}
281
282
		self::remove_excess_cols( compact( 'i', 'max_columns', 'form_id' ), $result );
283
284
		return $result;
285
	}
286
287
	/**
288
	 * @since 2.05.07
289
	 */
290
	private static function user_hidden_columns_for_form( $form_id, $result ) {
291
		$hidden = array();
292
		foreach ( (array) $result as $r ) {
293
			if ( ! empty( $r ) ) {
294
				list( $form_prefix, $field_key ) = explode( '_', $r );
0 ignored issues
show
Unused Code introduced by
The assignment to $field_key is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
295
296
				if ( (int) $form_prefix == (int) $form_id ) {
297
					$hidden[] = $r;
298
				}
299
300
				unset( $form_prefix );
301
			}
302
		}
303
		return $hidden;
304
	}
305
306
	/**
307
	 * Remove some columns by default when there are too many
308
	 *
309
	 * @since 2.05.07
310
	 */
311
	private static function remove_excess_cols( $atts, &$result ) {
312
		global $frm_vars;
313
314
		$remove_first = array(
315
			$atts['form_id'] . '_item_key' => '',
316
			$atts['form_id'] . '_id'       => '',
317
		);
318
		$cols = $remove_first + array_reverse( $frm_vars['cols'], true );
319
320
		$i = $atts['i'];
321
322
		foreach ( $cols as $col_key => $col ) {
323
			if ( $i <= $atts['max_columns'] ) {
324
				break;
325
			}
326
327
			if ( ! in_array( $col_key, $result, true ) ) {
328
				$result[] = $col_key;
329
				$i--;
330
			}
331
332
			unset( $col_key, $col );
333
		}
334
	}
335
336
	public static function display_list( $message = '', $errors = array() ) {
337
        global $wpdb, $frm_vars;
338
339
		$form = FrmForm::maybe_get_current_form();
340
		$params = FrmForm::get_admin_params( $form );
341
342
        if ( $form ) {
343
            $params['form'] = $form->id;
344
            $frm_vars['current_form'] = $form;
345
346
			self::get_delete_form_time( $form, $errors );
347
		}
348
349
        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
350
351
        $wp_list_table = new $table_class( array( 'params' => $params ) );
352
353
        $pagenum = $wp_list_table->get_pagenum();
354
355
        $wp_list_table->prepare_items();
356
357
        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
358
        if ( $pagenum > $total_pages && $total_pages > 0 ) {
359
			$url = add_query_arg( 'paged', $total_pages );
360
            if ( headers_sent() ) {
361
                echo FrmAppHelper::js_redirect($url);
0 ignored issues
show
introduced by
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'FrmAppHelper'
Loading history...
362
            } else {
363
                wp_redirect( esc_url_raw( $url ) );
364
            }
365
            die();
366
        }
367
368
        if ( empty($message) && isset($_GET['import-message']) ) {
369
            $message = __( 'Your import is complete', 'formidable' );
370
        }
371
372
		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
373
    }
374
375
	private static function get_delete_form_time( $form, &$errors ) {
376
		if ( 'trash' == $form->status ) {
377
			$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
378
			$time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
379
			$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 );
380
		}
381
	}
382
383
    /* Back End CRUD */
384
	public static function show( $id = 0 ) {
385
        FrmAppHelper::permission_check('frm_view_entries');
386
387
        if ( ! $id ) {
388
			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
389
390
            if ( ! $id ) {
391
				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
392
            }
393
        }
394
395
        $entry = FrmEntry::getOne($id, true);
396
		if ( ! $entry ) {
397
			echo '<div id="form_show_entry_page" class="wrap">' .
398
				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
0 ignored issues
show
introduced by
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw '__'
Loading history...
399
				'</div>';
400
			return;
401
		}
402
403
        $data = maybe_unserialize($entry->description);
404
		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
405
			$data = array( 'referrer' => $data );
406
		}
407
408
		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
409
        $to_emails = array();
410
411
		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
412
    }
413
414
    public static function destroy() {
415
        FrmAppHelper::permission_check('frm_delete_entries');
416
417
		$params = FrmForm::get_admin_params();
418
419
        if ( isset($params['keep_post']) && $params['keep_post'] ) {
420
            //unlink entry from post
421
            global $wpdb;
422
			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
423
        }
424
425
        $message = '';
426
        if ( FrmEntry::destroy( $params['id'] ) ) {
427
            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
428
        }
429
430
        self::display_list( $message );
431
    }
432
433
    public static function destroy_all() {
434
        if ( ! current_user_can( 'frm_delete_entries' ) ) {
435
            $frm_settings = FrmAppHelper::get_settings();
436
            wp_die( $frm_settings->admin_permission );
437
        }
438
439
        global $wpdb;
440
		$params = FrmForm::get_admin_params();
441
        $message = '';
442
        $errors = array();
443
        $form_id = (int) $params['form'];
444
445
        if ( $form_id ) {
446
            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
447
			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
448
449
            if ( $action ) {
450
                // this action takes a while, so only trigger it if there are posts to delete
451
                foreach ( $entry_ids as $entry_id ) {
0 ignored issues
show
Bug introduced by
The expression $entry_ids of type array|null|string|object is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
452
                    do_action( 'frm_before_destroy_entry', $entry_id );
453
                    unset( $entry_id );
454
                }
455
            }
456
457
            $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
458
            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
459
            if ( $results ) {
460
				FrmEntry::clear_cache();
461
                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
462
            }
463
        } else {
464
            $errors = __( 'No entries were specified', 'formidable' );
465
        }
466
467
        self::display_list( $message, $errors );
468
    }
469
470
    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
471
        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
472
        return FrmFormsController::show_form( $id, $key, $title, $description );
473
    }
474
475
    public static function get_form( $filename, $form, $title, $description ) {
476
        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
477
        return FrmFormsController::get_form( $form, $title, $description );
478
    }
479
480
    public static function process_entry( $errors = '', $ajax = false ) {
481
		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
482
		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
483
            return;
484
        }
485
486
        global $frm_vars;
487
488
		$form = FrmForm::getOne( $form_id );
489
        if ( ! $form ) {
490
            return;
491
        }
492
493
		$params = FrmForm::get_params( $form );
494
495
        if ( ! isset( $frm_vars['form_params'] ) ) {
496
            $frm_vars['form_params'] = array();
497
        }
498
		$frm_vars['form_params'][ $form->id ] = $params;
499
500
		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
501
            return;
502
        }
503
504
        if ( $errors == '' && ! $ajax ) {
505
			$errors = FrmEntryValidate::validate( $_POST );
506
        }
507
508
		/**
509
		 * Use this filter to add trigger actions and add errors after
510
		 * all other errors have been processed
511
		 * @since 2.0.6
512
		 */
513
		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
514
515
		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
516
517
        if ( empty( $errors ) ) {
518
			$_POST['frm_skip_cookie'] = 1;
519
            if ( $params['action'] == 'create' ) {
520
				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
521
					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
522
                }
523
            }
524
525
            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
526
			unset( $_POST['frm_skip_cookie'] );
527
        }
528
    }
529
530
    public static function delete_entry_before_redirect( $url, $form, $atts ) {
531
        self::_delete_entry( $atts['id'], $form );
532
        return $url;
533
    }
534
535
    //Delete entry if not redirected
536
    public static function delete_entry_after_save( $atts ) {
537
        self::_delete_entry( $atts['entry_id'], $atts['form'] );
538
    }
539
540
    private static function _delete_entry( $entry_id, $form ) {
541
        if ( ! $form ) {
542
            return;
543
        }
544
545
        $form->options = maybe_unserialize( $form->options );
546
        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
547
            FrmEntry::destroy( $entry_id );
548
        }
549
    }
550
551
	/**
552
	 * @param $atts
553
	 *
554
	 * @return array|string
555
	 */
556
	public static function show_entry_shortcode( $atts ) {
557
		$defaults = array(
558
			'id'             => false,
559
			'entry'          => false,
560
			'fields'         => false,
561
			'plain_text'     => false,
562
			'user_info'      => false,
563
			'include_blank'  => false,
564
			'default_email'  => false,
565
			'form_id'        => false,
566
			'format'         => 'text',
567
			'array_key'      => 'key',
568
			'direction'      => 'ltr',
569
			'font_size'      => '',
570
			'text_color'     => '',
571
			'border_width'   => '',
572
			'border_color'   => '',
573
			'bg_color'       => '',
574
			'alt_bg_color'   => '',
575
			'clickable'      => false,
576
			'exclude_fields' => '',
577
			'include_fields' => '',
578
			'include_extras' => '',
579
			'inline_style'   => 1,
580
		);
581
582
		$atts = shortcode_atts( $defaults, $atts );
583
584
		if ( $atts['default_email'] ) {
585
			$shortcode_atts = array( 'format' => $atts['format'], 'plain_text' => $atts['plain_text'] );
586
			$entry_shortcode_formatter = FrmEntryFactory::entry_shortcode_formatter_instance( $atts['form_id'], $shortcode_atts );
587
			$formatted_entry = $entry_shortcode_formatter->content();
588
589
		} else {
590
591
			$entry_formatter = FrmEntryFactory::entry_formatter_instance( $atts );
592
			$formatted_entry = $entry_formatter->get_formatted_entry_values();
593
594
		}
595
596
		return $formatted_entry;
597
	}
598
599
	public static function get_params( $form = null ) {
600
		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' );
601
		return FrmForm::get_params( $form );
602
	}
603
604
	public static function entry_sidebar( $entry ) {
605
        $data = maybe_unserialize($entry->description);
606
        $date_format = get_option('date_format');
607
        $time_format = get_option('time_format');
608
		if ( isset( $data['browser'] ) ) {
609
			$browser = FrmEntriesHelper::get_browser( $data['browser'] );
610
		}
611
612
		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
613
    }
614
615
	/***********************************************************************
616
	 * Deprecated Functions
617
	 ************************************************************************/
618
619
	/**
620
	 * @deprecated 2.02.14
621
	 *
622
	 * @return mixed
623
	 */
624
	public static function filter_email_value( $value ) {
625
		_deprecated_function( __FUNCTION__, '2.02.14', 'FrmProEntriesController::filter_value_in_single_entry_table' );
626
		return $value;
627
	}
628
629
	/**
630
	 * @deprecated 2.02.14
631
	 *
632
	 * @return mixed
633
	 */
634
	public static function filter_display_value( $value ) {
635
		_deprecated_function( __FUNCTION__, '2.02.14', 'FrmProEntriesController::filter_display_value' );
636
		return $value;
637
	}
638
639
	/**
640
	 * @deprecated 2.03.04
641
	 *
642
	 * @return mixed
643
	 */
644
	public static function filter_shortcode_value( $value ) {
645
		_deprecated_function( __FUNCTION__, '2.03.04', 'custom code' );
646
		return $value;
647
	}
648
}
649