Skip to content

Commit

Permalink
Ensure we have the same columns for all rows
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd committed Dec 16, 2024
1 parent 1052aab commit bc4d160
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/class-cf7-extras-integration-tablepress.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ private function get_data_for_table( $table, $form_data ) {

$table['data'][] = $table_row; // Append our row.

$max_cols = max( array_map( 'count', $table['data'] ) );
$cols_fill = array_fill( 0, $max_cols, '' );

// Ensure all rows have the same number of columns.
$table['data'] = array_map(
function( $row ) use ( $cols_fill ) {
return array_replace( $cols_fill, $row );
},
$table['data']
);

return $table;
}

Expand Down

0 comments on commit bc4d160

Please sign in to comment.