PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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 +30 -178 6.265.0 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,18 +11,10 @@
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 18 global $wpdb, $per_page, $mode;
31 19
32 20 $page = $this->get_pagenum();
@@ -49,11 +37,8 @@
49 37 'param' => 'order',
50 38 'default' => 'ASC',
51 39 )
52 40 );
53 -
54 - FrmAppController::apply_saved_sort_preference( $orderby, $order );
55 -
56 41 $start = self::get_param(
57 42 array(
58 43 'param' => 'start',
59 44 'default' => ( $page - 1 ) * $per_page,
@@ -86,14 +71,12 @@
86 71 'param' => 's',
87 72 'sanitize' => 'sanitize_text_field',
88 73 )
89 74 );
90 -
91 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',
@@ -218,29 +185,18 @@
218 185
219 186 return $links;
220 187 }
221 188
222 - /**
223 - * @param string $which
224 - *
225 - * @return void
226 - */
227 189 public function pagination( $which ) {
228 190 global $mode;
229 191
230 192 parent::pagination( $which );
231 193
232 - if ( 'top' === $which ) {
194 + if ( 'top' == $which ) {
233 195 $this->view_switcher( $mode );
234 196 }
235 197 }
236 198
237 - /**
238 - * @param stdClass $item
239 - * @param string $style
240 - *
241 - * @return string
242 - */
243 199 public function single_row( $item, $style = '' ) {
244 200 global $frm_vars, $mode;
245 201
246 202 // Set up the hover actions for this user
@@ -251,40 +207,27 @@
251 207
252 208 $action_links = $this->row_actions( $actions );
253 209
254 210 // Set up the checkbox ( because the user is editable, otherwise its empty )
255 - $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />';
256 - $checkbox_label_text = sprintf(
257 - // translators: Form title
258 - __( 'Select %s', 'formidable' ),
259 - ! empty( $item->name ) ? $item->name : FrmFormsHelper::get_no_title_text()
260 - );
211 + $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />';
261 212
262 - $checkbox .= '<label for="cb-item-action-' . absint( $item->id ) . '"><span class="screen-reader-text">' . esc_html( $checkbox_label_text ) . '</span></label>';
263 -
264 213 $r = '<tr id="item-action-' . absint( $item->id ) . '"' . $style . '>';
265 214
266 215 list( $columns, $hidden ) = $this->get_column_info();
267 216
268 217 $format = 'Y/m/d';
269 -
270 - if ( 'list' !== $mode ) {
218 + if ( 'list' != $mode ) {
271 219 $format .= ' \<\b\r \/\> g:i:s a';
272 220 }
273 221
274 222 foreach ( $columns as $column_name => $column_display_name ) {
275 - $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' : '' );
276 224
277 225 $style = '';
278 -
279 - if ( in_array( $column_name, $hidden, true ) ) {
226 + if ( in_array( $column_name, $hidden ) ) {
280 227 $class .= ' frm_hidden';
281 228 }
282 229
283 - if ( $column_name === 'name' ) {
284 - $class .= ' column-primary';
285 - }
286 -
287 230 $class = 'class="' . esc_attr( $class ) . '"';
288 231 $data_colname = ' data-colname="' . esc_attr( $column_display_name ) . '"';
289 232 $attributes = $class . $style . $data_colname;
290 233
@@ -296,15 +239,22 @@
296 239 case 'form_key':
297 240 $val = $item->{$column_name};
298 241 break;
299 242 case 'name':
300 - $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
243 + $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
301 244 $val .= $action_links;
245 +
302 246 break;
303 247 case 'created_at':
304 248 $date = gmdate( $format, strtotime( $item->created_at ) );
305 249 $val = '<abbr title="' . esc_attr( gmdate( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
306 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;
307 257 case 'entries':
308 258 if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
309 259 $val = FrmAppHelper::icon_by_class(
310 260 'frmfont frm_forbid_icon frm_bstooltip',
@@ -317,15 +267,9 @@
317 267 $text = FrmEntry::getRecordCount( $item->id );
318 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;
319 269 unset( $text );
320 270 }
321 - break;
322 - default:
323 - if ( method_exists( $this, 'column_' . $column_name ) ) {
324 - $val = call_user_func( array( $this, 'column_' . $column_name ), $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
325 - }
326 - break;
327 - }//end switch
271 + }
328 272
329 273 if ( isset( $val ) ) {
330 274 $r .= "<td $attributes>";
331 275 $r .= $val;
@@ -331,9 +275,9 @@
331 275 $r .= $val;
332 276 $r .= '</td>';
333 277 }
334 278 unset( $val );
335 - }//end foreach
279 + }
336 280 $r .= '</tr>';
337 281
338 282 return $r;
339 283 }
@@ -338,95 +282,19 @@
338 282 return $r;
339 283 }
340 284
341 285 /**
342 - * Get the HTML for the Actions column in the form list.
343 - * This includes multiple icons for triggering the embed modal, the visual styler, and an active landing page.
344 - *
345 - * @since 6.0
346 - *
347 - * @param stdClass $form
348 - *
349 - * @return string
350 - */
351 - protected function column_shortcode( $form ) {
352 - $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>';
353 - $val .= $this->column_style( $form );
354 - $val .= $this->column_views( $form );
355 - $val = apply_filters( 'frm_form_list_actions', $val, array( 'form' => $form ) );
356 - // Remove the space hard coded in Landing pages.
357 - $val = str_replace( '&nbsp;', '', $val );
358 - $val = '<div>' . $val . '</div>';
359 - return $val;
360 - }
361 -
362 - /**
363 - * Get the HTML for the Style column in the form list.
364 - *
365 - * @since 6.0
366 - *
367 - * @param stdClass $form
368 - *
369 - * @return string
370 - */
371 - protected function column_style( $form ) {
372 - $style_setting = $form->options['custom_style'] ?? '';
373 - $frm_settings = FrmAppHelper::get_settings();
374 -
375 - if ( $style_setting === '0' || 'none' === $frm_settings->load_style ) {
376 - // Don't show a link if styling is off.
377 - return '';
378 - }
379 -
380 - $style = FrmStylesController::get_form_style( $form );
381 -
382 - if ( ! $style ) {
383 - // Do a second pass to avoid null values.
384 - $frm_style = new FrmStyle( 'default' );
385 - $style = $frm_style->get_one();
386 - }
387 -
388 - $href = FrmStylesHelper::get_edit_url( $style, $form->id );
389 - return '<a href="' . esc_url( $href ) . '" title="' . esc_attr( $style->post_title ) . '">' . FrmAppHelper::icon_by_class( 'frmfont frm_pallet_icon', array( 'echo' => false ) ) . '</a>';
390 - }
391 -
392 - /**
393 - * Generate the HTML for the form Views page.
394 - *
395 - * @since 6.19
396 - *
397 - * @param stdClass $form Form object.
398 - *
399 - * @return string
400 - */
401 - protected function column_views( $form ) {
402 - $attributes = array(
403 - 'href' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $form->id ) . '&show_nav=1' ),
404 - 'title' => __( 'Link to list of all views for this form.', 'formidable' ),
405 - 'target' => '_blank',
406 - );
407 -
408 - return '<a ' . FrmAppHelper::array_to_html_params( $attributes ) . '>
409 - ' . FrmAppHelper::icon_by_class( 'frmfont frm_eye_icon', array( 'echo' => false ) ) .
410 - '</a>';
411 - }
412 -
413 - /**
414 - * @param array $actions
415 - * @param object $item
416 286 * @param string $edit_link
417 - *
418 - * @return void
419 287 */
420 288 private function get_actions( &$actions, $item, $edit_link ) {
421 289 $new_actions = FrmFormsHelper::get_action_links( $item->id, $item );
422 -
423 290 foreach ( $new_actions as $link => $action ) {
424 291 $new_actions[ $link ] = FrmFormsHelper::format_link_html( $action, 'short' );
425 292 }
426 293
427 - if ( 'trash' === $this->status ) {
294 + if ( 'trash' == $this->status ) {
428 295 $actions = $new_actions;
296 +
429 297 return;
430 298 }
431 299
432 300 if ( current_user_can( 'frm_edit_forms' ) ) {
@@ -438,31 +306,22 @@
438 306 $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview', 'formidable' ) . '</a>';
439 307 }
440 308
441 309 /**
442 - * @param object $item
443 - * @param array $actions
444 310 * @param string $edit_link
445 - * @param string $mode
446 - *
447 - * @return string
448 311 */
449 312 private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
450 313 $form_name = $item->name;
451 -
452 - if ( is_null( $form_name ) || trim( $form_name ) === '' ) {
453 - $form_name = FrmFormsHelper::get_no_title_text();
314 + if ( trim( $form_name ) == '' ) {
315 + $form_name = __( '(no title)', 'formidable' );
454 316 }
455 -
456 317 $form_name = FrmAppHelper::kses( $form_name );
457 -
458 318 if ( 'excerpt' != $mode ) {
459 319 $form_name = FrmAppHelper::truncate( $form_name, 50 );
460 320 }
461 321
462 322 $val = '<strong>';
463 -
464 - if ( 'trash' === $this->status ) {
323 + if ( 'trash' == $this->status ) {
465 324 $val .= $form_name;
466 325 } else {
467 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> ';
468 327 }
@@ -475,29 +334,22 @@
475 334 return $val;
476 335 }
477 336
478 337 /**
479 - * @param object $item
480 338 * @param string $val
481 - *
482 - * @return void
483 339 */
484 340 private function add_draft_label( $item, &$val ) {
485 - if ( 'draft' === $item->status && 'draft' != $this->status ) {
486 - $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>';
487 343 }
488 344 }
489 345
490 346 /**
491 - * @param object $item
492 347 * @param string $val
493 - *
494 - * @return void
495 348 */
496 349 private function add_form_description( $item, &$val ) {
497 350 global $mode;
498 -
499 - if ( 'excerpt' === $mode && ! is_null( $item->description ) ) {
351 + if ( 'excerpt' == $mode ) {
500 352 $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 );
501 353 }
502 354 }
503 355