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