WordPress.org

Ready to get started?Download WordPress

Forums

TablePress
[resolved] Global settings (6 posts)

  1. mvhoute
    Member
    Posted 1 year ago #

    I don't really have a support question, more a wish for future versions.

    I'm using Tablepress to display +/- 35 tables on a website. It would be a real timesaver if I can globally change the table options & features of the datatables Javascript library, in stead of changing the settings for each individual table.

    Is it possible to overrule the current settings for all tables?

    http://wordpress.org/extend/plugins/tablepress/

  2. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    thanks a lot for your post!

    Changing these globally is not possible (and likely won't be in the future), unfortunately.

    Instead, I suggest that you use a plugin filter hook, to set these globally. For that, there are actually tho approaches: You could use a hook to change the default states of these options, so that for example all new tables (but not existing tables) will have DataTables turned off. Or you could use a hook to override the states of the checkboxes when the table is shown. This could look like this:

    add_filter( 'tablepress_table_render_options', 'tablepress_override_table_options', 10, 2 );
    function tablepress_override_table_options( $render_options, $table ) {
      $render_options['use_datatables'] = false;
      $render_options['alternating_row_colors'] = false;
    }

    This would deactivate DataTables for all tables, and it would turn off the "Alternating Row Colors", in both times regardless of what the checkbox on the table's "Edit" screen is set to.

    To use this code, just paste it into your theme's "functions.php", or create a small plugin for it.
    (Note: This will require TablePress 0.7-beta (or the current master branch version from GitHub), as I noticed that I have to make a code change first, to make this this easy :-) )

    Regards,
    Tobias

  3. Mikko Saari
    Member
    Posted 1 year ago #

    Small update here - in case somebody else comes here looking for this. That filter function needs a

    return $render_options;

    in the end, otherwise it'll just break your rendering options.

  4. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    oops, that's embarrassing. Thanks for catching this, Mikko!

    Best wishes,
    Tobias

  5. mvhoute
    Member
    Posted 1 year ago #

    Maybe a bit too late, but still: thanks for the solution!

  6. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    no problem, you are very welcome! :-)

    Best wishes,
    Tobias

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic