PluginProbe
Extendify / 0.9.3
Extendify v0.9.3
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / app / Library / Controllers / PluginController.php

PluginController.php in Extendify 0.9.3, at app/Library/Controllers/PluginController.php

68 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Controls Plugins
4 */
5
6 namespace Extendify\Library\Controllers;
7
8 use Extendify\Library\Plugin;
9
10 if (!defined('ABSPATH')) {
11 die('No direct access.');
12 }
13
14 /**
15 * The controller for plugin dependency checking, etc
16 */
17 class PluginController
18 {
19
20 /**
21 * Return all plugins
22 *
23 * @return array
24 */
25 public static function index()
26 {
27 if (! function_exists('get_plugins')) {
28 require_once ABSPATH . 'wp-admin/includes/plugin.php';
29 }
30
31 return \get_plugins();
32 }
33
34 /**
35 * List active plugins
36 *
37 * @return array
38 */
39 public static function active()
40 {
41 return \get_option('active_plugins');
42 }
43
44 /**
45 * Install plugins
46 *
47 * @param \WP_REST_Request $request - The request.
48 * @return bool|WP_Error
49 */
50 public static function install($request)
51 {
52 if (!\current_user_can('activate_plugins')) {
53 return new \WP_Error('not_allowed', \__('You are not allowed to activate plugins on this site.', 'extendify'));
54 }
55
56 $requiredPlugins = json_decode($request->get_param('plugins'), true);
57 foreach ($requiredPlugins as $plugin) {
58 $status = Plugin::install_and_activate_plugin($plugin);
59 if (\is_wp_error($status)) {
60 // Return first error encountered.
61 return $status;
62 }
63 }
64
65 return true;
66 }
67 }
68