author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
* Upgrader API: Theme_Installer_Skin class |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
* @package WordPress |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
* @subpackage Upgrader |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
* Theme Installer Skin for the WordPress Theme Installer. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
* @since 2.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
* @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader-skins.php. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
* @see WP_Upgrader_Skin |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
class Theme_Installer_Skin extends WP_Upgrader_Skin { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
public $api; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
public $type; |
16 | 21 |
public $url; |
22 |
public $overwrite; |
|
23 |
||
24 |
private $is_downgrading = false; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
27 |
* Constructor. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
28 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
29 |
* Sets up the theme installer skin. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
30 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
31 |
* @since 2.8.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
32 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
* @param array $args |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
*/ |
9 | 35 |
public function __construct( $args = array() ) { |
36 |
$defaults = array( |
|
16 | 37 |
'type' => 'web', |
38 |
'url' => '', |
|
39 |
'theme' => '', |
|
40 |
'nonce' => '', |
|
41 |
'title' => '', |
|
42 |
'overwrite' => '', |
|
9 | 43 |
); |
44 |
$args = wp_parse_args( $args, $defaults ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
|
16 | 46 |
$this->type = $args['type']; |
47 |
$this->url = $args['url']; |
|
48 |
$this->api = isset( $args['api'] ) ? $args['api'] : array(); |
|
49 |
$this->overwrite = $args['overwrite']; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
|
9 | 51 |
parent::__construct( $args ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
55 |
* Performs an action before installing a theme. |
16 | 56 |
* |
57 |
* @since 2.8.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
58 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
59 |
public function before() { |
9 | 60 |
if ( ! empty( $this->api ) ) { |
16 | 61 |
$this->upgrader->strings['process_success'] = sprintf( |
62 |
$this->upgrader->strings['process_success_specific'], |
|
63 |
$this->api->name, |
|
64 |
$this->api->version |
|
65 |
); |
|
9 | 66 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
67 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
68 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
69 |
/** |
16 | 70 |
* Hides the `process_failed` error when updating a theme by uploading a zip file. |
71 |
* |
|
72 |
* @since 5.5.0 |
|
73 |
* |
|
18 | 74 |
* @param WP_Error $wp_error WP_Error object. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
75 |
* @return bool True if the error should be hidden, false otherwise. |
16 | 76 |
*/ |
77 |
public function hide_process_failed( $wp_error ) { |
|
78 |
if ( |
|
79 |
'upload' === $this->type && |
|
80 |
'' === $this->overwrite && |
|
81 |
$wp_error->get_error_code() === 'folder_exists' |
|
82 |
) { |
|
83 |
return true; |
|
84 |
} |
|
85 |
||
86 |
return false; |
|
87 |
} |
|
88 |
||
89 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
90 |
* Performs an action following a single theme install. |
16 | 91 |
* |
92 |
* @since 2.8.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
93 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
94 |
public function after() { |
16 | 95 |
if ( $this->do_overwrite() ) { |
96 |
return; |
|
97 |
} |
|
98 |
||
9 | 99 |
if ( empty( $this->upgrader->result['destination_name'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
100 |
return; |
9 | 101 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
102 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
103 |
$theme_info = $this->upgrader->theme_info(); |
9 | 104 |
if ( empty( $theme_info ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
105 |
return; |
9 | 106 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
107 |
|
9 | 108 |
$name = $theme_info->display( 'Name' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
109 |
$stylesheet = $this->upgrader->result['destination_name']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
110 |
$template = $theme_info->get_template(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
111 |
|
9 | 112 |
$activate_link = add_query_arg( |
113 |
array( |
|
114 |
'action' => 'activate', |
|
115 |
'template' => urlencode( $template ), |
|
116 |
'stylesheet' => urlencode( $stylesheet ), |
|
117 |
), |
|
118 |
admin_url( 'themes.php' ) |
|
119 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
120 |
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
121 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
122 |
$install_actions = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
|
19 | 124 |
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) && ! $theme_info->is_block_theme() ) { |
16 | 125 |
$customize_url = add_query_arg( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
array( |
9 | 127 |
'theme' => urlencode( $stylesheet ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
128 |
'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
129 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
admin_url( 'customize.php' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
131 |
); |
16 | 132 |
|
133 |
$install_actions['preview'] = sprintf( |
|
134 |
'<a href="%s" class="hide-if-no-customize load-customize">' . |
|
135 |
'<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
136 |
esc_url( $customize_url ), |
|
137 |
__( 'Live Preview' ), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
138 |
/* translators: Hidden accessibility text. %s: Theme name. */ |
16 | 139 |
sprintf( __( 'Live Preview “%s”' ), $name ) |
140 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
141 |
} |
16 | 142 |
|
143 |
$install_actions['activate'] = sprintf( |
|
144 |
'<a href="%s" class="activatelink">' . |
|
145 |
'<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
146 |
esc_url( $activate_link ), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
147 |
_x( 'Activate', 'theme' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
148 |
/* translators: Hidden accessibility text. %s: Theme name. */ |
16 | 149 |
sprintf( _x( 'Activate “%s”', 'theme' ), $name ) |
150 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
151 |
|
9 | 152 |
if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) { |
16 | 153 |
$install_actions['network_enable'] = sprintf( |
154 |
'<a href="%s" target="_parent">%s</a>', |
|
155 |
esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ), |
|
156 |
__( 'Network Enable' ) |
|
157 |
); |
|
9 | 158 |
} |
159 |
||
16 | 160 |
if ( 'web' === $this->type ) { |
161 |
$install_actions['themes_page'] = sprintf( |
|
162 |
'<a href="%s" target="_parent">%s</a>', |
|
163 |
self_admin_url( 'theme-install.php' ), |
|
18 | 164 |
__( 'Go to Theme Installer' ) |
16 | 165 |
); |
9 | 166 |
} elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) { |
16 | 167 |
$install_actions['themes_page'] = sprintf( |
168 |
'<a href="%s" target="_parent">%s</a>', |
|
169 |
self_admin_url( 'themes.php' ), |
|
18 | 170 |
__( 'Go to Themes page' ) |
16 | 171 |
); |
9 | 172 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
173 |
|
9 | 174 |
if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
175 |
unset( $install_actions['activate'], $install_actions['preview'] ); |
16 | 176 |
} elseif ( get_option( 'template' ) === $stylesheet ) { |
177 |
unset( $install_actions['activate'] ); |
|
9 | 178 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
179 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
180 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
181 |
* Filters the list of action links available following a single theme installation. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
182 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
183 |
* @since 2.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
184 |
* |
9 | 185 |
* @param string[] $install_actions Array of theme action links. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
186 |
* @param object $api Object containing WordPress.org API theme data. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
187 |
* @param string $stylesheet Theme directory name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
188 |
* @param WP_Theme $theme_info Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
189 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
190 |
$install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info ); |
9 | 191 |
if ( ! empty( $install_actions ) ) { |
192 |
$this->feedback( implode( ' | ', (array) $install_actions ) ); |
|
193 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
194 |
} |
16 | 195 |
|
196 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
197 |
* Checks if the theme can be overwritten and outputs the HTML for overwriting a theme on upload. |
16 | 198 |
* |
199 |
* @since 5.5.0 |
|
200 |
* |
|
201 |
* @return bool Whether the theme can be overwritten and HTML was outputted. |
|
202 |
*/ |
|
203 |
private function do_overwrite() { |
|
204 |
if ( 'upload' !== $this->type || ! is_wp_error( $this->result ) || 'folder_exists' !== $this->result->get_error_code() ) { |
|
205 |
return false; |
|
206 |
} |
|
207 |
||
208 |
$folder = $this->result->get_error_data( 'folder_exists' ); |
|
209 |
$folder = rtrim( $folder, '/' ); |
|
210 |
||
211 |
$current_theme_data = false; |
|
212 |
$all_themes = wp_get_themes( array( 'errors' => null ) ); |
|
213 |
||
214 |
foreach ( $all_themes as $theme ) { |
|
215 |
$stylesheet_dir = wp_normalize_path( $theme->get_stylesheet_directory() ); |
|
216 |
||
217 |
if ( rtrim( $stylesheet_dir, '/' ) !== $folder ) { |
|
218 |
continue; |
|
219 |
} |
|
220 |
||
221 |
$current_theme_data = $theme; |
|
222 |
} |
|
223 |
||
224 |
$new_theme_data = $this->upgrader->new_theme_data; |
|
225 |
||
226 |
if ( ! $current_theme_data || ! $new_theme_data ) { |
|
227 |
return false; |
|
228 |
} |
|
229 |
||
18 | 230 |
echo '<h2 class="update-from-upload-heading">' . esc_html__( 'This theme is already installed.' ) . '</h2>'; |
16 | 231 |
|
19 | 232 |
// Check errors for active theme. |
16 | 233 |
if ( is_wp_error( $current_theme_data->errors() ) ) { |
234 |
$this->feedback( 'current_theme_has_errors', $current_theme_data->errors()->get_error_message() ); |
|
235 |
} |
|
236 |
||
237 |
$this->is_downgrading = version_compare( $current_theme_data['Version'], $new_theme_data['Version'], '>' ); |
|
238 |
||
239 |
$is_invalid_parent = false; |
|
240 |
if ( ! empty( $new_theme_data['Template'] ) ) { |
|
241 |
$is_invalid_parent = ! in_array( $new_theme_data['Template'], array_keys( $all_themes ), true ); |
|
242 |
} |
|
243 |
||
244 |
$rows = array( |
|
245 |
'Name' => __( 'Theme name' ), |
|
246 |
'Version' => __( 'Version' ), |
|
247 |
'Author' => __( 'Author' ), |
|
248 |
'RequiresWP' => __( 'Required WordPress version' ), |
|
249 |
'RequiresPHP' => __( 'Required PHP version' ), |
|
250 |
'Template' => __( 'Parent theme' ), |
|
251 |
); |
|
252 |
||
253 |
$table = '<table class="update-from-upload-comparison"><tbody>'; |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
254 |
$table .= '<tr><th></th><th>' . esc_html_x( 'Installed', 'theme' ) . '</th><th>' . esc_html_x( 'Uploaded', 'theme' ) . '</th></tr>'; |
16 | 255 |
|
256 |
$is_same_theme = true; // Let's consider only these rows. |
|
257 |
||
258 |
foreach ( $rows as $field => $label ) { |
|
259 |
$old_value = $current_theme_data->display( $field, false ); |
|
260 |
$old_value = $old_value ? (string) $old_value : '-'; |
|
261 |
||
262 |
$new_value = ! empty( $new_theme_data[ $field ] ) ? (string) $new_theme_data[ $field ] : '-'; |
|
263 |
||
264 |
if ( $old_value === $new_value && '-' === $new_value && 'Template' === $field ) { |
|
265 |
continue; |
|
266 |
} |
|
267 |
||
268 |
$is_same_theme = $is_same_theme && ( $old_value === $new_value ); |
|
269 |
||
270 |
$diff_field = ( 'Version' !== $field && $new_value !== $old_value ); |
|
271 |
$diff_version = ( 'Version' === $field && $this->is_downgrading ); |
|
272 |
$invalid_parent = false; |
|
273 |
||
274 |
if ( 'Template' === $field && $is_invalid_parent ) { |
|
275 |
$invalid_parent = true; |
|
276 |
$new_value .= ' ' . __( '(not found)' ); |
|
277 |
} |
|
278 |
||
279 |
$table .= '<tr><td class="name-label">' . $label . '</td><td>' . wp_strip_all_tags( $old_value ) . '</td>'; |
|
280 |
$table .= ( $diff_field || $diff_version || $invalid_parent ) ? '<td class="warning">' : '<td>'; |
|
281 |
$table .= wp_strip_all_tags( $new_value ) . '</td></tr>'; |
|
282 |
} |
|
283 |
||
284 |
$table .= '</tbody></table>'; |
|
285 |
||
286 |
/** |
|
287 |
* Filters the compare table output for overwriting a theme package on upload. |
|
288 |
* |
|
289 |
* @since 5.5.0 |
|
290 |
* |
|
19 | 291 |
* @param string $table The output table with Name, Version, Author, RequiresWP, and RequiresPHP info. |
292 |
* @param WP_Theme $current_theme_data Active theme data. |
|
293 |
* @param array $new_theme_data Array with uploaded theme data. |
|
16 | 294 |
*/ |
295 |
echo apply_filters( 'install_theme_overwrite_comparison', $table, $current_theme_data, $new_theme_data ); |
|
296 |
||
297 |
$install_actions = array(); |
|
298 |
$can_update = true; |
|
299 |
||
18 | 300 |
$blocked_message = '<p>' . esc_html__( 'The theme cannot be updated due to the following:' ) . '</p>'; |
16 | 301 |
$blocked_message .= '<ul class="ul-disc">'; |
302 |
||
303 |
$requires_php = isset( $new_theme_data['RequiresPHP'] ) ? $new_theme_data['RequiresPHP'] : null; |
|
304 |
$requires_wp = isset( $new_theme_data['RequiresWP'] ) ? $new_theme_data['RequiresWP'] : null; |
|
305 |
||
306 |
if ( ! is_php_version_compatible( $requires_php ) ) { |
|
307 |
$error = sprintf( |
|
308 |
/* translators: 1: Current PHP version, 2: Version required by the uploaded theme. */ |
|
309 |
__( 'The PHP version on your server is %1$s, however the uploaded theme requires %2$s.' ), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
310 |
PHP_VERSION, |
16 | 311 |
$requires_php |
312 |
); |
|
313 |
||
314 |
$blocked_message .= '<li>' . esc_html( $error ) . '</li>'; |
|
315 |
$can_update = false; |
|
316 |
} |
|
317 |
||
318 |
if ( ! is_wp_version_compatible( $requires_wp ) ) { |
|
319 |
$error = sprintf( |
|
320 |
/* translators: 1: Current WordPress version, 2: Version required by the uploaded theme. */ |
|
321 |
__( 'Your WordPress version is %1$s, however the uploaded theme requires %2$s.' ), |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
322 |
esc_html( wp_get_wp_version() ), |
16 | 323 |
$requires_wp |
324 |
); |
|
325 |
||
326 |
$blocked_message .= '<li>' . esc_html( $error ) . '</li>'; |
|
327 |
$can_update = false; |
|
328 |
} |
|
329 |
||
330 |
$blocked_message .= '</ul>'; |
|
331 |
||
332 |
if ( $can_update ) { |
|
333 |
if ( $this->is_downgrading ) { |
|
334 |
$warning = sprintf( |
|
335 |
/* translators: %s: Documentation URL. */ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
336 |
__( 'You are uploading an older version of the installed theme. You can continue to install the older version, but be sure to <a href="%s">back up your database and files</a> first.' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
337 |
__( 'https://developer.wordpress.org/advanced-administration/security/backup/' ) |
16 | 338 |
); |
339 |
} else { |
|
340 |
$warning = sprintf( |
|
341 |
/* translators: %s: Documentation URL. */ |
|
342 |
__( 'You are updating a theme. Be sure to <a href="%s">back up your database and files</a> first.' ), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
343 |
__( 'https://developer.wordpress.org/advanced-administration/security/backup/' ) |
16 | 344 |
); |
345 |
} |
|
346 |
||
347 |
echo '<p class="update-from-upload-notice">' . $warning . '</p>'; |
|
348 |
||
349 |
$overwrite = $this->is_downgrading ? 'downgrade-theme' : 'update-theme'; |
|
350 |
||
351 |
$install_actions['overwrite_theme'] = sprintf( |
|
352 |
'<a class="button button-primary update-from-upload-overwrite" href="%s" target="_parent">%s</a>', |
|
353 |
wp_nonce_url( add_query_arg( 'overwrite', $overwrite, $this->url ), 'theme-upload' ), |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
354 |
_x( 'Replace installed with uploaded', 'theme' ) |
16 | 355 |
); |
356 |
} else { |
|
357 |
echo $blocked_message; |
|
358 |
} |
|
359 |
||
360 |
$cancel_url = add_query_arg( 'action', 'upload-theme-cancel-overwrite', $this->url ); |
|
361 |
||
362 |
$install_actions['themes_page'] = sprintf( |
|
363 |
'<a class="button" href="%s" target="_parent">%s</a>', |
|
364 |
wp_nonce_url( $cancel_url, 'theme-upload-cancel-overwrite' ), |
|
365 |
__( 'Cancel and go back' ) |
|
366 |
); |
|
367 |
||
368 |
/** |
|
18 | 369 |
* Filters the list of action links available following a single theme installation failure |
370 |
* when overwriting is allowed. |
|
16 | 371 |
* |
372 |
* @since 5.5.0 |
|
373 |
* |
|
374 |
* @param string[] $install_actions Array of theme action links. |
|
375 |
* @param object $api Object containing WordPress.org API theme data. |
|
376 |
* @param array $new_theme_data Array with uploaded theme data. |
|
377 |
*/ |
|
378 |
$install_actions = apply_filters( 'install_theme_overwrite_actions', $install_actions, $this->api, $new_theme_data ); |
|
379 |
||
380 |
if ( ! empty( $install_actions ) ) { |
|
381 |
printf( |
|
382 |
'<p class="update-from-upload-expired hidden">%s</p>', |
|
383 |
__( 'The uploaded file has expired. Please go back and upload it again.' ) |
|
384 |
); |
|
385 |
echo '<p class="update-from-upload-actions">' . implode( ' ', (array) $install_actions ) . '</p>'; |
|
386 |
} |
|
387 |
||
388 |
return true; |
|
389 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
390 |
} |