diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-05-16 11:35:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-16 11:35:49 +0200 |
commit | 8f80821820e4024c899d762efb0d2ab3426afc6c (patch) | |
tree | c799d0bdd2893b83c5e00224a5979872c4732047 | |
parent | cf01113cad2fc772113b5d1b7cd5be5e712ae0eb (diff) | |
parent | 50c9543f7b0160170461040d83016249d329ec8e (diff) | |
download | Shaarli-8f80821820e4024c899d762efb0d2ab3426afc6c.tar.gz Shaarli-8f80821820e4024c899d762efb0d2ab3426afc6c.tar.zst Shaarli-8f80821820e4024c899d762efb0d2ab3426afc6c.zip |
Merge pull request #1461 from flowgunso/documentation_how_create_plugin
-rw-r--r-- | doc/md/Plugin-System.md | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/doc/md/Plugin-System.md b/doc/md/Plugin-System.md index 9b0d3a7d..d5b16e2d 100644 --- a/doc/md/Plugin-System.md +++ b/doc/md/Plugin-System.md | |||
@@ -18,7 +18,7 @@ The plugin system let you: | |||
18 | 18 | ||
19 | First, chose a plugin name, such as `demo_plugin`. | 19 | First, chose a plugin name, such as `demo_plugin`. |
20 | 20 | ||
21 | Under `plugin` folder, create a folder named with your plugin name. Then create a <plugin_name>.php file in that folder. | 21 | Under `plugin` folder, create a folder named with your plugin name. Then create a <plugin_name>.meta file and a <plugin_name>.php file in that folder. |
22 | 22 | ||
23 | You should have the following tree view: | 23 | You should have the following tree view: |
24 | 24 | ||
@@ -26,17 +26,22 @@ You should have the following tree view: | |||
26 | | index.php | 26 | | index.php |
27 | | plugins/ | 27 | | plugins/ |
28 | |---| demo_plugin/ | 28 | |---| demo_plugin/ |
29 | | |---| demo_plugin.meta | ||
29 | | |---| demo_plugin.php | 30 | | |---| demo_plugin.php |
30 | ``` | 31 | ``` |
31 | 32 | ||
32 | ### Plugin initialization | 33 | ### Plugin initialization |
33 | 34 | ||
34 | 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. | 35 | At the beginning of Shaarli execution, all enabled plugins are loaded. At this point, the plugin system looks for an `init()` function in the <plugin_name>.php to execute and run it if it exists. This function must be named this way, and takes the `ConfigManager` as parameter. |
35 | 36 | ||
36 | <plugin_name>_init($conf) | 37 | <plugin_name>_init($conf) |
37 | 38 | ||
38 | 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. | 39 | 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. |
39 | 40 | ||
41 | The plugin system also looks for a `description` variable in the <plugin_name>.meta file, to be displayed in the plugin administration page. | ||
42 | |||
43 | description="The plugin does this and that." | ||
44 | |||
40 | ### Understanding hooks | 45 | ### Understanding hooks |
41 | 46 | ||
42 | A plugin is a set of functions. Each function will be triggered by the plugin system at certain point in Shaarli execution. | 47 | A plugin is a set of functions. Each function will be triggered by the plugin system at certain point in Shaarli execution. |