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