The Events Calendar + ACF: Select2 Conflict

I just noticed this issue today and thought I’d share a fix for it. Both Advanced Custom Fields and Modern Tribe’s The Events Calendar are enqueuing (globally) a version of Select2. Since they are not the same version, this will break some UI for ACF. If either of them are justified in loading select2 on every admin page, it’s ACF since you can literally create custom fields on just about every WordPress admin screen. TEC really only needs select2 on TEC related pages.

In my opinion, you should setup your plugins so that then only enqueue scripts/styles whenever they are needed. I still think ACF could do this only when certain field types are being used.

When I searched the web for this issue, I noticed a few posts on TEC forums that dated back to 2016, however this appears to still be a problem. Plus all of those posts were closed to replies, hence this blog post.

Anyway, the easiest fix in this situation was to disable TEC version when it wasn’t needed, on non-TEC related pages.

I hope this saves someone some time from chasing down this bug.

Write a Comment