PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0.09
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0.09
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/helpers/FrmFormsListHelper.php +48 -186 6.275.0.09 View file →
@@ -3,12 +3,8 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmFormsListHelper extends FrmListHelper {
7 -
8 - /**
9 - * @var string
10 - */
11 7 public $status = '';
12 8
13 9 public $total_items = 0;
14 10
@@ -15,20 +11,12 @@
15 11 public function __construct( $args ) {
16 12 $this->status = self::get_param( array( 'param' => 'form_type' ) );
17 13
18 14 parent::__construct( $args );
19 - $this->screen->set_screen_reader_content(
20 - array(
21 - 'heading_list' => esc_html__( 'Forms list', 'formidable' ),
22 - )
23 - );
24 15 }
25 16
26 - /**
27 - * @return void
28 - */
29 17 public function prepare_items() {
30 - global $per_page, $mode;
18 + global $wpdb, $per_page, $mode;
31 19
32 20 $page = $this->get_pagenum();
33 21 $per_page = $this->get_items_per_page( 'formidable_page_formidable_per_page' );
34 22
@@ -49,12 +37,9 @@
49 37 'param' => 'order',
50 38 'default' => 'ASC',
51 39 )
52 40 );
53 -
54 - FrmAppController::apply_saved_sort_preference( $orderby, $order );
55 -
56 - $start = self::get_param(
41 + $start = self::get_param(
57 42 array(
58 43 'param' => 'start',
59 44 'default' => ( $page - 1 ) * $per_page,
60 45 )
@@ -86,14 +71,12 @@
86 71 'param' => 's',
87 72 'sanitize' => 'sanitize_text_field',
88 73 )
89 74 );
90 -
91 - if ( $s !== '' ) {
75 + if ( $s != '' ) {
92 76 preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
93 77 $search_terms = array_map( 'trim', $matches[0] );
94 -
95 - foreach ( $search_terms as $term ) {
78 + foreach ( (array) $search_terms as $term ) {
96 79 $s_query[] = array(
97 80 'or' => true,
98 81 'name LIKE' => $term,
99 82 'description LIKE' => $term,
@@ -104,10 +87,10 @@
104 87 unset( $term );
105 88 }
106 89 }
107 90
108 - $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
109 - $total_items = FrmDb::get_count( 'frm_forms', $s_query );
91 + $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
92 + $total_items = FrmDb::get_count( 'frm_forms', $s_query );
110 93 $this->total_items = $total_items;
111 94
112 95 $this->set_pagination_args(
113 96 array(
@@ -116,11 +99,8 @@
116 99 )
117 100 );
118 101 }
119 102
120 - /**
121 - * @return void
122 - */
123 103 public function no_items() {
124 104 if ( $this->status === 'trash' ) {
125 105 echo '<p>';
126 106 esc_html_e( 'No forms found in the trash.', 'formidable' );
@@ -138,9 +118,9 @@
138 118
139 119 public function get_bulk_actions() {
140 120 $actions = array();
141 121
142 - if ( 'trash' === $this->status ) {
122 + if ( 'trash' == $this->status ) {
143 123 if ( current_user_can( 'frm_edit_forms' ) ) {
144 124 $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
145 125 }
146 126
@@ -155,19 +135,14 @@
155 135
156 136 return $actions;
157 137 }
158 138
159 - /**
160 - * @param string $which
161 - *
162 - * @return void
163 - */
164 139 public function extra_tablenav( $which ) {
165 - if ( 'top' !== $which ) {
140 + if ( 'top' != $which ) {
166 141 return;
167 142 }
168 143
169 - if ( 'trash' === $this->status && current_user_can( 'frm_delete_forms' ) ) {
144 + if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) {
170 145 ?>
171 146 <div class="alignleft actions frm_visible_overflow">
172 147 <?php submit_button( __( 'Empty Trash', 'formidable' ), 'apply', 'delete_all', false ); ?>
173 148 </div>
@@ -174,12 +149,10 @@
174 149 <?php
175 150 }
176 151 }
177 152
178 - /**
179 - * @return array
180 - */
181 153 public function get_views() {
154 +
182 155 $statuses = array(
183 156 'published' => __( 'My Forms', 'formidable' ),
184 157 'draft' => __( 'Drafts', 'formidable' ),
185 158 'trash' => __( 'Trash', 'formidable' ),
@@ -186,14 +159,8 @@
186 159 );
187 160
188 161 $links = array();
189 162 $counts = FrmForm::get_count();
190 - $form_type = FrmAppHelper::simple_get( 'form_type', 'sanitize_title', 'published' );
191 -
192 - if ( isset( $statuses[ $form_type ] ) ) {
193 - $counts->$form_type = $this->total_items;
194 - }
195 -
196 163 $form_type = self::get_param(
197 164 array(
198 165 'param' => 'form_type',
199 166 'default' => 'published',
@@ -200,13 +167,18 @@
200 167 )
201 168 );
202 169
203 170 foreach ( $statuses as $status => $name ) {
204 - $class = $status == $form_type ? ' class="current"' : ''; // phpcs:ignore Universal.Operators.StrictComparisons
205 171
172 + if ( $status == $form_type ) {
173 + $class = ' class="current"';
174 + } else {
175 + $class = '';
176 + }
177 +
206 178 if ( $counts->{$status} || 'draft' !== $status ) {
207 179 /* translators: %1$s: Status, %2$s: Number of items */
208 - $links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
180 + $links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
209 181 }
210 182
211 183 unset( $status, $name );
212 184 }
@@ -213,31 +185,20 @@
213 185
214 186 return $links;
215 187 }
216 188
217 - /**
218 - * @param string $which
219 - *
220 - * @return void
221 - */
222 189 public function pagination( $which ) {
223 190 global $mode;
224 191
225 192 parent::pagination( $which );
226 193
227 - if ( 'top' === $which ) {
194 + if ( 'top' == $which ) {
228 195 $this->view_switcher( $mode );
229 196 }
230 197 }
231 198
232 - /**
233 - * @param stdClass $item
234 - * @param string $style
235 - *
236 - * @return string
237 - */
238 199 public function single_row( $item, $style = '' ) {
239 - global $mode;
200 + global $frm_vars, $mode;
240 201
241 202 // Set up the hover actions for this user
242 203 $actions = array();
243 204 $edit_link = FrmForm::get_edit_link( $item->id );
@@ -246,38 +207,27 @@
246 207
247 208 $action_links = $this->row_actions( $actions );
248 209
249 210 // Set up the checkbox ( because the user is editable, otherwise its empty )
250 - $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />';
251 - $checkbox_label_text = sprintf(
252 - // translators: Form title
253 - __( 'Select %s', 'formidable' ),
254 - ! empty( $item->name ) ? $item->name : FrmFormsHelper::get_no_title_text()
255 - );
211 + $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />';
256 212
257 - $checkbox .= '<label for="cb-item-action-' . absint( $item->id ) . '"><span class="screen-reader-text">' . esc_html( $checkbox_label_text ) . '</span></label>';
258 - $r = '<tr id="item-action-' . absint( $item->id ) . '"' . $style . '>';
213 + $r = '<tr id="item-action-' . absint( $item->id ) . '"' . $style . '>';
259 214
260 215 list( $columns, $hidden ) = $this->get_column_info();
261 216
262 217 $format = 'Y/m/d';
263 -
264 - if ( 'list' !== $mode ) {
218 + if ( 'list' != $mode ) {
265 219 $format .= ' \<\b\r \/\> g:i:s a';
266 220 }
267 221
268 222 foreach ( $columns as $column_name => $column_display_name ) {
269 - $class = $column_name . ' column-' . $column_name . ( 'name' === $column_name ? ' post-title page-title column-title' : '' );
223 + $class = $column_name . ' column-' . $column_name . ( 'name' == $column_name ? ' post-title page-title column-title' : '' );
224 +
270 225 $style = '';
271 -
272 - if ( in_array( $column_name, $hidden, true ) ) {
226 + if ( in_array( $column_name, $hidden ) ) {
273 227 $class .= ' frm_hidden';
274 228 }
275 229
276 - if ( $column_name === 'name' ) {
277 - $class .= ' column-primary';
278 - }
279 -
280 230 $class = 'class="' . esc_attr( $class ) . '"';
281 231 $data_colname = ' data-colname="' . esc_attr( $column_display_name ) . '"';
282 232 $attributes = $class . $style . $data_colname;
283 233
@@ -289,17 +239,24 @@
289 239 case 'form_key':
290 240 $val = $item->{$column_name};
291 241 break;
292 242 case 'name':
293 - $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
243 + $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
294 244 $val .= $action_links;
245 +
295 246 break;
296 247 case 'created_at':
297 248 $date = gmdate( $format, strtotime( $item->created_at ) );
298 249 $val = '<abbr title="' . esc_attr( gmdate( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
299 250 break;
251 + case 'shortcode':
252 + $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>';
253 + if ( 'excerpt' == $mode ) {
254 + $val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />';
255 + }
256 + break;
300 257 case 'entries':
301 - if ( ! empty( $item->options['no_save'] ) ) {
258 + if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
302 259 $val = FrmAppHelper::icon_by_class(
303 260 'frmfont frm_forbid_icon frm_bstooltip',
304 261 array(
305 262 'title' => __( 'Saving entries is disabled for this form', 'formidable' ),
@@ -307,18 +264,12 @@
307 264 )
308 265 );
309 266 } else {
310 267 $text = FrmEntry::getRecordCount( $item->id );
311 - $val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
268 + $val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
312 269 unset( $text );
313 270 }
314 - break;
315 - default:
316 - if ( method_exists( $this, 'column_' . $column_name ) ) {
317 - $val = call_user_func( array( $this, 'column_' . $column_name ), $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
318 - }
319 - break;
320 - }//end switch
271 + }
321 272
322 273 if ( isset( $val ) ) {
323 274 $r .= "<td $attributes>";
324 275 $r .= $val;
@@ -324,99 +275,26 @@
324 275 $r .= $val;
325 276 $r .= '</td>';
326 277 }
327 278 unset( $val );
328 - }//end foreach
329 - return $r . '</tr>';
330 - }
331 -
332 - /**
333 - * Get the HTML for the Actions column in the form list.
334 - * This includes multiple icons for triggering the embed modal, the visual styler, and an active landing page.
335 - *
336 - * @since 6.0
337 - *
338 - * @param stdClass $form
339 - *
340 - * @return string
341 - */
342 - protected function column_shortcode( $form ) {
343 - $val = '<a href="#" class="frm-embed-form" role="button" aria-label="' . esc_attr__( 'Embed Form', 'formidable' ) . '">' . FrmAppHelper::icon_by_class( 'frmfont frm_code_icon', array( 'echo' => false ) ) . '</a>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
344 - $val .= $this->column_style( $form );
345 - $val .= $this->column_views( $form );
346 - $val = apply_filters( 'frm_form_list_actions', $val, array( 'form' => $form ) );
347 - // Remove the space hard coded in Landing pages.
348 - $val = str_replace( '&nbsp;', '', $val );
349 - return '<div>' . $val . '</div>';
350 - }
351 -
352 - /**
353 - * Get the HTML for the Style column in the form list.
354 - *
355 - * @since 6.0
356 - *
357 - * @param stdClass $form
358 - *
359 - * @return string
360 - */
361 - protected function column_style( $form ) {
362 - $style_setting = $form->options['custom_style'] ?? '';
363 - $frm_settings = FrmAppHelper::get_settings();
364 -
365 - if ( $style_setting === '0' || 'none' === $frm_settings->load_style ) {
366 - // Don't show a link if styling is off.
367 - return '';
368 279 }
280 + $r .= '</tr>';
369 281
370 - $style = FrmStylesController::get_form_style( $form );
371 -
372 - if ( ! $style ) {
373 - // Do a second pass to avoid null values.
374 - $frm_style = new FrmStyle( 'default' );
375 - $style = $frm_style->get_one();
376 - }
377 -
378 - $href = FrmStylesHelper::get_edit_url( $style, $form->id );
379 - return '<a href="' . esc_url( $href ) . '" title="' . esc_attr( $style->post_title ) . '">' . FrmAppHelper::icon_by_class( 'frmfont frm_pallet_icon', array( 'echo' => false ) ) . '</a>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
282 + return $r;
380 283 }
381 284
382 285 /**
383 - * Generate the HTML for the form Views page.
384 - *
385 - * @since 6.19
386 - *
387 - * @param stdClass $form Form object.
388 - *
389 - * @return string
390 - */
391 - protected function column_views( $form ) {
392 - $attributes = array(
393 - 'href' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $form->id ) . '&show_nav=1' ),
394 - 'title' => __( 'Link to list of all views for this form.', 'formidable' ),
395 - 'target' => '_blank',
396 - );
397 -
398 - return '<a ' . FrmAppHelper::array_to_html_params( $attributes ) . '>
399 - ' . FrmAppHelper::icon_by_class( 'frmfont frm_eye_icon', array( 'echo' => false ) ) .
400 - '</a>';
401 - }
402 -
403 - /**
404 - * @param array $actions
405 - * @param object $item
406 286 * @param string $edit_link
407 - *
408 - * @return void
409 287 */
410 288 private function get_actions( &$actions, $item, $edit_link ) {
411 289 $new_actions = FrmFormsHelper::get_action_links( $item->id, $item );
412 -
413 290 foreach ( $new_actions as $link => $action ) {
414 291 $new_actions[ $link ] = FrmFormsHelper::format_link_html( $action, 'short' );
415 292 }
416 293
417 - if ( 'trash' === $this->status ) {
294 + if ( 'trash' == $this->status ) {
418 295 $actions = $new_actions;
296 +
419 297 return;
420 298 }
421 299
422 300 if ( current_user_can( 'frm_edit_forms' ) ) {
@@ -428,34 +306,25 @@
428 306 $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview', 'formidable' ) . '</a>';
429 307 }
430 308
431 309 /**
432 - * @param object $item
433 - * @param array $actions
434 310 * @param string $edit_link
435 - * @param string $mode
436 - *
437 - * @return string
438 311 */
439 312 private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
440 313 $form_name = $item->name;
441 -
442 - if ( is_null( $form_name ) || trim( $form_name ) === '' ) {
443 - $form_name = FrmFormsHelper::get_no_title_text();
314 + if ( trim( $form_name ) == '' ) {
315 + $form_name = __( '(no title)', 'formidable' );
444 316 }
445 -
446 317 $form_name = FrmAppHelper::kses( $form_name );
447 -
448 - if ( 'excerpt' !== $mode ) {
318 + if ( 'excerpt' != $mode ) {
449 319 $form_name = FrmAppHelper::truncate( $form_name, 50 );
450 320 }
451 321
452 322 $val = '<strong>';
453 -
454 - if ( 'trash' === $this->status ) {
323 + if ( 'trash' == $this->status ) {
455 324 $val .= $form_name;
456 325 } else {
457 - $val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> '; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
326 + $val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> ';
458 327 }
459 328
460 329 $this->add_draft_label( $item, $val );
461 330 $val .= '</strong>';
@@ -465,29 +334,22 @@
465 334 return $val;
466 335 }
467 336
468 337 /**
469 - * @param object $item
470 338 * @param string $val
471 - *
472 - * @return void
473 339 */
474 340 private function add_draft_label( $item, &$val ) {
475 - if ( 'draft' === $item->status && 'draft' !== $this->status ) {
476 - $val .= ' - <span class="post-state">' . esc_html__( 'Draft', 'formidable' ) . '</span>';
341 + if ( 'draft' == $item->status && 'draft' != $this->status ) {
342 + $val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>';
477 343 }
478 344 }
479 345
480 346 /**
481 - * @param object $item
482 347 * @param string $val
483 - *
484 - * @return void
485 348 */
486 349 private function add_form_description( $item, &$val ) {
487 350 global $mode;
488 -
489 - if ( 'excerpt' === $mode && ! is_null( $item->description ) ) {
351 + if ( 'excerpt' == $mode ) {
490 352 $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 );
491 353 }
492 354 }
493 355