TGMPA / TGM-Plugin-Activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install, update and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference bundled plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.
http://tgmpluginactivation.com/
GNU General Public License v2.0
1.75k stars 431 forks source link

Allow Per-Instance Configuration #805

Open XedinUnknown opened 3 years ago

XedinUnknown commented 3 years ago

Fixes TGMPA/TGM-Plugin-Activation#804.

In general, this change simply shifts things to where they should be in order to properly configure multiple instances of TGMPA.

XedinUnknown commented 3 years ago

The build seems to be failing due to misconfigured CI: some packages require Composer v1, while Composer v2 is used on CI.

jrfnl commented 3 years ago

As per https://github.com/TGMPA/TGM-Plugin-Activation/issues/804#issuecomment-827580580:

TGMPA is single instance by design. Changing that is not open for discussion.

I suggest closing this PR.

XedinUnknown commented 3 years ago

As I have explained, nothing should change for the current users with this PR. Everyone should be able to continue using the single instance. Also, a class is not single-instance by design; the single-instance-ness is incidental, in that you can force a class to only have a single instance through high coupling etc, but this has no benefits while simply limiting consumers for no apparent reason. Your component (a part of an application, like a plugin or this lib) surely can use only a single instance of something, and can provide to its consumers ways to maintain consistency through the single instance - like by initializing an object, caching it, and always retrieving from cache. In this case, the tgmpa global is being used for that cache. So your component remains the same in the sense that it continues using only a single instance, and all of the consumers that follow your docs will thus use a single instance.

Given the above, I do not understand the relevance of your comment, sorry. Would you mind explaining exactly what the problem is, e.g. where in any code in this lib, including my PR, you see that it is no longer using a single instance?