From: Duncan C. <php...@dc...> - 2015-06-25 20:54:10
|
-------- Original Message -------- Subject: [phpList-developers] Writing Plugins From: Arnold Lesikar <ale...@ma...> To: php...@li... Date: 25/06/2015 19:44:01 > Hi all, > > I have made some changes in the Plugin Basics page at > https://resources.phplist.com/develop/plugins. First I have changed the > page title to the self-explanatory “How to Write a phpList Plugin.” > > Second I have added the following new sections; > 1. Using PHP program execution functions (The short answer here is: > *DON’T!)* > 2*. *Linking inside phpList > 3. Building an Ajax server page > > You might take a look to see if everything looks OK. > > Arnold Hi Arnold Something that you might want to add regarding a plugin's constructor. All plugins are instantiated, including those plugins that are disabled. So a constructor should limit itself to initialising variables etc, but nothing to do with the functionality of the plugin. Any "real" processing should take place in the activate() method, which is called only for enabled plugins. I didn't realise the implication of this until only recently. Also, in the final section on multiple plugin locations, I am not sure that the explanation of PLUGIN_ROOTDIRS is correct or at least is not clear. That constant can be a set of additional plugin locations, in effect multiple "plugins" directories. phplist doesn't search for plugins, merely accepts any that are present in any of the additional directories. A clearer example would be define("PLUGIN_ROOTDIRS","/home/me/git/phplist-plugin-plugin1/plugins;/home/me/git/phplist-plugin-plugin2/plugins"); with a directory structure /home/me/git/phplist-plugin-plugin1/plugins/plugin1.php /home/me/git/phplist-plugin-plugin1/plugins/plugin1/ /home/me/git/phplist-plugin-plugin2/plugins/plugin2.php /home/me/git/phplist-plugin-plugin2/plugins/plugin2/ |