PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.07.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.07.01
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
← All changes | classes/controllers/FrmEntriesController.php +113 -418 6.264.07.01 View file →
@@ -4,23 +4,15 @@
4 4 }
5 5
6 6 class FrmEntriesController {
7 7
8 - /**
9 - * @return void
10 - */
11 8 public static function menu() {
12 9 FrmAppHelper::force_capability( 'frm_view_entries' );
13 10
14 11 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
15 12
16 - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed();
17 -
18 - if ( ! $views_installed ) {
13 + if ( ! FrmAppHelper::pro_is_installed() ) {
19 14 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Views', 'formidable' ), __( 'Views', 'formidable' ), 'frm_view_entries', 'formidable-views', 'FrmFormsController::no_views' );
20 - self::maybe_redirect_to_views_upsell();
21 - } else {
22 - self::maybe_redirect_to_views_index();
23 15 }
24 16
25 17 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
26 18 self::load_manage_entries_hooks();
@@ -27,82 +19,12 @@
27 19 }
28 20 }
29 21
30 22 /**
31 - * This function is called when views is installed.
32 - * The Views add-on uses a different URL for the Views tab than the upsell page.
33 - * If the user is on the upsell page, instead of showing a permission error on reload,
34 - * redirect to the views index page.
35 - *
36 - * @since 6.14.1
37 - *
38 - * @return void
39 - */
40 - private static function maybe_redirect_to_views_index() {
41 - if ( ! FrmAppHelper::is_admin_page( 'formidable-views' ) ) {
42 - return;
43 - }
44 -
45 - $query_args = array(
46 - 'post_type' => 'frm_display',
47 - );
48 - $query_args = self::add_url_params_to_views_redirect_query_args( $query_args );
49 -
50 - wp_safe_redirect( add_query_arg( $query_args, admin_url( 'edit.php' ) ) );
51 - die();
52 - }
53 -
54 - /**
55 - * This function is called when views is inactive.
56 - * A user may deactivate views but then try to reload the views index.
57 - * Instead of showing a permission error, redirect to the views upsell page.
58 - *
59 - * @since 6.14.1
60 - *
61 - * @return void
62 - */
63 - private static function maybe_redirect_to_views_upsell() {
64 - global $pagenow;
65 -
66 - if ( 'edit.php' !== $pagenow || 'frm_display' !== FrmAppHelper::simple_get( 'post_type' ) ) {
67 - return;
68 - }
69 -
70 - $query_args = array(
71 - 'page' => 'formidable-views',
72 - );
73 - $query_args = self::add_url_params_to_views_redirect_query_args( $query_args );
74 -
75 - wp_safe_redirect( add_query_arg( $query_args, admin_url( 'admin.php' ) ) );
76 - die();
77 - }
78 -
79 - /**
80 - * @since 6.14.1
81 - *
82 - * @param array $query_args
83 - *
84 - * @return array
85 - */
86 - private static function add_url_params_to_views_redirect_query_args( $query_args ) {
87 - $query_args['show_nav'] = FrmAppHelper::simple_get( 'show_nav', 'absint', 0 );
88 -
89 - $form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 );
90 -
91 - if ( $form_id ) {
92 - $query_args['form'] = $form_id;
93 - }
94 -
95 - return $query_args;
96 - }
97 -
98 - /**
99 23 * @since 2.05.07
100 - *
101 - * @return void
102 24 */
103 25 private static function load_manage_entries_hooks() {
104 - if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new', 'duplicate' ), true ) ) {
26 + if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new' ) ) ) {
105 27 $menu_name = FrmAppHelper::get_menu_name();
106 28 $base = self::base_column_key( $menu_name );
107 29
108 30 add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' );
@@ -108,17 +30,13 @@
108 30 add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' );
109 31 add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' );
110 32 add_filter( 'manage_' . $base . '_sortable_columns', 'FrmEntriesController::sortable_columns' );
111 33 } else {
112 - add_filter( 'screen_options_show_screen', self::class . '::remove_screen_options', 10, 2 );
34 + add_filter( 'screen_options_show_screen', __CLASS__ . '::remove_screen_options', 10, 2 );
113 35 }
114 36 }
115 37
116 - /**
117 - * Display in Back End.
118 - *
119 - * @return mixed
120 - */
38 + /* Display in Back End */
121 39 public static function route() {
122 40 $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
123 41 FrmAppHelper::include_svg();
124 42
@@ -128,15 +46,13 @@
128 46 return self::$action();
129 47
130 48 default:
131 49 do_action( 'frm_entry_action_route', $action );
132 -
133 50 if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
134 51 return;
135 52 }
136 53
137 - self::display_list();
138 - return;
54 + return self::display_list();
139 55 }
140 56 }
141 57
142 58 /**
@@ -143,19 +59,12 @@
143 59 * Prevent the "screen options" tab from showing when
144 60 * editing or creating an entry
145 61 *
146 62 * @since 3.0
147 - *
148 - * @param bool $show_screen Whether to show the screen options tab.
149 - * @param object $screen The current screen object.
150 - *
151 - * @return bool
152 63 */
153 64 public static function remove_screen_options( $show_screen, $screen ) {
154 - $menu_name = sanitize_title( FrmAppHelper::get_menu_name() );
155 - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
156 -
157 - if ( $screen->id === $menu_name . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries' ) {
65 + $menu_name = sanitize_title( FrmAppHelper::get_menu_name() );
66 + if ( $screen->id == $menu_name . '_page_formidable-entries' ) {
158 67 $show_screen = false;
159 68 }
160 69
161 70 return $show_screen;
@@ -160,13 +69,8 @@
160 69
161 70 return $show_screen;
162 71 }
163 72
164 - /**
165 - * @param array $columns
166 - *
167 - * @return array
168 - */
169 73 public static function manage_columns( $columns ) {
170 74 global $frm_vars;
171 75 $form_id = FrmForm::get_current_form_id();
172 76
@@ -175,14 +79,13 @@
175 79
176 80 if ( $form_id ) {
177 81 self::get_columns_for_form( $form_id, $columns );
178 82 } else {
179 - $columns[ $form_id . '_form_id' ] = esc_html__( 'Form', 'formidable' );
180 - $columns[ $form_id . '_name' ] = esc_html__( 'Entry Name', 'formidable' );
181 - $columns[ $form_id . '_user_id' ] = esc_html__( 'Created By', 'formidable' );
83 + $columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' );
84 + $columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
85 + $columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
182 86 }
183 87
184 - $columns[ $form_id . '_is_draft' ] = esc_html__( 'Entry Status', 'formidable' );
185 88 $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
186 89 $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
187 90 self::maybe_add_ip_col( $form_id, $columns );
188 91
@@ -188,14 +91,13 @@
188 91
189 92 $frm_vars['cols'] = $columns;
190 93
191 94 $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
192 -
193 95 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
194 96 add_screen_option(
195 97 'per_page',
196 98 array(
197 - 'label' => esc_html__( 'Entries', 'formidable' ),
99 + 'label' => __( 'Entries', 'formidable' ),
198 100 'default' => 20,
199 101 'option' => 'formidable_page_formidable_entries_per_page',
200 102 )
201 103 );
@@ -203,34 +105,17 @@
203 105
204 106 return $columns;
205 107 }
206 108
207 - /**
208 - * @param int|string $form_id
209 - * @param array $columns
210 - *
211 - * @return void
212 - */
213 109 private static function get_columns_for_form( $form_id, &$columns ) {
214 110 $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
215 111
216 - /**
217 - * Allows changing fields in the Entries list table heading.
218 - *
219 - * @since 5.0.04
220 - *
221 - * @param array $fields Array of fields.
222 - * @param array $args The arguments. Contains `form_id`.
223 - */
224 - $form_cols = apply_filters( 'frm_fields_in_entries_list_table', $form_cols, compact( 'form_id' ) );
225 -
226 112 foreach ( $form_cols as $form_col ) {
227 113 if ( FrmField::is_no_save_field( $form_col->type ) ) {
228 114 continue;
229 115 }
230 116
231 - $has_child_fields = $form_col->type === 'form' && ! empty( $form_col->field_options['form_select'] );
232 -
117 + $has_child_fields = $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] );
233 118 if ( $has_child_fields ) {
234 119 self::add_subform_cols( $form_col, $form_id, $columns );
235 120 } else {
236 121 self::add_field_cols( $form_col, $form_id, $columns );
@@ -239,18 +124,11 @@
239 124 }
240 125
241 126 /**
242 127 * @since 3.01
243 - *
244 - * @param object $field The field object.
245 - * @param int|string $form_id The form ID.
246 - * @param array $columns The columns array.
247 - *
248 - * @return void
249 128 */
250 129 private static function add_subform_cols( $field, $form_id, &$columns ) {
251 130 $sub_form_cols = FrmField::get_all_for_form( $field->field_options['form_select'] );
252 -
253 131 if ( empty( $sub_form_cols ) ) {
254 132 return;
255 133 }
256 134
@@ -265,62 +143,24 @@
265 143 }
266 144
267 145 /**
268 146 * @since 3.01
269 - *
270 - * @param object $field The field object.
271 - * @param int|string $form_id The form ID.
272 - * @param array $columns The columns array.
273 - *
274 - * @return void
275 147 */
276 148 private static function add_field_cols( $field, $form_id, &$columns ) {
277 149 $col_id = $field->field_key;
278 -
279 150 if ( $field->form_id != $form_id ) {
280 151 $col_id .= '-_-form' . $field->form_id;
281 152 }
282 153
283 - $has_separate_value = ! FrmField::is_option_empty( $field, 'separate_value' );
284 - $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] === 'post_status';
285 - $include_column_for_sep_val = $has_separate_value && ! $is_post_status;
286 -
287 - if ( $include_column_for_sep_val ) {
288 - $columns[ $form_id . '_frmsep_' . $col_id ] = self::maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val );
154 + $has_separate_value = ! FrmField::is_option_empty( $field, 'separate_value' );
155 + $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] == 'post_status';
156 + if ( $has_separate_value && ! $is_post_status ) {
157 + $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 );
289 158 }
290 159
291 - $columns[ $form_id . '_' . $col_id ] = self::maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val, false );
160 + $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 );
292 161 }
293 162
294 - /**
295 - * Appends "(Value)" or "(Label)" to the field name if it's an option field that has a separate value/label.
296 - *
297 - * @since 6.25.1
298 - *
299 - * @param object $field
300 - * @param bool $include_column_for_sep_val
301 - * @param bool $is_value
302 - *
303 - * @return string
304 - */
305 - private static function maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val, $is_value = true ) {
306 - $field_name = FrmAppHelper::truncate( $field->name, 35 );
307 -
308 - if ( ! $include_column_for_sep_val || ! in_array( $field->type, array( 'select', 'radio', 'checkbox' ), true ) ) {
309 - return $field_name;
310 - }
311 -
312 - $append_text = $is_value ? esc_html__( 'value', 'formidable' ) : esc_html__( 'label', 'formidable' );
313 -
314 - return sprintf( '%s (%s)', $field_name, $append_text );
315 - }
316 -
317 - /**
318 - * @param int|string $form_id The form ID.
319 - * @param array $columns The columns array.
320 - *
321 - * @return void
322 - */
323 163 private static function maybe_add_ip_col( $form_id, &$columns ) {
324 164 if ( FrmAppHelper::ips_saved() ) {
325 165 $columns[ $form_id . '_ip' ] = 'IP';
326 166 }
@@ -325,20 +165,10 @@
325 165 $columns[ $form_id . '_ip' ] = 'IP';
326 166 }
327 167 }
328 168
329 - /**
330 - * @param bool $check The check value.
331 - * @param int $object_id The object ID.
332 - * @param string $meta_key The meta key.
333 - * @param mixed $meta_value The meta value.
334 - * @param mixed $prev_value The previous value.
335 - *
336 - * @return bool
337 - */
338 169 public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
339 170 $this_page_name = self::hidden_column_key();
340 -
341 171 if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
342 172 return $check;
343 173 }
344 174
@@ -346,10 +176,10 @@
346 176 $prev_value = get_metadata( 'user', $object_id, $meta_key, true );
347 177 }
348 178
349 179 global $frm_vars;
350 - // Add a check so we don't create a loop.
351 - $frm_vars['prev_hidden_cols'] = ! empty( $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
180 + //add a check so we don't create a loop
181 + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
352 182
353 183 return $check;
354 184 }
355 185
@@ -354,28 +184,18 @@
354 184 }
355 185
356 186 /**
357 187 * Add hidden columns back from other forms
358 - *
359 - * @param int $meta_id The meta ID.
360 - * @param int $object_id The object ID.
361 - * @param string $meta_key The meta key.
362 - * @param array $meta_value The meta value.
363 - *
364 - * @return void
365 188 */
366 189 public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
367 190 $this_page_name = self::hidden_column_key();
368 -
369 191 if ( $meta_key != $this_page_name ) {
370 192 return;
371 193 }
372 194
373 195 global $frm_vars;
374 -
375 196 if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
376 - // Don't continue if there's no previous value.
377 - return;
197 + return; // Don't continue if there's no previous value.
378 198 }
379 199
380 200 foreach ( $meta_value as $mk => $mv ) {
381 201 // Remove blank values.
@@ -396,10 +216,9 @@
396 216 }
397 217
398 218 $form_prefix = explode( '_', $prev_hidden );
399 219 $form_prefix = $form_prefix[0];
400 -
401 - if ( $form_prefix === $cur_form_prefix ) {
220 + if ( $form_prefix == $cur_form_prefix ) {
402 221 // Don't add back columns that are meant to be hidden.
403 222 continue;
404 223 }
405 224
@@ -415,12 +234,8 @@
415 234 }
416 235
417 236 /**
418 237 * @since 2.05.07
419 - *
420 - * @param string $menu_name
421 - *
422 - * @return string
423 238 */
424 239 private static function hidden_column_key( $menu_name = '' ) {
425 240 $base = self::base_column_key( $menu_name );
426 241
@@ -428,12 +243,8 @@
428 243 }
429 244
430 245 /**
431 246 * @since 2.05.07
432 - *
433 - * @param string $menu_name
434 - *
435 - * @return string
436 247 */
437 248 private static function base_column_key( $menu_name = '' ) {
438 249 if ( empty( $menu_name ) ) {
439 250 $menu_name = FrmAppHelper::get_menu_name();
@@ -438,22 +249,13 @@
438 249 if ( empty( $menu_name ) ) {
439 250 $menu_name = FrmAppHelper::get_menu_name();
440 251 }
441 252
442 - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
443 -
444 - return sanitize_title( $menu_name ) . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries';
253 + return sanitize_title( $menu_name ) . '_page_formidable-entries';
445 254 }
446 255
447 - /**
448 - * @param int $save
449 - * @param string $option
450 - * @param string $value
451 - *
452 - * @return int
453 - */
454 256 public static function save_per_page( $save, $option, $value ) {
455 - if ( $option === 'formidable_page_formidable_entries_per_page' ) {
257 + if ( $option == 'formidable_page_formidable_entries_per_page' ) {
456 258 $save = (int) $value;
457 259 }
458 260
459 261 return $save;
@@ -458,11 +260,8 @@
458 260
459 261 return $save;
460 262 }
461 263
462 - /**
463 - * @return array
464 - */
465 264 public static function sortable_columns() {
466 265 $form_id = FrmForm::get_current_form_id();
467 266 $fields = FrmField::get_all_for_form( $form_id );
468 267
@@ -474,16 +273,11 @@
474 273 $form_id . '_item_key' => 'item_key',
475 274 $form_id . '_is_draft' => 'is_draft',
476 275 );
477 276
478 - if ( ! $form_id ) {
479 - $columns[ $form_id . '_user_id' ] = 'user_id';
480 - $columns[ $form_id . '_name' ] = 'name';
481 - $columns[ $form_id . '_form_id' ] = 'form_id';
482 - }
483 -
484 277 foreach ( $fields as $field ) {
485 - if ( self::field_supports_sorting( $field ) ) {
278 + if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
279 + // Can't sort on checkboxes because they are stored serialized, or post fields
486 280 $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
487 281 }
488 282 }
489 283
@@ -489,44 +283,22 @@
489 283
490 284 return $columns;
491 285 }
492 286
493 - /**
494 - * Can't sort on checkboxes because they are sorted serialized.
495 - * Some post content can be sorted but not everything.
496 - *
497 - * @param stdClass $field
498 - *
499 - * @return bool
500 - */
501 - private static function field_supports_sorting( $field ) {
502 - $is_sortable = 'checkbox' !== $field->type && empty( $field->field_options['post_field'] );
503 - return apply_filters( 'frm_field_column_is_sortable', $is_sortable, $field );
504 - }
505 -
506 - /**
507 - * @param mixed $result Option value from database for hidden columns in entries table.
508 - *
509 - * @return array
510 - */
511 287 public static function hidden_columns( $result ) {
512 - global $frm_vars;
288 + $form_id = FrmForm::get_current_form_id();
513 289
514 - if ( ! is_array( $result ) ) {
515 - // Force an unexpected value to be an array.
516 - // Since $result is a filtered option and gets saved to the database, it's possible it could be a string.
517 - // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error.
518 - $result = array();
519 - }
290 + $hidden = self::user_hidden_columns_for_form( $form_id, $result );
520 291
521 - $form_id = FrmForm::get_current_form_id();
522 - $hidden = self::user_hidden_columns_for_form( $form_id, $result );
523 - $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
524 - $max_columns = 11;
292 + global $frm_vars;
293 + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
525 294
526 295 if ( ! empty( $hidden ) ) {
527 - $result = $hidden;
528 - $i = $i - count( $result );
296 + $result = $hidden;
297 + $i = $i - count( $result );
298 + $max_columns = 11;
299 + } else {
300 + $max_columns = 8;
529 301 }
530 302
531 303 if ( $i <= $max_columns ) {
532 304 return $result;
@@ -538,22 +310,16 @@
538 310 }
539 311
540 312 /**
541 313 * @since 2.05.07
542 - *
543 - * @param int|string $form_id
544 - * @param mixed $result
545 - *
546 - * @return array
547 314 */
548 315 private static function user_hidden_columns_for_form( $form_id, $result ) {
549 316 $hidden = array();
550 -
551 317 foreach ( (array) $result as $r ) {
552 318 if ( ! empty( $r ) ) {
553 319 list( $form_prefix, $field_key ) = explode( '_', $r );
554 320
555 - if ( (int) $form_prefix === (int) $form_id ) {
321 + if ( (int) $form_prefix == (int) $form_id ) {
556 322 $hidden[] = $r;
557 323 }
558 324
559 325 unset( $form_prefix );
@@ -566,13 +332,8 @@
566 332 /**
567 333 * Remove some columns by default when there are too many
568 334 *
569 335 * @since 2.05.07
570 - *
571 - * @param array $atts
572 - * @param array $result
573 - *
574 - * @return void
575 336 */
576 337 private static function remove_excess_cols( $atts, &$result ) {
577 338 global $frm_vars;
578 339
@@ -590,9 +351,9 @@
590 351 }
591 352
592 353 if ( empty( $result ) || ! in_array( $col_key, $result, true ) ) {
593 354 $result[] = $col_key;
594 - --$i;
355 + $i--;
595 356 }
596 357
597 358 unset( $col_key, $col );
598 359 }
@@ -597,14 +358,8 @@
597 358 unset( $col_key, $col );
598 359 }
599 360 }
600 361
601 - /**
602 - * @param string $message
603 - * @param array $errors
604 - *
605 - * @return void
606 - */
607 362 public static function display_list( $message = '', $errors = array() ) {
608 363 global $wpdb, $frm_vars;
609 364
610 365 $form = FrmForm::maybe_get_current_form();
@@ -625,14 +380,12 @@
625 380
626 381 $wp_list_table->prepare_items();
627 382
628 383 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
629 -
630 384 if ( $pagenum > $total_pages && $total_pages > 0 ) {
631 385 $url = add_query_arg( 'paged', $total_pages );
632 -
633 386 if ( headers_sent() ) {
634 - FrmAppHelper::js_redirect( $url, true );
387 + echo FrmAppHelper::js_redirect( $url ); // WPCS: XSS ok.
635 388 } else {
636 389 wp_redirect( esc_url_raw( $url ) );
637 390 }
638 391 die();
@@ -641,34 +394,22 @@
641 394 if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
642 395 $message = __( 'Your import is complete', 'formidable' );
643 396 }
644 397
645 - require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php';
398 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
646 399 }
647 400
648 - /**
649 - * @param object $form
650 - * @param array $errors
651 - *
652 - * @return void
653 - */
654 401 private static function get_delete_form_time( $form, &$errors ) {
655 - if ( 'trash' === $form->status ) {
402 + if ( 'trash' == $form->status ) {
656 403 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
657 - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( $form->options['trash_time'] ?? time() ) );
404 + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
658 405
659 406 /* translators: %1$s: Time string */
660 - $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 );
407 + $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 );
661 408 }
662 409 }
663 410
664 - /**
665 - * Back End CRUD.
666 - *
667 - * @param int $id
668 - *
669 - * @return void
670 - */
411 + /* Back End CRUD */
671 412 public static function show( $id = 0 ) {
672 413 FrmAppHelper::permission_check( 'frm_view_entries' );
673 414
674 415 if ( ! $id ) {
@@ -679,22 +420,17 @@
679 420 }
680 421 }
681 422
682 423 $entry = FrmEntry::getOne( $id, true );
424 + if ( ! $entry ) {
425 + echo '<div id="form_show_entry_page" class="wrap">' .
426 + esc_html__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
427 + '</div>';
683 428
684 - if ( ! $entry ) {
685 - FrmAppController::show_error_modal(
686 - array(
687 - 'title' => __( 'You can\'t view the entry', 'formidable' ),
688 - 'body' => __( 'You are trying to view an entry that does not exist', 'formidable' ),
689 - 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
690 - )
691 - );
692 429 return;
693 430 }
694 431
695 432 $data = $entry->description;
696 -
697 433 if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
698 434 $data = array( 'referrer' => $data );
699 435 }
700 436
@@ -700,30 +436,14 @@
700 436
701 437 $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
702 438 $form = FrmForm::getOne( $entry->form_id );
703 439
704 - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php';
440 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
705 441 }
706 442
707 - /**
708 - * Destroy an entry from the admin page.
709 - * 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.
710 - *
711 - * @return void
712 - */
713 443 public static function destroy() {
714 - $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_entries', '_wpnonce', -1 );
444 + FrmAppHelper::permission_check( 'frm_delete_entries' );
715 445
716 - if ( false !== $permission_error ) {
717 - $error_args = array(
718 - 'title' => __( 'Verification failed', 'formidable' ),
719 - 'body' => $permission_error,
720 - 'cancel_url' => admin_url( 'admin.php?page=formidable-entries' ),
721 - );
722 - FrmAppController::show_error_modal( $error_args );
723 - return;
724 - }
725 -
726 446 $params = FrmForm::get_admin_params();
727 447
728 448 if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
729 449 self::unlink_post( $params['id'] );
@@ -729,11 +449,10 @@
729 449 self::unlink_post( $params['id'] );
730 450 }
731 451
732 452 $message = '';
733 -
734 453 if ( FrmEntry::destroy( $params['id'] ) ) {
735 - $message = __( 'Entry was successfully deleted', 'formidable' );
454 + $message = __( 'Entry was Successfully Deleted', 'formidable' );
736 455 }
737 456
738 457 self::display_list( $message );
739 458 }
@@ -738,17 +457,20 @@
738 457 self::display_list( $message );
739 458 }
740 459
741 460 /**
742 - * @param array|string $errors
743 - * @param bool $ajax
744 - *
745 - * @return void
461 + * @deprecated 4.02.04 - Moved to Pro since it was unused in Lite.
746 462 */
463 + public static function destroy_all() {
464 + _deprecated_function( __METHOD__, '4.02.04', 'FrmProEntriesController::destroy_all' );
465 + if ( is_callable( 'FrmProEntriesController::destroy_all' ) ) {
466 + FrmProEntriesController::destroy_all();
467 + }
468 + }
469 +
747 470 public static function process_entry( $errors = '', $ajax = false ) {
748 471 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
749 -
750 - if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
472 + if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
751 473 return;
752 474 }
753 475
754 476 global $frm_vars;
@@ -753,19 +475,12 @@
753 475
754 476 global $frm_vars;
755 477
756 478 $form = FrmForm::getOne( $form_id );
757 -
758 479 if ( ! $form ) {
759 480 return;
760 481 }
761 482
762 - $is_preview = 'frm_forms_preview' === FrmAppHelper::simple_get( 'action' );
763 -
764 - if ( $is_preview && FrmFormsHelper::should_block_preview( $form->form_key ) ) {
765 - return;
766 - }
767 -
768 483 $params = FrmForm::get_params( $form );
769 484
770 485 if ( ! isset( $frm_vars['form_params'] ) ) {
771 486 $frm_vars['form_params'] = array();
@@ -776,9 +491,9 @@
776 491 return;
777 492 }
778 493
779 494 if ( $errors == '' && ! $ajax ) {
780 - $errors = FrmEntryValidate::validate( wp_unslash( $_POST ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
495 + $errors = FrmEntryValidate::validate( wp_unslash( $_POST ) );
781 496 }
782 497
783 498 /**
784 499 * Use this filter to add trigger actions and add errors after
@@ -792,12 +507,11 @@
792 507
793 508 if ( empty( $errors ) ) {
794 509 $_POST['frm_skip_cookie'] = 1;
795 510 $do_success = false;
796 -
797 - if ( $params['action'] === 'create' ) {
511 + if ( $params['action'] == 'create' ) {
798 512 if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
799 - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
513 + $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
800 514
801 515 $params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id'];
802 516 $do_success = true;
803 517 }
@@ -803,13 +517,12 @@
803 517 }
804 518 }
805 519
806 520 do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
807 -
808 521 if ( $do_success ) {
809 522 FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) );
810 523 }
811 - unset( $_POST['frm_skip_cookie'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
524 + unset( $_POST['frm_skip_cookie'] );
812 525 }
813 526 }
814 527
815 528 /**
@@ -824,17 +537,8 @@
824 537 public static function prepare_redirect_url( $url ) {
825 538 return str_replace( array( ' ', '[', ']', '|', '@' ), array( '%20', '%5B', '%5D', '%7C', '%40' ), $url );
826 539 }
827 540
828 - /**
829 - * Delete entry if redirected.
830 - *
831 - * @param string $url
832 - * @param object $form
833 - * @param array $atts
834 - *
835 - * @return string
836 - */
837 541 public static function delete_entry_before_redirect( $url, $form, $atts ) {
838 542 self::_delete_entry( $atts['id'], $form );
839 543
840 544 return $url;
@@ -843,23 +547,13 @@
843 547 /**
844 548 * Delete entry if not redirected.
845 549 *
846 550 * @param array $atts
847 - *
848 - * @return void
849 551 */
850 552 public static function delete_entry_after_save( $atts ) {
851 553 self::_delete_entry( $atts['entry_id'], $atts['form'] );
852 554 }
853 555
854 - /**
855 - * Delete entry if not redirected.
856 - *
857 - * @param int $entry_id
858 - * @param object $form
859 - *
860 - * @return void
861 - */
862 556 private static function _delete_entry( $entry_id, $form ) {
863 557 if ( ! $form ) {
864 558 return;
865 559 }
@@ -864,9 +558,8 @@
864 558 return;
865 559 }
866 560
867 561 FrmAppHelper::unserialize_or_decode( $form->options );
868 -
869 562 if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
870 563 self::unlink_post( $entry_id );
871 564 FrmEntry::destroy( $entry_id );
872 565 }
@@ -873,12 +566,8 @@
873 566 }
874 567
875 568 /**
876 569 * Unlink entry from post
877 - *
878 - * @param int $entry_id
879 - *
880 - * @return void
881 570 */
882 571 private static function unlink_post( $entry_id ) {
883 572 global $wpdb;
884 573 $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $entry_id ) );
@@ -885,42 +574,39 @@
885 574 FrmEntry::clear_cache();
886 575 }
887 576
888 577 /**
889 - * @param array $atts
578 + * @param $atts
890 579 *
891 580 * @return array|string
892 581 */
893 582 public static function show_entry_shortcode( $atts ) {
894 583 $defaults = array(
895 - 'id' => false,
896 - 'entry' => false,
897 - 'fields' => false,
898 - 'plain_text' => false,
899 - 'user_info' => false,
900 - 'include_blank' => false,
901 - 'default_email' => false,
902 - 'form_id' => false,
903 - 'format' => 'text',
904 - 'array_key' => 'key',
905 - 'direction' => 'ltr',
906 - 'font_size' => '',
907 - 'text_color' => '',
908 - 'border_width' => '',
909 - 'border_color' => '',
910 - 'bg_color' => '',
911 - 'alt_bg_color' => '',
912 - 'class' => '',
913 - 'clickable' => false,
914 - 'exclude_fields' => '',
915 - 'include_fields' => '',
916 - 'include_extras' => '',
917 - 'inline_style' => 1,
918 - 'table_style' => '',
919 - // Return embedded fields as nested array.
920 - 'child_array' => false,
921 - 'line_breaks' => true,
922 - 'array_separator' => ', ',
584 + 'id' => false,
585 + 'entry' => false,
586 + 'fields' => false,
587 + 'plain_text' => false,
588 + 'user_info' => false,
589 + 'include_blank' => false,
590 + 'default_email' => false,
591 + 'form_id' => false,
592 + 'format' => 'text',
593 + 'array_key' => 'key',
594 + 'direction' => 'ltr',
595 + 'font_size' => '',
596 + 'text_color' => '',
597 + 'border_width' => '',
598 + 'border_color' => '',
599 + 'bg_color' => '',
600 + 'alt_bg_color' => '',
601 + 'class' => '',
602 + 'clickable' => false,
603 + 'exclude_fields' => '',
604 + 'include_fields' => '',
605 + 'include_extras' => '',
606 + 'inline_style' => 1,
607 + 'child_array' => false, // return embedded fields as nested array
608 + 'line_breaks' => true,
923 609 );
924 610 $defaults = apply_filters( 'frm_show_entry_defaults', $defaults );
925 611
926 612 $atts = shortcode_atts( $defaults, $atts );
@@ -943,13 +629,8 @@
943 629
944 630 return $formatted_entry;
945 631 }
946 632
947 - /**
948 - * @param false|object $entry
949 - *
950 - * @return void
951 - */
952 633 public static function entry_sidebar( $entry = false ) {
953 634 $data = array();
954 635 $id = 0;
955 636
@@ -958,22 +639,36 @@
958 639
959 640 if ( $entry ) {
960 641 $id = $entry->id;
961 642 $data = $entry->description;
962 -
963 643 if ( isset( $data['browser'] ) ) {
964 644 $browser = FrmEntriesHelper::get_browser( $data['browser'] );
965 645 }
966 - /**
967 - * Add or remove information in the entry sidebar.
968 - *
969 - * @since 5.5.2
970 - *
971 - * @param array $data
972 - * @param array{entry:\stdClass} $entry
973 - */
974 - $data = apply_filters( 'frm_sidebar_data', $data, compact( 'entry' ) );
975 646 }
976 647
977 - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php';
648 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
649 + }
650 +
651 + /**
652 + * @deprecated 4.0
653 + */
654 + public static function contextual_help( $help, $screen_id, $screen ) {
655 + _deprecated_function( __METHOD__, '4.0' );
656 + return $help;
657 + }
658 +
659 + /**
660 + * @deprecated 1.07.05
661 + * @codeCoverageIgnore
662 + */
663 + public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
664 + return FrmDeprecated::show_form( $id, $key, $title, $description );
665 + }
666 +
667 + /**
668 + * @deprecated 1.07.05
669 + * @codeCoverageIgnore
670 + */
671 + public static function get_form( $filename, $form, $title, $description ) {
672 + return FrmDeprecated::get_form( $filename, $form, $title, $description );
978 673 }
979 674 }