wp/wp-admin/update-core.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
    17 if ( is_multisite() && ! is_network_admin() ) {
    17 if ( is_multisite() && ! is_network_admin() ) {
    18 	wp_redirect( network_admin_url( 'update-core.php' ) );
    18 	wp_redirect( network_admin_url( 'update-core.php' ) );
    19 	exit();
    19 	exit();
    20 }
    20 }
    21 
    21 
    22 if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) )
    22 if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_languages' ) )
    23 	wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
    23 	wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
    24 
    24 
       
    25 /**
       
    26  *
       
    27  * @global string $wp_local_package
       
    28  * @global wpdb   $wpdb
       
    29  *
       
    30  * @staticvar bool $first_pass
       
    31  *
       
    32  * @param object $update
       
    33  */
    25 function list_core_update( $update ) {
    34 function list_core_update( $update ) {
    26  	global $wp_local_package, $wpdb, $wp_version;
    35  	global $wp_local_package, $wpdb;
    27   	static $first_pass = true;
    36   	static $first_pass = true;
       
    37 
       
    38 	$wp_version = get_bloginfo( 'version' );
    28 
    39 
    29  	if ( 'en_US' == $update->locale && 'en_US' == get_locale() )
    40  	if ( 'en_US' == $update->locale && 'en_US' == get_locale() )
    30  		$version_string = $update->current;
    41  		$version_string = $update->current;
    31  	// If the only available update is a partial builds, it doesn't need a language-specific version string.
    42  	// If the only available update is a partial builds, it doesn't need a language-specific version string.
    32  	elseif ( 'en_US' == $update->locale && $update->packages->partial && $wp_version == $update->partial_version && ( $updates = get_core_updates() ) && 1 == count( $updates ) )
    43  	elseif ( 'en_US' == $update->locale && $update->packages->partial && $wp_version == $update->partial_version && ( $updates = get_core_updates() ) && 1 == count( $updates ) )
    41 	$form_action = 'update-core.php?action=do-core-upgrade';
    52 	$form_action = 'update-core.php?action=do-core-upgrade';
    42 	$php_version    = phpversion();
    53 	$php_version    = phpversion();
    43 	$mysql_version  = $wpdb->db_version();
    54 	$mysql_version  = $wpdb->db_version();
    44 	$show_buttons = true;
    55 	$show_buttons = true;
    45 	if ( 'development' == $update->response ) {
    56 	if ( 'development' == $update->response ) {
    46 		$message = __('You are using a development version of WordPress. You can update to the latest nightly build automatically or download the nightly build and install it manually:');
    57 		$message = __('You are using a development version of WordPress. You can update to the latest nightly build automatically:');
    47 		$download = __('Download nightly build');
       
    48 	} else {
    58 	} else {
    49 		if ( $current ) {
    59 		if ( $current ) {
    50 			$message = sprintf( __( 'If you need to re-install version %s, you can do so here or download the package and re-install manually:' ), $version_string );
    60 			$message = sprintf( __( 'If you need to re-install version %s, you can do so here:' ), $version_string );
    51 			$submit = __('Re-install Now');
    61 			$submit = __('Re-install Now');
    52 			$form_action = 'update-core.php?action=do-core-reinstall';
    62 			$form_action = 'update-core.php?action=do-core-reinstall';
    53 		} else {
    63 		} else {
    54 			$php_compat     = version_compare( $php_version, $update->php_version, '>=' );
    64 			$php_compat     = version_compare( $php_version, $update->php_version, '>=' );
    55 			if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
    65 			if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
    56 				$mysql_compat = true;
    66 				$mysql_compat = true;
    57 			else
    67 			else
    58 				$mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' );
    68 				$mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' );
    59 
    69 
    60 			if ( !$mysql_compat && !$php_compat )
    70 			if ( !$mysql_compat && !$php_compat )
       
    71 				/* 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 */
    61 				$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 );
    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 );
    62 			elseif ( !$php_compat )
    73 			elseif ( !$php_compat )
       
    74 				/* translators: 1: WordPress version number, 2: Minimum required PHP version number, 3: Current PHP version number */
    63 				$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 );
    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 );
    64 			elseif ( !$mysql_compat )
    76 			elseif ( !$mysql_compat )
       
    77 				/* translators: 1: WordPress version number, 2: Minimum required MySQL version number, 3: Current MySQL version number */
    65 				$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 );
    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 );
    66 			else
    79 			else
    67 				$message = 	sprintf(__('You can update to <a href="https://codex.wordpress.org/Version_%1$s">WordPress %2$s</a> automatically or download the package and install it manually:'), $update->current, $version_string);
    80 				/* 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);
    68 			if ( !$mysql_compat || !$php_compat )
    82 			if ( !$mysql_compat || !$php_compat )
    69 				$show_buttons = false;
    83 				$show_buttons = false;
    70 		}
    84 		}
    71 		$download = sprintf(__('Download %s'), $version_string);
       
    72 	}
    85 	}
    73 
    86 
    74 	echo '<p>';
    87 	echo '<p>';
    75 	echo $message;
    88 	echo $message;
    76 	echo '</p>';
    89 	echo '</p>';
    79 	echo '<p>';
    92 	echo '<p>';
    80 	echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
    93 	echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
    81 	echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
    94 	echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
    82 	if ( $show_buttons ) {
    95 	if ( $show_buttons ) {
    83 		if ( $first_pass ) {
    96 		if ( $first_pass ) {
    84 			submit_button( $submit, $current ? 'button' : 'primary regular', 'upgrade', false );
    97 			submit_button( $submit, $current ? '' : 'primary regular', 'upgrade', false );
    85 			$first_pass = false;
    98 			$first_pass = false;
    86 		} else {
    99 		} else {
    87 			submit_button( $submit, 'button', 'upgrade', false );
   100 			submit_button( $submit, '', 'upgrade', false );
    88 		}
   101 		}
    89 		echo '&nbsp;<a href="' . esc_url( $update->download ) . '" class="button">' . $download . '</a>&nbsp;';
       
    90 	}
   102 	}
    91 	if ( 'en_US' != $update->locale )
   103 	if ( 'en_US' != $update->locale )
    92 		if ( !isset( $update->dismissed ) || !$update->dismissed )
   104 		if ( !isset( $update->dismissed ) || !$update->dismissed )
    93 			submit_button( __('Hide this update'), 'button', 'dismiss', false );
   105 			submit_button( __( 'Hide this update' ), '', 'dismiss', false );
    94 		else
   106 		else
    95 			submit_button( __('Bring back this update'), 'button', 'undismiss', false );
   107 			submit_button( __( 'Bring back this update' ), '', 'undismiss', false );
    96 	echo '</p>';
   108 	echo '</p>';
    97 	if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) )
   109 	if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) )
    98 	    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>';
   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>';
    99 	// Partial builds don't need language-specific warnings.
   111 	// Partial builds don't need language-specific warnings.
   100 	elseif ( 'en_US' == $update->locale && get_locale() != 'en_US' && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) {
   112 	elseif ( 'en_US' == $update->locale && get_locale() != 'en_US' && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) {
   102 	}
   114 	}
   103 	echo '</form>';
   115 	echo '</form>';
   104 
   116 
   105 }
   117 }
   106 
   118 
       
   119 /**
       
   120  * @since 2.7.0
       
   121  */
   107 function dismissed_updates() {
   122 function dismissed_updates() {
   108 	$dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) );
   123 	$dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) );
   109 	if ( $dismissed ) {
   124 	if ( $dismissed ) {
   110 
   125 
   111 		$show_text = esc_js(__('Show hidden updates'));
   126 		$show_text = esc_js(__('Show hidden updates'));
   120 		});
   135 		});
   121 	</script>
   136 	</script>
   122 	<?php
   137 	<?php
   123 		echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>';
   138 		echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>';
   124 		echo '<ul id="dismissed-updates" class="core-updates dismissed">';
   139 		echo '<ul id="dismissed-updates" class="core-updates dismissed">';
   125 		foreach( (array) $dismissed as $update) {
   140 		foreach ( (array) $dismissed as $update) {
   126 			echo '<li>';
   141 			echo '<li>';
   127 			list_core_update( $update );
   142 			list_core_update( $update );
   128 			echo '</li>';
   143 			echo '</li>';
   129 		}
   144 		}
   130 		echo '</ul>';
   145 		echo '</ul>';
   134 /**
   149 /**
   135  * Display upgrade WordPress for downloading latest or upgrading automatically form.
   150  * Display upgrade WordPress for downloading latest or upgrading automatically form.
   136  *
   151  *
   137  * @since 2.7.0
   152  * @since 2.7.0
   138  *
   153  *
   139  * @return null
   154  * @global string $required_php_version
       
   155  * @global string $required_mysql_version
   140  */
   156  */
   141 function core_upgrade_preamble() {
   157 function core_upgrade_preamble() {
   142 	global $wp_version, $required_php_version, $required_mysql_version;
   158 	global $required_php_version, $required_mysql_version;
   143 
   159 
       
   160 	$wp_version = get_bloginfo( 'version' );
   144 	$updates = get_core_updates();
   161 	$updates = get_core_updates();
   145 
   162 
   146 	if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
   163 	if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
   147 		echo '<h3>';
   164 		echo '<h2>';
   148 		_e('You have the latest version of WordPress.');
   165 		_e('You have the latest version of WordPress.');
   149 
   166 
   150 		if ( wp_http_supports( array( 'ssl' ) ) ) {
   167 		if ( wp_http_supports( array( 'ssl' ) ) ) {
   151 			require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
   168 			require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
   152 			$upgrader = new WP_Automatic_Updater;
   169 			$upgrader = new WP_Automatic_Updater;
   158 			);
   175 			);
   159 			$should_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH );
   176 			$should_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH );
   160 			if ( $should_auto_update )
   177 			if ( $should_auto_update )
   161 				echo ' ' . __( 'Future security updates will be applied automatically.' );
   178 				echo ' ' . __( 'Future security updates will be applied automatically.' );
   162 		}
   179 		}
   163 		echo '</h3>';
   180 		echo '</h2>';
   164 	} else {
   181 	} else {
   165 		echo '<div class="updated inline"><p>';
   182 		echo '<div class="notice notice-warning"><p>';
   166 		_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.');
   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.');
   167 		echo '</p></div>';
   184 		echo '</p></div>';
   168 
   185 
   169 		echo '<h3 class="response">';
   186 		echo '<h2 class="response">';
   170 		_e( 'An updated version of WordPress is available.' );
   187 		_e( 'An updated version of WordPress is available.' );
   171 		echo '</h3>';
   188 		echo '</h2>';
   172 	}
   189 	}
   173 
   190 
   174 	if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) {
   191 	if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) {
   175 		require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
   192 		require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
   176 		$upgrader = new WP_Automatic_Updater;
   193 		$upgrader = new WP_Automatic_Updater;
   180 			echo '</p></div>';
   197 			echo '</p></div>';
   181 		}
   198 		}
   182 	}
   199 	}
   183 
   200 
   184 	echo '<ul class="core-updates">';
   201 	echo '<ul class="core-updates">';
   185 	foreach( (array) $updates as $update ) {
   202 	foreach ( (array) $updates as $update ) {
   186 		echo '<li>';
   203 		echo '<li>';
   187 		list_core_update( $update );
   204 		list_core_update( $update );
   188 		echo '</li>';
   205 		echo '</li>';
   189 	}
   206 	}
   190 	echo '</ul>';
   207 	echo '</ul>';
   197 	}
   214 	}
   198 	dismissed_updates();
   215 	dismissed_updates();
   199 }
   216 }
   200 
   217 
   201 function list_plugin_updates() {
   218 function list_plugin_updates() {
   202 	global $wp_version;
   219 	$wp_version = get_bloginfo( 'version' );
   203 
   220 	$cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
   204 	$cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
       
   205 
   221 
   206 	require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
   222 	require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
   207 	$plugins = get_plugin_updates();
   223 	$plugins = get_plugin_updates();
   208 	if ( empty( $plugins ) ) {
   224 	if ( empty( $plugins ) ) {
   209 		echo '<h3>' . __( 'Plugins' ) . '</h3>';
   225 		echo '<h2>' . __( 'Plugins' ) . '</h2>';
   210 		echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
   226 		echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
   211 		return;
   227 		return;
   212 	}
   228 	}
   213 	$form_action = 'update-core.php?action=do-plugin-upgrade';
   229 	$form_action = 'update-core.php?action=do-plugin-upgrade';
   214 
   230 
   216 	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, '=') )
   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, '=') )
   217 		$core_update_version = false;
   233 		$core_update_version = false;
   218 	else
   234 	else
   219 		$core_update_version = $core_updates[0]->current;
   235 		$core_update_version = $core_updates[0]->current;
   220 	?>
   236 	?>
   221 <h3><?php _e( 'Plugins' ); ?></h3>
   237 <h2><?php _e( 'Plugins' ); ?></h2>
   222 <p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click &#8220;Update Plugins&#8221;.' ); ?></p>
   238 <p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click &#8220;Update Plugins&#8221;.' ); ?></p>
   223 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade">
   239 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade">
   224 <?php wp_nonce_field('upgrade-core'); ?>
   240 <?php wp_nonce_field('upgrade-core'); ?>
   225 <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
   241 <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
   226 <table class="widefat" id="update-plugins-table">
   242 <table class="widefat updates-table" id="update-plugins-table">
   227 	<thead>
   243 	<thead>
   228 	<tr>
   244 	<tr>
   229 		<th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th>
   245 		<td class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></td>
   230 		<th scope="col" class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></th>
   246 		<td class="manage-column"><label for="plugins-select-all"><?php _e( 'Select All' ); ?></label></td>
   231 	</tr>
   247 	</tr>
   232 	</thead>
   248 	</thead>
   233 
   249 
   234 	<tbody class="plugins">
   250 	<tbody class="plugins">
   235 <?php
   251 <?php
   236 	foreach ( (array) $plugins as $plugin_file => $plugin_data) {
   252 	foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
   237 		$info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
   253 		$plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );
   238 		if ( is_wp_error( $info ) ) {
   254 
   239 			$info = false;
   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 			}			
   240 		}
   262 		}
   241 
   263 
   242 		// Get plugin compat for running version of WordPress.
   264 		// Get plugin compat for running version of WordPress.
   243 		if ( isset($info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {
   265 		if ( isset($plugin_data->update->tested) && version_compare($plugin_data->update->tested, $cur_wp_version, '>=') ) {
   244 			$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
   266 			$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
   245 		} elseif ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
   267 		} elseif ( isset($plugin_data->update->compatibility->{$cur_wp_version}) ) {
   246 			$compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
   268 			$compat = $plugin_data->update->compatibility->{$cur_wp_version};
   247 			$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $cur_wp_version, $compat[0], $compat[2], $compat[1]);
   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);
   248 		} else {
   270 		} else {
   249 			$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version);
   271 			$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version);
   250 		}
   272 		}
   251 		// Get plugin compat for updated version of WordPress.
   273 		// Get plugin compat for updated version of WordPress.
   252 		if ( $core_update_version ) {
   274 		if ( $core_update_version ) {
   253 			if ( isset($info->compatibility[$core_update_version][$plugin_data->update->new_version]) ) {
   275 			if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) {
   254 				$update_compat = $info->compatibility[$core_update_version][$plugin_data->update->new_version];
   276 				$compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $core_update_version );
   255 				$compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $core_update_version, $update_compat[0], $update_compat[2], $update_compat[1]);
   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);
   256 			} else {
   280 			} else {
   257 				$compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version);
   281 				$compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version);
   258 			}
   282 			}
   259 		}
   283 		}
   260 		// Get the upgrade notice for the new plugin version.
   284 		// Get the upgrade notice for the new plugin version.
   263 		} else {
   287 		} else {
   264 			$upgrade_notice = '';
   288 			$upgrade_notice = '';
   265 		}
   289 		}
   266 
   290 
   267 		$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '&section=changelog&TB_iframe=true&width=640&height=662');
   291 		$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '&section=changelog&TB_iframe=true&width=640&height=662');
   268 		$details_text = sprintf(__('View version %1$s details'), $plugin_data->update->new_version);
   292 		$details = sprintf(
   269 		$details = sprintf('<a href="%1$s" class="thickbox" title="%2$s">%3$s</a>.', esc_url($details_url), esc_attr($plugin_data->Name), $details_text);
   293 			'<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>',
   270 
   294 			esc_url( $details_url ),
   271 		echo "
   295 			/* translators: 1: plugin name, 2: version number */
   272 	<tr>
   296 			esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ),
   273 		<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
   297 			/* translators: %s: plugin version */
   274 		<td><p><strong>{$plugin_data->Name}</strong><br />" . sprintf(__('You have version %1$s installed. Update to %2$s.'), $plugin_data->Version, $plugin_data->update->new_version) . ' ' . $details . $compat . $upgrade_notice . "</p></td>
   298 			sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version )
   275 	</tr>";
   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>
       
   312 			</td>
       
   313 			<td class="plugin-title"><p>
       
   314 				<?php echo $icon; ?>
       
   315 				<strong><?php echo $plugin_data->Name; ?></strong>
       
   316 				<?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 				?>
       
   324 			</p></td>
       
   325 		</tr>
       
   326 		<?php
   276 	}
   327 	}
   277 ?>
   328 ?>
   278 	</tbody>
   329 	</tbody>
   279 
   330 
   280 	<tfoot>
   331 	<tfoot>
   281 	<tr>
   332 	<tr>
   282 		<th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></th>
   333 		<td class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></td>
   283 		<th scope="col" class="manage-column"><label for="plugins-select-all-2"><?php _e( 'Select All' ); ?></label></th>
   334 		<td class="manage-column"><label for="plugins-select-all-2"><?php _e( 'Select All' ); ?></label></td>
   284 	</tr>
   335 	</tr>
   285 	</tfoot>
   336 	</tfoot>
   286 </table>
   337 </table>
   287 <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
   338 <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
   288 </form>
   339 </form>
   289 <?php
   340 <?php
   290 }
   341 }
   291 
   342 
       
   343 /**
       
   344  * @since 2.9.0
       
   345  */
   292 function list_theme_updates() {
   346 function list_theme_updates() {
   293 	$themes = get_theme_updates();
   347 	$themes = get_theme_updates();
   294 	if ( empty( $themes ) ) {
   348 	if ( empty( $themes ) ) {
   295 		echo '<h3>' . __( 'Themes' ) . '</h3>';
   349 		echo '<h2>' . __( 'Themes' ) . '</h2>';
   296 		echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
   350 		echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
   297 		return;
   351 		return;
   298 	}
   352 	}
   299 
   353 
   300 	$form_action = 'update-core.php?action=do-theme-upgrade';
   354 	$form_action = 'update-core.php?action=do-theme-upgrade';
   301 
       
   302 ?>
   355 ?>
   303 <h3><?php _e( 'Themes' ); ?></h3>
   356 <h2><?php _e( 'Themes' ); ?></h2>
   304 <p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click &#8220;Update Themes&#8221;.' ); ?></p>
   357 <p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click &#8220;Update Themes&#8221;.' ); ?></p>
   305 <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>
   358 <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>
   306 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
   359 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
   307 <?php wp_nonce_field('upgrade-core'); ?>
   360 <?php wp_nonce_field('upgrade-core'); ?>
   308 <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
   361 <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
   309 <table class="widefat" id="update-themes-table">
   362 <table class="widefat updates-table" id="update-themes-table">
   310 	<thead>
   363 	<thead>
   311 	<tr>
   364 	<tr>
   312 		<th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th>
   365 		<td class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></td>
   313 		<th scope="col" class="manage-column"><label for="themes-select-all"><?php _e('Select All'); ?></label></th>
   366 		<td class="manage-column"><label for="themes-select-all"><?php _e( 'Select All' ); ?></label></td>
   314 	</tr>
   367 	</tr>
   315 	</thead>
   368 	</thead>
   316 
   369 
   317 	<tbody class="plugins">
   370 	<tbody class="plugins">
   318 <?php
   371 <?php
   319 	foreach ( $themes as $stylesheet => $theme ) {
   372 	foreach ( $themes as $stylesheet => $theme ) {
   320 		echo "
   373 		$checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
   321 	<tr>
   374 		?>
   322 		<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr( $stylesheet ) . "' /></th>
   375 		<tr>
   323 		<td class='plugin-title'><img src='" . esc_url( $theme->get_screenshot() ) . "' width='85' height='64' style='float:left; padding: 0 5px 5px' /><strong>" . $theme->display('Name') . '</strong> ' . sprintf( __( 'You have version %1$s installed. Update to %2$s.' ), $theme->display('Version'), $theme->update['new_version'] ) . "</td>
   376 			<td class="check-column">
   324 	</tr>";
   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>
       
   384 			</td>
       
   385 			<td class="plugin-title"><p>
       
   386 				<img src="<?php echo esc_url( $theme->get_screenshot() ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" />
       
   387 				<strong><?php echo $theme->display( 'Name' ); ?></strong>
       
   388 				<?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 				?>
       
   395 			</p></td>
       
   396 		</tr>
       
   397 		<?php
   325 	}
   398 	}
   326 ?>
   399 ?>
   327 	</tbody>
   400 	</tbody>
   328 
   401 
   329 	<tfoot>
   402 	<tfoot>
   330 	<tr>
   403 	<tr>
   331 		<th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th>
   404 		<td class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></td>
   332 		<th scope="col" class="manage-column"><label for="themes-select-all-2"><?php _e( 'Select All' ); ?></label></th>
   405 		<td class="manage-column"><label for="themes-select-all-2"><?php _e( 'Select All' ); ?></label></td>
   333 	</tr>
   406 	</tr>
   334 	</tfoot>
   407 	</tfoot>
   335 </table>
   408 </table>
   336 <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
   409 <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
   337 </form>
   410 </form>
   338 <?php
   411 <?php
   339 }
   412 }
   340 
   413 
       
   414 /**
       
   415  * @since 3.7.0
       
   416  */
   341 function list_translation_updates() {
   417 function list_translation_updates() {
   342 	$updates = wp_get_translation_updates();
   418 	$updates = wp_get_translation_updates();
   343 	if ( ! $updates ) {
   419 	if ( ! $updates ) {
   344 		if ( 'en_US' != get_locale() ) {
   420 		if ( 'en_US' != get_locale() ) {
   345 			echo '<h3>' . __( 'Translations' ) . '</h3>';
   421 			echo '<h2>' . __( 'Translations' ) . '</h2>';
   346 			echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>';
   422 			echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>';
   347 		}
   423 		}
   348 		return;
   424 		return;
   349 	}
   425 	}
   350 
   426 
   351 	$form_action = 'update-core.php?action=do-translation-upgrade';
   427 	$form_action = 'update-core.php?action=do-translation-upgrade';
   352 	?>
   428 	?>
   353 	<h3><?php _e( 'Translations' ); ?></h3>
   429 	<h2><?php _e( 'Translations' ); ?></h2>
   354 	<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-translations" class="upgrade">
   430 	<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-translations" class="upgrade">
   355 		<p><?php _e( 'New translations are available.' ); ?></p>
   431 		<p><?php _e( 'New translations are available.' ); ?></p>
   356 		<?php wp_nonce_field( 'upgrade-translations' ); ?>
   432 		<?php wp_nonce_field( 'upgrade-translations' ); ?>
   357 		<p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
   433 		<p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
   358 	</form>
   434 	</form>
   362 /**
   438 /**
   363  * Upgrade WordPress core display.
   439  * Upgrade WordPress core display.
   364  *
   440  *
   365  * @since 2.7.0
   441  * @since 2.7.0
   366  *
   442  *
   367  * @return null
   443  * @global WP_Filesystem_Base $wp_filesystem Subclass
       
   444  *
       
   445  * @param bool $reinstall
   368  */
   446  */
   369 function do_core_upgrade( $reinstall = false ) {
   447 function do_core_upgrade( $reinstall = false ) {
   370 	global $wp_filesystem;
   448 	global $wp_filesystem;
   371 
   449 
   372 	include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
   450 	include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
   387 	// that it's safe to do so. This only happens when there are no new files to create.
   465 	// that it's safe to do so. This only happens when there are no new files to create.
   388 	$allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
   466 	$allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
   389 
   467 
   390 ?>
   468 ?>
   391 	<div class="wrap">
   469 	<div class="wrap">
   392 	<h2><?php _e('Update WordPress'); ?></h2>
   470 	<h1><?php _e( 'Update WordPress' ); ?></h1>
   393 <?php
   471 <?php
   394 
   472 
   395 	if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ) ) ) {
   473 	if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ) ) ) {
   396 		echo '</div>';
   474 		echo '</div>';
   397 		return;
   475 		return;
   421 		'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership
   499 		'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership
   422 	) );
   500 	) );
   423 
   501 
   424 	if ( is_wp_error($result) ) {
   502 	if ( is_wp_error($result) ) {
   425 		show_message($result);
   503 		show_message($result);
   426 		if ('up_to_date' != $result->get_error_code() )
   504 		if ( 'up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code() )
   427 			show_message( __('Installation Failed') );
   505 			show_message( __('Installation Failed') );
   428 		echo '</div>';
   506 		echo '</div>';
   429 		return;
   507 		return;
   430 	}
   508 	}
   431 
   509 
   438 	window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
   516 	window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
   439 	</script>
   517 	</script>
   440 	<?php
   518 	<?php
   441 }
   519 }
   442 
   520 
       
   521 /**
       
   522  * @since 2.7.0
       
   523  */
   443 function do_dismiss_core_update() {
   524 function do_dismiss_core_update() {
   444 	$version = isset( $_POST['version'] )? $_POST['version'] : false;
   525 	$version = isset( $_POST['version'] )? $_POST['version'] : false;
   445 	$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
   526 	$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
   446 	$update = find_core_update( $version, $locale );
   527 	$update = find_core_update( $version, $locale );
   447 	if ( !$update )
   528 	if ( !$update )
   449 	dismiss_core_update( $update );
   530 	dismiss_core_update( $update );
   450 	wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
   531 	wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
   451 	exit;
   532 	exit;
   452 }
   533 }
   453 
   534 
       
   535 /**
       
   536  * @since 2.7.0
       
   537  */
   454 function do_undismiss_core_update() {
   538 function do_undismiss_core_update() {
   455 	$version = isset( $_POST['version'] )? $_POST['version'] : false;
   539 	$version = isset( $_POST['version'] )? $_POST['version'] : false;
   456 	$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
   540 	$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
   457 	$update = find_core_update( $version, $locale );
   541 	$update = find_core_update( $version, $locale );
   458 	if ( !$update )
   542 	if ( !$update )
   472 }
   556 }
   473 
   557 
   474 $title = __('WordPress Updates');
   558 $title = __('WordPress Updates');
   475 $parent_file = 'index.php';
   559 $parent_file = 'index.php';
   476 
   560 
   477 $updates_overview  = '<p>' . __( 'On this screen, you can update to the latest version of WordPress, as well as update your themes and plugins from the WordPress.org repositories.' ) . '</p>';
   561 $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>';
   478 $updates_overview .= '<p>' . __( 'If an update is available, you&#8127;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>';
   562 $updates_overview .= '<p>' . __( 'If an update is available, you&#8127;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>';
   479 
   563 
   480 get_current_screen()->add_help_tab( array(
   564 get_current_screen()->add_help_tab( array(
   481 	'id'      => 'overview',
   565 	'id'      => 'overview',
   482 	'title'   => __( 'Overview' ),
   566 	'title'   => __( 'Overview' ),
   496 	'content' => $updates_howto
   580 	'content' => $updates_howto
   497 ) );
   581 ) );
   498 
   582 
   499 get_current_screen()->set_help_sidebar(
   583 get_current_screen()->set_help_sidebar(
   500 	'<p><strong>' . __('For more information:') . '</strong></p>' .
   584 	'<p><strong>' . __('For more information:') . '</strong></p>' .
   501 	'<p>' . __( '<a href="https://codex.wordpress.org/Dashboard_Updates_Screen" target="_blank">Documentation on Updating WordPress</a>' ) . '</p>' .
   585 	'<p>' . __( '<a href="https://codex.wordpress.org/Dashboard_Updates_Screen">Documentation on Updating WordPress</a>' ) . '</p>' .
   502 	'<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
   586 	'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
   503 );
   587 );
   504 
   588 
   505 if ( 'upgrade-core' == $action ) {
   589 if ( 'upgrade-core' == $action ) {
   506 	// Force a update check when requested
   590 	// Force a update check when requested
   507 	$force_check = ! empty( $_GET['force-check'] );
   591 	$force_check = ! empty( $_GET['force-check'] );
   508 	wp_version_check( array(), $force_check );
   592 	wp_version_check( array(), $force_check );
   509 
   593 
   510 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   594 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   511 	?>
   595 	?>
   512 	<div class="wrap">
   596 	<div class="wrap">
   513 	<h2><?php _e('WordPress Updates'); ?></h2>
   597 	<h1><?php _e( 'WordPress Updates' ); ?></h1>
   514 	<?php
   598 	<?php
   515 	if ( $upgrade_error ) {
   599 	if ( $upgrade_error ) {
   516 		echo '<div class="error"><p>';
   600 		echo '<div class="error"><p>';
   517 		if ( $upgrade_error == 'themes' )
   601 		if ( $upgrade_error == 'themes' )
   518 			_e('Please select one or more themes to update.');
   602 			_e('Please select one or more themes to update.');
   519 		else
   603 		else
   520 			_e('Please select one or more plugins to update.');
   604 			_e('Please select one or more plugins to update.');
   521 		echo '</p></div>';
   605 		echo '</p></div>';
   522 	}
   606 	}
   523 
   607 
       
   608 	$last_update_check = false;
       
   609 	$current = get_site_transient( 'update_core' );
       
   610 
       
   611 	if ( $current && isset ( $current->last_checked ) )	{
       
   612 		$last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
       
   613 	}
       
   614 
   524 	echo '<p>';
   615 	echo '<p>';
   525 	/* translators: %1 date, %2 time. */
   616 	/* translators: %1 date, %2 time. */
   526 	printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
   617 	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 ) );
   527 	echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php?force-check=1') ) . '">' . __( 'Check Again' ) . '</a>';
   618 	echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php?force-check=1') ) . '">' . __( 'Check Again' ) . '</a>';
   528 	echo '</p>';
   619 	echo '</p>';
   529 
   620 
   530 	if ( $core = current_user_can( 'update_core' ) )
   621 	if ( current_user_can( 'update_core' ) ) {
   531 		core_upgrade_preamble();
   622 		core_upgrade_preamble();
   532 	if ( $plugins = current_user_can( 'update_plugins' ) )
   623 	}
       
   624 	if ( current_user_can( 'update_plugins' ) ) {
   533 		list_plugin_updates();
   625 		list_plugin_updates();
   534 	if ( $themes = current_user_can( 'update_themes' ) )
   626 	}
       
   627 	if ( current_user_can( 'update_themes' ) ) {
   535 		list_theme_updates();
   628 		list_theme_updates();
   536 	if ( $core || $plugins || $themes )
   629 	}
       
   630 	if ( current_user_can( 'update_languages' ) ) {
   537 		list_translation_updates();
   631 		list_translation_updates();
   538 	unset( $core, $plugins, $themes );
   632 	}
       
   633 
   539 	/**
   634 	/**
   540 	 * Fires after the core, plugin, and theme update tables.
   635 	 * Fires after the core, plugin, and theme update tables.
   541 	 *
   636 	 *
   542 	 * @since 2.9.0
   637 	 * @since 2.9.0
   543 	 */
   638 	 */
   544 	do_action( 'core_upgrade_preamble' );
   639 	do_action( 'core_upgrade_preamble' );
   545 	echo '</div>';
   640 	echo '</div>';
       
   641 
       
   642 	wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
       
   643 		'totals'  => wp_get_update_data(),
       
   644 	) );
       
   645 
   546 	include(ABSPATH . 'wp-admin/admin-footer.php');
   646 	include(ABSPATH . 'wp-admin/admin-footer.php');
   547 
   647 
   548 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
   648 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
   549 
   649 
   550 	if ( ! current_user_can( 'update_core' ) )
   650 	if ( ! current_user_can( 'update_core' ) )
   551 		wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
   651 		wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
   552 
   652 
   553 	check_admin_referer('upgrade-core');
   653 	check_admin_referer('upgrade-core');
   554 
   654 
   555 	// Do the (un)dismiss actions before headers, so that they can redirect.
   655 	// Do the (un)dismiss actions before headers, so that they can redirect.
   556 	if ( isset( $_POST['dismiss'] ) )
   656 	if ( isset( $_POST['dismiss'] ) )
   565 		$reinstall = false;
   665 		$reinstall = false;
   566 
   666 
   567 	if ( isset( $_POST['upgrade'] ) )
   667 	if ( isset( $_POST['upgrade'] ) )
   568 		do_core_upgrade($reinstall);
   668 		do_core_upgrade($reinstall);
   569 
   669 
       
   670 	wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
       
   671 		'totals'  => wp_get_update_data(),
       
   672 	) );
       
   673 
   570 	include(ABSPATH . 'wp-admin/admin-footer.php');
   674 	include(ABSPATH . 'wp-admin/admin-footer.php');
   571 
   675 
   572 } elseif ( 'do-plugin-upgrade' == $action ) {
   676 } elseif ( 'do-plugin-upgrade' == $action ) {
   573 
   677 
   574 	if ( ! current_user_can( 'update_plugins' ) )
   678 	if ( ! current_user_can( 'update_plugins' ) )
   575 		wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
   679 		wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
   576 
   680 
   577 	check_admin_referer('upgrade-core');
   681 	check_admin_referer('upgrade-core');
   578 
   682 
   579 	if ( isset( $_GET['plugins'] ) ) {
   683 	if ( isset( $_GET['plugins'] ) ) {
   580 		$plugins = explode( ',', $_GET['plugins'] );
   684 		$plugins = explode( ',', $_GET['plugins'] );
   590 
   694 
   591 	$title = __('Update Plugins');
   695 	$title = __('Update Plugins');
   592 
   696 
   593 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   697 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   594 	echo '<div class="wrap">';
   698 	echo '<div class="wrap">';
   595 	echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
   699 	echo '<h1>' . __( 'Update Plugins' ) . '</h1>';
   596 	echo '<iframe src="', $url, '" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0"></iframe>';
   700 	echo '<iframe src="', $url, '" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="' . esc_attr__( 'Update progress' ) . '"></iframe>';
   597 	echo '</div>';
   701 	echo '</div>';
       
   702 
       
   703 	wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
       
   704 		'totals'  => wp_get_update_data(),
       
   705 	) );
       
   706 
   598 	include(ABSPATH . 'wp-admin/admin-footer.php');
   707 	include(ABSPATH . 'wp-admin/admin-footer.php');
   599 
   708 
   600 } elseif ( 'do-theme-upgrade' == $action ) {
   709 } elseif ( 'do-theme-upgrade' == $action ) {
   601 
   710 
   602 	if ( ! current_user_can( 'update_themes' ) )
   711 	if ( ! current_user_can( 'update_themes' ) )
   603 		wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
   712 		wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
   604 
   713 
   605 	check_admin_referer('upgrade-core');
   714 	check_admin_referer('upgrade-core');
   606 
   715 
   607 	if ( isset( $_GET['themes'] ) ) {
   716 	if ( isset( $_GET['themes'] ) ) {
   608 		$themes = explode( ',', $_GET['themes'] );
   717 		$themes = explode( ',', $_GET['themes'] );
   619 	$title = __('Update Themes');
   728 	$title = __('Update Themes');
   620 
   729 
   621 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   730 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   622 	?>
   731 	?>
   623 	<div class="wrap">
   732 	<div class="wrap">
   624 		<h2><?php echo esc_html__('Update Themes') ?></h2>
   733 		<h1><?php _e( 'Update Themes' ); ?></h1>
   625 		<iframe src="<?php echo $url ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0"></iframe>
   734 		<iframe src="<?php echo $url ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe>
   626 	</div>
   735 	</div>
   627 	<?php
   736 	<?php
       
   737 
       
   738 	wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
       
   739 		'totals'  => wp_get_update_data(),
       
   740 	) );
       
   741 
   628 	include(ABSPATH . 'wp-admin/admin-footer.php');
   742 	include(ABSPATH . 'wp-admin/admin-footer.php');
   629 
   743 
   630 } elseif ( 'do-translation-upgrade' == $action ) {
   744 } elseif ( 'do-translation-upgrade' == $action ) {
   631 
   745 
   632 	if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_themes' ) )
   746 	if ( ! current_user_can( 'update_languages' ) )
   633 		wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
   747 		wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
   634 
   748 
   635 	check_admin_referer( 'upgrade-translations' );
   749 	check_admin_referer( 'upgrade-translations' );
   636 
   750 
   637 	require_once( ABSPATH . 'wp-admin/admin-header.php' );
   751 	require_once( ABSPATH . 'wp-admin/admin-header.php' );
   638 	include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
   752 	include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
   642 	$title = __( 'Update Translations' );
   756 	$title = __( 'Update Translations' );
   643 	$context = WP_LANG_DIR;
   757 	$context = WP_LANG_DIR;
   644 
   758 
   645 	$upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
   759 	$upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
   646 	$result = $upgrader->bulk_upgrade();
   760 	$result = $upgrader->bulk_upgrade();
       
   761 
       
   762 	wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
       
   763 		'totals'  => wp_get_update_data(),
       
   764 	) );
   647 
   765 
   648 	require_once( ABSPATH . 'wp-admin/admin-footer.php' );
   766 	require_once( ABSPATH . 'wp-admin/admin-footer.php' );
   649 
   767 
   650 } else {
   768 } else {
   651 	/**
   769 	/**