Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am adding the ability to add add-on to my plugin. Right now i am using:

foreach(glob(GMW_PATH .'/plugins/*', GLOB_ONLYDIR) as $dir) {  
   include_once $dir . '/connect.php';  
} 

The function loop trough all the folders inside the "plugins" folder in my plugin and includes the connect.php file that is inside each of those folders (each add-on folder include the connect.php file).

This is the first time i am using GLOB_ONLYDIR and i am not sure about its performance. Is it a good idea to use the above or should i create each add-on as a stand alone plugin, which they actually are, but add the a ability to just activate them from the plugins page?

Thank you.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Depends on your plugin. I prefer to use plugins with the minimal functionality that meets my needs. Less configuration options, less documentation to read, and hopefully less bugs. You also need to think on the upgrade process. If you make a change in a big plugin I should look into upgrading it even if the change is in a functionality I don't use, and upgrades are always risky or take time to test.

Therefor, if you can break up your functionality into several plugins, that is the way to go IMO. But if it is not possible for what you do, then before you think about distributing addons for your plugin, think how are they going to be installed and upgraded. Unless you have a good plan for managing the addons I suggest you distribute them with the main plugin and then you can directly include them without the need for GLOB_ONLYDIR.

share|improve this answer
    
Thank you mark for your answer.This is my premium version of my plugin that i am working on which has a fair amount of settings, features ,documentation and few bugs as well (being fixed). Reasons for the add-ons are 1)so users will be able to turn-off/on features they do not need for better performance. 2) To be able to provide different add-ons with different memberships. –  Eyal Dec 15 '12 at 15:14
    
There is the basic main plugin and on top of that users can add the add-ons by just dropping the folder on each add-on into the plugins folder that within my plugin. I already have few add-ons ready and i am close to release the premium version. Right now i use the GLOB_ONLYDIR to include the add-ons just not sure it this is the best way to go. if for performance it is best to let GLOB_ONLYDIR loop trough folders in order to connect the add-ons or change the add-ons connect.php file to be able to activate/deactivate from the plugins admin page. which wont be too difficult to do. –  Eyal Dec 15 '12 at 15:25
    
Then it is really a PHP question, but I don't think it really matters how you implement this kind of thing as DB access is usually your performance bottleneck and not file system access. –  Mark Kaplun Dec 15 '12 at 17:28
    
And just to give you a different implementation idea, you can have a function called _eyal_register_my_addon($filepath) which each addon calls to register its main file, and then you can have the addons as plugins where each plugin calls _eyal_register_my_addon(FILE) on init or earlier –  Mark Kaplun Dec 15 '12 at 17:34
    
so if i understand your suggestion that means to go the other way i thought and just create the add-on as stand alone plugins activate them from the plugins page in the admin? which in this case you think will be better? –  Eyal Dec 15 '12 at 18:41
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.