| @@ -56,9 +56,9 @@ | ||
| 56 | 56 | if ( 0 === count( $dom_tables ) ) { |
| 57 | 57 | return new WP_Error( 'table_import_html_dom_get_tables' ); |
| 58 | 58 | } |
| 59 | 59 | libxml_clear_errors(); // Clear errors so that we only catch those inside the table in the next line. |
| 60 | - $table = simplexml_import_dom( $dom_tables->item( 0 ) ); // @phpstan-ignore-line | |
| 60 | + $table = simplexml_import_dom( $dom_tables->item( 0 ) ); // @phpstan-ignore argument.type | |
| 61 | 61 | if ( is_null( $table ) ) { |
| 62 | 62 | return new WP_Error( 'table_import_html_simplexml_import_dom_failed' ); |
| 63 | 63 | } |
| 64 | 64 | |
| @@ -64,19 +64,19 @@ | ||
| 64 | 64 | |
| 65 | 65 | $errors = libxml_get_errors(); |
| 66 | 66 | libxml_clear_errors(); |
| 67 | 67 | if ( ! empty( $errors ) ) { |
| 68 | - $output = '<strong>' . __( 'The imported file contains errors:', 'tablepress' ) . '</strong><br /><br />'; | |
| 68 | + $output = '<strong>' . __( 'The imported file contains errors:', 'tablepress' ) . '</strong><br><br>'; | |
| 69 | 69 | foreach ( $errors as $error ) { |
| 70 | 70 | switch ( $error->level ) { |
| 71 | 71 | case LIBXML_ERR_WARNING: |
| 72 | - $output .= "Warning {$error->code}: {$error->message} in line {$error->line}, column {$error->column}<br />"; | |
| 72 | + $output .= "Warning {$error->code}: {$error->message} in line {$error->line}, column {$error->column}<br>"; | |
| 73 | 73 | break; |
| 74 | 74 | case LIBXML_ERR_ERROR: |
| 75 | - $output .= "Error {$error->code}: {$error->message} in line {$error->line}, column {$error->column}<br />"; | |
| 75 | + $output .= "Error {$error->code}: {$error->message} in line {$error->line}, column {$error->column}<br>"; | |
| 76 | 76 | break; |
| 77 | 77 | case LIBXML_ERR_FATAL: |
| 78 | - $output .= "Fatal Error {$error->code}: {$error->message} in line {$error->line}, column {$error->column}<br />"; | |
| 78 | + $output .= "Fatal Error {$error->code}: {$error->message} in line {$error->line}, column {$error->column}<br>"; | |
| 79 | 79 | break; |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | wp_die( $output, 'Import Error', array( 'response' => 200, 'back_link' => true ) ); |
| @@ -86,20 +86,22 @@ | ||
| 86 | 86 | 'data' => array(), |
| 87 | 87 | 'options' => array(), |
| 88 | 88 | ); |
| 89 | 89 | if ( isset( $table->thead ) ) { |
| 90 | - $html_table['data'] = array_merge( $html_table['data'], self::_import_html_rows( $table->thead[0]->tr ) ); // @phpstan-ignore-line | |
| 91 | - $html_table['options']['table_head'] = true; | |
| 90 | + $head_rows = self::_import_html_rows( $table->thead[0]->tr ); // @phpstan-ignore property.nonObject | |
| 91 | + $html_table['data'] = array_merge( $html_table['data'], $head_rows ); | |
| 92 | + $html_table['options']['table_head'] = count( $head_rows ); | |
| 92 | 93 | } |
| 93 | 94 | if ( isset( $table->tbody ) ) { |
| 94 | - $html_table['data'] = array_merge( $html_table['data'], self::_import_html_rows( $table->tbody[0]->tr ) ); // @phpstan-ignore-line | |
| 95 | + $html_table['data'] = array_merge( $html_table['data'], self::_import_html_rows( $table->tbody[0]->tr ) ); // @phpstan-ignore property.nonObject | |
| 95 | 96 | } |
| 96 | 97 | if ( isset( $table->tr ) ) { |
| 97 | 98 | $html_table['data'] = array_merge( $html_table['data'], self::_import_html_rows( $table->tr ) ); |
| 98 | 99 | } |
| 99 | 100 | if ( isset( $table->tfoot ) ) { |
| 100 | - $html_table['data'] = array_merge( $html_table['data'], self::_import_html_rows( $table->tfoot[0]->tr ) ); // @phpstan-ignore-line | |
| 101 | - $html_table['options']['table_foot'] = true; | |
| 101 | + $foot_rows = self::_import_html_rows( $table->tfoot[0]->tr ); // @phpstan-ignore property.nonObject | |
| 102 | + $html_table['data'] = array_merge( $html_table['data'], $foot_rows ); | |
| 103 | + $html_table['options']['table_foot'] = count( $foot_rows ); | |
| 102 | 104 | } |
| 103 | 105 | |
| 104 | 106 | return $html_table; |
| 105 | 107 | } |
| @@ -132,15 +134,15 @@ | ||
| 132 | 134 | $new_row[] = $rowspans[ $row_idx ][ $column_idx ]; |
| 133 | 135 | ++$column_idx; |
| 134 | 136 | } |
| 135 | 137 | |
| 136 | - $cell_xml = $cell->asXml(); | |
| 138 | + $cell_xml = $cell->asXML(); | |
| 137 | 139 | |
| 138 | 140 | // Get content between <td>...</td>, or <th>...</th>, possibly with HTML. |
| 139 | 141 | if ( false !== $cell_xml && 1 === preg_match( '#<t[d|h].*?>(.*)</t[d|h]>#is', $cell_xml, $matches ) ) { |
| 140 | 142 | /* |
| 141 | 143 | * Decode HTML entities again, as there might be some left especially in attributes of HTML tags in the cells, |
| 142 | - * see https://secure.php.net/manual/en/simplexmlelement.asxml.php#107137. | |
| 144 | + * see https://www.php.net/manual/en/simplexmlelement.asxml.php#107137. | |
| 143 | 145 | */ |
| 144 | 146 | $new_row[] = html_entity_decode( $matches[1], ENT_NOQUOTES, 'UTF-8' ); |
| 145 | 147 | |
| 146 | 148 | // Search for colspan and rowspan attributes in the cell's HTML tag. |