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