PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 3.4.0
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v3.4.0
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-theme-installer.php
superb-blocks / src / data / utils Last commit date
wizard 1 year ago class-addons-template-util.php 1 year ago 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-quiet-skin.php 1 year ago class-request-exception.php 1 year ago class-script-translations.php 1 year ago class-settings-exception.php 1 year ago class-theme-installer.php 1 year ago
class-theme-installer.php
72 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/theme-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/theme.php');
13 require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
14
15 class ThemeInstaller
16 {
17 public static function Install($theme)
18 {
19 $activated = self::ActivateTheme($theme);
20 if ($activated) {
21 return true;
22 }
23
24 $themes_api = \themes_api(
25 'theme_information',
26 array(
27 'slug' => $theme,
28 'fields' => array(
29 'description' => false,
30 'sections' => false,
31 'requires' => false,
32 'rating' => false,
33 'ratings' => false,
34 'downloaded' => false,
35 'last_updated' => false,
36 'added' => false,
37 'tags' => false,
38 'compatibility' => false,
39 'homepage' => false,
40 'donate_link' => false,
41 ),
42 )
43 );
44
45 if (is_wp_error($themes_api)) {
46 return false;
47 }
48
49 $upgrader = new \Theme_Upgrader(new QuietSkin());
50
51 $installation_result = $upgrader->install($themes_api->download_link);
52
53 if (!$installation_result || is_wp_error($installation_result)) {
54 return false;
55 }
56
57 return self::ActivateTheme($theme);
58 }
59
60 private static function ActivateTheme($theme_slug)
61 {
62 // Activate theme
63 $theme = wp_get_theme($theme_slug);
64 if ($theme->exists()) {
65 switch_theme($theme->get_stylesheet());
66 return true;
67 }
68
69 return false;
70 }
71 }
72