Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create API to register plugins #2

Closed
GaryJones opened this issue Sep 30, 2011 · 2 comments
Closed

Create API to register plugins #2

GaryJones opened this issue Sep 30, 2011 · 2 comments

Comments

@GaryJones
Copy link
Member

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:

TGM_Plugin_Activation::instance->register( $my_plugin );

it might be nice to create a helper wrapper function (outside of the class):

    TGM_Plugin_Activation::instance->register( $plugin_args );
}

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.

@thomasgriffin
Copy link
Contributor

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:

$my_plugin = array(
    array(
        'name' => '',
        'destination' => '',
        'source' => ''
    ),
    array(
        'name' => '',
        'destination' => '',
        'source' => ''
    ),
);

tgmpa_register_plugins( $my_plugin );

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.

@thomasgriffin
Copy link
Contributor

Althought, multiple objects/function calls wouldn't be terrible, but I'd prefer to keep it to one a piece. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants