| @@ -149,9 +149,9 @@ | ||
| 149 | 149 | // wp_enqueue_script( 'list-table' ); |
| 150 | 150 | add_action( 'admin_footer', array( $this, '_js_vars' ) ); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if ( empty( $this->modes ) ) { | |
| 153 | + if ( ! $this->modes ) { | |
| 154 | 154 | $this->modes = array( |
| 155 | 155 | 'list' => __( 'List View', 'formidable' ), |
| 156 | 156 | 'excerpt' => __( 'Excerpt View', 'formidable' ), |
| 157 | 157 | ); |
| @@ -161,8 +161,11 @@ | ||
| 161 | 161 | public function ajax_user_can() { |
| 162 | 162 | return current_user_can( 'administrator' ); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | + /** | |
| 166 | + * @return array | |
| 167 | + */ | |
| 165 | 168 | public function get_columns() { |
| 166 | 169 | return array(); |
| 167 | 170 | } |
| 168 | 171 | |
| @@ -222,10 +225,17 @@ | ||
| 222 | 225 | $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
| 223 | 226 | } |
| 224 | 227 | |
| 225 | 228 | // Redirect if page number is invalid and headers are not already sent. |
| 226 | - if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) { | |
| 227 | - wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) ); | |
| 229 | + if ( ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) { | |
| 230 | + $url = add_query_arg( 'paged', $args['total_pages'] ); | |
| 231 | + | |
| 232 | + if ( headers_sent() ) { | |
| 233 | + FrmAppHelper::js_redirect( $url, true ); | |
| 234 | + exit; | |
| 235 | + } | |
| 236 | + | |
| 237 | + wp_safe_redirect( $url ); | |
| 228 | 238 | exit; |
| 229 | 239 | } |
| 230 | 240 | |
| 231 | 241 | $this->_pagination_args = $args; |
| @@ -241,15 +251,13 @@ | ||
| 241 | 251 | * |
| 242 | 252 | * @return int Number of items that correspond to the given pagination argument. |
| 243 | 253 | */ |
| 244 | 254 | public function get_pagination_arg( $key ) { |
| 245 | - if ( 'page' == $key ) { | |
| 255 | + if ( 'page' === $key ) { | |
| 246 | 256 | return $this->get_pagenum(); |
| 247 | 257 | } |
| 248 | 258 | |
| 249 | - if ( isset( $this->_pagination_args[ $key ] ) ) { | |
| 250 | - return $this->_pagination_args[ $key ]; | |
| 251 | - } | |
| 259 | + return $this->_pagination_args[ $key ] ?? null; | |
| 252 | 260 | } |
| 253 | 261 | |
| 254 | 262 | /** |
| 255 | 263 | * Whether the table has items to display or not |
| @@ -296,12 +304,14 @@ | ||
| 296 | 304 | * |
| 297 | 305 | * @return void |
| 298 | 306 | */ |
| 299 | 307 | private function hidden_search_inputs( $param_name ) { |
| 300 | - if ( ! empty( $_REQUEST[ $param_name ] ) ) { | |
| 301 | - $value = sanitize_text_field( wp_unslash( $_REQUEST[ $param_name ] ) ); | |
| 302 | - echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $value ) . '" />'; | |
| 308 | + if ( empty( $_REQUEST[ $param_name ] ) ) { | |
| 309 | + return; | |
| 303 | 310 | } |
| 311 | + | |
| 312 | + $value = sanitize_text_field( wp_unslash( $_REQUEST[ $param_name ] ) ); | |
| 313 | + echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $value ) . '" />'; | |
| 304 | 314 | } |
| 305 | 315 | |
| 306 | 316 | /** |
| 307 | 317 | * Get an associative array ( id => link ) with the list |
| @@ -333,9 +343,9 @@ | ||
| 333 | 343 | * @param array $views An array of available list table views. |
| 334 | 344 | */ |
| 335 | 345 | $views = apply_filters( 'views_' . $this->screen->id, $views ); |
| 336 | 346 | |
| 337 | - if ( empty( $views ) ) { | |
| 347 | + if ( ! $views ) { | |
| 338 | 348 | return; |
| 339 | 349 | } |
| 340 | 350 | |
| 341 | 351 | echo "<ul class='subsubsub'>\n"; |
| @@ -391,9 +401,9 @@ | ||
| 391 | 401 | } else { |
| 392 | 402 | $two = '2'; |
| 393 | 403 | }//end if |
| 394 | 404 | |
| 395 | - if ( empty( $this->_actions ) ) { | |
| 405 | + if ( ! $this->_actions ) { | |
| 396 | 406 | return; |
| 397 | 407 | } |
| 398 | 408 | |
| 399 | 409 | echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . esc_html__( 'Select bulk action', 'formidable' ) . '</label>'; |
| @@ -460,13 +470,9 @@ | ||
| 460 | 470 | } |
| 461 | 471 | |
| 462 | 472 | $action = $this->get_bulk_action( 'action' ); |
| 463 | 473 | |
| 464 | - if ( $action === false ) { | |
| 465 | - $action = $this->get_bulk_action( 'action2' ); | |
| 466 | - } | |
| 467 | - | |
| 468 | - return $action; | |
| 474 | + return $action === false ? $this->get_bulk_action( 'action2' ) : $action; | |
| 469 | 475 | } |
| 470 | 476 | |
| 471 | 477 | /** |
| 472 | 478 | * @param string $action_name |
| @@ -481,10 +487,11 @@ | ||
| 481 | 487 | 'sanitize' => 'sanitize_text_field', |
| 482 | 488 | ) |
| 483 | 489 | ); |
| 484 | 490 | |
| 491 | + // phpcs:ignore Universal.Operators.StrictComparisons | |
| 485 | 492 | if ( $action_param && - 1 != $action_param ) { |
| 486 | - $action = $action_param; | |
| 493 | + return $action_param; | |
| 487 | 494 | } |
| 488 | 495 | |
| 489 | 496 | return $action; |
| 490 | 497 | } |
| @@ -501,14 +508,13 @@ | ||
| 501 | 508 | */ |
| 502 | 509 | protected function row_actions( $actions, $always_visible = false ) { |
| 503 | 510 | $action_count = count( $actions ); |
| 504 | 511 | |
| 505 | - $i = 0; | |
| 506 | - | |
| 507 | 512 | if ( ! $action_count ) { |
| 508 | 513 | return ''; |
| 509 | 514 | } |
| 510 | 515 | |
| 516 | + $i = 0; | |
| 511 | 517 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
| 512 | 518 | |
| 513 | 519 | foreach ( $actions as $action => $link ) { |
| 514 | 520 | ++$i; |
| @@ -517,11 +523,9 @@ | ||
| 517 | 523 | } |
| 518 | 524 | |
| 519 | 525 | $out .= '</div>'; |
| 520 | 526 | |
| 521 | - $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'formidable' ) . '</span></button>'; | |
| 522 | - | |
| 523 | - return $out; | |
| 527 | + return $out . ( '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' ); | |
| 524 | 528 | } |
| 525 | 529 | |
| 526 | 530 | /** |
| 527 | 531 | * Display a view switcher |
| @@ -530,8 +534,9 @@ | ||
| 530 | 534 | * |
| 531 | 535 | * @param string $current_mode |
| 532 | 536 | */ |
| 533 | 537 | protected function view_switcher( $current_mode ) { |
| 538 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 534 | 539 | ?> |
| 535 | 540 | <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>"/> |
| 536 | 541 | <div class="view-switch"> |
| 537 | 542 | <?php |
| @@ -537,9 +542,9 @@ | ||
| 537 | 542 | <?php |
| 538 | 543 | foreach ( $this->modes as $mode => $title ) { |
| 539 | 544 | $classes = array( 'view-' . $mode ); |
| 540 | 545 | |
| 541 | - if ( $current_mode == $mode ) { | |
| 546 | + if ( $current_mode === $mode ) { | |
| 542 | 547 | $classes[] = 'current'; |
| 543 | 548 | } |
| 544 | 549 | |
| 545 | 550 | printf( |
| @@ -551,8 +556,9 @@ | ||
| 551 | 556 | } |
| 552 | 557 | ?> |
| 553 | 558 | </div> |
| 554 | 559 | <?php |
| 560 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 555 | 561 | } |
| 556 | 562 | |
| 557 | 563 | /** |
| 558 | 564 | * Get the current page number |
| @@ -583,9 +589,9 @@ | ||
| 583 | 589 | */ |
| 584 | 590 | protected function get_items_per_page( $option, $default = 20 ) { |
| 585 | 591 | $per_page = (int) get_user_option( $option ); |
| 586 | 592 | |
| 587 | - if ( empty( $per_page ) || $per_page < 1 ) { | |
| 593 | + if ( ! $per_page || $per_page < 1 ) { | |
| 588 | 594 | $per_page = $default; |
| 589 | 595 | } |
| 590 | 596 | |
| 591 | 597 | /** |
| @@ -611,9 +617,9 @@ | ||
| 611 | 617 | * |
| 612 | 618 | * @param string $which |
| 613 | 619 | */ |
| 614 | 620 | protected function pagination( $which ) { |
| 615 | - if ( empty( $this->_pagination_args ) ) { | |
| 621 | + if ( ! $this->_pagination_args ) { | |
| 616 | 622 | return; |
| 617 | 623 | } |
| 618 | 624 | |
| 619 | 625 | $total_items = $this->_pagination_args['total_items']; |
| @@ -626,17 +632,14 @@ | ||
| 626 | 632 | |
| 627 | 633 | /* translators: %s: Number of items */ |
| 628 | 634 | $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items, 'formidable' ), number_format_i18n( $total_items ) ) . '</span>'; |
| 629 | 635 | |
| 630 | - $current = $this->get_pagenum(); | |
| 631 | - | |
| 632 | - $page_links = array(); | |
| 633 | - | |
| 636 | + $current = $this->get_pagenum(); | |
| 637 | + $page_links = array(); | |
| 634 | 638 | $total_pages_before = '<span class="paging-input">'; |
| 635 | 639 | $total_pages_after = '</span>'; |
| 640 | + $disable = $this->disabled_pages( $total_pages ); | |
| 636 | 641 | |
| 637 | - $disable = $this->disabled_pages( $total_pages ); | |
| 638 | - | |
| 639 | 642 | $page_links[] = $this->add_page_link( |
| 640 | 643 | array( |
| 641 | 644 | 'page' => 'first', |
| 642 | 645 | 'arrow' => '«', |
| @@ -653,15 +656,15 @@ | ||
| 653 | 656 | 'disabled' => $disable['prev'], |
| 654 | 657 | ) |
| 655 | 658 | ); |
| 656 | 659 | |
| 657 | - if ( 'bottom' == $which ) { | |
| 660 | + if ( 'bottom' === $which ) { | |
| 658 | 661 | $html_current_page = $current; |
| 659 | - $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</span><span id="table-paging" class="paging-input">'; | |
| 662 | + $total_pages_before = '<span class="screen-reader-text">' . esc_html__( 'Current Page', 'formidable' ) . '</span><span id="table-paging" class="paging-input">'; | |
| 660 | 663 | } else { |
| 661 | 664 | $html_current_page = sprintf( |
| 662 | 665 | "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />", |
| 663 | - '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</label>', | |
| 666 | + '<label for="current-page-selector" class="screen-reader-text">' . esc_html__( 'Current Page', 'formidable' ) . '</label>', | |
| 664 | 667 | $current, |
| 665 | 668 | strlen( $total_pages ) |
| 666 | 669 | ); |
| 667 | 670 | } |
| @@ -690,9 +693,9 @@ | ||
| 690 | 693 | ); |
| 691 | 694 | |
| 692 | 695 | $pagination_links_class = 'pagination-links'; |
| 693 | 696 | |
| 694 | - if ( ! empty( $infinite_scroll ) ) { | |
| 697 | + if ( $infinite_scroll ) { | |
| 695 | 698 | $pagination_links_class = ' hide-if-js'; |
| 696 | 699 | } |
| 697 | 700 | |
| 698 | 701 | $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . implode( "\n", $page_links ) . '</span>'; |
| @@ -720,19 +723,21 @@ | ||
| 720 | 723 | 'prev' => false, |
| 721 | 724 | 'next' => false, |
| 722 | 725 | ); |
| 723 | 726 | |
| 727 | + // phpcs:ignore Universal.Operators.StrictComparisons | |
| 724 | 728 | if ( $current == 1 ) { |
| 725 | 729 | $disable['first'] = true; |
| 726 | 730 | $disable['prev'] = true; |
| 727 | - } elseif ( $current == 2 ) { | |
| 731 | + } elseif ( $current == 2 ) { // phpcs:ignore Universal.Operators.StrictComparisons | |
| 728 | 732 | $disable['first'] = true; |
| 729 | 733 | } |
| 730 | 734 | |
| 735 | + // phpcs:ignore Universal.Operators.StrictComparisons | |
| 731 | 736 | if ( $current == $total_pages ) { |
| 732 | 737 | $disable['last'] = true; |
| 733 | 738 | $disable['next'] = true; |
| 734 | - } elseif ( $current == $total_pages - 1 ) { | |
| 739 | + } elseif ( $current == $total_pages - 1 ) { // phpcs:ignore Universal.Operators.StrictComparisons | |
| 735 | 740 | $disable['last'] = true; |
| 736 | 741 | } |
| 737 | 742 | |
| 738 | 743 | return $disable; |
| @@ -755,9 +760,8 @@ | ||
| 755 | 760 | } |
| 756 | 761 | |
| 757 | 762 | private function current_url() { |
| 758 | 763 | $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 759 | - | |
| 760 | 764 | return remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url ); |
| 761 | 765 | } |
| 762 | 766 | |
| 763 | 767 | /** |
| @@ -765,15 +769,9 @@ | ||
| 765 | 769 | * |
| 766 | 770 | * @return string |
| 767 | 771 | */ |
| 768 | 772 | private function add_page_link( $atts ) { |
| 769 | - if ( $atts['disabled'] ) { | |
| 770 | - $link = $this->add_disabled_link( $atts['arrow'] ); | |
| 771 | - } else { | |
| 772 | - $link = $this->add_active_link( $atts ); | |
| 773 | - } | |
| 774 | - | |
| 775 | - return $link; | |
| 773 | + return $atts['disabled'] ? $this->add_disabled_link( $atts['arrow'] ) : $this->add_active_link( $atts ); | |
| 776 | 774 | } |
| 777 | 775 | |
| 778 | 776 | /** |
| 779 | 777 | * @param string $label |
| @@ -825,14 +823,13 @@ | ||
| 825 | 823 | * |
| 826 | 824 | * @return string Name of the default primary column, in this case, an empty string. |
| 827 | 825 | */ |
| 828 | 826 | protected function get_default_primary_column_name() { |
| 829 | - $columns = $this->get_columns(); | |
| 830 | - $column = ''; | |
| 827 | + $column = ''; | |
| 831 | 828 | |
| 832 | 829 | // We need a primary defined so responsive views show something, |
| 833 | - // so let's fall back to the first non-checkbox column. | |
| 834 | - foreach ( $columns as $col => $column_name ) { | |
| 830 | + // So let's fall back to the first non-checkbox column. | |
| 831 | + foreach ( $this->get_columns() as $col => $column_name ) { | |
| 835 | 832 | if ( 'cb' === $col ) { |
| 836 | 833 | continue; |
| 837 | 834 | } |
| 838 | 835 | |
| @@ -854,9 +851,9 @@ | ||
| 854 | 851 | $columns = $this->get_columns(); |
| 855 | 852 | $default = $this->get_default_primary_column_name(); |
| 856 | 853 | |
| 857 | 854 | // If the primary column doesn't exist fall back to the |
| 858 | - // first non-checkbox column. | |
| 855 | + // First non-checkbox column. | |
| 859 | 856 | if ( ! isset( $columns[ $default ] ) ) { |
| 860 | 857 | $default = self::get_default_primary_column_name(); |
| 861 | 858 | } |
| 862 | 859 | |
| @@ -869,10 +866,10 @@ | ||
| 869 | 866 | * @param string $context Screen ID for specific list table, e.g. 'plugins'. |
| 870 | 867 | */ |
| 871 | 868 | $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
| 872 | 869 | |
| 873 | - if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { | |
| 874 | - $column = $default; | |
| 870 | + if ( ! $column || ! isset( $columns[ $column ] ) ) { | |
| 871 | + return $default; | |
| 875 | 872 | } |
| 876 | 873 | |
| 877 | 874 | return $column; |
| 878 | 875 | } |
| @@ -899,10 +896,8 @@ | ||
| 899 | 896 | } |
| 900 | 897 | |
| 901 | 898 | $columns = get_column_headers( $this->screen ); |
| 902 | 899 | $hidden = get_hidden_columns( $this->screen ); |
| 903 | - | |
| 904 | - $sortable_columns = $this->get_sortable_columns(); | |
| 905 | 900 | /** |
| 906 | 901 | * Filter the list table sortable columns for a specific screen. |
| 907 | 902 | * |
| 908 | 903 | * The dynamic portion of the hook name, `$this->screen->id`, refers |
| @@ -911,14 +906,14 @@ | ||
| 911 | 906 | * @since 3.5.0 |
| 912 | 907 | * |
| 913 | 908 | * @param array $sortable_columns An array of sortable columns. |
| 914 | 909 | */ |
| 915 | - $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns ); | |
| 910 | + $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $this->get_sortable_columns() ); | |
| 916 | 911 | |
| 917 | 912 | $sortable = array(); |
| 918 | 913 | |
| 919 | 914 | foreach ( $_sortable as $id => $data ) { |
| 920 | - if ( empty( $data ) ) { | |
| 915 | + if ( ! $data ) { | |
| 921 | 916 | continue; |
| 922 | 917 | } |
| 923 | 918 | |
| 924 | 919 | $data = (array) $data; |
| @@ -961,31 +956,21 @@ | ||
| 961 | 956 | * @param bool $with_id Whether to set the id attribute or not. |
| 962 | 957 | * |
| 963 | 958 | * @return void |
| 964 | 959 | */ |
| 965 | - public function print_column_headers( $with_id = true ) { | |
| 960 | + public function print_column_headers( $with_id = true ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh, Generic.Metrics.CyclomaticComplexity.MaxExceeded, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 966 | 961 | list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
| 967 | 962 | |
| 968 | - $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); | |
| 969 | - $current_url = remove_query_arg( 'paged', $current_url ); | |
| 963 | + $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); | |
| 964 | + $current_url = remove_query_arg( 'paged', $current_url ); | |
| 965 | + $current_orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( wp_unslash( $_GET['orderby'] ) ) : ''; | |
| 966 | + $current_order = isset( $_GET['order'] ) && 'desc' === $_GET['order'] ? 'desc' : 'asc'; | |
| 970 | 967 | |
| 971 | - if ( isset( $_GET['orderby'] ) ) { | |
| 972 | - $current_orderby = sanitize_text_field( wp_unslash( $_GET['orderby'] ) ); | |
| 973 | - } else { | |
| 974 | - $current_orderby = ''; | |
| 975 | - } | |
| 976 | - | |
| 977 | - if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { | |
| 978 | - $current_order = 'desc'; | |
| 979 | - } else { | |
| 980 | - $current_order = 'asc'; | |
| 981 | - } | |
| 982 | - | |
| 983 | 968 | FrmAppController::apply_saved_sort_preference( $current_orderby, $current_order ); |
| 984 | 969 | |
| 985 | 970 | if ( ! empty( $columns['cb'] ) ) { |
| 986 | 971 | static $cb_counter = 1; |
| 987 | - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>'; | |
| 972 | + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . esc_html__( 'Select All', 'formidable' ) . '</label>'; | |
| 988 | 973 | $columns['cb'] .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />'; |
| 989 | 974 | ++$cb_counter; |
| 990 | 975 | } |
| 991 | 976 | |
| @@ -993,8 +978,9 @@ | ||
| 993 | 978 | $class = array( 'manage-column', "column-$column_key" ); |
| 994 | 979 | $aria_sort_attr = ''; |
| 995 | 980 | $order_text = ''; |
| 996 | 981 | |
| 982 | + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 997 | 983 | if ( in_array( $column_key, $hidden ) ) { |
| 998 | 984 | $class[] = 'hidden'; |
| 999 | 985 | } |
| 1000 | 986 | |
| @@ -1010,8 +996,9 @@ | ||
| 1010 | 996 | |
| 1011 | 997 | if ( isset( $sortable[ $column_key ] ) ) { |
| 1012 | 998 | list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
| 1013 | 999 | |
| 1000 | + // phpcs:ignore Universal.Operators.StrictComparisons | |
| 1014 | 1001 | if ( $current_orderby == $orderby ) { |
| 1015 | 1002 | // The sorted column. The `aria-sort` attribute must be set only on the sorted column. |
| 1016 | 1003 | if ( 'asc' === $current_order ) { |
| 1017 | 1004 | $order = 'desc'; |
| @@ -1057,9 +1044,9 @@ | ||
| 1057 | 1044 | $tag = 'cb' === $column_key ? 'td' : 'th'; |
| 1058 | 1045 | $scope = 'th' === $tag ? 'scope="col"' : ''; |
| 1059 | 1046 | $id = $with_id ? "id='" . esc_attr( $column_key ) . "'" : ''; |
| 1060 | 1047 | |
| 1061 | - if ( ! empty( $class ) ) { | |
| 1048 | + if ( $class ) { | |
| 1062 | 1049 | $class = "class='" . esc_attr( implode( ' ', $class ) ) . "'"; |
| 1063 | 1050 | } |
| 1064 | 1051 | |
| 1065 | 1052 | if ( ! $this->has_min_items() && ! $with_id ) { |
| @@ -1091,8 +1078,9 @@ | ||
| 1091 | 1078 | $this->display_tablenav( 'top' ); |
| 1092 | 1079 | } |
| 1093 | 1080 | $this->screen->render_screen_reader_content( 'heading_list' ); |
| 1094 | 1081 | |
| 1082 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 1095 | 1083 | ?> |
| 1096 | 1084 | <table class="wp-list-table <?php echo esc_attr( implode( ' ', $this->get_table_classes() ) ); ?>"> |
| 1097 | 1085 | <?php if ( $this->has_min_items( 1 ) ) { ?> |
| 1098 | 1086 | <thead> |
| @@ -1114,8 +1102,10 @@ | ||
| 1114 | 1102 | </tfoot> |
| 1115 | 1103 | <?php } ?> |
| 1116 | 1104 | </table> |
| 1117 | 1105 | <?php |
| 1106 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 1107 | + | |
| 1118 | 1108 | if ( $this->should_display( $args, 'display-bottom-nav' ) ) { |
| 1119 | 1109 | $this->display_tablenav( 'bottom' ); |
| 1120 | 1110 | } |
| 1121 | 1111 | } |
| @@ -1158,11 +1148,12 @@ | ||
| 1158 | 1148 | // Don't show bulk actions if no items. |
| 1159 | 1149 | return; |
| 1160 | 1150 | } |
| 1161 | 1151 | } elseif ( ! $this->has_min_items() ) { |
| 1162 | - // don't show the bulk actions when there aren't many rows. | |
| 1152 | + // Don't show the bulk actions when there aren't many rows. | |
| 1163 | 1153 | return; |
| 1164 | 1154 | } |
| 1155 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 1165 | 1156 | ?> |
| 1166 | 1157 | <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
| 1167 | 1158 | |
| 1168 | 1159 | <div class="alignleft actions bulkactions"> |
| @@ -1175,8 +1166,9 @@ | ||
| 1175 | 1166 | |
| 1176 | 1167 | <br class="clear"/> |
| 1177 | 1168 | </div> |
| 1178 | 1169 | <?php |
| 1170 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 1179 | 1171 | } |
| 1180 | 1172 | |
| 1181 | 1173 | /** |
| 1182 | 1174 | * Use this to exclude the footer labels and bulk items. |
| @@ -1221,9 +1213,9 @@ | ||
| 1221 | 1213 | * Generates content for a single row of the table |
| 1222 | 1214 | * |
| 1223 | 1215 | * @since 2.0.18 |
| 1224 | 1216 | * |
| 1225 | - * @param object $item The current item. | |
| 1217 | + * @param stdClass $item The current item. | |
| 1226 | 1218 | */ |
| 1227 | 1219 | public function single_row( $item ) { |
| 1228 | 1220 | echo '<tr>'; |
| 1229 | 1221 | $this->single_row_columns( $item ); |
| @@ -1246,8 +1238,9 @@ | ||
| 1246 | 1238 | if ( $primary === $column_name ) { |
| 1247 | 1239 | $classes .= ' has-row-actions column-primary'; |
| 1248 | 1240 | } |
| 1249 | 1241 | |
| 1242 | + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 1250 | 1243 | if ( in_array( $column_name, $hidden ) ) { |
| 1251 | 1244 | $classes .= ' hidden'; |
| 1252 | 1245 | } |
| 1253 | 1246 | |
| @@ -1286,9 +1279,9 @@ | ||
| 1286 | 1279 | * |
| 1287 | 1280 | * @return string The row actions output. In this case, an empty string. |
| 1288 | 1281 | */ |
| 1289 | 1282 | protected function handle_row_actions( $item, $column_name, $primary ) { |
| 1290 | - return $column_name == $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' : ''; | |
| 1283 | + return $column_name == $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' : ''; // phpcs:ignore Universal.Operators.StrictComparisons, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 1291 | 1284 | } |
| 1292 | 1285 | |
| 1293 | 1286 | /** |
| 1294 | 1287 | * Handle an incoming ajax request (called from admin-ajax.php) |
| @@ -1305,10 +1298,9 @@ | ||
| 1305 | 1298 | } else { |
| 1306 | 1299 | $this->display_rows_or_placeholder(); |
| 1307 | 1300 | } |
| 1308 | 1301 | |
| 1309 | - $rows = ob_get_clean(); | |
| 1310 | - | |
| 1302 | + $rows = ob_get_clean(); | |
| 1311 | 1303 | $response = array( 'rows' => $rows ); |
| 1312 | 1304 | |
| 1313 | 1305 | if ( isset( $this->_pagination_args['total_items'] ) ) { |
| 1314 | 1306 | $response['total_items_i18n'] = sprintf( |