PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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/FrmEntriesListHelper.php +56 -48 6.26 → trunk View file →
@@ -16,8 +16,11 @@
16 16 * @var bool|int
17 17 */
18 18 public $total_items = 0;
19 19
20 + /**
21 + * @param array $args
22 + */
20 23 public function __construct( $args ) {
21 24 parent::__construct( $args );
22 25 $this->screen->set_screen_reader_content(
23 26 array(
@@ -30,10 +33,9 @@
30 33 * @return void
31 34 */
32 35 public function prepare_items() {
33 36 $this->set_per_page();
34 - $s_query = array();
35 -
37 + $s_query = array();
36 38 $join_form_in_query = false;
37 39
38 40 $this->items = $this->get_entry_items( $s_query, $join_form_in_query );
39 41 $this->set_total_items( $s_query );
@@ -89,12 +91,11 @@
89 91 */
90 92 protected function get_entry_items( &$s_query, &$join_form_in_query ) {
91 93 global $per_page;
92 94 $s_query = $this->get_search_query( $join_form_in_query );
93 - $order = $this->get_order_by();
94 95 $limit = $this->get_limit( $per_page );
95 96
96 - return FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query );
97 + return FrmEntry::getAll( $s_query, $this->get_order_by(), $limit, true, $join_form_in_query );
97 98 }
98 99
99 100 /**
100 101 * @since 6.5.4
@@ -116,9 +117,9 @@
116 117 );
117 118
118 119 FrmAppController::apply_saved_sort_preference( $orderby, $order );
119 120
120 - if ( strpos( $orderby, 'meta' ) !== false ) {
121 + if ( str_contains( $orderby, 'meta' ) ) {
121 122 $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
122 123
123 124 if ( in_array( $order_field_type, array( 'number', 'scale', 'star' ), true ) ) {
124 125 $orderby .= '+0';
@@ -176,9 +177,9 @@
176 177 'sanitize' => 'sanitize_text_field',
177 178 )
178 179 );
179 180
180 - if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
181 + if ( $s !== '' && FrmAppHelper::pro_is_installed() ) {
181 182 $fid = self::get_param( array( 'param' => 'fid' ) );
182 183 $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
183 184 }
184 185
@@ -206,11 +207,22 @@
206 207 'sanitize' => 'sanitize_text_field',
207 208 )
208 209 );
209 210
210 - if ( ! empty( $s ) ) {
211 - esc_html_e( 'No Entries Found', 'formidable' );
211 + if ( $s !== '' ) {
212 + $current_url = set_url_scheme(
213 + 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' )
214 + );
215 + $clear_url = remove_query_arg( 's', $current_url );
212 216
217 + echo '<p>';
218 + printf(
219 + /* translators: %1$s: Start link HTML, %2$s: End link HTML */
220 + esc_html__( 'No entries match your search. %1$sClear search%2$s', 'formidable' ),
221 + '<a href="' . esc_url( $clear_url ) . '">',
222 + '</a>'
223 + );
224 + echo '</p>';
213 225 return;
214 226 }
215 227
216 228 $form_id = $this->params['form'];
@@ -242,14 +254,14 @@
242 254 // Searching is a pro feature
243 255 }
244 256
245 257 /**
246 - * @param string $which
258 + * @param string $which
247 259 *
248 260 * @return void
249 261 */
250 262 protected function display_tablenav( $which ) {
251 - $is_footer = ( $which !== 'top' );
263 + $is_footer = $which !== 'top';
252 264
253 265 if ( $is_footer && ! empty( $this->items ) ) {
254 266 $utm = array(
255 267 'campaign' => 'spam-protection',
@@ -254,8 +266,9 @@
254 266 $utm = array(
255 267 'campaign' => 'spam-protection',
256 268 'content' => 'entries-list-spam-protection',
257 269 );
270 + // phpcs:disable Generic.WhiteSpace.ScopeIndent
258 271 ?>
259 272 <p>
260 273 <?php esc_html_e( 'Getting spam form submissions?', 'formidable' ); ?>
261 274 <a href="<?php echo esc_url( FrmAppHelper::admin_upgrade_link( $utm, 'knowledgebase/add-spam-protection/' ) ); ?>" target="_blank">
@@ -262,14 +275,15 @@
262 275 <?php esc_html_e( 'Learn how to prevent them.', 'formidable' ); ?>
263 276 </a>
264 277 </p>
265 278 <?php
279 + // phpcs:enable Generic.WhiteSpace.ScopeIndent
266 280 }
267 281 parent::display_tablenav( $which );
268 282 }
269 283
270 284 /**
271 - * @param string $which
285 + * @param string $which
272 286 *
273 287 * @return void
274 288 */
275 289 protected function extra_tablenav( $which ) {
@@ -274,20 +288,22 @@
274 288 */
275 289 protected function extra_tablenav( $which ) {
276 290 $form_id = FrmAppHelper::simple_get( 'form', 'absint' );
277 291
278 - if ( $which === 'top' && ! $form_id ) {
279 - echo '<div class="alignleft actions">';
292 + if ( $which !== 'top' || $form_id ) {
293 + return;
294 + }
280 295
281 - // Override the referrer to prevent it from being used for the screen options.
282 - echo '<input type="hidden" name="_wp_http_referer" value="" />';
296 + echo '<div class="alignleft actions">';
283 297
284 - echo '<label for="form" class="screen-reader-text">' . esc_html__( 'Filter by form', 'formidable' ) . '</label>';
298 + // Override the referrer to prevent it from being used for the screen options.
299 + echo '<input type="hidden" name="_wp_http_referer" value="" />';
285 300
286 - FrmFormsHelper::forms_dropdown( 'form', $form_id, array( 'blank' => __( 'View all forms', 'formidable' ) ) );
287 - submit_button( __( 'Filter', 'formidable' ), 'filter_action action', '', false, array( 'id' => 'post-query-submit' ) );
288 - echo '</div>';
289 - }
301 + echo '<label for="form" class="screen-reader-text">' . esc_html__( 'Filter by form', 'formidable' ) . '</label>';
302 +
303 + FrmFormsHelper::forms_dropdown( 'form', $form_id, array( 'blank' => __( 'View all forms', 'formidable' ) ) );
304 + submit_button( __( 'Filter', 'formidable' ), 'filter_action action', '', false, array( 'id' => 'post-query-submit' ) );
305 + echo '</div>';
290 306 }
291 307
292 308 /**
293 309 * Gets the name of the primary column in the Entries screen
@@ -293,18 +309,17 @@
293 309 * Gets the name of the primary column in the Entries screen
294 310 *
295 311 * @since 2.0.14
296 312 *
297 - * @return string $primary_column
313 + * @return string Primary column.
298 314 */
299 315 protected function get_primary_column_name() {
300 - $columns = get_column_headers( $this->screen );
301 - $hidden = get_hidden_columns( $this->screen );
302 -
316 + $columns = get_column_headers( $this->screen );
317 + $hidden = get_hidden_columns( $this->screen );
303 318 $primary_column = '';
304 319
305 320 foreach ( $columns as $column_key => $column_display_name ) {
306 - if ( 'cb' !== $column_key && ! in_array( $column_key, $hidden ) ) {
321 + if ( 'cb' !== $column_key && ! in_array( $column_key, $hidden, true ) ) {
307 322 $primary_column = $column_key;
308 323 break;
309 324 }
310 325 }
@@ -327,10 +342,10 @@
327 342 return sprintf( __( 'Entry %d', 'formidable' ), $item->id );
328 343 }
329 344
330 345 /**
331 - * @param object $item
332 - * @param string $style
346 + * @param stdClass $item
347 + * @param string $style
333 348 *
334 349 * @return string
335 350 */
336 351 public function single_row( $item, $style = '' ) {
@@ -344,9 +359,9 @@
344 359
345 360 // Set up the checkbox ( because the user is editable, otherwise its empty )
346 361 $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
347 362 /* translators: %s: Form name */
348 - $checkbox .= "<label for='cb-item-action-{$item->id}'><span class='screen-reader-text'>" . esc_html( sprintf( __( 'Select %s', 'formidable' ), self::get_entry_label( $item ) ) ) . '</span></label>';
363 + $checkbox .= "<label for='cb-item-action-{$item->id}'><span class='screen-reader-text'>" . esc_html( sprintf( __( 'Select %s', 'formidable' ), self::get_entry_label( $item ) ) ) . '</span></label>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
349 364
350 365 $r = "<tr id='item-action-{$item->id}'$style>";
351 366
352 367 list( $columns, $hidden, , $primary ) = $this->get_column_info();
@@ -360,9 +375,9 @@
360 375 $class .= ' column-primary';
361 376 }
362 377
363 378 if ( in_array( $column_name, $hidden, true ) ) {
364 - $class .= ' frm_hidden';
379 + $class .= ' hidden';
365 380 } elseif ( ! $action_col && ! in_array( $column_name, $action_columns, true ) ) {
366 381 $action_col = $column_name;
367 382 }
368 383
@@ -367,10 +382,9 @@
367 382 }
368 383
369 384 $attributes = 'class="' . esc_attr( $class ) . '"';
370 385 unset( $class );
371 - $attributes .= ' data-colname="' . $column_display_name . '"';
372 -
386 + $attributes .= ' data-colname="' . $column_display_name . '"';
373 387 $form_id = $this->params['form'] ? $this->params['form'] : 0;
374 388 $this->column_name = preg_replace( '/^(' . $form_id . '_)/', '', $column_name );
375 389
376 390 if ( $this->column_name === 'cb' ) {
@@ -375,16 +389,12 @@
375 389
376 390 if ( $this->column_name === 'cb' ) {
377 391 $r .= "<th scope='row' class='check-column'>$checkbox</th>";
378 392 } else {
379 - if ( in_array( $column_name, $hidden, true ) ) {
380 - $val = '';
381 - } else {
382 - $val = $this->column_value( $item );
383 - }
393 + $val = in_array( $column_name, $hidden, true ) ? '' : $this->column_value( $item );
394 + $r .= "<td $attributes>";
384 395
385 - $r .= "<td $attributes>";
386 -
396 + // phpcs:ignore Universal.Operators.StrictComparisons
387 397 if ( $column_name == $action_col ) {
388 398 $edit_link = admin_url( 'admin.php?page=formidable-entries&frm_action=edit&id=' . $item->id );
389 399 $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
390 400 $r .= $action_links;
@@ -395,11 +405,9 @@
395 405 $r .= '</td>';
396 406 }//end if
397 407 unset( $val );
398 408 }//end foreach
399 - $r .= '</tr>';
400 -
401 - return $r;
409 + return $r . '</tr>';
402 410 }
403 411
404 412 /**
405 413 * Get the column names that the logged in user can action on
@@ -490,10 +498,10 @@
490 498 *
491 499 * @return string
492 500 */
493 501 private function maybe_fix_column_name( $column_name ) {
494 - if ( 0 === strpos( $column_name, '0_' ) ) {
495 - $column_name = substr( $column_name, 2 );
502 + if ( str_starts_with( $column_name, '0_' ) ) {
503 + return substr( $column_name, 2 );
496 504 }
497 505 return $column_name;
498 506 }
499 507
@@ -504,13 +512,13 @@
504 512 *
505 513 * @return void
506 514 */
507 515 private function get_actions( &$actions, $item, $view_link ) {
508 - $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
516 + $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . esc_html__( 'View', 'formidable' ) . '</a>';
509 517
510 518 if ( current_user_can( 'frm_delete_entries' ) ) {
511 519 $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
512 - $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Permanently delete this entry?', 'formidable' ) . '" data-frmverify-btn="frm-button-red">' . __( 'Delete', 'formidable' ) . '</a>';
520 + $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Permanently delete this entry?', 'formidable' ) . '" data-frmverify-btn="frm-button-red">' . esc_html__( 'Delete', 'formidable' ) . '</a>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
513 521 }
514 522
515 523 $actions = apply_filters( 'frm_row_actions', $actions, $item );
516 524 }
@@ -516,9 +524,9 @@
516 524 }
517 525
518 526 /**
519 527 * @param object $item
520 - * @param false $val
528 + * @param mixed $val
521 529 *
522 530 * @return void
523 531 */
524 532 private function get_column_value( $item, &$val ) {
@@ -523,9 +531,9 @@
523 531 */
524 532 private function get_column_value( $item, &$val ) {
525 533 $col_name = $this->column_name;
526 534
527 - if ( strpos( $col_name, 'frmsep_' ) === 0 ) {
535 + if ( str_starts_with( $col_name, 'frmsep_' ) ) {
528 536 $sep_val = true;
529 537 $col_name = str_replace( 'frmsep_', '', $col_name );
530 538 } else {
531 539 $sep_val = false;
@@ -530,9 +538,9 @@
530 538 } else {
531 539 $sep_val = false;
532 540 }
533 541
534 - if ( strpos( $col_name, '-_-' ) ) {
542 + if ( str_contains( $col_name, '-_-' ) ) {
535 543 list( $col_name, $embedded_field_id ) = explode( '-_-', $col_name );
536 544 }
537 545
538 546 $field = FrmField::getOne( $col_name );