WPClubManager / wp-club-manager

Create and manage a sports club or league website quickly and easily using WordPress.
https://wpclubmanager.com
Other
33 stars 13 forks source link

ACF Compatibility: Renamed jQuery.timepicker to jQuery.wpcmtimepicker. #20

Closed DaveyJake closed 4 years ago

DaveyJake commented 4 years ago

Renaming the plugin ensures complete ACF compatibility with no conflicts at runtime. The timepicker now works as expected. The changes made for this to work include the following:

roofdog commented 4 years ago

Hi Davey,

Sorry for the delay into looking into these changes! I moved house earlier this week and have only just got back online!

I'll properly review these commits and get back to you very soon.

Cheers

roofdog commented 4 years ago

Hi Davey,

What issue was being caused after the last merge using WP conditionals to check if the script should be loaded dependant on ACF?

I don't really want to be editing and renaming the jquery.timepicker script as that could well cause issues with maintaining the plugin in the future.

Cheers

DaveyJake commented 4 years ago

Hey mate!

The ACF plugin uses a different jQuery Timepicker plugin from a completely different codebase. The issue is a namespace conflict as both are named $.fn.timepicker.

When ACF and WPCM are used on the same post type (wpcm_match in this case), the ACF version gets loaded long before the WPCM version does. As a result, the UI when selecting a match date becomes unusable and doesn't function at all as expected.

roofdog commented 4 years ago

Hi mate,

Sorry for the delays! Things are a bit crazy over here with the lock down... strange times indeed.

Thanks for the reply. I would then be inclined to revert our timepicker script to the same one used by ACF, which uses jQuery UI so will be a good fit anyway. I would rather maintain the separate field for the match time in the match admin page so we could use the .timepicker object.

Then we should use WP conditional functions to enqueue scripts if ACF isn't installed.

roofdog commented 4 years ago

Hey Davey,

I've taken a good look into this now and am going to resort to your suggestion as I much prefer the timepicker plugin we are already using!

I've forked the jquery-timepicker plugin and renamed the function. I've committed the new timepicker version to the dev branch so feel free to check it out and give me feedback before I release v2.1.10.

Thanks for your help again :)