• Resolved Darek L

    (@darekl)


    Hi Tobias,

    I finished the backup plugin (I have 21 buttons already with scheduling auto backup for kkstar ratings as well ;D). It need some more testing of course but all buttons work fine.

    But now I want make some more corrections in my custom template for wordpress website. I want to use wp_enqueue_script for custom TablePress sort settings. Before I had HTML entry with my custom TablePress file just before footer close tag. The sort depends on datatables. So jquery.datatables.min.js need to be loaded before custom TablePress sort settings.

    I saw that in TablePress plugin (controller-frontend.php file) the file jquery.datatables.min.js is enqueued with handle tablepress-datatables.

    Now when I set dependencies of tablepress-datatables everything works fine and my custom TablePress settings is loaded just after the jquery.datatables.min.js.

    It that correct? The handle tablepress-datatables will not change in the future? Maybe it will be more safe back to the old solution and place it in HTML link tag just before footer?

    Regards,
    Darek

    https://www.ads-software.com/plugins/tablepress/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi Darek,

    no, that handle will probably not change, but I still don’t recommend to use that.
    Instead, use a filter hook like tablepress_all_datatables_commands to append setting, or change the parameters via tablepress_datatables_parameters. The better approach would however likely be to just enqueue the DataTables JS library yourself, as TablePress will only ever register and enqueue it in the frontend part of the site.

    Regards,
    Tobias

    Thread Starter Darek L

    (@darekl)

    Tobias,

    Why don’t recommend that? What about wp_enqueue_script, is it all bad idea?

    Instead, use a filter hook like tablepress_all_datatables_commands to append setting, or change the parameters via tablepress_datatables_parameters.

    What do You mean by filter hook? However I am not sure if it is possible to do that by changing TablePress settings. First I have to get kkstar ratings directly from db via AJAX and then when table is loaded sort using new values readable for TablePress. This is how it goes shortly… I use fnSort with custom sType.

    DataTables JS library yourself

    Not will be loaded twice?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no, don’t get me wrong, I’m not discouraging using wp_enqueue_script. I guess I was just confused by what exactly you are trying to do.
    If the approach with wp_enqueue_script works for you, keep using it, of course! I just want to stress that there’s no guarantee that TablePress will actually register the script, as it will only do so when it needs it.

    Regards,
    Tobias

    Thread Starter Darek L

    (@darekl)

    Tobias, actually I don’t see any other solution except that one above with the handle or just use <link> HTML tag just after wp_footer() as I had before ;-(

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    ok, then definitely keep using that method. A fixed <link> is bad.

    Regards,
    Tobias

    Thread Starter Darek L

    (@darekl)

    Tobias, thanks. The wp_enqueue_script is more recommended for wordpress, so this is why I want to use it now instead of the <link> HTML tag. I guess the key is to set the dependencies correctly and allow wordpress do the rest. However, I don’t use the wp_register_script, only wp_enqueue_script. Bad?

    I hope the handle will not be changing so often and all dependencies will be loaded as they should ??

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    just using wp_enqueue_script is totally fine. You don’t have to use wp_register_script explicitly. WordPress will call that from wp_enqueue_script automatically if necessary.

    Regards,
    Tobias

    Thread Starter Darek L

    (@darekl)

    OK. Thanks.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    sure, no problem!

    Best wishes,
    Tobias

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘wp_enqueue_script and custom TablePress settings’ is closed to new replies.