These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Changes the load priority of a plugin. |
||
4 | * |
||
5 | * Plugin priority affects view, action, and page handler |
||
6 | * overriding as well as the order of view extensions. Plugins with higher |
||
7 | * priority are loaded after and override plugins with lower priorities. |
||
8 | * |
||
9 | * NOTE: When viewing the plugin admin page, plugins LOWER on the page |
||
10 | * have HIGHER priority and will override views, etc from plugins above them. |
||
11 | */ |
||
12 | |||
13 | $plugin_guid = get_input('plugin_guid'); |
||
14 | $priority = get_input('priority'); |
||
15 | |||
16 | $plugin = get_entity($plugin_guid); |
||
17 | |||
18 | if (!($plugin instanceof ElggPlugin)) { |
||
19 | return elgg_error_response(elgg_echo('admin:plugins:set_priority:no', [$plugin_guid])); |
||
20 | } |
||
21 | |||
22 | View Code Duplication | if (!$plugin->setPriority($priority)) { |
|
1 ignored issue
–
show
|
|||
23 | $msg = $plugin->getError(); |
||
24 | $string = ($msg) ? 'admin:plugins:set_priority:no_with_msg' : 'admin:plugins:set_priority:no'; |
||
25 | |||
26 | return elgg_error_response(elgg_echo($string, [$plugin->getDisplayName(), $msg])); |
||
27 | } |
||
28 | |||
29 | // don't regenerate the simplecache because the plugin won't be |
||
30 | // loaded until next run. Just invalidate and let it regnerate as needed |
||
31 | elgg_flush_caches(); |
||
32 | |||
33 | return elgg_ok_response(); |
||
34 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.