PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 3.3.1
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v3.3.1
4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 trunk 1.0.0 2.0.0 2.0.1 2.0.2 2.0.3 3.0 3.0.1 3.0.2 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.4 3.2.5 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1
superb-blocks / src / data / utils / class-plugin-installer.php
superb-blocks / src / data / utils Last commit date
class-base-exception.php 1 year ago class-cache-constants.php 1 year ago class-cache-exception.php 1 year ago class-key-exception.php 1 year ago class-keytypes.php 1 year ago class-option-exception.php 1 year ago class-plugin-installer.php 1 year ago class-quiet-skin.php 1 year ago class-settings-exception.php 1 year ago
class-plugin-installer.php
79 lines
1 <?php
2
3 namespace SuperbAddons\Data\Utils;
4
5 defined('ABSPATH') || exit();
6
7 use SuperbAddons\Data\Utils\QuietSkin;
8
9 require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
10 require_once(ABSPATH . 'wp-admin/includes/file.php');
11 require_once(ABSPATH . 'wp-admin/includes/misc.php');
12 require_once(ABSPATH . 'wp-admin/includes/plugin.php');
13 require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
14
15 class PluginInstaller
16 {
17 public static function Install($plugin)
18 {
19 // Sanitize $plugin
20 switch ($plugin) {
21 case 'elementor':
22 // Allowed
23 $plugin_path = $plugin . '/' . $plugin . '.php';
24 break;
25 default:
26 return false;
27 }
28
29 self::ActivatePlugin($plugin_path);
30 if (\is_plugin_active($plugin_path)) {
31 return true;
32 }
33
34 $plugins_api = \plugins_api(
35 'plugin_information',
36 array(
37 'slug' => $plugin,
38 'fields' => array(
39 'short_description' => false,
40 'sections' => false,
41 'requires' => false,
42 'rating' => false,
43 'ratings' => false,
44 'downloaded' => false,
45 'last_updated' => false,
46 'added' => false,
47 'tags' => false,
48 'compatibility' => false,
49 'homepage' => false,
50 'donate_link' => false,
51 ),
52 )
53 );
54
55 if (is_wp_error($plugins_api)) {
56 return false;
57 }
58
59 $upgrader = new \Plugin_Upgrader(new QuietSkin());
60
61 $installation_result = $upgrader->install($plugins_api->download_link);
62
63 if (!$installation_result || is_wp_error($installation_result)) {
64 return false;
65 }
66
67 self::ActivatePlugin($plugin_path);
68
69 return true;
70 }
71
72 private static function ActivatePlugin($plugin_path)
73 {
74 if (file_exists(WP_PLUGIN_DIR . '/' . $plugin_path)) {
75 \activate_plugin($plugin_path, '', false, true);
76 }
77 }
78 }
79