PluginProbe ʕ •ᴥ•ʔ
10Web Booster – Website speed optimization, Cache & Page Speed optimizer / trunk
10Web Booster – Website speed optimization, Cache & Page Speed optimizer vtrunk
2.33.0 2.30.5 2.30.7 2.30.9 2.31.10 2.31.8 2.32.11 2.32.21 2.32.3 2.32.4 2.32.7 2.6.31 2.6.40 2.6.42 2.6.7 2.7.37 2.7.44 2.7.47 2.8.18 2.8.19 2.8.32 2.8.34 2.8.35 2.9.23 2.9.24 2.9.25 2.9.27 v2.27.4 trunk 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.17 2.0.18 2.0.21 2.0.22 2.0.25 2.0.26 2.0.27 2.0.3 2.0.7 2.0.9 2.10.46 2.10.65 2.10.66 2.10.68 2.11.41 2.11.42 2.11.43 2.12.15 2.12.21 2.12.22 2.12.23 2.12.26 2.13.37 2.13.40 2.13.41 2.13.42 2.13.44 2.13.45 2.13.47 2.14.49 2.14.50 2.15.18 2.17.21 2.17.23 2.18.17 2.19.44 2.19.45 2.19.46 2.19.49 2.2.12 2.2.15 2.2.16 2.2.18 2.2.8 2.20.31 2.20.32 2.20.33 2.21.11 2.21.12 2.21.16 2.21.25 2.22.32 2.23.13 2.23.15 2.23.16 2.23.18 2.24.12 2.24.14 2.24.18 2.25.14 2.26.6 2.28.10 2.28.13 2.28.14 2.28.7 2.29.1 2.29.2 2.29.3 2.3.0 2.3.1 2.3.2 2.3.3 2.30.18
tenweb-speed-optimizer / vendor / 10web / authorization / src / InstalledTheme.php
tenweb-speed-optimizer / vendor / 10web / authorization / src Last commit date
config 1 month ago Amazon.php 4 years ago Helper.php 1 month ago InstalledPlugin.php 3 years ago InstalledTheme.php 4 years ago Login.php 1 month ago Product.php 4 years ago ProductActions.php 4 years ago ProductState.php 1 year ago WpAjaxUpgraderSkin.php 4 years ago
InstalledTheme.php
161 lines
1 <?php
2
3 namespace Tenweb_Authorization {
4
5 use Tenweb_Authorization\Product;
6
7 class InstalledTheme extends Product implements ProductActions
8 {
9
10 private $state = null;
11
12 public function __construct($state, $id, $slug, $title, $description)
13 {
14 $this->state = $state;
15 parent::__construct($id, $slug, $title, $description, 'theme');
16 $this->installed = true;
17 }
18
19 public function get_state()
20 {
21 return $this->state;
22 }
23
24 public function activate()
25 {
26
27 switch_theme($this->slug);
28 $active_theme = wp_get_theme();
29
30 if ($this->title == $active_theme['Name'] || str_replace(" Theme", "", $this->title) == $active_theme["Name"]) {
31 return true;
32 } else {
33 $this->set_error('failed_to_activate', 'Failed to activate.');
34
35 return false;
36 }
37
38
39 }
40
41 public function deactivate()
42 {
43 }
44
45 public function update()
46 {
47
48 $is_active = $this->state->active;
49
50 $this->include_upgrade_libs();
51 $skin = $this->get_skin();
52
53 if ($skin == null) {
54 return false;
55 }
56
57 $upgrader = new \Theme_Upgrader($skin);
58
59 $fs_options = apply_filters('upgrader_package_options', array('destination' => WP_PLUGIN_DIR));
60 if ($upgrader->fs_connect(array(WP_CONTENT_DIR, $fs_options['destination'])) !== true) {
61 $this->set_error('fs_error', "File system error. Invalid file permissions or FTP credentials.");
62
63 return false;
64 }
65
66 if ($this->set_download_data() == false) {
67 return false;
68 }
69
70 $update_themes = get_site_transient('update_themes');
71
72 if (is_object($update_themes)) {
73 $old_update_themes = clone $update_themes;
74 } else {
75 $old_update_themes = $update_themes;
76 $update_themes = new \stdClass();
77 }
78
79 $theme_object = array(
80 'package' => $this->download_data['url']
81 );
82 $update_themes->response[$this->slug] = $theme_object;
83
84 $GLOBALS['tenweb_update_process'] = true;
85 set_site_transient('update_themes', $update_themes, 60 * 60);
86
87 add_filter('http_request_args', array($this, 'add_headers'), 9999, 2);
88
89 $result = $upgrader->upgrade($this->slug);
90 $GLOBALS['tenweb_update_process'] = false;
91
92 set_site_transient('update_themes', $old_update_themes, 60 * 60);
93
94 if ($is_active == 1) {
95 $this->activate();
96 }
97
98 if ($result === true) {
99 return true;
100 } else if (is_wp_error($result)) {
101 $this->set_error('failed_to_install', $result->get_error_message());
102
103 return false;
104 } else {
105 $this->set_error('failed_to_install', 'Something went wrong.');
106
107 return false;
108 }
109
110 }
111
112 function delete()
113 {
114 // Check filesystem credentials. `delete_theme()` will bail otherwise.
115 $url = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode($this->slug), 'delete-theme_' . $this->slug);
116 ob_start();
117 $credentials = request_filesystem_credentials($url);
118 ob_end_clean();
119
120 if (false === $credentials || !WP_Filesystem($credentials)) {
121 global $wp_filesystem;
122
123 // Pass through the error from WP_Filesystem if one was raised.
124 if ($wp_filesystem instanceof \WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
125 $this->set_error('fs_error', esc_html($wp_filesystem->errors->get_error_message()));
126 } else {
127 $this->set_error('fs_error', 'Unable to connect to the filesystem. Please confirm your credentials.');
128 }
129
130 return false;
131 }
132
133 include_once(ABSPATH . 'wp-admin/includes/theme.php');
134
135 $result = delete_theme($this->slug);
136
137 if (is_wp_error($result)) {
138 $this->set_error('failed_to_delete', $result->get_error_message());
139
140 return false;
141 } else if (false === $result) {
142 $this->set_error('failed_to_delete', 'Theme could not be deleted.');
143
144 return false;
145 }
146
147 return true;
148 }
149
150 public function has_update()
151 {
152
153 $av_version = ($this->state->is_paid) ? $this->latest_versions['paid'] : $this->latest_versions['free'];
154 $av_version = ltrim($av_version, 'v');
155
156 return version_compare($this->state->version, $av_version, "<");
157 }
158
159 }
160 }
161