X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=doc%2Fmd%2FPlugin-System.md;h=d5b16e2d0d2a200129e709b80932ee3a3ceb7b4e;hb=60ae241251b753fc052e50ebd95277dfcb074cb0;hp=cbec04c0fa0bf12ad87f2b33824c64f7c2700c0b;hpb=e8cef3ac43d5a50485c72ea2e8267e92b00be609;p=github%2Fshaarli%2FShaarli.git diff --git a/doc/md/Plugin-System.md b/doc/md/Plugin-System.md index cbec04c0..d5b16e2d 100644 --- a/doc/md/Plugin-System.md +++ b/doc/md/Plugin-System.md @@ -18,7 +18,7 @@ The plugin system let you: First, chose a plugin name, such as `demo_plugin`. -Under `plugin` folder, create a folder named with your plugin name. Then create a .php file in that folder. +Under `plugin` folder, create a folder named with your plugin name. Then create a .meta file and a .php file in that folder. You should have the following tree view: @@ -26,17 +26,22 @@ You should have the following tree view: | index.php | plugins/ |---| demo_plugin/ +| |---| demo_plugin.meta | |---| demo_plugin.php ``` ### Plugin initialization -At the beginning of Shaarli execution, all enabled plugins are loaded. At this point, the plugin system looks for an `init()` function to execute and run it if it exists. This function must be named this way, and takes the `ConfigManager` as parameter. +At the beginning of Shaarli execution, all enabled plugins are loaded. At this point, the plugin system looks for an `init()` function in the .php to execute and run it if it exists. This function must be named this way, and takes the `ConfigManager` as parameter. _init($conf) This function can be used to create initial data, load default settings, etc. But also to set *plugin errors*. If the initialization function returns an array of strings, they will be understand as errors, and displayed in the header to logged in users. +The plugin system also looks for a `description` variable in the .meta file, to be displayed in the plugin administration page. + + description="The plugin does this and that." + ### Understanding hooks A plugin is a set of functions. Each function will be triggered by the plugin system at certain point in Shaarli execution. @@ -137,6 +142,7 @@ If it's still not working, please [open an issue](https://github.com/shaarli/Sha | [render_feed](#render_feed) | Allow to do add tags in RSS and ATOM feeds. | | [save_link](#save_link) | Allow to alter the link being saved in the datastore. | | [delete_link](#delete_link) | Allow to do an action before a link is deleted from the datastore. | +| [save_plugin_parameters](#save_plugin_parameters) | Allow to manipulate plugin parameters before they're saved. | @@ -471,6 +477,22 @@ Allow to execute any action before the link is actually removed from the datasto - created - updated + +#### save_plugin_parameters + +Triggered when the plugin parameters are saved from the plugin administration page. + +Plugins can perform an action every times their settings are updated. +For example it is used to update the CSS file of the `default_colors` plugins. + +##### Data + +`$data` input contains the `$_POST` array. + +So if the plugin has a parameter called `MYPLUGIN_PARAMETER`, +the array will contain an entry with `MYPLUGIN_PARAMETER` as a key. + + ## Guide for template designer ### Plugin administration