Dear Mr B?thge,
I like your TablePress plugin – beautiful code. ?? I will use the responsive extension and will make a donation.
I found this post – great to learn about the “tablepress_table_render_data” hook! I too will be using TablePress to display tables with dynamic content. I will call tablepress_print_table() in my shortcodes, when I need to display a table. I will design the tables (and perhaps add a row with headers) in your practical editor, and the rest of the rows will be calculated at run time.
It’s a bit cumbersome to use a hook, though. It would be much more practical to just send the data as an argument to the tablepress_print_table() call. Like this, e.g., using a new “data” argument to tablepress_print_table():
// calculated of course, not constant values
$mydata = array(
array( 'First row', 123, 'London' ),
array( 'Second row', 456, 'Paris' ),
array( 'Third row', 789, 'Rome' ),
);
tablepress_print_table( array( 'id' => '1', 'data' => $mydata ));
TablePress reads the table from the database as usual (and the JSON in the post is unpacked), but after that the items in the “data” argument array are added to the “$table[‘data’]” array. (After some checking, of course. So that all rows have the expected number of columns and so on.) The argument is only allowed in the tablepress_print_table() call, not when using the [table] shortcode.
Wouldn’t an extra argument like that be pretty easy to implement? I think it could be useful to many developers. I would be great if it could be added in a future version! ??
Best regards
Anders from Sweden