| @@ -355,9 +355,8 @@ | ||
| 355 | 355 | $num_columns = ( $num_rows > 0 ) ? count( $this->table['data'][0] ) : 0; |
| 356 | 356 | |
| 357 | 357 | // Check if there are rows and columns in the table (might not be the case after removing hidden rows/columns!). |
| 358 | 358 | if ( 0 === $num_rows || 0 === $num_columns ) { |
| 359 | - /* translators: %s: Table ID */ | |
| 360 | 359 | $this->output = sprintf( __( '<!-- The table with the ID %s is empty! -->', 'tablepress' ), $this->table['id'] ); |
| 361 | 360 | return; |
| 362 | 361 | } |
| 363 | 362 | |
| @@ -478,9 +477,9 @@ | ||
| 478 | 477 | // Loop through rows in reversed order, to search for rowspan trigger keyword. |
| 479 | 478 | $row_idx = $this->last_row_idx; |
| 480 | 479 | |
| 481 | 480 | // Render the table footer rows, if there is at least one extra row. |
| 482 | - if ( $this->render_options['table_foot'] > 0 && $num_rows >= $this->render_options['table_head'] + $this->render_options['table_foot'] ) { | |
| 481 | + if ( $this->render_options['table_foot'] > 0 && $num_rows >= $this->render_options['table_head'] + $this->render_options['table_foot'] ) { // @phpstan-ignore greaterOrEqual.invalid (`table_head` and `table_foot` are integers.) | |
| 483 | 482 | $last_tbody_idx = $this->last_row_idx - $this->render_options['table_foot']; |
| 484 | 483 | while ( $row_idx > $last_tbody_idx ) { |
| 485 | 484 | $tfoot[] = $this->_render_row( $row_idx, 'th' ); |
| 486 | 485 | --$row_idx; |
| @@ -667,9 +666,9 @@ | ||
| 667 | 666 | |
| 668 | 667 | // Legacy support for attributes that are not encouraged in HTML5. |
| 669 | 668 | foreach ( array( 'cellspacing', 'cellpadding', 'border' ) as $attribute ) { |
| 670 | 669 | if ( false !== $this->render_options[ $attribute ] ) { |
| 671 | - $table_attributes[ $attribute ] = (string) absint( $this->render_options[ $attribute ] ); | |
| 670 | + $table_attributes[ $attribute ] = (int) $this->render_options[ $attribute ]; | |
| 672 | 671 | } |
| 673 | 672 | } |
| 674 | 673 | |
| 675 | 674 | /** |
| @@ -703,12 +702,12 @@ | ||
| 703 | 702 | unset( $table_html ); // Unset the potentially large variable to free up memory. |
| 704 | 703 | |
| 705 | 704 | // name/description below table (HTML already generated above). |
| 706 | 705 | if ( $this->render_options['print_name'] && 'below' === $this->render_options['print_name_position'] ) { |
| 707 | - $output .= $print_name_html; | |
| 706 | + $output .= $print_name_html; // @phpstan-ignore variable.undefined (The variable is set above.) | |
| 708 | 707 | } |
| 709 | 708 | if ( $this->render_options['print_description'] && 'below' === $this->render_options['print_description_position'] ) { |
| 710 | - $output .= $print_description_html; | |
| 709 | + $output .= $print_description_html; // @phpstan-ignore variable.undefined (The variable is set above.) | |
| 711 | 710 | } |
| 712 | 711 | |
| 713 | 712 | /** |
| 714 | 713 | * Filters the generated HTML code for the table and HTML elements around it. |
| @@ -752,9 +751,10 @@ | ||
| 752 | 751 | // Invalid rowspan, so we set cell content from #rowspan# to empty. |
| 753 | 752 | $cell_content = ''; |
| 754 | 753 | } elseif ( $this->span_trigger['colspan'] === $cell_content ) { // There will be a colspan. |
| 755 | 754 | if ( ! ( |
| 756 | - ( 0 === $col_idx ) // No colspan inside first column. | |
| 755 | + ( ( 0 === $row_idx ) && 1 === $this->render_options['table_head'] && $this->render_options['use_datatables'] ) // Don't allow colspan inside a single row table head, as DataTables seems to have a bug here. | |
| 756 | + || ( 0 === $col_idx ) // No colspan inside first column. | |
| 757 | 757 | || ( 1 === $col_idx && $this->render_options['first_column_th'] ) // No colspan into first column head. |
| 758 | 758 | ) ) { |
| 759 | 759 | // Increase counter for colspan in this row. |
| 760 | 760 | ++$this->colspan[ $row_idx ]; |
| @@ -838,17 +838,13 @@ | ||
| 838 | 838 | */ |
| 839 | 839 | $tag_attributes = apply_filters( 'tablepress_cell_tag_attributes', $tag_attributes, $this->table['id'], $cell_content, $row_idx + 1, $col_idx + 1, $this->colspan[ $row_idx ], $this->rowspan[ $col_idx ] ); |
| 840 | 840 | $tag_attributes = $this->_attributes_array_to_string( $tag_attributes ); |
| 841 | 841 | |
| 842 | - if ( '' === $cell_content ) { | |
| 843 | - $cell_tag = 'td'; // For accessibility, empty cells should use `td` and not `th` tags. | |
| 844 | - } elseif ( $this->render_options['first_column_th'] && 0 === $col_idx ) { | |
| 845 | - $cell_tag = 'th'; // Non-empty cells in the first column should use `th` tags, if enabled. | |
| 846 | - } else { | |
| 847 | - $cell_tag = $tag; // Otherwise, use the tag that was passed in as the default for the row. | |
| 842 | + if ( $this->render_options['first_column_th'] && 0 === $col_idx ) { | |
| 843 | + $tag = 'th'; | |
| 848 | 844 | } |
| 849 | 845 | |
| 850 | - $row_cells[] = "<{$cell_tag}{$tag_attributes}>{$cell_content}</{$cell_tag}>"; | |
| 846 | + $row_cells[] = "<{$tag}{$tag_attributes}>{$cell_content}</{$tag}>"; | |
| 851 | 847 | $this->colspan[ $row_idx ] = 1; // Reset. |
| 852 | 848 | $this->rowspan[ $col_idx ] = 1; // Reset. |
| 853 | 849 | } |
| 854 | 850 | |
| @@ -1009,13 +1005,8 @@ | ||
| 1009 | 1005 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;{$rtl_direction} |
| 1010 | 1006 | } |
| 1011 | 1007 | p { |
| 1012 | 1008 | font-size: 13px; |
| 1013 | - } | |
| 1014 | - .preview { | |
| 1015 | - overflow-x: auto; | |
| 1016 | - overflow-y: hidden; | |
| 1017 | - scroll-behavior: smooth; | |
| 1018 | 1009 | } |
| 1019 | 1010 | {$default_css_minified} |
| 1020 | 1011 | </style> |
| 1021 | 1012 | CSS; |