• First of all, thanks for this awesome plugin. It makes it so much easier to let my clients manage data tables on their websites.

    However, I have one minor request. I’ve been looking through the source for the plugin, and see that you’ve implemented a lot of great filters; but there seems to be one filter still missing: the “caption” filter. I’d like to see the following change made, if possible (I can submit a patch if you want). Thanks.

    Change:

    $caption = '';
                if ( !empty( $this->output_options['edit_table_url'] ) ) {
                    $edit_table_link = "<a href=\"{$this->output_options['edit_table_url']}\" title=\"" . __( 'Edit', 'default' ) . "\">" . __( 'Edit', 'default' ) . "</a>";
                    $caption = "<caption style=\"caption-side: bottom; text-align: left; border:none; background: none;\">{$edit_table_link}</caption>\n";
                }

    to:

    $caption = '';
                $caption_text = apply_filters( 'wp_table_reloaded_table_caption_arg', '', $table['id'], $table );
                if ( !empty( $this->output_options['edit_table_url'] ) ) {
                    $edit_table_link = "<a href=\"{$this->output_options['edit_table_url']}\" title=\"" . __( 'Edit', 'default' ) . "\">" . __( 'Edit', 'default' ) . "</a>";
                    $caption_text .= $edit_table_link;
                }
                if ( ! empty( $caption_text ) ) {
                    $caption = "<caption style=\"caption-side: bottom; text-align: left; border:none; background: none;\">{$caption_text}</caption>\n";
                }

    That way, as users, we’d be able to add our own captions to the tables. Do you think this would be possible? Thanks.

    http://ww.wp.xz.cn/extend/plugins/wp-table-reloaded/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi Curtiss,

    thanks for your post, and the suggestion!

    You are correct, there’s no filter for the <caption> tag at this time. I’m not really sure why though 🙂 Might be that I just forgot it, or might be that I thought that it is not necessary (because you could filter the final table HTML in the wp_table_reloaded_post_output_table hook and add it there).
    But the best solution likely is to just add it, as you suggest 🙂

    I’d suggest something like this, for some more flexibility:

    // <caption> tag
    $caption = apply_filters( 'wp_table_reloaded_table_caption_arg', '', $table );
    $caption_style = $caption_class = '';
    if ( ! empty( $caption ) )
    	$caption_class = "wp-table-reloaded-table-caption wp-table-reloaded-table-caption-id-{$table['id']}";
    if ( ! empty( $this->output_options['edit_table_url'] ) ) {
    	if ( ! empty( $caption ) )
    		$caption .= '<br/>';
    	else
    		$caption_style = ' style="caption-side:bottom;text-align:left;border:none;background:none;"';
    	$caption .= "<a href=\"{$this->output_options['edit_table_url']}\" title=\"" . __( 'Edit', 'default' ) . "\">" . __( 'Edit', 'default' ) . "</a>";
    }
    if ( ! empty( $caption ) )
    	$caption = "<caption{$caption_class}{$caption_style}>\n{$caption}</caption>\n";

    Is that ok for you?

    I’ll add that code to the plugin then, so that it will be included in the next version. Meanwhile, you can just go ahead and modify the plugin file in your installation (as that change will then not be lost after the update, obviously).

    Regards,
    Tobias

    Thread Starter Curtiss Grymala

    (@cgrymala)

    Looks great to me. I’ll give it a shot. Thanks for the quick response.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    ok then, it’s in 🙂

    Best wishes,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: WP-Table Reloaded] Feature Request: Filter for table caption?’ is closed to new replies.