Changeset 42343 for trunk/src/wp-admin/update-core.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/update-core.php (modified) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/update-core.php
r41755 r42343 20 20 } 21 21 22 if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_languages' ) ) 22 if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_languages' ) ) { 23 23 wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); 24 } 24 25 25 26 /** 26 *27 27 * @global string $wp_local_package 28 28 * @global wpdb $wpdb … … 33 33 */ 34 34 function list_core_update( $update ) { 35 global $wp_local_package, $wpdb;36 static $first_pass = true;35 global $wp_local_package, $wpdb; 36 static $first_pass = true; 37 37 38 38 $wp_version = get_bloginfo( 'version' ); 39 39 40 if ( 'en_US' == $update->locale && 'en_US' == get_locale() ) 41 $version_string = $update->current; 42 // If the only available update is a partial builds, it doesn't need a language-specific version string. 43 elseif ( 'en_US' == $update->locale && $update->packages->partial && $wp_version == $update->partial_version && ( $updates = get_core_updates() ) && 1 == count( $updates ) ) 44 $version_string = $update->current; 45 else 46 $version_string = sprintf( "%s–<strong>%s</strong>", $update->current, $update->locale ); 40 if ( 'en_US' == $update->locale && 'en_US' == get_locale() ) { 41 $version_string = $update->current; 42 } // If the only available update is a partial builds, it doesn't need a language-specific version string. 43 elseif ( 'en_US' == $update->locale && $update->packages->partial && $wp_version == $update->partial_version && ( $updates = get_core_updates() ) && 1 == count( $updates ) ) { 44 $version_string = $update->current; 45 } else { 46 $version_string = sprintf( '%s–<strong>%s</strong>', $update->current, $update->locale ); 47 } 47 48 48 49 $current = false; 49 if ( ! isset($update->response) || 'latest' == $update->response )50 if ( ! isset( $update->response ) || 'latest' == $update->response ) { 50 51 $current = true; 51 $submit = __('Update Now'); 52 $form_action = 'update-core.php?action=do-core-upgrade'; 53 $php_version = phpversion(); 54 $mysql_version = $wpdb->db_version(); 55 $show_buttons = true; 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; 56 58 if ( 'development' == $update->response ) { 57 $message = __( 'You are using a development version of WordPress. You can update to the latest nightly build automatically:');59 $message = __( 'You are using a development version of WordPress. You can update to the latest nightly build automatically:' ); 58 60 } else { 59 61 if ( $current ) { 60 $message = sprintf( __( 'If you need to re-install version %s, you can do so here:' ), $version_string );61 $submit = __('Re-install Now');62 $message = sprintf( __( 'If you need to re-install version %s, you can do so here:' ), $version_string ); 63 $submit = __( 'Re-install Now' ); 62 64 $form_action = 'update-core.php?action=do-core-reinstall'; 63 65 } else { 64 $php_compat = version_compare( $php_version, $update->php_version, '>=' );65 if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) 66 $php_compat = version_compare( $php_version, $update->php_version, '>=' ); 67 if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) { 66 68 $mysql_compat = true; 67 else69 } else { 68 70 $mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' ); 69 70 if ( !$mysql_compat && !$php_compat ) 71 } 72 73 if ( ! $mysql_compat && ! $php_compat ) { 71 74 /* translators: 1: WordPress version number, 2: Minimum required PHP version number, 3: Minimum required MySQL version number, 4: Current PHP version number, 5: Current MySQL version number */ 72 $message = sprintf( __( 'You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version );73 elseif ( !$php_compat )75 $message = sprintf( __( 'You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.' ), $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version ); 76 } elseif ( ! $php_compat ) { 74 77 /* translators: 1: WordPress version number, 2: Minimum required PHP version number, 3: Current PHP version number */ 75 $message = sprintf( __( 'You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $update->current, $update->php_version, $php_version );76 elseif ( !$mysql_compat )78 $message = sprintf( __( 'You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.' ), $update->current, $update->php_version, $php_version ); 79 } elseif ( ! $mysql_compat ) { 77 80 /* translators: 1: WordPress version number, 2: Minimum required MySQL version number, 3: Current MySQL version number */ 78 $message = sprintf( __( 'You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $update->current, $update->mysql_version, $mysql_version );79 else80 /* translators: 1: WordPress version number, 2: WordPress version number including locale if necessary */81 $message = sprintf(__('You can update to <a href="https://codex.wordpress.org/Version_%1$s">WordPress %2$s</a> automatically:'), $update->current, $version_string);82 if ( ! $mysql_compat || !$php_compat )81 $message = sprintf( __( 'You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.' ), $update->current, $update->mysql_version, $mysql_version ); 82 } else { /* translators: 1: WordPress version number, 2: WordPress version number including locale if necessary */ 83 $message = sprintf( __( 'You can update to <a href="https://codex.wordpress.org/Version_%1$s">WordPress %2$s</a> automatically:' ), $update->current, $version_string ); 84 } 85 if ( ! $mysql_compat || ! $php_compat ) { 83 86 $show_buttons = false; 87 } 84 88 } 85 89 } … … 89 93 echo '</p>'; 90 94 echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">'; 91 wp_nonce_field( 'upgrade-core');95 wp_nonce_field( 'upgrade-core' ); 92 96 echo '<p>'; 93 echo '<input name="version" value="' . esc_attr($update->current) .'" type="hidden"/>';94 echo '<input name="locale" value="' . esc_attr($update->locale) .'" type="hidden"/>';97 echo '<input name="version" value="' . esc_attr( $update->current ) . '" type="hidden"/>'; 98 echo '<input name="locale" value="' . esc_attr( $update->locale ) . '" type="hidden"/>'; 95 99 if ( $show_buttons ) { 96 100 if ( $first_pass ) { … … 101 105 } 102 106 } 103 if ( 'en_US' != $update->locale ) 104 if ( ! isset( $update->dismissed ) || !$update->dismissed )107 if ( 'en_US' != $update->locale ) { 108 if ( ! isset( $update->dismissed ) || ! $update->dismissed ) { 105 109 submit_button( __( 'Hide this update' ), '', 'dismiss', false ); 106 else110 } else { 107 111 submit_button( __( 'Bring back this update' ), '', 'undismiss', false ); 112 } 113 } 108 114 echo '</p>'; 109 if ( 'en_US' != $update->locale && ( ! isset($wp_local_package) || $wp_local_package != $update->locale ) )110 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>';111 // Partial builds don't need language-specific warnings.115 if ( 'en_US' != $update->locale && ( ! isset( $wp_local_package ) || $wp_local_package != $update->locale ) ) { 116 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>'; 117 } // Partial builds don't need language-specific warnings. 112 118 elseif ( 'en_US' == $update->locale && get_locale() != 'en_US' && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) { 113 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>';119 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>'; 114 120 } 115 121 echo '</form>'; … … 121 127 */ 122 128 function dismissed_updates() { 123 $dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) ); 129 $dismissed = get_core_updates( 130 array( 131 'dismissed' => true, 132 'available' => false, 133 ) 134 ); 124 135 if ( $dismissed ) { 125 136 126 $show_text = esc_js( __('Show hidden updates'));127 $hide_text = esc_js( __('Hide hidden updates'));137 $show_text = esc_js( __( 'Show hidden updates' ) ); 138 $hide_text = esc_js( __( 'Hide hidden updates' ) ); 128 139 ?> 129 140 <script type="text/javascript"> … … 136 147 </script> 137 148 <?php 138 echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">' .__('Show hidden updates').'</a></p>';149 echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">' . __( 'Show hidden updates' ) . '</a></p>'; 139 150 echo '<ul id="dismissed-updates" class="core-updates dismissed">'; 140 foreach ( (array) $dismissed as $update) {141 echo '<li>';142 list_core_update( $update );143 echo '</li>';144 }151 foreach ( (array) $dismissed as $update ) { 152 echo '<li>'; 153 list_core_update( $update ); 154 echo '</li>'; 155 } 145 156 echo '</ul>'; 146 157 } … … 159 170 160 171 $wp_version = get_bloginfo( 'version' ); 161 $updates = get_core_updates();162 163 if ( ! isset($updates[0]->response) || 'latest' == $updates[0]->response ) {172 $updates = get_core_updates(); 173 174 if ( ! isset( $updates[0]->response ) || 'latest' == $updates[0]->response ) { 164 175 echo '<h2>'; 165 _e( 'You have the latest version of WordPress.');176 _e( 'You have the latest version of WordPress.' ); 166 177 167 178 if ( wp_http_supports( array( 'ssl' ) ) ) { 168 179 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 169 $upgrader = new WP_Automatic_Updater;180 $upgrader = new WP_Automatic_Updater; 170 181 $future_minor_update = (object) array( 171 182 'current' => $wp_version . '.1.next.minor', … … 174 185 'mysql_version' => $required_mysql_version, 175 186 ); 176 $should_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH );177 if ( $should_auto_update ) 187 $should_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH ); 188 if ( $should_auto_update ) { 178 189 echo ' ' . __( 'Future security updates will be applied automatically.' ); 190 } 179 191 } 180 192 echo '</h2>'; 181 193 } else { 182 194 echo '<div class="notice notice-warning"><p>'; 183 _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.');195 _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.' ); 184 196 echo '</p></div>'; 185 197 … … 211 223 } elseif ( ! $updates ) { 212 224 list( $normalized_version ) = explode( '-', $wp_version ); 213 echo '<p>' . sprintf( __( '<a href="% s">Learn more about WordPress %s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>';225 echo '<p>' . sprintf( __( '<a href="%1$s">Learn more about WordPress %2$s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>'; 214 226 } 215 227 dismissed_updates(); … … 217 229 218 230 function list_plugin_updates() { 219 $wp_version = get_bloginfo( 'version' );231 $wp_version = get_bloginfo( 'version' ); 220 232 $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version ); 221 233 222 require_once( ABSPATH . 'wp-admin/includes/plugin-install.php');234 require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); 223 235 $plugins = get_plugin_updates(); 224 236 if ( empty( $plugins ) ) { … … 230 242 231 243 $core_updates = get_core_updates(); 232 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, '=') )244 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, '=' ) ) { 233 245 $core_update_version = false; 234 else246 } else { 235 247 $core_update_version = $core_updates[0]->current; 248 } 236 249 ?> 237 250 <h2><?php _e( 'Plugins' ); ?></h2> 238 251 <p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click “Update Plugins”.' ); ?></p> 239 252 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade"> 240 <?php wp_nonce_field( 'upgrade-core'); ?>241 <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins'); ?>" name="upgrade" /></p>253 <?php wp_nonce_field( 'upgrade-core' ); ?> 254 <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p> 242 255 <table class="widefat updates-table" id="update-plugins-table"> 243 256 <thead> … … 250 263 <tbody class="plugins"> 251 264 <?php 252 foreach ( (array) $plugins as $plugin_file => $plugin_data ) { 253 $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true ); 254 255 $icon = '<span class="dashicons dashicons-admin-plugins"></span>'; 256 $preferred_icons = array( 'svg', '1x', '2x', 'default' ); 257 foreach ( $preferred_icons as $preferred_icon ) { 258 if ( ! empty( $plugin_data->update->icons[ $preferred_icon ] ) ) { 259 $icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" />'; 260 break; 261 } 265 foreach ( (array) $plugins as $plugin_file => $plugin_data ) { 266 $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true ); 267 268 $icon = '<span class="dashicons dashicons-admin-plugins"></span>'; 269 $preferred_icons = array( 'svg', '1x', '2x', 'default' ); 270 foreach ( $preferred_icons as $preferred_icon ) { 271 if ( ! empty( $plugin_data->update->icons[ $preferred_icon ] ) ) { 272 $icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" />'; 273 break; 262 274 } 263 264 // Get plugin compat for running version of WordPress. 265 if ( isset($plugin_data->update->tested) && version_compare($plugin_data->update->tested, $cur_wp_version, '>=') ) { 266 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version); 267 } elseif ( isset($plugin_data->update->compatibility->{$cur_wp_version}) ) { 268 $compat = $plugin_data->update->compatibility->{$cur_wp_version}; 269 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $cur_wp_version, $compat->percent, $compat->votes, $compat->total_votes); 275 } 276 277 // Get plugin compat for running version of WordPress. 278 if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $cur_wp_version, '>=' ) ) { 279 $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $cur_wp_version ); 280 } elseif ( isset( $plugin_data->update->compatibility->{$cur_wp_version} ) ) { 281 $compat = $plugin_data->update->compatibility->{$cur_wp_version}; 282 $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)' ), $cur_wp_version, $compat->percent, $compat->votes, $compat->total_votes ); 283 } else { 284 $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: Unknown' ), $cur_wp_version ); 285 } 286 // Get plugin compat for updated version of WordPress. 287 if ( $core_update_version ) { 288 if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) { 289 $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $core_update_version ); 290 } elseif ( isset( $plugin_data->update->compatibility->{$core_update_version} ) ) { 291 $update_compat = $plugin_data->update->compatibility->{$core_update_version}; 292 $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)' ), $core_update_version, $update_compat->percent, $update_compat->votes, $update_compat->total_votes ); 270 293 } else { 271 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version);294 $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: Unknown' ), $core_update_version ); 272 295 } 273 // Get plugin compat for updated version of WordPress. 274 if ( $core_update_version ) { 275 if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) { 276 $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $core_update_version ); 277 } elseif ( isset( $plugin_data->update->compatibility->{$core_update_version} ) ) { 278 $update_compat = $plugin_data->update->compatibility->{$core_update_version}; 279 $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $core_update_version, $update_compat->percent, $update_compat->votes, $update_compat->total_votes); 280 } else { 281 $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version); 282 } 283 } 284 // Get the upgrade notice for the new plugin version. 285 if ( isset($plugin_data->update->upgrade_notice) ) { 286 $upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice); 287 } else { 288 $upgrade_notice = ''; 289 } 290 291 $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'); 292 $details = sprintf( 293 '<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>', 294 esc_url( $details_url ), 295 /* translators: 1: plugin name, 2: version number */ 296 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ), 297 /* translators: %s: plugin version */ 298 sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version ) 299 ); 300 301 $checkbox_id = "checkbox_" . md5( $plugin_data->Name ); 302 ?> 303 <tr> 304 <td class="check-column"> 305 <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" /> 306 <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"><?php 307 /* translators: %s: plugin name */ 308 printf( __( 'Select %s' ), 309 $plugin_data->Name 310 ); 311 ?></label> 296 } 297 // Get the upgrade notice for the new plugin version. 298 if ( isset( $plugin_data->update->upgrade_notice ) ) { 299 $upgrade_notice = '<br />' . strip_tags( $plugin_data->update->upgrade_notice ); 300 } else { 301 $upgrade_notice = ''; 302 } 303 304 $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' ); 305 $details = sprintf( 306 '<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>', 307 esc_url( $details_url ), 308 /* translators: 1: plugin name, 2: version number */ 309 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ), 310 /* translators: %s: plugin version */ 311 sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version ) 312 ); 313 314 $checkbox_id = 'checkbox_' . md5( $plugin_data->Name ); 315 ?> 316 <tr> 317 <td class="check-column"> 318 <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" /> 319 <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"> 320 <?php 321 /* translators: %s: plugin name */ 322 printf( 323 __( 'Select %s' ), 324 $plugin_data->Name 325 ); 326 ?> 327 </label> 312 328 </td> 313 329 <td class="plugin-title"><p> … … 315 331 <strong><?php echo $plugin_data->Name; ?></strong> 316 332 <?php 317 /* translators: 1: plugin version, 2: new version */ 318 printf( __( 'You have version %1$s installed. Update to %2$s.' ), 319 $plugin_data->Version, 320 $plugin_data->update->new_version 321 ); 322 echo ' ' . $details . $compat . $upgrade_notice; 323 ?> 333 /* translators: 1: plugin version, 2: new version */ 334 printf( 335 __( 'You have version %1$s installed. Update to %2$s.' ), 336 $plugin_data->Version, 337 $plugin_data->update->new_version 338 ); 339 echo ' ' . $details . $compat . $upgrade_notice; 340 ?> 324 341 </p></td> 325 342 </tr> 326 343 <?php 327 }344 } 328 345 ?> 329 346 </tbody> … … 336 353 </tfoot> 337 354 </table> 338 <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins'); ?>" name="upgrade" /></p>355 <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p> 339 356 </form> 340 357 <?php … … 358 375 <p><?php printf( __( '<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.' ), __( 'https://codex.wordpress.org/Child_Themes' ) ); ?></p> 359 376 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade"> 360 <?php wp_nonce_field( 'upgrade-core'); ?>361 <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes'); ?>" name="upgrade" /></p>377 <?php wp_nonce_field( 'upgrade-core' ); ?> 378 <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p> 362 379 <table class="widefat updates-table" id="update-themes-table"> 363 380 <thead> … … 370 387 <tbody class="plugins"> 371 388 <?php 372 foreach ( $themes as $stylesheet => $theme ) { 373 $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) ); 374 ?> 375 <tr> 376 <td class="check-column"> 377 <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" /> 378 <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"><?php 379 /* translators: %s: theme name */ 380 printf( __( 'Select %s' ), 381 $theme->display( 'Name' ) 382 ); 383 ?></label> 389 foreach ( $themes as $stylesheet => $theme ) { 390 $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) ); 391 ?> 392 <tr> 393 <td class="check-column"> 394 <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" /> 395 <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"> 396 <?php 397 /* translators: %s: theme name */ 398 printf( 399 __( 'Select %s' ), 400 $theme->display( 'Name' ) 401 ); 402 ?> 403 </label> 384 404 </td> 385 405 <td class="plugin-title"><p> … … 387 407 <strong><?php echo $theme->display( 'Name' ); ?></strong> 388 408 <?php 389 /* translators: 1: theme version, 2: new version */ 390 printf( __( 'You have version %1$s installed. Update to %2$s.' ), 391 $theme->display( 'Version' ), 392 $theme->update['new_version'] 393 ); 394 ?> 409 /* translators: 1: theme version, 2: new version */ 410 printf( 411 __( 'You have version %1$s installed. Update to %2$s.' ), 412 $theme->display( 'Version' ), 413 $theme->update['new_version'] 414 ); 415 ?> 395 416 </p></td> 396 417 </tr> 397 418 <?php 398 }419 } 399 420 ?> 400 421 </tbody> … … 407 428 </tfoot> 408 429 </table> 409 <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes'); ?>" name="upgrade" /></p>430 <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p> 410 431 </form> 411 432 <?php … … 450 471 include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); 451 472 452 if ( $reinstall ) 473 if ( $reinstall ) { 453 474 $url = 'update-core.php?action=do-core-reinstall'; 454 else475 } else { 455 476 $url = 'update-core.php?action=do-core-upgrade'; 456 $url = wp_nonce_url($url, 'upgrade-core'); 457 458 $version = isset( $_POST['version'] )? $_POST['version'] : false; 459 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US'; 460 $update = find_core_update( $version, $locale ); 461 if ( !$update ) 477 } 478 $url = wp_nonce_url( $url, 'upgrade-core' ); 479 480 $version = isset( $_POST['version'] ) ? $_POST['version'] : false; 481 $locale = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US'; 482 $update = find_core_update( $version, $locale ); 483 if ( ! $update ) { 462 484 return; 485 } 463 486 464 487 // Allow relaxed file ownership writes for User-initiated upgrades when the API specifies … … 471 494 <?php 472 495 473 if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ) ) ) { 474 echo '</div>'; 475 return; 476 } 477 478 if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) { 479 // Failed to connect, Error and request again 480 request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ); 481 echo '</div>'; 482 return; 483 } 484 485 if ( $wp_filesystem->errors->get_error_code() ) { 486 foreach ( $wp_filesystem->errors->get_error_messages() as $message ) 487 show_message($message); 488 echo '</div>'; 489 return; 490 } 491 492 if ( $reinstall ) 493 $update->response = 'reinstall'; 496 if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ) ) ) { 497 echo '</div>'; 498 return; 499 } 500 501 if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) { 502 // Failed to connect, Error and request again 503 request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ); 504 echo '</div>'; 505 return; 506 } 507 508 if ( $wp_filesystem->errors->get_error_code() ) { 509 foreach ( $wp_filesystem->errors->get_error_messages() as $message ) { 510 show_message( $message ); 511 } 512 echo '</div>'; 513 return; 514 } 515 516 if ( $reinstall ) { 517 $update->response = 'reinstall'; 518 } 494 519 495 520 add_filter( 'update_feedback', 'show_message' ); 496 521 497 522 $upgrader = new Core_Upgrader(); 498 $result = $upgrader->upgrade( $update, array( 499 'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership 500 ) ); 501 502 if ( is_wp_error($result) ) { 503 show_message($result); 504 if ( 'up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code() ) 505 show_message( __('Installation Failed') ); 506 echo '</div>'; 507 return; 508 } 509 510 show_message( __('WordPress updated successfully') ); 523 $result = $upgrader->upgrade( 524 $update, array( 525 'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership, 526 ) 527 ); 528 529 if ( is_wp_error( $result ) ) { 530 show_message( $result ); 531 if ( 'up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code() ) { 532 show_message( __( 'Installation Failed' ) ); 533 } 534 echo '</div>'; 535 return; 536 } 537 538 show_message( __( 'WordPress updated successfully' ) ); 511 539 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>' ); 512 540 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>' ); … … 523 551 */ 524 552 function do_dismiss_core_update() { 525 $version = isset( $_POST['version'] ) ? $_POST['version'] : false;526 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';527 $update = find_core_update( $version, $locale );528 if ( ! $update )553 $version = isset( $_POST['version'] ) ? $_POST['version'] : false; 554 $locale = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US'; 555 $update = find_core_update( $version, $locale ); 556 if ( ! $update ) { 529 557 return; 558 } 530 559 dismiss_core_update( $update ); 531 wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core') );560 wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core' ) ); 532 561 exit; 533 562 } … … 537 566 */ 538 567 function do_undismiss_core_update() { 539 $version = isset( $_POST['version'] ) ? $_POST['version'] : false;540 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';541 $update = find_core_update( $version, $locale );542 if ( ! $update )568 $version = isset( $_POST['version'] ) ? $_POST['version'] : false; 569 $locale = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US'; 570 $update = find_core_update( $version, $locale ); 571 if ( ! $update ) { 543 572 return; 573 } 544 574 undismiss_core_update( $version, $locale ); 545 wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core') );575 wp_redirect( wp_nonce_url( 'update-core.php?action=upgrade-core', 'upgrade-core' ) ); 546 576 exit; 547 577 } 548 578 549 $action = isset( $_GET['action']) ? $_GET['action'] : 'upgrade-core';579 $action = isset( $_GET['action'] ) ? $_GET['action'] : 'upgrade-core'; 550 580 551 581 $upgrade_error = false; … … 553 583 && ! isset( $_POST['checked'] ) ) { 554 584 $upgrade_error = $action == 'do-theme-upgrade' ? 'themes' : 'plugins'; 555 $action = 'upgrade-core';556 } 557 558 $title = __('WordPress Updates');585 $action = 'upgrade-core'; 586 } 587 588 $title = __( 'WordPress Updates' ); 559 589 $parent_file = 'index.php'; 560 590 … … 562 592 $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>'; 563 593 564 get_current_screen()->add_help_tab( array( 565 'id' => 'overview', 566 'title' => __( 'Overview' ), 567 'content' => $updates_overview 568 ) ); 594 get_current_screen()->add_help_tab( 595 array( 596 'id' => 'overview', 597 'title' => __( 'Overview' ), 598 'content' => $updates_overview, 599 ) 600 ); 569 601 570 602 $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>'; … … 575 607 } 576 608 577 get_current_screen()->add_help_tab( array( 578 'id' => 'how-to-update', 579 'title' => __( 'How to Update' ), 580 'content' => $updates_howto 581 ) ); 609 get_current_screen()->add_help_tab( 610 array( 611 'id' => 'how-to-update', 612 'title' => __( 'How to Update' ), 613 'content' => $updates_howto, 614 ) 615 ); 582 616 583 617 get_current_screen()->set_help_sidebar( 584 '<p><strong>' . __( 'For more information:') . '</strong></p>' .618 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 585 619 '<p>' . __( '<a href="https://codex.wordpress.org/Dashboard_Updates_Screen">Documentation on Updating WordPress</a>' ) . '</p>' . 586 620 '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>' … … 592 626 wp_version_check( array(), $force_check ); 593 627 594 require_once( ABSPATH . 'wp-admin/admin-header.php');628 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 595 629 ?> 596 630 <div class="wrap"> … … 599 633 if ( $upgrade_error ) { 600 634 echo '<div class="error"><p>'; 601 if ( $upgrade_error == 'themes' ) 602 _e('Please select one or more themes to update.'); 603 else 604 _e('Please select one or more plugins to update.'); 635 if ( $upgrade_error == 'themes' ) { 636 _e( 'Please select one or more themes to update.' ); 637 } else { 638 _e( 'Please select one or more plugins to update.' ); 639 } 605 640 echo '</p></div>'; 606 641 } 607 642 608 643 $last_update_check = false; 609 $current = get_site_transient( 'update_core' );610 611 if ( $current && isset ( $current->last_checked ) ){644 $current = get_site_transient( 'update_core' ); 645 646 if ( $current && isset( $current->last_checked ) ) { 612 647 $last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; 613 648 } … … 616 651 /* translators: %1 date, %2 time. */ 617 652 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 ) ); 618 echo ' <a class="button" href="' . esc_url( self_admin_url( 'update-core.php?force-check=1') ) . '">' . __( 'Check Again' ) . '</a>';653 echo ' <a class="button" href="' . esc_url( self_admin_url( 'update-core.php?force-check=1' ) ) . '">' . __( 'Check Again' ) . '</a>'; 619 654 echo '</p>'; 620 655 … … 640 675 echo '</div>'; 641 676 642 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 643 'totals' => wp_get_update_data(), 644 ) ); 645 646 include(ABSPATH . 'wp-admin/admin-footer.php'); 677 wp_localize_script( 678 'updates', '_wpUpdatesItemCounts', array( 679 'totals' => wp_get_update_data(), 680 ) 681 ); 682 683 include( ABSPATH . 'wp-admin/admin-footer.php' ); 647 684 648 685 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) { 649 686 650 if ( ! current_user_can( 'update_core' ) ) 687 if ( ! current_user_can( 'update_core' ) ) { 651 688 wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); 652 653 check_admin_referer('upgrade-core'); 689 } 690 691 check_admin_referer( 'upgrade-core' ); 654 692 655 693 // Do the (un)dismiss actions before headers, so that they can redirect. 656 if ( isset( $_POST['dismiss'] ) ) 694 if ( isset( $_POST['dismiss'] ) ) { 657 695 do_dismiss_core_update(); 658 elseif ( isset( $_POST['undismiss'] ) )696 } elseif ( isset( $_POST['undismiss'] ) ) { 659 697 do_undismiss_core_update(); 660 661 require_once(ABSPATH . 'wp-admin/admin-header.php'); 662 if ( 'do-core-reinstall' == $action ) 698 } 699 700 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 701 if ( 'do-core-reinstall' == $action ) { 663 702 $reinstall = true; 664 else703 } else { 665 704 $reinstall = false; 666 667 if ( isset( $_POST['upgrade'] ) ) 668 do_core_upgrade($reinstall); 669 670 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 671 'totals' => wp_get_update_data(), 672 ) ); 673 674 include(ABSPATH . 'wp-admin/admin-footer.php'); 705 } 706 707 if ( isset( $_POST['upgrade'] ) ) { 708 do_core_upgrade( $reinstall ); 709 } 710 711 wp_localize_script( 712 'updates', '_wpUpdatesItemCounts', array( 713 'totals' => wp_get_update_data(), 714 ) 715 ); 716 717 include( ABSPATH . 'wp-admin/admin-footer.php' ); 675 718 676 719 } elseif ( 'do-plugin-upgrade' == $action ) { 677 720 678 if ( ! current_user_can( 'update_plugins' ) ) 721 if ( ! current_user_can( 'update_plugins' ) ) { 679 722 wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); 680 681 check_admin_referer('upgrade-core'); 723 } 724 725 check_admin_referer( 'upgrade-core' ); 682 726 683 727 if ( isset( $_GET['plugins'] ) ) { … … 686 730 $plugins = (array) $_POST['checked']; 687 731 } else { 688 wp_redirect( admin_url( 'update-core.php') );732 wp_redirect( admin_url( 'update-core.php' ) ); 689 733 exit; 690 734 } 691 735 692 $url = 'update.php?action=update-selected&plugins=' . urlencode( implode(',', $plugins));693 $url = wp_nonce_url( $url, 'bulk-update-plugins');694 695 $title = __( 'Update Plugins');696 697 require_once( ABSPATH . 'wp-admin/admin-header.php');736 $url = 'update.php?action=update-selected&plugins=' . urlencode( implode( ',', $plugins ) ); 737 $url = wp_nonce_url( $url, 'bulk-update-plugins' ); 738 739 $title = __( 'Update Plugins' ); 740 741 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 698 742 echo '<div class="wrap">'; 699 743 echo '<h1>' . __( 'Update Plugins' ) . '</h1>'; … … 701 745 echo '</div>'; 702 746 703 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 704 'totals' => wp_get_update_data(), 705 ) ); 706 707 include(ABSPATH . 'wp-admin/admin-footer.php'); 747 wp_localize_script( 748 'updates', '_wpUpdatesItemCounts', array( 749 'totals' => wp_get_update_data(), 750 ) 751 ); 752 753 include( ABSPATH . 'wp-admin/admin-footer.php' ); 708 754 709 755 } elseif ( 'do-theme-upgrade' == $action ) { 710 756 711 if ( ! current_user_can( 'update_themes' ) ) 757 if ( ! current_user_can( 'update_themes' ) ) { 712 758 wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); 713 714 check_admin_referer('upgrade-core'); 759 } 760 761 check_admin_referer( 'upgrade-core' ); 715 762 716 763 if ( isset( $_GET['themes'] ) ) { … … 719 766 $themes = (array) $_POST['checked']; 720 767 } else { 721 wp_redirect( admin_url( 'update-core.php') );768 wp_redirect( admin_url( 'update-core.php' ) ); 722 769 exit; 723 770 } 724 771 725 $url = 'update.php?action=update-selected-themes&themes=' . urlencode( implode(',', $themes));726 $url = wp_nonce_url( $url, 'bulk-update-themes');727 728 $title = __( 'Update Themes');729 730 require_once( ABSPATH . 'wp-admin/admin-header.php');772 $url = 'update.php?action=update-selected-themes&themes=' . urlencode( implode( ',', $themes ) ); 773 $url = wp_nonce_url( $url, 'bulk-update-themes' ); 774 775 $title = __( 'Update Themes' ); 776 777 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 731 778 ?> 732 779 <div class="wrap"> 733 780 <h1><?php _e( 'Update Themes' ); ?></h1> 734 <iframe src="<?php echo $url ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe>781 <iframe src="<?php echo $url; ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe> 735 782 </div> 736 783 <?php 737 784 738 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 739 'totals' => wp_get_update_data(), 740 ) ); 741 742 include(ABSPATH . 'wp-admin/admin-footer.php'); 785 wp_localize_script( 786 'updates', '_wpUpdatesItemCounts', array( 787 'totals' => wp_get_update_data(), 788 ) 789 ); 790 791 include( ABSPATH . 'wp-admin/admin-footer.php' ); 743 792 744 793 } elseif ( 'do-translation-upgrade' == $action ) { 745 794 746 if ( ! current_user_can( 'update_languages' ) ) 795 if ( ! current_user_can( 'update_languages' ) ) { 747 796 wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); 797 } 748 798 749 799 check_admin_referer( 'upgrade-translations' ); … … 752 802 include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); 753 803 754 $url = 'update-core.php?action=do-translation-upgrade';755 $nonce = 'upgrade-translations';756 $title = __( 'Update Translations' );804 $url = 'update-core.php?action=do-translation-upgrade'; 805 $nonce = 'upgrade-translations'; 806 $title = __( 'Update Translations' ); 757 807 $context = WP_LANG_DIR; 758 808 759 809 $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) ); 760 $result = $upgrader->bulk_upgrade(); 761 762 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 763 'totals' => wp_get_update_data(), 764 ) ); 810 $result = $upgrader->bulk_upgrade(); 811 812 wp_localize_script( 813 'updates', '_wpUpdatesItemCounts', array( 814 'totals' => wp_get_update_data(), 815 ) 816 ); 765 817 766 818 require_once( ABSPATH . 'wp-admin/admin-footer.php' );
Note: See TracChangeset
for help on using the changeset viewer.