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