author | ymh <ymh.work@gmail.com> |
Tue, 27 Sep 2022 16:37:53 +0200 | |
changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Update Core administration panel. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** WordPress Administration Bootstrap */ |
|
16 | 10 |
require_once __DIR__ . '/admin.php'; |
0 | 11 |
|
12 |
wp_enqueue_style( 'plugin-install' ); |
|
13 |
wp_enqueue_script( 'plugin-install' ); |
|
5 | 14 |
wp_enqueue_script( 'updates' ); |
0 | 15 |
add_thickbox(); |
16 |
||
17 |
if ( is_multisite() && ! is_network_admin() ) { |
|
18 |
wp_redirect( network_admin_url( 'update-core.php' ) ); |
|
16 | 19 |
exit; |
0 | 20 |
} |
21 |
||
9 | 22 |
if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_languages' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
9 | 24 |
} |
0 | 25 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
26 |
/** |
16 | 27 |
* Lists available core updates. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
* |
16 | 29 |
* @since 2.7.0 |
30 |
* |
|
31 |
* @global string $wp_local_package Locale code of the package. |
|
32 |
* @global wpdb $wpdb WordPress database abstraction object. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
* @param object $update |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
*/ |
0 | 36 |
function list_core_update( $update ) { |
9 | 37 |
global $wp_local_package, $wpdb; |
38 |
static $first_pass = true; |
|
0 | 39 |
|
16 | 40 |
$wp_version = get_bloginfo( 'version' ); |
18 | 41 |
$version_string = sprintf( '%s–%s', $update->current, get_locale() ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
|
16 | 43 |
if ( 'en_US' === $update->locale && 'en_US' === get_locale() ) { |
9 | 44 |
$version_string = $update->current; |
16 | 45 |
} elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version == $update->partial_version ) { |
46 |
$updates = get_core_updates(); |
|
47 |
if ( $updates && 1 === count( $updates ) ) { |
|
48 |
// If the only available update is a partial builds, it doesn't need a language-specific version string. |
|
49 |
$version_string = $update->current; |
|
50 |
} |
|
19 | 51 |
} elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() ) { |
52 |
$version_string = sprintf( '%s–%s', $update->current, $update->locale ); |
|
9 | 53 |
} |
0 | 54 |
|
55 |
$current = false; |
|
16 | 56 |
if ( ! isset( $update->response ) || 'latest' === $update->response ) { |
0 | 57 |
$current = true; |
9 | 58 |
} |
18 | 59 |
|
60 |
$message = ''; |
|
9 | 61 |
$form_action = 'update-core.php?action=do-core-upgrade'; |
62 |
$php_version = phpversion(); |
|
63 |
$mysql_version = $wpdb->db_version(); |
|
64 |
$show_buttons = true; |
|
18 | 65 |
|
66 |
// Nightly build versions have two hyphens and a commit number. |
|
67 |
if ( preg_match( '/-\w+-\d+/', $update->current ) ) { |
|
68 |
// Retrieve the major version number. |
|
69 |
preg_match( '/^\d+.\d+/', $update->current, $update_major ); |
|
70 |
/* translators: %s: WordPress version. */ |
|
71 |
$submit = sprintf( __( 'Update to latest %s nightly' ), $update_major[0] ); |
|
72 |
} else { |
|
73 |
/* translators: %s: WordPress version. */ |
|
74 |
$submit = sprintf( __( 'Update to version %s' ), $version_string ); |
|
75 |
} |
|
76 |
||
16 | 77 |
if ( 'development' === $update->response ) { |
18 | 78 |
$message = __( 'You can update to the latest nightly build manually:' ); |
0 | 79 |
} else { |
80 |
if ( $current ) { |
|
16 | 81 |
/* translators: %s: WordPress version. */ |
18 | 82 |
$submit = sprintf( __( 'Re-install version %s' ), $version_string ); |
0 | 83 |
$form_action = 'update-core.php?action=do-core-reinstall'; |
84 |
} else { |
|
9 | 85 |
$php_compat = version_compare( $php_version, $update->php_version, '>=' ); |
86 |
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) { |
|
0 | 87 |
$mysql_compat = true; |
9 | 88 |
} else { |
0 | 89 |
$mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' ); |
9 | 90 |
} |
91 |
||
92 |
$version_url = sprintf( |
|
16 | 93 |
/* translators: %s: WordPress version. */ |
9 | 94 |
esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ), |
95 |
sanitize_title( $update->current ) |
|
96 |
); |
|
97 |
||
16 | 98 |
$php_update_message = '</p><p>' . sprintf( |
99 |
/* translators: %s: URL to Update PHP page. */ |
|
100 |
__( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
101 |
esc_url( wp_get_update_php_url() ) |
|
102 |
); |
|
0 | 103 |
|
9 | 104 |
$annotation = wp_get_update_php_annotation(); |
16 | 105 |
|
9 | 106 |
if ( $annotation ) { |
107 |
$php_update_message .= '</p><p><em>' . $annotation . '</em>'; |
|
108 |
} |
|
109 |
||
110 |
if ( ! $mysql_compat && ! $php_compat ) { |
|
16 | 111 |
$message = sprintf( |
112 |
/* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number. */ |
|
113 |
__( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), |
|
114 |
$version_url, |
|
115 |
$update->current, |
|
116 |
$update->php_version, |
|
117 |
$update->mysql_version, |
|
118 |
$php_version, |
|
119 |
$mysql_version |
|
120 |
) . $php_update_message; |
|
9 | 121 |
} elseif ( ! $php_compat ) { |
16 | 122 |
$message = sprintf( |
123 |
/* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */ |
|
124 |
__( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), |
|
125 |
$version_url, |
|
126 |
$update->current, |
|
127 |
$update->php_version, |
|
128 |
$php_version |
|
129 |
) . $php_update_message; |
|
9 | 130 |
} elseif ( ! $mysql_compat ) { |
16 | 131 |
$message = sprintf( |
132 |
/* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */ |
|
133 |
__( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.' ), |
|
134 |
$version_url, |
|
135 |
$update->current, |
|
136 |
$update->mysql_version, |
|
137 |
$mysql_version |
|
138 |
); |
|
9 | 139 |
} else { |
16 | 140 |
$message = sprintf( |
18 | 141 |
/* translators: 1: Installed WordPress version number, 2: URL to WordPress release notes, 3: New WordPress version number, including locale if necessary. */ |
142 |
__( 'You can update from WordPress %1$s to <a href="%2$s">WordPress %3$s</a> manually:' ), |
|
143 |
$wp_version, |
|
16 | 144 |
$version_url, |
145 |
$version_string |
|
146 |
); |
|
9 | 147 |
} |
18 | 148 |
|
9 | 149 |
if ( ! $mysql_compat || ! $php_compat ) { |
0 | 150 |
$show_buttons = false; |
9 | 151 |
} |
0 | 152 |
} |
153 |
} |
|
154 |
||
155 |
echo '<p>'; |
|
156 |
echo $message; |
|
157 |
echo '</p>'; |
|
18 | 158 |
|
19 | 159 |
echo '<form method="post" action="' . esc_url( $form_action ) . '" name="upgrade" class="upgrade">'; |
9 | 160 |
wp_nonce_field( 'upgrade-core' ); |
18 | 161 |
|
0 | 162 |
echo '<p>'; |
18 | 163 |
echo '<input name="version" value="' . esc_attr( $update->current ) . '" type="hidden" />'; |
164 |
echo '<input name="locale" value="' . esc_attr( $update->locale ) . '" type="hidden" />'; |
|
0 | 165 |
if ( $show_buttons ) { |
166 |
if ( $first_pass ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
167 |
submit_button( $submit, $current ? '' : 'primary regular', 'upgrade', false ); |
0 | 168 |
$first_pass = false; |
169 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
170 |
submit_button( $submit, '', 'upgrade', false ); |
0 | 171 |
} |
172 |
} |
|
16 | 173 |
if ( 'en_US' !== $update->locale ) { |
9 | 174 |
if ( ! isset( $update->dismissed ) || ! $update->dismissed ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
submit_button( __( 'Hide this update' ), '', 'dismiss', false ); |
9 | 176 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
submit_button( __( 'Bring back this update' ), '', 'undismiss', false ); |
9 | 178 |
} |
179 |
} |
|
0 | 180 |
echo '</p>'; |
18 | 181 |
|
16 | 182 |
if ( 'en_US' !== $update->locale && ( ! isset( $wp_local_package ) || $wp_local_package != $update->locale ) ) { |
183 |
echo '<p class="hint">' . __( 'This localized version contains both the translation and various other localization fixes.' ) . '</p>'; |
|
184 |
} elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) { |
|
9 | 185 |
// Partial builds don't need language-specific warnings. |
16 | 186 |
echo '<p class="hint">' . sprintf( |
187 |
/* translators: %s: WordPress version. */ |
|
188 |
__( 'You are about to install WordPress %s <strong>in English (US).</strong> There is a chance this update will break your translation. You may prefer to wait for the localized version to be released.' ), |
|
189 |
'development' !== $update->response ? $update->current : '' |
|
190 |
) . '</p>'; |
|
0 | 191 |
} |
18 | 192 |
|
0 | 193 |
echo '</form>'; |
194 |
||
195 |
} |
|
196 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
/** |
16 | 198 |
* Display dismissed updates. |
199 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
200 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
201 |
*/ |
0 | 202 |
function dismissed_updates() { |
9 | 203 |
$dismissed = get_core_updates( |
204 |
array( |
|
205 |
'dismissed' => true, |
|
206 |
'available' => false, |
|
207 |
) |
|
208 |
); |
|
19 | 209 |
|
0 | 210 |
if ( $dismissed ) { |
9 | 211 |
$show_text = esc_js( __( 'Show hidden updates' ) ); |
212 |
$hide_text = esc_js( __( 'Hide hidden updates' ) ); |
|
213 |
?> |
|
19 | 214 |
<script type="text/javascript"> |
215 |
jQuery( function( $ ) { |
|
216 |
$( '#show-dismissed' ).on( 'click', function() { |
|
217 |
var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) ); |
|
218 |
||
219 |
if ( isExpanded ) { |
|
220 |
$( this ).text( '<?php echo $show_text; ?>' ).attr( 'aria-expanded', 'false' ); |
|
221 |
} else { |
|
222 |
$( this ).text( '<?php echo $hide_text; ?>' ).attr( 'aria-expanded', 'true' ); |
|
223 |
} |
|
224 |
||
225 |
$( '#dismissed-updates' ).toggle( 'fast' ); |
|
226 |
}); |
|
227 |
}); |
|
228 |
</script> |
|
9 | 229 |
<?php |
230 |
echo '<p class="hide-if-no-js"><button type="button" class="button" id="show-dismissed" aria-expanded="false">' . __( 'Show hidden updates' ) . '</button></p>'; |
|
0 | 231 |
echo '<ul id="dismissed-updates" class="core-updates dismissed">'; |
9 | 232 |
foreach ( (array) $dismissed as $update ) { |
0 | 233 |
echo '<li>'; |
234 |
list_core_update( $update ); |
|
235 |
echo '</li>'; |
|
236 |
} |
|
237 |
echo '</ul>'; |
|
238 |
} |
|
239 |
} |
|
240 |
||
241 |
/** |
|
242 |
* Display upgrade WordPress for downloading latest or upgrading automatically form. |
|
243 |
* |
|
5 | 244 |
* @since 2.7.0 |
0 | 245 |
* |
16 | 246 |
* @global string $required_php_version The required PHP version string. |
247 |
* @global string $required_mysql_version The required MySQL version string. |
|
0 | 248 |
*/ |
249 |
function core_upgrade_preamble() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
global $required_php_version, $required_mysql_version; |
0 | 251 |
|
18 | 252 |
$updates = get_core_updates(); |
0 | 253 |
|
18 | 254 |
// Include an unmodified $wp_version. |
255 |
require ABSPATH . WPINC . '/version.php'; |
|
256 |
||
257 |
$is_development_version = preg_match( '/alpha|beta|RC/', $wp_version ); |
|
16 | 258 |
|
259 |
if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { |
|
18 | 260 |
echo '<h2 class="response">'; |
261 |
_e( 'An updated version of WordPress is available.' ); |
|
262 |
echo '</h2>'; |
|
263 |
||
264 |
echo '<div class="notice notice-warning inline"><p>'; |
|
16 | 265 |
printf( |
266 |
/* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */ |
|
267 |
__( '<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.' ), |
|
268 |
__( 'https://wordpress.org/support/article/wordpress-backups/' ), |
|
269 |
__( 'https://wordpress.org/support/article/updating-wordpress/' ) |
|
270 |
); |
|
0 | 271 |
echo '</p></div>'; |
18 | 272 |
} elseif ( $is_development_version ) { |
273 |
echo '<h2 class="response">' . __( 'You are using a development version of WordPress.' ) . '</h2>'; |
|
274 |
} else { |
|
275 |
echo '<h2 class="response">' . __( 'You have the latest version of WordPress.' ) . '</h2>'; |
|
0 | 276 |
} |
277 |
||
278 |
echo '<ul class="core-updates">'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
279 |
foreach ( (array) $updates as $update ) { |
0 | 280 |
echo '<li>'; |
281 |
list_core_update( $update ); |
|
282 |
echo '</li>'; |
|
283 |
} |
|
284 |
echo '</ul>'; |
|
18 | 285 |
|
0 | 286 |
// Don't show the maintenance mode notice when we are only showing a single re-install option. |
16 | 287 |
if ( $updates && ( count( $updates ) > 1 || 'latest' !== $updates[0]->response ) ) { |
288 |
echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, this mode will be deactivated.' ) . '</p>'; |
|
0 | 289 |
} elseif ( ! $updates ) { |
290 |
list( $normalized_version ) = explode( '-', $wp_version ); |
|
16 | 291 |
echo '<p>' . sprintf( |
292 |
/* translators: 1: URL to About screen, 2: WordPress version. */ |
|
293 |
__( '<a href="%1$s">Learn more about WordPress %2$s</a>.' ), |
|
294 |
esc_url( self_admin_url( 'about.php' ) ), |
|
295 |
$normalized_version |
|
296 |
) . '</p>'; |
|
0 | 297 |
} |
18 | 298 |
|
0 | 299 |
dismissed_updates(); |
300 |
} |
|
301 |
||
16 | 302 |
/** |
18 | 303 |
* Display WordPress auto-updates settings. |
304 |
* |
|
305 |
* @since 5.6.0 |
|
306 |
*/ |
|
307 |
function core_auto_updates_settings() { |
|
308 |
if ( isset( $_GET['core-major-auto-updates-saved'] ) ) { |
|
309 |
if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) { |
|
310 |
$notice_text = __( 'Automatic updates for all WordPress versions have been enabled. Thank you!' ); |
|
311 |
echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>'; |
|
312 |
} elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) { |
|
313 |
$notice_text = __( 'WordPress will only receive automatic security and maintenance releases from now on.' ); |
|
314 |
echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>'; |
|
315 |
} |
|
316 |
} |
|
317 |
||
318 |
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
319 |
$updater = new WP_Automatic_Updater(); |
|
320 |
||
321 |
// Defaults: |
|
322 |
$upgrade_dev = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled'; |
|
323 |
$upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled'; |
|
324 |
$upgrade_major = get_site_option( 'auto_update_core_major', 'unset' ) === 'enabled'; |
|
325 |
||
326 |
$can_set_update_option = true; |
|
327 |
// WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'development', 'branch-development', 'minor', false. |
|
328 |
if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { |
|
329 |
if ( false === WP_AUTO_UPDATE_CORE ) { |
|
330 |
// Defaults to turned off, unless a filter allows it. |
|
331 |
$upgrade_dev = false; |
|
332 |
$upgrade_minor = false; |
|
333 |
$upgrade_major = false; |
|
334 |
} elseif ( true === WP_AUTO_UPDATE_CORE |
|
335 |
|| in_array( WP_AUTO_UPDATE_CORE, array( 'beta', 'rc', 'development', 'branch-development' ), true ) |
|
336 |
) { |
|
337 |
// ALL updates for core. |
|
338 |
$upgrade_dev = true; |
|
339 |
$upgrade_minor = true; |
|
340 |
$upgrade_major = true; |
|
341 |
} elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) { |
|
342 |
// Only minor updates for core. |
|
343 |
$upgrade_dev = false; |
|
344 |
$upgrade_minor = true; |
|
345 |
$upgrade_major = false; |
|
346 |
} |
|
347 |
||
348 |
// The UI is overridden by the `WP_AUTO_UPDATE_CORE` constant. |
|
349 |
$can_set_update_option = false; |
|
350 |
} |
|
351 |
||
352 |
if ( $updater->is_disabled() ) { |
|
353 |
$upgrade_dev = false; |
|
354 |
$upgrade_minor = false; |
|
355 |
$upgrade_major = false; |
|
356 |
||
357 |
/* |
|
358 |
* The UI is overridden by the `AUTOMATIC_UPDATER_DISABLED` constant |
|
359 |
* or the `automatic_updater_disabled` filter, |
|
360 |
* or by `wp_is_file_mod_allowed( 'automatic_updater' )`. |
|
361 |
* See `WP_Automatic_Updater::is_disabled()`. |
|
362 |
*/ |
|
363 |
$can_set_update_option = false; |
|
364 |
} |
|
365 |
||
366 |
// Is the UI overridden by a plugin using the `allow_major_auto_core_updates` filter? |
|
367 |
if ( has_filter( 'allow_major_auto_core_updates' ) ) { |
|
368 |
$can_set_update_option = false; |
|
369 |
} |
|
370 |
||
371 |
/** This filter is documented in wp-admin/includes/class-core-upgrader.php */ |
|
372 |
$upgrade_dev = apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ); |
|
373 |
/** This filter is documented in wp-admin/includes/class-core-upgrader.php */ |
|
374 |
$upgrade_minor = apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor ); |
|
375 |
/** This filter is documented in wp-admin/includes/class-core-upgrader.php */ |
|
376 |
$upgrade_major = apply_filters( 'allow_major_auto_core_updates', $upgrade_major ); |
|
377 |
||
378 |
$auto_update_settings = array( |
|
379 |
'dev' => $upgrade_dev, |
|
380 |
'minor' => $upgrade_minor, |
|
381 |
'major' => $upgrade_major, |
|
382 |
); |
|
383 |
||
384 |
if ( $upgrade_major ) { |
|
385 |
$wp_version = get_bloginfo( 'version' ); |
|
386 |
$updates = get_core_updates(); |
|
387 |
||
388 |
if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { |
|
389 |
echo '<p>' . wp_get_auto_update_message() . '</p>'; |
|
390 |
} |
|
391 |
} |
|
392 |
||
393 |
$action_url = self_admin_url( 'update-core.php?action=core-major-auto-updates-settings' ); |
|
394 |
?> |
|
395 |
||
396 |
<p class="auto-update-status"> |
|
397 |
<?php |
|
398 |
||
399 |
if ( $updater->is_vcs_checkout( ABSPATH ) ) { |
|
400 |
_e( 'This site appears to be under version control. Automatic updates are disabled.' ); |
|
401 |
} elseif ( $upgrade_major ) { |
|
402 |
_e( 'This site is automatically kept up to date with each new version of WordPress.' ); |
|
403 |
||
404 |
if ( $can_set_update_option ) { |
|
405 |
echo '<br>'; |
|
406 |
printf( |
|
407 |
'<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-disable">%s</a>', |
|
408 |
wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' ), |
|
409 |
__( 'Switch to automatic updates for maintenance and security releases only.' ) |
|
410 |
); |
|
411 |
} |
|
412 |
} elseif ( $upgrade_minor ) { |
|
413 |
_e( 'This site is automatically kept up to date with maintenance and security releases of WordPress only.' ); |
|
414 |
||
415 |
if ( $can_set_update_option ) { |
|
416 |
echo '<br>'; |
|
417 |
printf( |
|
418 |
'<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-enable">%s</a>', |
|
419 |
wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' ), |
|
420 |
__( 'Enable automatic updates for all new versions of WordPress.' ) |
|
421 |
); |
|
422 |
} |
|
423 |
} else { |
|
424 |
_e( 'This site will not receive automatic updates for new versions of WordPress.' ); |
|
425 |
} |
|
426 |
?> |
|
427 |
</p> |
|
428 |
||
429 |
<?php |
|
430 |
/** |
|
431 |
* Fires after the major core auto-update settings. |
|
432 |
* |
|
433 |
* @since 5.6.0 |
|
434 |
* |
|
435 |
* @param array $auto_update_settings { |
|
436 |
* Array of core auto-update settings. |
|
437 |
* |
|
438 |
* @type bool $dev Whether to enable automatic updates for development versions. |
|
439 |
* @type bool $minor Whether to enable minor automatic core updates. |
|
440 |
* @type bool $major Whether to enable major automatic core updates. |
|
441 |
* } |
|
442 |
*/ |
|
443 |
do_action( 'after_core_auto_updates_settings', $auto_update_settings ); |
|
444 |
} |
|
445 |
||
446 |
/** |
|
16 | 447 |
* Display the upgrade plugins form. |
448 |
* |
|
449 |
* @since 2.9.0 |
|
450 |
*/ |
|
0 | 451 |
function list_plugin_updates() { |
9 | 452 |
$wp_version = get_bloginfo( 'version' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
$cur_wp_version = preg_replace( '/-.*$/', '', $wp_version ); |
0 | 454 |
|
16 | 455 |
require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
0 | 456 |
$plugins = get_plugin_updates(); |
457 |
if ( empty( $plugins ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
echo '<h2>' . __( 'Plugins' ) . '</h2>'; |
0 | 459 |
echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>'; |
460 |
return; |
|
461 |
} |
|
462 |
$form_action = 'update-core.php?action=do-plugin-upgrade'; |
|
463 |
||
464 |
$core_updates = get_core_updates(); |
|
16 | 465 |
if ( ! isset( $core_updates[0]->response ) || 'latest' === $core_updates[0]->response || 'development' === $core_updates[0]->response || version_compare( $core_updates[0]->current, $cur_wp_version, '=' ) ) { |
0 | 466 |
$core_update_version = false; |
9 | 467 |
} else { |
0 | 468 |
$core_update_version = $core_updates[0]->current; |
9 | 469 |
} |
18 | 470 |
|
471 |
$plugins_count = count( $plugins ); |
|
0 | 472 |
?> |
18 | 473 |
<h2> |
474 |
<?php |
|
475 |
printf( |
|
476 |
'%s <span class="count">(%d)</span>', |
|
477 |
__( 'Plugins' ), |
|
478 |
number_format_i18n( $plugins_count ) |
|
479 |
); |
|
480 |
?> |
|
481 |
</h2> |
|
0 | 482 |
<p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click “Update Plugins”.' ); ?></p> |
483 |
<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade"> |
|
9 | 484 |
<?php wp_nonce_field( 'upgrade-core' ); ?> |
485 |
<p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
486 |
<table class="widefat updates-table" id="update-plugins-table"> |
0 | 487 |
<thead> |
488 |
<tr> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
489 |
<td class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
490 |
<td class="manage-column"><label for="plugins-select-all"><?php _e( 'Select All' ); ?></label></td> |
0 | 491 |
</tr> |
492 |
</thead> |
|
493 |
||
494 |
<tbody class="plugins"> |
|
9 | 495 |
<?php |
16 | 496 |
|
497 |
$auto_updates = array(); |
|
498 |
if ( wp_is_auto_update_enabled_for_type( 'plugin' ) ) { |
|
499 |
$auto_updates = (array) get_site_option( 'auto_update_plugins', array() ); |
|
500 |
$auto_update_notice = ' | ' . wp_get_auto_update_message(); |
|
501 |
} |
|
502 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
503 |
foreach ( (array) $plugins as $plugin_file => $plugin_data ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
504 |
$plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
505 |
|
9 | 506 |
$icon = '<span class="dashicons dashicons-admin-plugins"></span>'; |
507 |
$preferred_icons = array( 'svg', '2x', '1x', 'default' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
508 |
foreach ( $preferred_icons as $preferred_icon ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
509 |
if ( ! empty( $plugin_data->update->icons[ $preferred_icon ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
510 |
$icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" />'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
511 |
break; |
9 | 512 |
} |
5 | 513 |
} |
514 |
||
0 | 515 |
// Get plugin compat for running version of WordPress. |
9 | 516 |
if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $cur_wp_version, '>=' ) ) { |
16 | 517 |
/* translators: %s: WordPress version. */ |
518 |
$compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $cur_wp_version ); |
|
0 | 519 |
} else { |
16 | 520 |
/* translators: %s: WordPress version. */ |
521 |
$compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $cur_wp_version ); |
|
0 | 522 |
} |
523 |
// Get plugin compat for updated version of WordPress. |
|
524 |
if ( $core_update_version ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
525 |
if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) { |
16 | 526 |
/* translators: %s: WordPress version. */ |
527 |
$compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $core_update_version ); |
|
0 | 528 |
} else { |
16 | 529 |
/* translators: %s: WordPress version. */ |
530 |
$compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $core_update_version ); |
|
0 | 531 |
} |
532 |
} |
|
9 | 533 |
|
534 |
$requires_php = isset( $plugin_data->update->requires_php ) ? $plugin_data->update->requires_php : null; |
|
535 |
$compatible_php = is_php_version_compatible( $requires_php ); |
|
536 |
||
537 |
if ( ! $compatible_php && current_user_can( 'update_php' ) ) { |
|
19 | 538 |
$compat .= '<br>' . __( 'This update does not work with your version of PHP.' ) . ' '; |
9 | 539 |
$compat .= sprintf( |
16 | 540 |
/* translators: %s: URL to Update PHP page. */ |
9 | 541 |
__( '<a href="%s">Learn more about updating PHP</a>.' ), |
542 |
esc_url( wp_get_update_php_url() ) |
|
543 |
); |
|
544 |
||
545 |
$annotation = wp_get_update_php_annotation(); |
|
546 |
||
547 |
if ( $annotation ) { |
|
548 |
$compat .= '</p><p><em>' . $annotation . '</em>'; |
|
549 |
} |
|
550 |
} |
|
551 |
||
0 | 552 |
// Get the upgrade notice for the new plugin version. |
9 | 553 |
if ( isset( $plugin_data->update->upgrade_notice ) ) { |
554 |
$upgrade_notice = '<br />' . strip_tags( $plugin_data->update->upgrade_notice ); |
|
0 | 555 |
} else { |
556 |
$upgrade_notice = ''; |
|
557 |
} |
|
558 |
||
9 | 559 |
$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '§ion=changelog&TB_iframe=true&width=640&height=662' ); |
560 |
$details = sprintf( |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
561 |
'<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
562 |
esc_url( $details_url ), |
16 | 563 |
/* translators: 1: Plugin name, 2: Version number. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
564 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ), |
16 | 565 |
/* translators: %s: Plugin version. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
566 |
sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
567 |
); |
0 | 568 |
|
18 | 569 |
$checkbox_id = 'checkbox_' . md5( $plugin_file ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
570 |
?> |
9 | 571 |
<tr> |
572 |
<td class="check-column"> |
|
16 | 573 |
<?php if ( $compatible_php ) : ?> |
574 |
<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" /> |
|
575 |
<label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"> |
|
576 |
<?php |
|
577 |
/* translators: %s: Plugin name. */ |
|
578 |
printf( __( 'Select %s' ), $plugin_data->Name ); |
|
579 |
?> |
|
580 |
</label> |
|
581 |
<?php endif; ?> |
|
9 | 582 |
</td> |
583 |
<td class="plugin-title"><p> |
|
584 |
<?php echo $icon; ?> |
|
585 |
<strong><?php echo $plugin_data->Name; ?></strong> |
|
586 |
<?php |
|
587 |
printf( |
|
16 | 588 |
/* translators: 1: Plugin version, 2: New version. */ |
9 | 589 |
__( 'You have version %1$s installed. Update to %2$s.' ), |
590 |
$plugin_data->Version, |
|
591 |
$plugin_data->update->new_version |
|
592 |
); |
|
16 | 593 |
|
9 | 594 |
echo ' ' . $details . $compat . $upgrade_notice; |
16 | 595 |
|
596 |
if ( in_array( $plugin_file, $auto_updates, true ) ) { |
|
597 |
echo $auto_update_notice; |
|
598 |
} |
|
9 | 599 |
?> |
600 |
</p></td> |
|
601 |
</tr> |
|
16 | 602 |
<?php |
0 | 603 |
} |
9 | 604 |
?> |
0 | 605 |
</tbody> |
5 | 606 |
|
607 |
<tfoot> |
|
608 |
<tr> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
609 |
<td class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
610 |
<td class="manage-column"><label for="plugins-select-all-2"><?php _e( 'Select All' ); ?></label></td> |
5 | 611 |
</tr> |
612 |
</tfoot> |
|
0 | 613 |
</table> |
9 | 614 |
<p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p> |
0 | 615 |
</form> |
9 | 616 |
<?php |
0 | 617 |
} |
618 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
/** |
16 | 620 |
* Display the upgrade themes form. |
621 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
622 |
* @since 2.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
*/ |
0 | 624 |
function list_theme_updates() { |
625 |
$themes = get_theme_updates(); |
|
626 |
if ( empty( $themes ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
627 |
echo '<h2>' . __( 'Themes' ) . '</h2>'; |
0 | 628 |
echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>'; |
629 |
return; |
|
630 |
} |
|
631 |
||
632 |
$form_action = 'update-core.php?action=do-theme-upgrade'; |
|
18 | 633 |
|
634 |
$themes_count = count( $themes ); |
|
9 | 635 |
?> |
18 | 636 |
<h2> |
637 |
<?php |
|
638 |
printf( |
|
639 |
'%s <span class="count">(%d)</span>', |
|
640 |
__( 'Themes' ), |
|
641 |
number_format_i18n( $themes_count ) |
|
642 |
); |
|
643 |
?> |
|
644 |
</h2> |
|
0 | 645 |
<p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click “Update Themes”.' ); ?></p> |
9 | 646 |
<p> |
647 |
<?php |
|
648 |
printf( |
|
16 | 649 |
/* translators: %s: Link to documentation on child themes. */ |
9 | 650 |
__( '<strong>Please Note:</strong> Any customizations you have made to theme files will be lost. Please consider using <a href="%s">child themes</a> for modifications.' ), |
651 |
__( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ) |
|
652 |
); |
|
653 |
?> |
|
654 |
</p> |
|
0 | 655 |
<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade"> |
9 | 656 |
<?php wp_nonce_field( 'upgrade-core' ); ?> |
657 |
<p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
658 |
<table class="widefat updates-table" id="update-themes-table"> |
0 | 659 |
<thead> |
660 |
<tr> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
<td class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
662 |
<td class="manage-column"><label for="themes-select-all"><?php _e( 'Select All' ); ?></label></td> |
0 | 663 |
</tr> |
664 |
</thead> |
|
665 |
||
666 |
<tbody class="plugins"> |
|
9 | 667 |
<?php |
16 | 668 |
$auto_updates = array(); |
669 |
if ( wp_is_auto_update_enabled_for_type( 'theme' ) ) { |
|
670 |
$auto_updates = (array) get_site_option( 'auto_update_themes', array() ); |
|
671 |
$auto_update_notice = ' | ' . wp_get_auto_update_message(); |
|
672 |
} |
|
673 |
||
0 | 674 |
foreach ( $themes as $stylesheet => $theme ) { |
16 | 675 |
$requires_wp = isset( $theme->update['requires'] ) ? $theme->update['requires'] : null; |
676 |
$requires_php = isset( $theme->update['requires_php'] ) ? $theme->update['requires_php'] : null; |
|
677 |
||
678 |
$compatible_wp = is_wp_version_compatible( $requires_wp ); |
|
679 |
$compatible_php = is_php_version_compatible( $requires_php ); |
|
680 |
||
681 |
$compat = ''; |
|
682 |
||
683 |
if ( ! $compatible_wp && ! $compatible_php ) { |
|
19 | 684 |
$compat .= '<br>' . __( 'This update does not work with your versions of WordPress and PHP.' ) . ' '; |
16 | 685 |
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { |
686 |
$compat .= sprintf( |
|
687 |
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ |
|
688 |
__( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ), |
|
689 |
self_admin_url( 'update-core.php' ), |
|
690 |
esc_url( wp_get_update_php_url() ) |
|
691 |
); |
|
692 |
||
693 |
$annotation = wp_get_update_php_annotation(); |
|
694 |
||
695 |
if ( $annotation ) { |
|
696 |
$compat .= '</p><p><em>' . $annotation . '</em>'; |
|
697 |
} |
|
698 |
} elseif ( current_user_can( 'update_core' ) ) { |
|
699 |
$compat .= sprintf( |
|
700 |
/* translators: %s: URL to WordPress Updates screen. */ |
|
701 |
__( '<a href="%s">Please update WordPress</a>.' ), |
|
702 |
self_admin_url( 'update-core.php' ) |
|
703 |
); |
|
704 |
} elseif ( current_user_can( 'update_php' ) ) { |
|
705 |
$compat .= sprintf( |
|
706 |
/* translators: %s: URL to Update PHP page. */ |
|
707 |
__( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
708 |
esc_url( wp_get_update_php_url() ) |
|
709 |
); |
|
710 |
||
711 |
$annotation = wp_get_update_php_annotation(); |
|
712 |
||
713 |
if ( $annotation ) { |
|
714 |
$compat .= '</p><p><em>' . $annotation . '</em>'; |
|
715 |
} |
|
716 |
} |
|
717 |
} elseif ( ! $compatible_wp ) { |
|
19 | 718 |
$compat .= '<br>' . __( 'This update does not work with your version of WordPress.' ) . ' '; |
16 | 719 |
if ( current_user_can( 'update_core' ) ) { |
720 |
$compat .= sprintf( |
|
721 |
/* translators: %s: URL to WordPress Updates screen. */ |
|
722 |
__( '<a href="%s">Please update WordPress</a>.' ), |
|
723 |
self_admin_url( 'update-core.php' ) |
|
724 |
); |
|
725 |
} |
|
726 |
} elseif ( ! $compatible_php ) { |
|
19 | 727 |
$compat .= '<br>' . __( 'This update does not work with your version of PHP.' ) . ' '; |
16 | 728 |
if ( current_user_can( 'update_php' ) ) { |
729 |
$compat .= sprintf( |
|
730 |
/* translators: %s: URL to Update PHP page. */ |
|
731 |
__( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
732 |
esc_url( wp_get_update_php_url() ) |
|
733 |
); |
|
734 |
||
735 |
$annotation = wp_get_update_php_annotation(); |
|
736 |
||
737 |
if ( $annotation ) { |
|
738 |
$compat .= '</p><p><em>' . $annotation . '</em>'; |
|
739 |
} |
|
740 |
} |
|
741 |
} |
|
742 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
743 |
$checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
744 |
?> |
9 | 745 |
<tr> |
746 |
<td class="check-column"> |
|
16 | 747 |
<?php if ( $compatible_wp && $compatible_php ) : ?> |
748 |
<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" /> |
|
749 |
<label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"> |
|
750 |
<?php |
|
751 |
/* translators: %s: Theme name. */ |
|
752 |
printf( __( 'Select %s' ), $theme->display( 'Name' ) ); |
|
753 |
?> |
|
754 |
</label> |
|
755 |
<?php endif; ?> |
|
9 | 756 |
</td> |
757 |
<td class="plugin-title"><p> |
|
19 | 758 |
<img src="<?php echo esc_url( $theme->get_screenshot() . '?ver=' . $theme->version ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" /> |
9 | 759 |
<strong><?php echo $theme->display( 'Name' ); ?></strong> |
760 |
<?php |
|
761 |
printf( |
|
16 | 762 |
/* translators: 1: Theme version, 2: New version. */ |
9 | 763 |
__( 'You have version %1$s installed. Update to %2$s.' ), |
764 |
$theme->display( 'Version' ), |
|
765 |
$theme->update['new_version'] |
|
766 |
); |
|
16 | 767 |
|
768 |
echo ' ' . $compat; |
|
769 |
||
770 |
if ( in_array( $stylesheet, $auto_updates, true ) ) { |
|
771 |
echo $auto_update_notice; |
|
772 |
} |
|
9 | 773 |
?> |
774 |
</p></td> |
|
775 |
</tr> |
|
776 |
<?php |
|
0 | 777 |
} |
9 | 778 |
?> |
0 | 779 |
</tbody> |
5 | 780 |
|
781 |
<tfoot> |
|
782 |
<tr> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
783 |
<td class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
784 |
<td class="manage-column"><label for="themes-select-all-2"><?php _e( 'Select All' ); ?></label></td> |
5 | 785 |
</tr> |
786 |
</tfoot> |
|
0 | 787 |
</table> |
9 | 788 |
<p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p> |
0 | 789 |
</form> |
9 | 790 |
<?php |
0 | 791 |
} |
792 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
793 |
/** |
16 | 794 |
* Display the update translations form. |
795 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
796 |
* @since 3.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
797 |
*/ |
0 | 798 |
function list_translation_updates() { |
799 |
$updates = wp_get_translation_updates(); |
|
800 |
if ( ! $updates ) { |
|
16 | 801 |
if ( 'en_US' !== get_locale() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
802 |
echo '<h2>' . __( 'Translations' ) . '</h2>'; |
0 | 803 |
echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>'; |
804 |
} |
|
805 |
return; |
|
806 |
} |
|
807 |
||
808 |
$form_action = 'update-core.php?action=do-translation-upgrade'; |
|
809 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
810 |
<h2><?php _e( 'Translations' ); ?></h2> |
5 | 811 |
<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-translations" class="upgrade"> |
812 |
<p><?php _e( 'New translations are available.' ); ?></p> |
|
813 |
<?php wp_nonce_field( 'upgrade-translations' ); ?> |
|
0 | 814 |
<p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p> |
815 |
</form> |
|
816 |
<?php |
|
817 |
} |
|
818 |
||
819 |
/** |
|
820 |
* Upgrade WordPress core display. |
|
821 |
* |
|
5 | 822 |
* @since 2.7.0 |
0 | 823 |
* |
9 | 824 |
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
825 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
826 |
* @param bool $reinstall |
0 | 827 |
*/ |
828 |
function do_core_upgrade( $reinstall = false ) { |
|
829 |
global $wp_filesystem; |
|
830 |
||
16 | 831 |
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
0 | 832 |
|
9 | 833 |
if ( $reinstall ) { |
0 | 834 |
$url = 'update-core.php?action=do-core-reinstall'; |
9 | 835 |
} else { |
0 | 836 |
$url = 'update-core.php?action=do-core-upgrade'; |
9 | 837 |
} |
838 |
$url = wp_nonce_url( $url, 'upgrade-core' ); |
|
0 | 839 |
|
9 | 840 |
$version = isset( $_POST['version'] ) ? $_POST['version'] : false; |
841 |
$locale = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US'; |
|
842 |
$update = find_core_update( $version, $locale ); |
|
843 |
if ( ! $update ) { |
|
0 | 844 |
return; |
9 | 845 |
} |
0 | 846 |
|
5 | 847 |
// Allow relaxed file ownership writes for User-initiated upgrades when the API specifies |
848 |
// that it's safe to do so. This only happens when there are no new files to create. |
|
849 |
$allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files; |
|
850 |
||
9 | 851 |
?> |
0 | 852 |
<div class="wrap"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
853 |
<h1><?php _e( 'Update WordPress' ); ?></h1> |
9 | 854 |
<?php |
0 | 855 |
|
16 | 856 |
$credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ); |
857 |
if ( false === $credentials ) { |
|
0 | 858 |
echo '</div>'; |
859 |
return; |
|
860 |
} |
|
861 |
||
5 | 862 |
if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) { |
16 | 863 |
// Failed to connect. Error and request again. |
5 | 864 |
request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ); |
0 | 865 |
echo '</div>'; |
866 |
return; |
|
867 |
} |
|
868 |
||
9 | 869 |
if ( $wp_filesystem->errors->has_errors() ) { |
870 |
foreach ( $wp_filesystem->errors->get_error_messages() as $message ) { |
|
871 |
show_message( $message ); |
|
872 |
} |
|
0 | 873 |
echo '</div>'; |
874 |
return; |
|
875 |
} |
|
876 |
||
9 | 877 |
if ( $reinstall ) { |
0 | 878 |
$update->response = 'reinstall'; |
9 | 879 |
} |
0 | 880 |
|
881 |
add_filter( 'update_feedback', 'show_message' ); |
|
882 |
||
883 |
$upgrader = new Core_Upgrader(); |
|
9 | 884 |
$result = $upgrader->upgrade( |
885 |
$update, |
|
886 |
array( |
|
887 |
'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership, |
|
888 |
) |
|
889 |
); |
|
0 | 890 |
|
9 | 891 |
if ( is_wp_error( $result ) ) { |
892 |
show_message( $result ); |
|
893 |
if ( 'up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code() ) { |
|
16 | 894 |
show_message( __( 'Installation failed.' ) ); |
9 | 895 |
} |
0 | 896 |
echo '</div>'; |
897 |
return; |
|
898 |
} |
|
899 |
||
16 | 900 |
show_message( __( 'WordPress updated successfully.' ) ); |
901 |
show_message( |
|
902 |
'<span class="hide-if-no-js">' . sprintf( |
|
903 |
/* translators: 1: WordPress version, 2: URL to About screen. */ |
|
904 |
__( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ), |
|
905 |
$result, |
|
906 |
esc_url( self_admin_url( 'about.php?updated' ) ) |
|
907 |
) . '</span>' |
|
908 |
); |
|
909 |
show_message( |
|
910 |
'<span class="hide-if-js">' . sprintf( |
|
911 |
/* translators: 1: WordPress version, 2: URL to About screen. */ |
|
912 |
__( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), |
|
913 |
$result, |
|
914 |
esc_url( self_admin_url( 'about.php?updated' ) ) |
|
915 |
) . '</span>' |
|
916 |
); |
|
0 | 917 |
?> |
918 |
</div> |
|
919 |
<script type="text/javascript"> |
|
920 |
window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>'; |
|
921 |
</script> |
|
922 |
<?php |
|
923 |
} |
|
924 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
925 |
/** |
16 | 926 |
* Dismiss a core update. |
927 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
928 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
929 |
*/ |
0 | 930 |
function do_dismiss_core_update() { |
9 | 931 |
$version = isset( $_POST['version'] ) ? $_POST['version'] : false; |
932 |
$locale = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US'; |
|
933 |
$update = find_core_update( $version, $locale ); |
|
934 |
if ( ! $update ) { |
|
0 | 935 |
return; |
9 | 936 |
} |
0 | 937 |
dismiss_core_update( $update ); |
9 | 938 |
wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core' ) ); |
0 | 939 |
exit; |
940 |
} |
|
941 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
942 |
/** |
16 | 943 |
* Undismiss a core update. |
944 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
945 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
946 |
*/ |
0 | 947 |
function do_undismiss_core_update() { |
9 | 948 |
$version = isset( $_POST['version'] ) ? $_POST['version'] : false; |
949 |
$locale = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US'; |
|
950 |
$update = find_core_update( $version, $locale ); |
|
951 |
if ( ! $update ) { |
|
0 | 952 |
return; |
9 | 953 |
} |
0 | 954 |
undismiss_core_update( $version, $locale ); |
9 | 955 |
wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core' ) ); |
0 | 956 |
exit; |
957 |
} |
|
958 |
||
9 | 959 |
$action = isset( $_GET['action'] ) ? $_GET['action'] : 'upgrade-core'; |
0 | 960 |
|
961 |
$upgrade_error = false; |
|
16 | 962 |
if ( ( 'do-theme-upgrade' === $action || ( 'do-plugin-upgrade' === $action && ! isset( $_GET['plugins'] ) ) ) |
0 | 963 |
&& ! isset( $_POST['checked'] ) ) { |
16 | 964 |
$upgrade_error = ( 'do-theme-upgrade' === $action ) ? 'themes' : 'plugins'; |
9 | 965 |
$action = 'upgrade-core'; |
0 | 966 |
} |
967 |
||
9 | 968 |
$title = __( 'WordPress Updates' ); |
5 | 969 |
$parent_file = 'index.php'; |
970 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
971 |
$updates_overview = '<p>' . __( 'On this screen, you can update to the latest version of WordPress, as well as update your themes, plugins, and translations from the WordPress.org repositories.' ) . '</p>'; |
5 | 972 |
$updates_overview .= '<p>' . __( 'If an update is available, you᾿ll see a notification appear in the Toolbar and navigation menu.' ) . ' ' . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' ) . '</p>'; |
0 | 973 |
|
9 | 974 |
get_current_screen()->add_help_tab( |
975 |
array( |
|
976 |
'id' => 'overview', |
|
977 |
'title' => __( 'Overview' ), |
|
978 |
'content' => $updates_overview, |
|
979 |
) |
|
980 |
); |
|
0 | 981 |
|
18 | 982 |
$updates_howto = '<p>' . __( '<strong>WordPress</strong> — Updating your WordPress installation is a simple one-click procedure: just <strong>click on the “Update now” button</strong> when you are notified that a new version is available.' ) . ' ' . __( 'In most cases, WordPress will automatically apply maintenance and security updates in the background for you.' ) . '</p>'; |
5 | 983 |
$updates_howto .= '<p>' . __( '<strong>Themes and Plugins</strong> — To update individual themes or plugins from this screen, use the checkboxes to make your selection, then <strong>click on the appropriate “Update” button</strong>. To update all of your themes or plugins at once, you can check the box at the top of the section to select all before clicking the update button.' ) . '</p>'; |
984 |
||
16 | 985 |
if ( 'en_US' !== get_locale() ) { |
5 | 986 |
$updates_howto .= '<p>' . __( '<strong>Translations</strong> — The files translating WordPress into your language are updated for you whenever any other updates occur. But if these files are out of date, you can <strong>click the “Update Translations”</strong> button.' ) . '</p>'; |
987 |
} |
|
988 |
||
9 | 989 |
get_current_screen()->add_help_tab( |
990 |
array( |
|
991 |
'id' => 'how-to-update', |
|
992 |
'title' => __( 'How to Update' ), |
|
993 |
'content' => $updates_howto, |
|
994 |
) |
|
995 |
); |
|
0 | 996 |
|
16 | 997 |
$help_sidebar_autoupdates = ''; |
998 |
||
999 |
if ( ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) || ( current_user_can( 'update_plugins' ) && wp_is_auto_update_enabled_for_type( 'plugin' ) ) ) { |
|
18 | 1000 |
$help_tab_autoupdates = '<p>' . __( 'Auto-updates can be enabled or disabled for WordPress major versions and for each individual theme or plugin. Themes or plugins with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '</p>'; |
16 | 1001 |
$help_tab_autoupdates .= '<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>'; |
1002 |
||
1003 |
get_current_screen()->add_help_tab( |
|
1004 |
array( |
|
1005 |
'id' => 'plugins-themes-auto-updates', |
|
1006 |
'title' => __( 'Auto-updates' ), |
|
1007 |
'content' => $help_tab_autoupdates, |
|
1008 |
) |
|
1009 |
); |
|
1010 |
||
1011 |
$help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-themes-auto-updates/">Learn more: Auto-updates documentation</a>' ) . '</p>'; |
|
1012 |
} |
|
1013 |
||
0 | 1014 |
get_current_screen()->set_help_sidebar( |
9 | 1015 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
16 | 1016 |
'<p>' . __( '<a href="https://wordpress.org/support/article/dashboard-updates-screen/">Documentation on Updating WordPress</a>' ) . '</p>' . |
1017 |
$help_sidebar_autoupdates . |
|
9 | 1018 |
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
0 | 1019 |
); |
1020 |
||
16 | 1021 |
if ( 'upgrade-core' === $action ) { |
1022 |
// Force a update check when requested. |
|
5 | 1023 |
$force_check = ! empty( $_GET['force-check'] ); |
1024 |
wp_version_check( array(), $force_check ); |
|
0 | 1025 |
|
16 | 1026 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
0 | 1027 |
?> |
1028 |
<div class="wrap"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1029 |
<h1><?php _e( 'WordPress Updates' ); ?></h1> |
18 | 1030 |
<p><?php _e( 'Here you can find information about updates, set auto-updates and see what plugins or themes need updating.' ); ?></p> |
1031 |
||
0 | 1032 |
<?php |
1033 |
if ( $upgrade_error ) { |
|
1034 |
echo '<div class="error"><p>'; |
|
16 | 1035 |
if ( 'themes' === $upgrade_error ) { |
9 | 1036 |
_e( 'Please select one or more themes to update.' ); |
1037 |
} else { |
|
1038 |
_e( 'Please select one or more plugins to update.' ); |
|
1039 |
} |
|
0 | 1040 |
echo '</p></div>'; |
1041 |
} |
|
1042 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1043 |
$last_update_check = false; |
9 | 1044 |
$current = get_site_transient( 'update_core' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1045 |
|
9 | 1046 |
if ( $current && isset( $current->last_checked ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1047 |
$last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1048 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1049 |
|
18 | 1050 |
echo '<h2 class="wp-current-version">'; |
1051 |
/* translators: Current version of WordPress. */ |
|
1052 |
printf( __( 'Current version: %s' ), get_bloginfo( 'version' ) ); |
|
1053 |
echo '</h2>'; |
|
1054 |
||
1055 |
echo '<p class="update-last-checked">'; |
|
16 | 1056 |
/* translators: 1: Date, 2: Time. */ |
19 | 1057 |
printf( __( 'Last checked on %1$s at %2$s.' ), date_i18n( __( 'F j, Y' ), $last_update_check ), date_i18n( __( 'g:i a T' ), $last_update_check ) ); |
18 | 1058 |
echo ' <a href="' . esc_url( self_admin_url( 'update-core.php?force-check=1' ) ) . '">' . __( 'Check again.' ) . '</a>'; |
0 | 1059 |
echo '</p>'; |
1060 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1061 |
if ( current_user_can( 'update_core' ) ) { |
18 | 1062 |
core_auto_updates_settings(); |
0 | 1063 |
core_upgrade_preamble(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1064 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1065 |
if ( current_user_can( 'update_plugins' ) ) { |
0 | 1066 |
list_plugin_updates(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1067 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1068 |
if ( current_user_can( 'update_themes' ) ) { |
0 | 1069 |
list_theme_updates(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1070 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1071 |
if ( current_user_can( 'update_languages' ) ) { |
0 | 1072 |
list_translation_updates(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1073 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1074 |
|
5 | 1075 |
/** |
1076 |
* Fires after the core, plugin, and theme update tables. |
|
1077 |
* |
|
1078 |
* @since 2.9.0 |
|
1079 |
*/ |
|
1080 |
do_action( 'core_upgrade_preamble' ); |
|
0 | 1081 |
echo '</div>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1082 |
|
9 | 1083 |
wp_localize_script( |
1084 |
'updates', |
|
1085 |
'_wpUpdatesItemCounts', |
|
1086 |
array( |
|
1087 |
'totals' => wp_get_update_data(), |
|
1088 |
) |
|
1089 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1090 |
|
16 | 1091 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |
0 | 1092 |
|
16 | 1093 |
} elseif ( 'do-core-upgrade' === $action || 'do-core-reinstall' === $action ) { |
0 | 1094 |
|
9 | 1095 |
if ( ! current_user_can( 'update_core' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1096 |
wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
9 | 1097 |
} |
0 | 1098 |
|
9 | 1099 |
check_admin_referer( 'upgrade-core' ); |
0 | 1100 |
|
5 | 1101 |
// Do the (un)dismiss actions before headers, so that they can redirect. |
9 | 1102 |
if ( isset( $_POST['dismiss'] ) ) { |
0 | 1103 |
do_dismiss_core_update(); |
9 | 1104 |
} elseif ( isset( $_POST['undismiss'] ) ) { |
0 | 1105 |
do_undismiss_core_update(); |
9 | 1106 |
} |
0 | 1107 |
|
16 | 1108 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
1109 |
if ( 'do-core-reinstall' === $action ) { |
|
0 | 1110 |
$reinstall = true; |
9 | 1111 |
} else { |
0 | 1112 |
$reinstall = false; |
9 | 1113 |
} |
0 | 1114 |
|
9 | 1115 |
if ( isset( $_POST['upgrade'] ) ) { |
1116 |
do_core_upgrade( $reinstall ); |
|
1117 |
} |
|
0 | 1118 |
|
9 | 1119 |
wp_localize_script( |
1120 |
'updates', |
|
1121 |
'_wpUpdatesItemCounts', |
|
1122 |
array( |
|
1123 |
'totals' => wp_get_update_data(), |
|
1124 |
) |
|
1125 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1126 |
|
16 | 1127 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |
0 | 1128 |
|
16 | 1129 |
} elseif ( 'do-plugin-upgrade' === $action ) { |
0 | 1130 |
|
9 | 1131 |
if ( ! current_user_can( 'update_plugins' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1132 |
wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
9 | 1133 |
} |
0 | 1134 |
|
9 | 1135 |
check_admin_referer( 'upgrade-core' ); |
0 | 1136 |
|
1137 |
if ( isset( $_GET['plugins'] ) ) { |
|
1138 |
$plugins = explode( ',', $_GET['plugins'] ); |
|
1139 |
} elseif ( isset( $_POST['checked'] ) ) { |
|
1140 |
$plugins = (array) $_POST['checked']; |
|
1141 |
} else { |
|
9 | 1142 |
wp_redirect( admin_url( 'update-core.php' ) ); |
0 | 1143 |
exit; |
1144 |
} |
|
1145 |
||
9 | 1146 |
$url = 'update.php?action=update-selected&plugins=' . urlencode( implode( ',', $plugins ) ); |
1147 |
$url = wp_nonce_url( $url, 'bulk-update-plugins' ); |
|
0 | 1148 |
|
19 | 1149 |
// Used in the HTML title tag. |
9 | 1150 |
$title = __( 'Update Plugins' ); |
0 | 1151 |
|
16 | 1152 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
18 | 1153 |
?> |
1154 |
<div class="wrap"> |
|
1155 |
<h1><?php _e( 'Update Plugins' ); ?></h1> |
|
1156 |
<iframe src="<?php echo $url; ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe> |
|
1157 |
</div> |
|
1158 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1159 |
|
9 | 1160 |
wp_localize_script( |
1161 |
'updates', |
|
1162 |
'_wpUpdatesItemCounts', |
|
1163 |
array( |
|
1164 |
'totals' => wp_get_update_data(), |
|
1165 |
) |
|
1166 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1167 |
|
16 | 1168 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |
0 | 1169 |
|
16 | 1170 |
} elseif ( 'do-theme-upgrade' === $action ) { |
0 | 1171 |
|
9 | 1172 |
if ( ! current_user_can( 'update_themes' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1173 |
wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
9 | 1174 |
} |
0 | 1175 |
|
9 | 1176 |
check_admin_referer( 'upgrade-core' ); |
0 | 1177 |
|
1178 |
if ( isset( $_GET['themes'] ) ) { |
|
1179 |
$themes = explode( ',', $_GET['themes'] ); |
|
1180 |
} elseif ( isset( $_POST['checked'] ) ) { |
|
1181 |
$themes = (array) $_POST['checked']; |
|
1182 |
} else { |
|
9 | 1183 |
wp_redirect( admin_url( 'update-core.php' ) ); |
0 | 1184 |
exit; |
1185 |
} |
|
1186 |
||
9 | 1187 |
$url = 'update.php?action=update-selected-themes&themes=' . urlencode( implode( ',', $themes ) ); |
1188 |
$url = wp_nonce_url( $url, 'bulk-update-themes' ); |
|
0 | 1189 |
|
19 | 1190 |
// Used in the HTML title tag. |
9 | 1191 |
$title = __( 'Update Themes' ); |
0 | 1192 |
|
16 | 1193 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
5 | 1194 |
?> |
1195 |
<div class="wrap"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1196 |
<h1><?php _e( 'Update Themes' ); ?></h1> |
9 | 1197 |
<iframe src="<?php echo $url; ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe> |
5 | 1198 |
</div> |
1199 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1200 |
|
9 | 1201 |
wp_localize_script( |
1202 |
'updates', |
|
1203 |
'_wpUpdatesItemCounts', |
|
1204 |
array( |
|
1205 |
'totals' => wp_get_update_data(), |
|
1206 |
) |
|
1207 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1208 |
|
16 | 1209 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |
0 | 1210 |
|
16 | 1211 |
} elseif ( 'do-translation-upgrade' === $action ) { |
0 | 1212 |
|
9 | 1213 |
if ( ! current_user_can( 'update_languages' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1214 |
wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
9 | 1215 |
} |
0 | 1216 |
|
1217 |
check_admin_referer( 'upgrade-translations' ); |
|
1218 |
||
16 | 1219 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
1220 |
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
0 | 1221 |
|
9 | 1222 |
$url = 'update-core.php?action=do-translation-upgrade'; |
1223 |
$nonce = 'upgrade-translations'; |
|
1224 |
$title = __( 'Update Translations' ); |
|
0 | 1225 |
$context = WP_LANG_DIR; |
1226 |
||
1227 |
$upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) ); |
|
9 | 1228 |
$result = $upgrader->bulk_upgrade(); |
0 | 1229 |
|
9 | 1230 |
wp_localize_script( |
1231 |
'updates', |
|
1232 |
'_wpUpdatesItemCounts', |
|
1233 |
array( |
|
1234 |
'totals' => wp_get_update_data(), |
|
1235 |
) |
|
1236 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1237 |
|
16 | 1238 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |
0 | 1239 |
|
18 | 1240 |
} elseif ( 'core-major-auto-updates-settings' === $action ) { |
1241 |
||
1242 |
if ( ! current_user_can( 'update_core' ) ) { |
|
1243 |
wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
|
1244 |
} |
|
1245 |
||
1246 |
$redirect_url = self_admin_url( 'update-core.php' ); |
|
1247 |
||
1248 |
if ( isset( $_GET['value'] ) ) { |
|
1249 |
check_admin_referer( 'core-major-auto-updates-nonce' ); |
|
1250 |
||
1251 |
if ( 'enable' === $_GET['value'] ) { |
|
1252 |
update_site_option( 'auto_update_core_major', 'enabled' ); |
|
1253 |
$redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'enabled', $redirect_url ); |
|
1254 |
} elseif ( 'disable' === $_GET['value'] ) { |
|
1255 |
update_site_option( 'auto_update_core_major', 'disabled' ); |
|
1256 |
$redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'disabled', $redirect_url ); |
|
1257 |
} |
|
1258 |
} |
|
1259 |
||
1260 |
wp_redirect( $redirect_url ); |
|
1261 |
exit; |
|
0 | 1262 |
} else { |
5 | 1263 |
/** |
1264 |
* Fires for each custom update action on the WordPress Updates screen. |
|
1265 |
* |
|
1266 |
* The dynamic portion of the hook name, `$action`, refers to the |
|
1267 |
* passed update action. The hook fires in lieu of all available |
|
1268 |
* default update actions. |
|
1269 |
* |
|
1270 |
* @since 3.2.0 |
|
1271 |
*/ |
|
16 | 1272 |
do_action( "update-core-custom_{$action}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
0 | 1273 |
} |