These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Disable all specified installed plugins. |
||
4 | * |
||
5 | * Specified plugins in the mod/ directory are disabled and the views cache and simplecache |
||
6 | * are reset. |
||
7 | * |
||
8 | * @package Elgg.Core |
||
9 | * @subpackage Administration.Plugins |
||
10 | */ |
||
11 | |||
12 | $guids = get_input('guids'); |
||
13 | |||
14 | View Code Duplication | if (empty($guids)) { |
|
15 | $plugins = elgg_get_plugins('active'); |
||
16 | } else { |
||
17 | $plugins = elgg_get_entities([ |
||
18 | 'type' => 'object', |
||
19 | 'subtype' => 'plugin', |
||
20 | 'guids' => explode(',', $guids), |
||
21 | 'limit' => false |
||
22 | ]); |
||
23 | } |
||
24 | |||
25 | if (empty($plugins)) { |
||
26 | forward(REFERER); |
||
27 | } |
||
28 | |||
29 | foreach ($plugins as $plugin) { |
||
30 | if (!$plugin->isActive()) { |
||
31 | continue; |
||
32 | } |
||
33 | |||
34 | View Code Duplication | if (!$plugin->deactivate()) { |
|
1 ignored issue
–
show
|
|||
35 | $msg = $plugin->getError(); |
||
36 | $string = ($msg) ? 'admin:plugins:deactivate:no_with_msg' : 'admin:plugins:deactivate:no'; |
||
37 | register_error(elgg_echo($string, [$plugin->getDisplayName(), $plugin->getError()])); |
||
38 | } |
||
39 | } |
||
40 | |||
41 | // don't regenerate the simplecache because the plugin won't be |
||
42 | // loaded until next run. Just invalidate and let it regnerate as needed |
||
43 | elgg_flush_caches(); |
||
44 | |||
45 | forward(REFERER); |
||
46 |
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.