• Resolved Rub3X

    (@rub3x)


    Tobias,

    I made a script which creates rows in the table and edits existing rows. It works fine, but when I open that table up in the WordPress administration panel and make a manual change to anything (or make no change at all) and click Save, the table breaks. As soon as I hit save it randomly hides 90% of the rows on the table when the table is outputted. The only way I can fix this is to manually check each row and click the show button. I see no area in the SQL database where a row can be marked as hidden or shown, and I see no reason why clicking save within the WordPress admin would automatically hide 90% of rows.

    Do you have any insight as to why this is happening?

    https://ww.wp.xz.cn/plugins/tablepress/

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

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    The reason for this likely is that either your script is not setting the visibility information correct (which is stored in the wp_postmeta DB table), or that something is broken with that DB table.

    I therefore suggest that you don’t directly edit the table data by manipulating the JSON data in the database, but that you instead use the TablePress functions for this, like TablePress::$model_table->load() and ->save().

    Regards,
    Tobias

    Thread Starter Rub3X

    (@rub3x)

    Ah I see why it does it. I created the table manually with the default 5 rows 5 columns or whatever it is. Then when my script populates the table it doesn’t add the additional 1s for each new row in post_meta. So the table itself has 50 rows while there’s only five 1s set in post_meta. So when you click save it must see there’s more rows in the table than there are in post_meta and flips them all to 0 by default.

    By chance is there just a way to disable the show/hide row feature within the plugin?

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    yes, that’s exactly the reason. When modifying the table data, you will have to change the visibility as well. Something quick like https://github.com/TobiasBg/TablePress/blob/6b04e07a9c8c6e0d4262b7415f3d8c7ed28c080e/controllers/controller-admin.php#L1351 might do it.

    Turning off the functionality is not directly possible. You could however override the settings on the “Edit” screen. That is, a user would still be able to mark rows/columns as hidden, and they would appear with the red background color there, but TablePress would ignore that and still show all rows/columns. For that, you could hook into a filter and set all rows/columns to visible, e.g. with

    add_filter( 'tablepress_table_render_options', 'Rub3X_tablepress_show_all_cells', 10, 2 );
    function Rub3X_tablepress_show_all_cells( $render_options, $table ) {
       $render_options['show_rows'] = 'all';
       $render_options['show_columns'] = 'all';
       return $render_options;
    }

    This will basically set the show_rows and show_columns Shortcode parameters for all tables, as mentioned on https://tablepress.org/faq/documentation-shortcode-table/

    Regards,
    Tobias

    Thread Starter Rub3X

    (@rub3x)

    Thank you, and thanks for your dedication to the community 🙂

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

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

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

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

The topic ‘Hidden’ is closed to new replies.