1 | <?php |
||
2 | /** |
||
3 | * Saves global plugin settings. |
||
4 | * |
||
5 | * This action can be overriden for a specific plugin by creating the |
||
6 | * <plugin_id>/settings/save action in that plugin. |
||
7 | * |
||
8 | * @uses array $_REQUEST['params'] A set of key/value pairs to save to the ElggPlugin entity |
||
9 | * @uses mixed $_REQUEST['flush_cache'] If a truthy value is provided the caches will be flushed |
||
10 | * @uses int $_REQUEST['plugin_id'] The ID of the plugin |
||
11 | */ |
||
12 | |||
13 | $params = get_input('params'); |
||
14 | $flush_cache = get_input('flush_cache'); |
||
15 | $plugin_id = get_input('plugin_id'); |
||
16 | $plugin = elgg_get_plugin_from_id($plugin_id); |
||
17 | |||
18 | if (!$plugin) { |
||
19 | return elgg_error_response(elgg_echo('plugins:settings:save:fail', [$plugin_id])); |
||
20 | } |
||
21 | |||
22 | $plugin_name = $plugin->getDisplayName(); |
||
23 | |||
24 | $result = false; |
||
25 | |||
26 | foreach ($params as $k => $v) { |
||
27 | $result = $plugin->setSetting($k, $v); |
||
28 | if (!$result) { |
||
29 | return elgg_error_response(elgg_echo('plugins:settings:save:fail', [$plugin_name])); |
||
30 | } |
||
31 | } |
||
32 | |||
33 | if ($flush_cache) { |
||
34 | elgg_flush_caches(); |
||
1 ignored issue
–
show
|
|||
35 | } |
||
36 | |||
37 | return elgg_ok_response('', elgg_echo('plugins:settings:save:ok', [$plugin_name])); |
||
38 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.