• Resolved brambil

    (@brambil)


    Dear,
    I’m trying to write a plugin that uses TablePress to show data (scoring) generated from a software.

    From my software I can upload an HTML file to a server, my idea is to make an admin_post_nopriv target that receive as parameter the filename and the tableid to force an update of the tablepress that has the result stored inside.

    To do this I would rely on TablePress_Admin_Controller extending it, but I don’t know how load it inside my plugin.

    If I simply try to extend TablePress_Admin_Controller I got an error, even if the class extension is made after plugins are loaded or with wp_loaded.
    add_action('plugins_loaded', function () { require_once('RegattaImporter.php'); });

    Inside RegattaImporter.php there is the class extension.

    Can you help me?

    Thanks

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

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    I would not really recommend this approach. From what I understand, you are looking for an automatic import of data from an HTML file. For that, the TablePress Extension from https://tablepress.org/extensions/table-auto-import/ should be a better solution.

    Regards,
    Tobias

    Thread Starter brambil

    (@brambil)

    Dear,
    I have an HTML file with many tables.
    I use information in other tag (h3, p) to determinate witch tablepress update and to modify the post where the table is show. So I need many customization, I read about auto-import but it con assolve only partially my needs. I will give it a try but I need on-demand update and not programmatically and some pre-work to extract other information from the file.

    Thanks.

    • This reply was modified 2 years, 10 months ago by brambil.
    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    ok, I see. I’m not sure how you want to force the update then though, as TablePress will not be able to extract the table data from an HTML file with many tables…
    But of course feel free to investigate this further. The plugins_loaded hook is howewer too early, as TablePress only loads and initializes itself on the init hook. Please see the classes/class-tablepress.php file for this.

    Regards,
    Tobias

    Thread Starter brambil

    (@brambil)

    My HTML is an output from a scoring software, so I know how is formatted.

    Each table is inside a div, in each div there is an <heading>, a <p> and the table.
    My script will explode the html, for each div extract heading and p information that I will use to update post and identify the tablepress id to update, finally I will pass all the code to tablepress to work on the table.

    I will investigate the code and share the solution. Maybe it could be useful for other people who use the same scoring software.

    • This reply was modified 2 years, 10 months ago by brambil.
    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    what is your goal with TablePress here, actually? Are you trying to do this so that you can add the JavaScript features to your tables (sorting, searching, pagination, …)? If yes, it might be much easier to just manually load the DataTables JS library from https://datatables.net/ into your site. (That’s the library that TablePress uses for these features.)

    Regards,
    Tobias

    Thread Starter brambil

    (@brambil)

    Thanks.

    It could be an options, but my goal is also integrate tables in my WP Posts.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    ah, ok. Then, directly using DataTables will indeed not help. I hope that you can find a good solution with TablePress then!

    Best wishes,
    Tobias

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Use TablePress_Admin_Controller in another plugin’ is closed to new replies.