• Resolved mumbomedia

    (@mumbomedia)


    Hello

    thank your for this wonderful plugin.
    The only things I want to change is the used datepicker and timepicker.
    I want to use the jQuery.ui Datepicker instead.
    So I know I have to rewrite the function rtb_enqueue_assets() and maybe rtb_get_datepicker_rules() found in includes/template-functions.php
    I hope I could do this by making an addon.

    Kind regards

    mumbomedia

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi mumbomedia,

    Yes, you can do this with an addon. Here’s how I might go about it:

    1. There’s a filter you can use to disable all frontend asset loading:

    https://github.com/NateWr/restaurant-reservations/blob/master/restaurant-reservations.php#L56

    This will prevent all the scripts from being registered here:

    https://github.com/NateWr/restaurant-reservations/blob/master/restaurant-reservations.php#L256-L279

    2. In your addon, I’d then register the reservations styles (if you want them).

    3. The script booking-form.js just won’t work with a different picker, so you’ll need to rebuild the functionality there in your own addon. Once you’ve done that, register that script and enqueue it. You’ll also need to pass the settings to your new script with wp_localize_script. Here’s how it’s done for the default script:

    https://github.com/NateWr/restaurant-reservations/blob/master/includes/template-functions.php#L172-L184

    One thing you’ll need to make sure of is that your datepicker submits the value in the correct format. It expects yyyy/mm/dd in the Pickadate formats, which are documented here.

    Probably the hardest thing you’ll run into is managing the scheduling rules. Transforming the rules from the settings into rules your datepicker understands can be tricky.

    Good luck and let me know how you get on! If you don’t mind sharing the results in a gist or github repo that’d be great.

    Thread Starter mumbomedia

    (@mumbomedia)

    Hi NateWr,

    thanks for the fast reply.
    I couldnt figure out how to setup a filter so the frontend assets are not loaded.
    I’ve tried it using the function.php of my theme but I debugged that the construct was called before the filter was registered and therefore the filter had no effect.
    Maybe there is a misunderstanding.
    Your offer a addon like the custom fields.
    So I have think if I could provide it like this.

    Hi mumbomedia,

    Ah, you’re right. The plugin instantiates too early. The only way for you to hook into that filter would be if you add a mu-plugin which is loaded before-hand. I’ve added an issue about this to the plugin’s GitHub repo.

    The alternative approach will be to hook into wp_footer and call wp_dequeue_script and wp_dequeue_style on each of the pickadate scripts/styles, as well as the booking-form.js file.

    Thread Starter mumbomedia

    (@mumbomedia)

    Hi NateWr,

    I’ve solved it by making a plugin, which checks if your plugin is installed and active.
    Now I’ve been able to set the filter so the script are not loaded.

    You’re right that could be an alternative approach.
    But I think a plugin is a better approach because it is working regardless which theme is used.
    Actually I am working on the Javascripts so that every works.

    Have a nice day.

    Hi mumbomedia,

    Glad to hear you’re able to move forward with it.

    You can hook into wp_footer from a plugin, too, not just a theme. But however you manage it, I agree doing it from a plugin is best.

    I’d love to see the final results as other people might find this useful.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change Date- and Timepicker to jQuery.ui’ is closed to new replies.