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