• Resolved Mickey Kay

    (@mcguive7)


    Hi there,

    First of all – FANTASTIC plugin. Love it! Thanks for all your hard work.

    Secondly, I have what I think is a pretty simple feature request, which entails adding a few hooks/filters to the handle_post_action_edit function in controller-admin.php.

    At present, it’s very difficult to add custom metaboxes and save associated data on a per-table basis (for example, say I want to add a custom metabox on the edit table screen for something like “Show table on tablet screen sizes”). At present, you manually specify the checkboxes and fields to be parsed on save, however if you were to pass these values through a filter and/or call a few actions, this would allow users to very easily save custom data as well. For example, line 720 defines the checkboxes that will be parsed:

    $checkbox_options = array(...)

    If you were to then pass this through a filter like so:

    $checkbox_options = apply_filters( 'tablepress_checkbox_options_to_save_on_edit', $checkbox_options, $edit_table );

    . . . this would allow users to easily add their own checkbox options.

    Alternately, if you want to keep things more generic, then you could simply pass the full $edit_table array through a filter before saving, as this would allow users to customize it as they see fit, running their own custom functionality to add/remove/edit options, which could be very handy. In fact, this might be the simplest fix, just adding the following on line 729:

    $edit_table = apply_filters( 'tablepress_edit_table', $edit_table );

    Any chance you could take a look and see if this makes sense to implement? Thanks!

    https://wordpress.org/plugins/tablepress/

Viewing 1 replies (of 1 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    I see what you mean, but I’m a bit reluctant to adding this like this. First of all, I’m not sure that adding own data to a TablePress table like this is a good idea. This data would not get exported or imported and there are many possibilities, where it could get “lost”.

    Also, just adding it in the controller-admin.php is probably not sufficient, as tables are actually (by default) saved via controller-admin-ajax.php…

    Now, I’d definitely like to make extending TablePress like this easier, but as every added hook means that it would have to be supported in the future, I’ll have to be very cautious here.

    Your best chance should therefore be to add a custom handler to admin_post_tablepress_edit and wp_ajax_tablepress_save_table and then store the extra data with that.

    Regards,
    Tobias

Viewing 1 replies (of 1 total)
  • The topic ‘Feature request: additional filters/hooks’ is closed to new replies.