The following code adds the scope="row"
attribute to the row header tag, but, as you mentioned, this will apply this to all tables on the page:
add_filter( 'tablepress_table_render_options', 'check_table_render_options', 10, 2 );
function check_table_render_options( $render_options, $table ) {
if( $render_options['first_column_th'] === true ) {
add_filter( 'tablepress_cell_tag_attributes', 'custom_cell_tag_attributes', 10, 7 );
function custom_cell_tag_attributes( $tag_attributes, $table_id, $cell_content, $row_idx, $col_idx, $colspan_row, $rowspan_col ) {
if( $col_idx === 1 ) {
$tag_attributes['scope'] = 'row';
}
return $tag_attributes;
}
}
return $render_options;
}
I’m still trying to wrap my head around what to do with the tablepress_table_output
filter.