• Resolved rachitarora

    (@rachitarora)


    Hi,
    I am having the following ADA issues using the TablePress plugin on my website. Let me know what needs to be done to resolve that.
    – All layout tables do not contain th elements.
    – All complex data tables have a summary.
    – All data tables contain a caption unless the table is identified within the document.
    – Use colgroup and col elements to group columns.
    – Use thead to group repeated table headers, tfoot for repeated table footers, and tbody for other groups of rows.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Most of these should be fulfilled already:
    – th elements are only used in the table header row, which can be turned off.
    – A summary is not automatically added, but can be added e.g. with this piece of PHP code in your theme’s “functions.php” file:

    function ada_tablepress_add_summary( $table_attributes, $table, $render_options ) {
    	$table_attributes[ summary'] = $table['description'];
    	return $table_attributes;
    }
    add_filter( 'tablepress_table_tag_attributes', 'ada_tablepress_add_summary', 10, 3 );

    (The table description will then be used as the summary.)
    – A caption is added if you turn on the “Table Description” checkbox.
    – colgroup and col elements are not supported at the moment, but often not necessary.
    – TablePress uses these elements in the header, footer, and body.

    Regards,
    Tobias

    good tip.
    Adding to the ADA issue above for TablePress, any good solution for following item?
    – Data tables that contain both row and column headers use the scope attribute to identify cells.

    Thanks,

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    for the new question: Not directly. You would have to implement this directly using a filter hook, tablepress_cell_tag_attributes defined here.

    Regards,
    Tobias

    good pointer, but is it possible if you give me more details on doing so in the code? appreciate your help.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no, sorry, I don’t have an example available here. You would need to write a PHP function that hooks into that filter and then makes the necessary code additions.

    Regards,
    Tobias

    Thread Starter rachitarora

    (@rachitarora)

    Hi,
    When I am using tablepress_cell_tag_attributes in my functions.php, I am trying to add the scope=”col” to particular rows but I am unable to do so. Below is the code I am using

    function ada_tablepress_add_scope( $tag_attributes, $row_idx ) {
        if ($row_idx === 0) {
            $tag_attributes['scope'] = "col";
            return $tag_attributes;
        }
    }
    add_filter( 'tablepress_cell_tag_attributes', 'ada_tablepress_add_scope' );

    I am getting the below error

    Warning: Missing argument 2 for ada_tablepress_add_scope(), called in /var/www/public/wp-includes/class-wp-hook.php on line 288 and defined in /var/www/public/wp-content/themes/xxxxxxxxx/functions.php on line 99
    
    Notice: Undefined variable: row_idx in /var/www/public/wp-content/themes/xxxxxxx/functions.php on line 100
    
    Fatal error: Uncaught TypeError: Argument 1 passed to TablePress_Render::_attributes_array_to_string() must be of the type array, null given, called in /var/www/public/wp-content/plugins/tablepress/classes

    Please let me know how to get around the above issue.
    Thank you.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    you are very close! As that filter hook uses more parameters, we need to adjust for that:

    function ada_tablepress_add_scope(  $tag_attributes, $table_id, $cell_content, $row_number, $col_number, $colspan, $rowspan ) {
        if ( $row_idx === 1 ) {
            $tag_attributes['scope'] = "col";
            return $tag_attributes;
        }
    }
    add_filter( 'tablepress_cell_tag_attributes', 'ada_tablepress_add_scope', 10, 7 );
    

    Node the longer list of parameters and the 10, 7 parameter in the add_filter call that is necessary to tell WordPress to actually fill all parameters with values.
    Then (which actually looks like a mistake by me in the plugin code), the row and column numbers are not the index, i.e. they start with 1 instead of 0.

    Regards,
    Tobias

    Thread Starter rachitarora

    (@rachitarora)

    Hi,
    Thank you for the tip. Works like a charm ??
    Thanks again.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘TablePress ADA accessibility’ is closed to new replies.