You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of getting developers to amend the current $args array property to add to the list of required plugins, create a register() method as an API that would allow themes to add to a protected $plugins array property (effectively $args, renamed).
As developers would be required to do something like:
I like where you are going. It would be best to create one function that contains all the objects that store the plugin arrays, and then that function do all the heavy lifting. The last thing I would want to do is clutter up a theme authors functions.php file or wherever they decide to put this.
I definitely like the register() API. I'll hash this out later to see what I can come up with. Ultimately, the best solution would be the theme developer only having to do something like this:
That would be desirable because they only have to create one object and make one function call. Ultimately tgmpa_register_plugins() would be the large helper function in which everything else is stored and parsed.
Instead of getting developers to amend the current $args array property to add to the list of required plugins, create a
register()
method as an API that would allow themes to add to a protected $plugins array property (effectively $args, renamed).As developers would be required to do something like:
it might be nice to create a helper wrapper function (outside of the class):
So they can use the slightly simpler (easier to remember):
$my_plugin = array ( 'name' => '...', 'destination' => '...', 'source' => '...' ); $my_plugin2 = array ( 'name' => '...', 'destination' => '...', 'source' => '...' ); tgmpa_register_plugin( $my_plugin ); tgmpa_register_plugin( $my_plugin2 );
You might even create another helper function
tgmpa_register_plugins()
which can take an array of plugin arrays.What we're working towards is not having the developers needing to touch anything inside your code at all.
The text was updated successfully, but these errors were encountered: