Closed NateWr closed 7 years ago
You're right - if Plugin B comes with version 1.2.0 and calls set_template_data()
, but Plugin A comes with version 1.1.0 earlier and includes it first (and the Plugin B include fails as the class now exists in memory), then yes, set_template_data()
won't exist.
This issue is something that many similar drop-in libraries face. TGMPA has the same problem. I think CMB2 changes the main class name with each release to get around it.
There are two approaches I can think of.
I've not heard of any GTL conflicts yet, but the advice regardless would be for the plugin author using an old version of the library, to update it, as per the handling of most dependencies.
Thanks for the reply @GaryJones. I've gone ahead and prefixed it for my case, just to err on the side of caution. In a perfect world users would keep everything up to date, but well, that doesn't always happen. :)
It would be useful if the class was namespaced, as what some plugin developers are doing now to avoid conflicts on libraries are using namespace altering tools. Certainly I have done this with Stripe PHP SDK for instance when I discovered conflicts between versions.
The readme for this library already includes a reference to https://github.com/coenjacobs/mozart to help with auto-prefixing / namespacing to avoid the potential conflicts.
Ah.. I missed that. Thanks
I notice that the documentation suggests including
class-gamajo-template-loader.php
and then extendingGamajo_Template_Loader
. Won't we end up with hard-to-debug plugin conflicts doing it this way?If Plugin A expects to use a method of
Gamajo_Template_Loader
but Plugin B has already loaded an old version without that method, we'll have problems.Am I missing something here? Thanks.