author | ymh <ymh.work@gmail.com> |
Mon, 08 Sep 2025 19:44:41 +0200 | |
changeset 23 | 417f20492bf7 |
parent 22 | 8c2e4d02f4ef |
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: Plugin_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 |
* Plugin Installer Skin for WordPress Plugin 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 Plugin_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:
18
diff
changeset
|
27 |
* Constructor. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
28 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
29 |
* Sets up the plugin installer skin. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
30 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
31 |
* @since 2.8.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
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 |
'plugin' => '', |
|
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:
18
diff
changeset
|
55 |
* Performs an action before installing a plugin. |
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 plugin 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:
18
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:
18
diff
changeset
|
90 |
* Performs an action following a plugin 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 |
// Check if the plugin can be overwritten and output the HTML. |
96 |
if ( $this->do_overwrite() ) { |
|
97 |
return; |
|
98 |
} |
|
99 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
100 |
$plugin_file = $this->upgrader->plugin_info(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
101 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
102 |
$install_actions = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
103 |
|
9 | 104 |
$from = isset( $_GET['from'] ) ? wp_unslash( $_GET['from'] ) : 'plugins'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
105 |
|
16 | 106 |
if ( 'import' === $from ) { |
107 |
$install_actions['activate_plugin'] = sprintf( |
|
108 |
'<a class="button button-primary" href="%s" target="_parent">%s</a>', |
|
109 |
wp_nonce_url( 'plugins.php?action=activate&from=import&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ), |
|
110 |
__( 'Activate Plugin & Run Importer' ) |
|
111 |
); |
|
112 |
} elseif ( 'press-this' === $from ) { |
|
113 |
$install_actions['activate_plugin'] = sprintf( |
|
114 |
'<a class="button button-primary" href="%s" target="_parent">%s</a>', |
|
115 |
wp_nonce_url( 'plugins.php?action=activate&from=press-this&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ), |
|
18 | 116 |
__( 'Activate Plugin & Go to Press This' ) |
16 | 117 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
118 |
} else { |
16 | 119 |
$install_actions['activate_plugin'] = sprintf( |
120 |
'<a class="button button-primary" href="%s" target="_parent">%s</a>', |
|
121 |
wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ), |
|
122 |
__( 'Activate Plugin' ) |
|
123 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
125 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { |
16 | 127 |
$install_actions['network_activate'] = sprintf( |
128 |
'<a class="button button-primary" href="%s" target="_parent">%s</a>', |
|
129 |
wp_nonce_url( 'plugins.php?action=activate&networkwide=1&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
130 |
_x( 'Network Activate', 'plugin' ) |
16 | 131 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
132 |
unset( $install_actions['activate_plugin'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
133 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
134 |
|
16 | 135 |
if ( 'import' === $from ) { |
136 |
$install_actions['importers_page'] = sprintf( |
|
137 |
'<a href="%s" target="_parent">%s</a>', |
|
138 |
admin_url( 'import.php' ), |
|
18 | 139 |
__( 'Go to Importers' ) |
16 | 140 |
); |
141 |
} elseif ( 'web' === $this->type ) { |
|
142 |
$install_actions['plugins_page'] = sprintf( |
|
143 |
'<a href="%s" target="_parent">%s</a>', |
|
144 |
self_admin_url( 'plugin-install.php' ), |
|
18 | 145 |
__( 'Go to Plugin Installer' ) |
16 | 146 |
); |
147 |
} elseif ( 'upload' === $this->type && 'plugins' === $from ) { |
|
148 |
$install_actions['plugins_page'] = sprintf( |
|
149 |
'<a href="%s">%s</a>', |
|
150 |
self_admin_url( 'plugin-install.php' ), |
|
18 | 151 |
__( 'Go to Plugin Installer' ) |
16 | 152 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
153 |
} else { |
16 | 154 |
$install_actions['plugins_page'] = sprintf( |
155 |
'<a href="%s" target="_parent">%s</a>', |
|
156 |
self_admin_url( 'plugins.php' ), |
|
18 | 157 |
__( 'Go to Plugins page' ) |
16 | 158 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
159 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
160 |
|
9 | 161 |
if ( ! $this->result || is_wp_error( $this->result ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
162 |
unset( $install_actions['activate_plugin'], $install_actions['network_activate'] ); |
16 | 163 |
} elseif ( ! current_user_can( 'activate_plugin', $plugin_file ) || is_plugin_active( $plugin_file ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
164 |
unset( $install_actions['activate_plugin'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
165 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
166 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
167 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
168 |
* Filters the list of action links available following a single plugin installation. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
169 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
170 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
171 |
* |
9 | 172 |
* @param string[] $install_actions Array of plugin action links. |
173 |
* @param object $api Object containing WordPress.org API plugin data. Empty |
|
174 |
* for non-API installs, such as when a plugin is installed |
|
175 |
* via upload. |
|
176 |
* @param string $plugin_file Path to the plugin file relative to the plugins directory. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
177 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
178 |
$install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file ); |
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 |
if ( ! empty( $install_actions ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
181 |
$this->feedback( implode( ' ', (array) $install_actions ) ); |
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 |
} |
16 | 184 |
|
185 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
186 |
* Checks if the plugin can be overwritten and outputs the HTML for overwriting a plugin on upload. |
16 | 187 |
* |
188 |
* @since 5.5.0 |
|
189 |
* |
|
190 |
* @return bool Whether the plugin can be overwritten and HTML was outputted. |
|
191 |
*/ |
|
192 |
private function do_overwrite() { |
|
193 |
if ( 'upload' !== $this->type || ! is_wp_error( $this->result ) || 'folder_exists' !== $this->result->get_error_code() ) { |
|
194 |
return false; |
|
195 |
} |
|
196 |
||
197 |
$folder = $this->result->get_error_data( 'folder_exists' ); |
|
198 |
$folder = ltrim( substr( $folder, strlen( WP_PLUGIN_DIR ) ), '/' ); |
|
199 |
||
200 |
$current_plugin_data = false; |
|
201 |
$all_plugins = get_plugins(); |
|
202 |
||
203 |
foreach ( $all_plugins as $plugin => $plugin_data ) { |
|
204 |
if ( strrpos( $plugin, $folder ) !== 0 ) { |
|
205 |
continue; |
|
206 |
} |
|
207 |
||
208 |
$current_plugin_data = $plugin_data; |
|
209 |
} |
|
210 |
||
211 |
$new_plugin_data = $this->upgrader->new_plugin_data; |
|
212 |
||
213 |
if ( ! $current_plugin_data || ! $new_plugin_data ) { |
|
214 |
return false; |
|
215 |
} |
|
216 |
||
18 | 217 |
echo '<h2 class="update-from-upload-heading">' . esc_html__( 'This plugin is already installed.' ) . '</h2>'; |
16 | 218 |
|
219 |
$this->is_downgrading = version_compare( $current_plugin_data['Version'], $new_plugin_data['Version'], '>' ); |
|
220 |
||
221 |
$rows = array( |
|
222 |
'Name' => __( 'Plugin name' ), |
|
223 |
'Version' => __( 'Version' ), |
|
224 |
'Author' => __( 'Author' ), |
|
225 |
'RequiresWP' => __( 'Required WordPress version' ), |
|
226 |
'RequiresPHP' => __( 'Required PHP version' ), |
|
227 |
); |
|
228 |
||
229 |
$table = '<table class="update-from-upload-comparison"><tbody>'; |
|
18 | 230 |
$table .= '<tr><th></th><th>' . esc_html_x( 'Current', 'plugin' ) . '</th>'; |
231 |
$table .= '<th>' . esc_html_x( 'Uploaded', 'plugin' ) . '</th></tr>'; |
|
16 | 232 |
|
233 |
$is_same_plugin = true; // Let's consider only these rows. |
|
234 |
||
235 |
foreach ( $rows as $field => $label ) { |
|
236 |
$old_value = ! empty( $current_plugin_data[ $field ] ) ? (string) $current_plugin_data[ $field ] : '-'; |
|
237 |
$new_value = ! empty( $new_plugin_data[ $field ] ) ? (string) $new_plugin_data[ $field ] : '-'; |
|
238 |
||
239 |
$is_same_plugin = $is_same_plugin && ( $old_value === $new_value ); |
|
240 |
||
241 |
$diff_field = ( 'Version' !== $field && $new_value !== $old_value ); |
|
242 |
$diff_version = ( 'Version' === $field && $this->is_downgrading ); |
|
243 |
||
244 |
$table .= '<tr><td class="name-label">' . $label . '</td><td>' . wp_strip_all_tags( $old_value ) . '</td>'; |
|
245 |
$table .= ( $diff_field || $diff_version ) ? '<td class="warning">' : '<td>'; |
|
246 |
$table .= wp_strip_all_tags( $new_value ) . '</td></tr>'; |
|
247 |
} |
|
248 |
||
249 |
$table .= '</tbody></table>'; |
|
250 |
||
251 |
/** |
|
252 |
* Filters the compare table output for overwriting a plugin package on upload. |
|
253 |
* |
|
254 |
* @since 5.5.0 |
|
255 |
* |
|
256 |
* @param string $table The output table with Name, Version, Author, RequiresWP, and RequiresPHP info. |
|
257 |
* @param array $current_plugin_data Array with current plugin data. |
|
258 |
* @param array $new_plugin_data Array with uploaded plugin data. |
|
259 |
*/ |
|
260 |
echo apply_filters( 'install_plugin_overwrite_comparison', $table, $current_plugin_data, $new_plugin_data ); |
|
261 |
||
262 |
$install_actions = array(); |
|
263 |
$can_update = true; |
|
264 |
||
18 | 265 |
$blocked_message = '<p>' . esc_html__( 'The plugin cannot be updated due to the following:' ) . '</p>'; |
16 | 266 |
$blocked_message .= '<ul class="ul-disc">'; |
267 |
||
268 |
$requires_php = isset( $new_plugin_data['RequiresPHP'] ) ? $new_plugin_data['RequiresPHP'] : null; |
|
269 |
$requires_wp = isset( $new_plugin_data['RequiresWP'] ) ? $new_plugin_data['RequiresWP'] : null; |
|
270 |
||
271 |
if ( ! is_php_version_compatible( $requires_php ) ) { |
|
272 |
$error = sprintf( |
|
273 |
/* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */ |
|
274 |
__( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
275 |
PHP_VERSION, |
16 | 276 |
$requires_php |
277 |
); |
|
278 |
||
279 |
$blocked_message .= '<li>' . esc_html( $error ) . '</li>'; |
|
280 |
$can_update = false; |
|
281 |
} |
|
282 |
||
283 |
if ( ! is_wp_version_compatible( $requires_wp ) ) { |
|
284 |
$error = sprintf( |
|
285 |
/* translators: 1: Current WordPress version, 2: Version required by the uploaded plugin. */ |
|
286 |
__( 'Your WordPress version is %1$s, however the uploaded plugin requires %2$s.' ), |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
287 |
esc_html( wp_get_wp_version() ), |
16 | 288 |
$requires_wp |
289 |
); |
|
290 |
||
291 |
$blocked_message .= '<li>' . esc_html( $error ) . '</li>'; |
|
292 |
$can_update = false; |
|
293 |
} |
|
294 |
||
295 |
$blocked_message .= '</ul>'; |
|
296 |
||
297 |
if ( $can_update ) { |
|
298 |
if ( $this->is_downgrading ) { |
|
299 |
$warning = sprintf( |
|
300 |
/* translators: %s: Documentation URL. */ |
|
301 |
__( 'You are uploading an older version of a current plugin. 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:
18
diff
changeset
|
302 |
__( 'https://developer.wordpress.org/advanced-administration/security/backup/' ) |
16 | 303 |
); |
304 |
} else { |
|
305 |
$warning = sprintf( |
|
306 |
/* translators: %s: Documentation URL. */ |
|
307 |
__( 'You are updating a plugin. 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:
18
diff
changeset
|
308 |
__( 'https://developer.wordpress.org/advanced-administration/security/backup/' ) |
16 | 309 |
); |
310 |
} |
|
311 |
||
312 |
echo '<p class="update-from-upload-notice">' . $warning . '</p>'; |
|
313 |
||
314 |
$overwrite = $this->is_downgrading ? 'downgrade-plugin' : 'update-plugin'; |
|
315 |
||
316 |
$install_actions['overwrite_plugin'] = sprintf( |
|
317 |
'<a class="button button-primary update-from-upload-overwrite" href="%s" target="_parent">%s</a>', |
|
318 |
wp_nonce_url( add_query_arg( 'overwrite', $overwrite, $this->url ), 'plugin-upload' ), |
|
18 | 319 |
_x( 'Replace current with uploaded', 'plugin' ) |
16 | 320 |
); |
321 |
} else { |
|
322 |
echo $blocked_message; |
|
323 |
} |
|
324 |
||
325 |
$cancel_url = add_query_arg( 'action', 'upload-plugin-cancel-overwrite', $this->url ); |
|
326 |
||
327 |
$install_actions['plugins_page'] = sprintf( |
|
328 |
'<a class="button" href="%s">%s</a>', |
|
329 |
wp_nonce_url( $cancel_url, 'plugin-upload-cancel-overwrite' ), |
|
330 |
__( 'Cancel and go back' ) |
|
331 |
); |
|
332 |
||
333 |
/** |
|
18 | 334 |
* Filters the list of action links available following a single plugin installation failure |
335 |
* when overwriting is allowed. |
|
16 | 336 |
* |
337 |
* @since 5.5.0 |
|
338 |
* |
|
339 |
* @param string[] $install_actions Array of plugin action links. |
|
340 |
* @param object $api Object containing WordPress.org API plugin data. |
|
341 |
* @param array $new_plugin_data Array with uploaded plugin data. |
|
342 |
*/ |
|
343 |
$install_actions = apply_filters( 'install_plugin_overwrite_actions', $install_actions, $this->api, $new_plugin_data ); |
|
344 |
||
345 |
if ( ! empty( $install_actions ) ) { |
|
346 |
printf( |
|
347 |
'<p class="update-from-upload-expired hidden">%s</p>', |
|
348 |
__( 'The uploaded file has expired. Please go back and upload it again.' ) |
|
349 |
); |
|
350 |
echo '<p class="update-from-upload-actions">' . implode( ' ', (array) $install_actions ) . '</p>'; |
|
351 |
} |
|
352 |
||
353 |
return true; |
|
354 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
355 |
} |