wp/wp-admin/update-core.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    40 	$wp_version     = get_bloginfo( 'version' );
    40 	$wp_version     = get_bloginfo( 'version' );
    41 	$version_string = sprintf( '%s–%s', $update->current, get_locale() );
    41 	$version_string = sprintf( '%s–%s', $update->current, get_locale() );
    42 
    42 
    43 	if ( 'en_US' === $update->locale && 'en_US' === get_locale() ) {
    43 	if ( 'en_US' === $update->locale && 'en_US' === get_locale() ) {
    44 		$version_string = $update->current;
    44 		$version_string = $update->current;
    45 	} elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version == $update->partial_version ) {
    45 	} elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version === $update->partial_version ) {
    46 		$updates = get_core_updates();
    46 		$updates = get_core_updates();
    47 		if ( $updates && 1 === count( $updates ) ) {
    47 		if ( $updates && 1 === count( $updates ) ) {
    48 			// If the only available update is a partial builds, it doesn't need a language-specific version string.
    48 			// If the only available update is a partial builds, it doesn't need a language-specific version string.
    49 			$version_string = $update->current;
    49 			$version_string = $update->current;
    50 		}
    50 		}
    57 		$current = true;
    57 		$current = true;
    58 	}
    58 	}
    59 
    59 
    60 	$message       = '';
    60 	$message       = '';
    61 	$form_action   = 'update-core.php?action=do-core-upgrade';
    61 	$form_action   = 'update-core.php?action=do-core-upgrade';
    62 	$php_version   = phpversion();
    62 	$php_version   = PHP_VERSION;
    63 	$mysql_version = $wpdb->db_version();
    63 	$mysql_version = $wpdb->db_version();
    64 	$show_buttons  = true;
    64 	$show_buttons  = true;
    65 
    65 
    66 	// Nightly build versions have two hyphens and a commit number.
    66 	// Nightly build versions have two hyphens and a commit number.
    67 	if ( preg_match( '/-\w+-\d+/', $update->current ) ) {
    67 	if ( preg_match( '/-\w+-\d+/', $update->current ) ) {
    89 				$mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' );
    89 				$mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' );
    90 			}
    90 			}
    91 
    91 
    92 			$version_url = sprintf(
    92 			$version_url = sprintf(
    93 				/* translators: %s: WordPress version. */
    93 				/* translators: %s: WordPress version. */
    94 				esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ),
    94 				esc_url( __( 'https://wordpress.org/documentation/wordpress-version/version-%s/' ) ),
    95 				sanitize_title( $update->current )
    95 				sanitize_title( $update->current )
    96 			);
    96 			);
    97 
    97 
    98 			$php_update_message = '</p><p>' . sprintf(
    98 			$php_update_message = '</p><p>' . sprintf(
    99 				/* translators: %s: URL to Update PHP page. */
    99 				/* translators: %s: URL to Update PHP page. */
   177 			submit_button( __( 'Bring back this update' ), '', 'undismiss', false );
   177 			submit_button( __( 'Bring back this update' ), '', 'undismiss', false );
   178 		}
   178 		}
   179 	}
   179 	}
   180 	echo '</p>';
   180 	echo '</p>';
   181 
   181 
   182 	if ( 'en_US' !== $update->locale && ( ! isset( $wp_local_package ) || $wp_local_package != $update->locale ) ) {
   182 	if ( 'en_US' !== $update->locale && ( ! isset( $wp_local_package ) || $wp_local_package !== $update->locale ) ) {
   183 		echo '<p class="hint">' . __( 'This localized version contains both the translation and various other localization fixes.' ) . '</p>';
   183 		echo '<p class="hint">' . __( 'This localized version contains both the translation and various other localization fixes.' ) . '</p>';
   184 	} elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) {
   184 	} elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() && ( ! $update->packages->partial && $wp_version === $update->partial_version ) ) {
   185 		// Partial builds don't need language-specific warnings.
   185 		// Partial builds don't need language-specific warnings.
   186 		echo '<p class="hint">' . sprintf(
   186 		echo '<p class="hint">' . sprintf(
   187 			/* translators: %s: WordPress version. */
   187 			/* translators: %s: WordPress version. */
   188 			__( '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.' ),
   188 			__( '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.' ),
   189 			'development' !== $update->response ? $update->current : ''
   189 			'development' !== $update->response ? $update->current : ''
   190 		) . '</p>';
   190 		) . '</p>';
   191 	}
   191 	}
   192 
   192 
   193 	echo '</form>';
   193 	echo '</form>';
   194 
       
   195 }
   194 }
   196 
   195 
   197 /**
   196 /**
   198  * Display dismissed updates.
   197  * Display dismissed updates.
   199  *
   198  *
   240 
   239 
   241 /**
   240 /**
   242  * Display upgrade WordPress for downloading latest or upgrading automatically form.
   241  * Display upgrade WordPress for downloading latest or upgrading automatically form.
   243  *
   242  *
   244  * @since 2.7.0
   243  * @since 2.7.0
   245  *
       
   246  * @global string $required_php_version   The required PHP version string.
       
   247  * @global string $required_mysql_version The required MySQL version string.
       
   248  */
   244  */
   249 function core_upgrade_preamble() {
   245 function core_upgrade_preamble() {
   250 	global $required_php_version, $required_mysql_version;
       
   251 
       
   252 	$updates = get_core_updates();
   246 	$updates = get_core_updates();
   253 
   247 
   254 	// Include an unmodified $wp_version.
   248 	// Include an unmodified $wp_version.
   255 	require ABSPATH . WPINC . '/version.php';
   249 	require ABSPATH . WPINC . '/version.php';
   256 
   250 
   259 	if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
   253 	if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
   260 		echo '<h2 class="response">';
   254 		echo '<h2 class="response">';
   261 		_e( 'An updated version of WordPress is available.' );
   255 		_e( 'An updated version of WordPress is available.' );
   262 		echo '</h2>';
   256 		echo '</h2>';
   263 
   257 
   264 		echo '<div class="notice notice-warning inline"><p>';
   258 		$message = sprintf(
   265 		printf(
       
   266 			/* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */
   259 			/* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */
   267 			__( '<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.' ),
   260 			__( '<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.' ),
   268 			__( 'https://wordpress.org/support/article/wordpress-backups/' ),
   261 			__( 'https://developer.wordpress.org/advanced-administration/security/backup/' ),
   269 			__( 'https://wordpress.org/support/article/updating-wordpress/' )
   262 			__( 'https://wordpress.org/documentation/article/updating-wordpress/' )
   270 		);
   263 		);
   271 		echo '</p></div>';
   264 		wp_admin_notice(
       
   265 			$message,
       
   266 			array(
       
   267 				'type'               => 'warning',
       
   268 				'additional_classes' => array( 'inline' ),
       
   269 			)
       
   270 		);
   272 	} elseif ( $is_development_version ) {
   271 	} elseif ( $is_development_version ) {
   273 		echo '<h2 class="response">' . __( 'You are using a development version of WordPress.' ) . '</h2>';
   272 		echo '<h2 class="response">' . __( 'You are using a development version of WordPress.' ) . '</h2>';
   274 	} else {
   273 	} else {
   275 		echo '<h2 class="response">' . __( 'You have the latest version of WordPress.' ) . '</h2>';
   274 		echo '<h2 class="response">' . __( 'You have the latest version of WordPress.' ) . '</h2>';
   276 	}
   275 	}
   306  */
   305  */
   307 function core_auto_updates_settings() {
   306 function core_auto_updates_settings() {
   308 	if ( isset( $_GET['core-major-auto-updates-saved'] ) ) {
   307 	if ( isset( $_GET['core-major-auto-updates-saved'] ) ) {
   309 		if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) {
   308 		if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) {
   310 			$notice_text = __( 'Automatic updates for all WordPress versions have been enabled. Thank you!' );
   309 			$notice_text = __( 'Automatic updates for all WordPress versions have been enabled. Thank you!' );
   311 			echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>';
   310 			wp_admin_notice(
       
   311 				$notice_text,
       
   312 				array(
       
   313 					'type'        => 'success',
       
   314 					'dismissible' => true,
       
   315 				)
       
   316 			);
   312 		} elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) {
   317 		} elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) {
   313 			$notice_text = __( 'WordPress will only receive automatic security and maintenance releases from now on.' );
   318 			$notice_text = __( 'WordPress will only receive automatic security and maintenance releases from now on.' );
   314 			echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>';
   319 			wp_admin_notice(
       
   320 				$notice_text,
       
   321 				array(
       
   322 					'type'        => 'success',
       
   323 					'dismissible' => true,
       
   324 				)
       
   325 			);
   315 		}
   326 		}
   316 	}
   327 	}
   317 
   328 
   318 	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
   329 	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
   319 	$updater = new WP_Automatic_Updater();
   330 	$updater = new WP_Automatic_Updater();
   400 			_e( 'This site appears to be under version control. Automatic updates are disabled.' );
   411 			_e( 'This site appears to be under version control. Automatic updates are disabled.' );
   401 		} elseif ( $upgrade_major ) {
   412 		} elseif ( $upgrade_major ) {
   402 			_e( 'This site is automatically kept up to date with each new version of WordPress.' );
   413 			_e( 'This site is automatically kept up to date with each new version of WordPress.' );
   403 
   414 
   404 			if ( $can_set_update_option ) {
   415 			if ( $can_set_update_option ) {
   405 				echo '<br>';
   416 				echo '<br />';
   406 				printf(
   417 				printf(
   407 					'<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-disable">%s</a>',
   418 					'<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-disable">%s</a>',
   408 					wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' ),
   419 					wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' ),
   409 					__( 'Switch to automatic updates for maintenance and security releases only.' )
   420 					__( 'Switch to automatic updates for maintenance and security releases only.' )
   410 				);
   421 				);
   411 			}
   422 			}
   412 		} elseif ( $upgrade_minor ) {
   423 		} elseif ( $upgrade_minor ) {
   413 			_e( 'This site is automatically kept up to date with maintenance and security releases of WordPress only.' );
   424 			_e( 'This site is automatically kept up to date with maintenance and security releases of WordPress only.' );
   414 
   425 
   415 			if ( $can_set_update_option ) {
   426 			if ( $can_set_update_option ) {
   416 				echo '<br>';
   427 				echo '<br />';
   417 				printf(
   428 				printf(
   418 					'<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-enable">%s</a>',
   429 					'<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-enable">%s</a>',
   419 					wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' ),
   430 					wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' ),
   420 					__( 'Enable automatic updates for all new versions of WordPress.' )
   431 					__( 'Enable automatic updates for all new versions of WordPress.' )
   421 				);
   432 				);
   533 
   544 
   534 		$requires_php   = isset( $plugin_data->update->requires_php ) ? $plugin_data->update->requires_php : null;
   545 		$requires_php   = isset( $plugin_data->update->requires_php ) ? $plugin_data->update->requires_php : null;
   535 		$compatible_php = is_php_version_compatible( $requires_php );
   546 		$compatible_php = is_php_version_compatible( $requires_php );
   536 
   547 
   537 		if ( ! $compatible_php && current_user_can( 'update_php' ) ) {
   548 		if ( ! $compatible_php && current_user_can( 'update_php' ) ) {
   538 			$compat .= '<br>' . __( 'This update does not work with your version of PHP.' ) . '&nbsp;';
   549 			$compat .= '<br />' . __( 'This update does not work with your version of PHP.' ) . '&nbsp;';
   539 			$compat .= sprintf(
   550 			$compat .= sprintf(
   540 				/* translators: %s: URL to Update PHP page. */
   551 				/* translators: %s: URL to Update PHP page. */
   541 				__( '<a href="%s">Learn more about updating PHP</a>.' ),
   552 				__( '<a href="%s">Learn more about updating PHP</a>.' ),
   542 				esc_url( wp_get_update_php_url() )
   553 				esc_url( wp_get_update_php_url() )
   543 			);
   554 			);
   570 		?>
   581 		?>
   571 	<tr>
   582 	<tr>
   572 		<td class="check-column">
   583 		<td class="check-column">
   573 			<?php if ( $compatible_php ) : ?>
   584 			<?php if ( $compatible_php ) : ?>
   574 				<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" />
   585 				<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" />
   575 				<label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
   586 				<label for="<?php echo $checkbox_id; ?>">
       
   587 					<span class="screen-reader-text">
   576 					<?php
   588 					<?php
   577 					/* translators: %s: Plugin name. */
   589 					/* translators: Hidden accessibility text. %s: Plugin name. */
   578 					printf( __( 'Select %s' ), $plugin_data->Name );
   590 					printf( __( 'Select %s' ), $plugin_data->Name );
   579 					?>
   591 					?>
       
   592 					</span>
   580 				</label>
   593 				</label>
   581 			<?php endif; ?>
   594 			<?php endif; ?>
   582 		</td>
   595 		</td>
   583 		<td class="plugin-title"><p>
   596 		<td class="plugin-title"><p>
   584 			<?php echo $icon; ?>
   597 			<?php echo $icon; ?>
   589 				__( 'You have version %1$s installed. Update to %2$s.' ),
   602 				__( 'You have version %1$s installed. Update to %2$s.' ),
   590 				$plugin_data->Version,
   603 				$plugin_data->Version,
   591 				$plugin_data->update->new_version
   604 				$plugin_data->update->new_version
   592 			);
   605 			);
   593 
   606 
   594 			echo ' ' . $details . $compat . $upgrade_notice;
   607 			echo ' ' . $details . $compat;
   595 
   608 
   596 			if ( in_array( $plugin_file, $auto_updates, true ) ) {
   609 			if ( in_array( $plugin_file, $auto_updates, true ) ) {
   597 				echo $auto_update_notice;
   610 				echo $auto_update_notice;
   598 			}
   611 			}
       
   612 
       
   613 			echo $upgrade_notice;
   599 			?>
   614 			?>
   600 		</p></td>
   615 		</p></td>
   601 	</tr>
   616 	</tr>
   602 			<?php
   617 			<?php
   603 	}
   618 	}
   679 		$compatible_php = is_php_version_compatible( $requires_php );
   694 		$compatible_php = is_php_version_compatible( $requires_php );
   680 
   695 
   681 		$compat = '';
   696 		$compat = '';
   682 
   697 
   683 		if ( ! $compatible_wp && ! $compatible_php ) {
   698 		if ( ! $compatible_wp && ! $compatible_php ) {
   684 			$compat .= '<br>' . __( 'This update does not work with your versions of WordPress and PHP.' ) . '&nbsp;';
   699 			$compat .= '<br />' . __( 'This update does not work with your versions of WordPress and PHP.' ) . '&nbsp;';
   685 			if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
   700 			if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
   686 				$compat .= sprintf(
   701 				$compat .= sprintf(
   687 					/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
   702 					/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
   688 					__( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
   703 					__( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
   689 					self_admin_url( 'update-core.php' ),
   704 					esc_url( self_admin_url( 'update-core.php' ) ),
   690 					esc_url( wp_get_update_php_url() )
   705 					esc_url( wp_get_update_php_url() )
   691 				);
   706 				);
   692 
   707 
   693 				$annotation = wp_get_update_php_annotation();
   708 				$annotation = wp_get_update_php_annotation();
   694 
   709 
   697 				}
   712 				}
   698 			} elseif ( current_user_can( 'update_core' ) ) {
   713 			} elseif ( current_user_can( 'update_core' ) ) {
   699 				$compat .= sprintf(
   714 				$compat .= sprintf(
   700 					/* translators: %s: URL to WordPress Updates screen. */
   715 					/* translators: %s: URL to WordPress Updates screen. */
   701 					__( '<a href="%s">Please update WordPress</a>.' ),
   716 					__( '<a href="%s">Please update WordPress</a>.' ),
   702 					self_admin_url( 'update-core.php' )
   717 					esc_url( self_admin_url( 'update-core.php' ) )
   703 				);
   718 				);
   704 			} elseif ( current_user_can( 'update_php' ) ) {
   719 			} elseif ( current_user_can( 'update_php' ) ) {
   705 				$compat .= sprintf(
   720 				$compat .= sprintf(
   706 					/* translators: %s: URL to Update PHP page. */
   721 					/* translators: %s: URL to Update PHP page. */
   707 					__( '<a href="%s">Learn more about updating PHP</a>.' ),
   722 					__( '<a href="%s">Learn more about updating PHP</a>.' ),
   713 				if ( $annotation ) {
   728 				if ( $annotation ) {
   714 					$compat .= '</p><p><em>' . $annotation . '</em>';
   729 					$compat .= '</p><p><em>' . $annotation . '</em>';
   715 				}
   730 				}
   716 			}
   731 			}
   717 		} elseif ( ! $compatible_wp ) {
   732 		} elseif ( ! $compatible_wp ) {
   718 			$compat .= '<br>' . __( 'This update does not work with your version of WordPress.' ) . '&nbsp;';
   733 			$compat .= '<br />' . __( 'This update does not work with your version of WordPress.' ) . '&nbsp;';
   719 			if ( current_user_can( 'update_core' ) ) {
   734 			if ( current_user_can( 'update_core' ) ) {
   720 				$compat .= sprintf(
   735 				$compat .= sprintf(
   721 					/* translators: %s: URL to WordPress Updates screen. */
   736 					/* translators: %s: URL to WordPress Updates screen. */
   722 					__( '<a href="%s">Please update WordPress</a>.' ),
   737 					__( '<a href="%s">Please update WordPress</a>.' ),
   723 					self_admin_url( 'update-core.php' )
   738 					esc_url( self_admin_url( 'update-core.php' ) )
   724 				);
   739 				);
   725 			}
   740 			}
   726 		} elseif ( ! $compatible_php ) {
   741 		} elseif ( ! $compatible_php ) {
   727 			$compat .= '<br>' . __( 'This update does not work with your version of PHP.' ) . '&nbsp;';
   742 			$compat .= '<br />' . __( 'This update does not work with your version of PHP.' ) . '&nbsp;';
   728 			if ( current_user_can( 'update_php' ) ) {
   743 			if ( current_user_can( 'update_php' ) ) {
   729 				$compat .= sprintf(
   744 				$compat .= sprintf(
   730 					/* translators: %s: URL to Update PHP page. */
   745 					/* translators: %s: URL to Update PHP page. */
   731 					__( '<a href="%s">Learn more about updating PHP</a>.' ),
   746 					__( '<a href="%s">Learn more about updating PHP</a>.' ),
   732 					esc_url( wp_get_update_php_url() )
   747 					esc_url( wp_get_update_php_url() )
   744 		?>
   759 		?>
   745 	<tr>
   760 	<tr>
   746 		<td class="check-column">
   761 		<td class="check-column">
   747 			<?php if ( $compatible_wp && $compatible_php ) : ?>
   762 			<?php if ( $compatible_wp && $compatible_php ) : ?>
   748 				<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
   763 				<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
   749 				<label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
   764 				<label for="<?php echo $checkbox_id; ?>">
       
   765 					<span class="screen-reader-text">
   750 					<?php
   766 					<?php
   751 					/* translators: %s: Theme name. */
   767 					/* translators: Hidden accessibility text. %s: Theme name. */
   752 					printf( __( 'Select %s' ), $theme->display( 'Name' ) );
   768 					printf( __( 'Select %s' ), $theme->display( 'Name' ) );
   753 					?>
   769 					?>
       
   770 					</span>
   754 				</label>
   771 				</label>
   755 			<?php endif; ?>
   772 			<?php endif; ?>
   756 		</td>
   773 		</td>
   757 		<td class="plugin-title"><p>
   774 		<td class="plugin-title"><p>
   758 			<img src="<?php echo esc_url( $theme->get_screenshot() . '?ver=' . $theme->version ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" />
   775 			<img src="<?php echo esc_url( $theme->get_screenshot() . '?ver=' . $theme->version ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" />
   815 	</form>
   832 	</form>
   816 	<?php
   833 	<?php
   817 }
   834 }
   818 
   835 
   819 /**
   836 /**
   820  * Upgrade WordPress core display.
   837  * Upgrades WordPress core display.
   821  *
   838  *
   822  * @since 2.7.0
   839  * @since 2.7.0
   823  *
   840  *
   824  * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
   841  * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
   825  *
   842  *
   842 	$update  = find_core_update( $version, $locale );
   859 	$update  = find_core_update( $version, $locale );
   843 	if ( ! $update ) {
   860 	if ( ! $update ) {
   844 		return;
   861 		return;
   845 	}
   862 	}
   846 
   863 
   847 	// Allow relaxed file ownership writes for User-initiated upgrades when the API specifies
   864 	/*
   848 	// that it's safe to do so. This only happens when there are no new files to create.
   865 	 * Allow relaxed file ownership writes for User-initiated upgrades when the API specifies
       
   866 	 * that it's safe to do so. This only happens when there are no new files to create.
       
   867 	 */
   849 	$allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
   868 	$allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
   850 
   869 
   851 	?>
   870 	?>
   852 	<div class="wrap">
   871 	<div class="wrap">
   853 	<h1><?php _e( 'Update WordPress' ); ?></h1>
   872 	<h1><?php _e( 'Update WordPress' ); ?></h1>
   888 		)
   907 		)
   889 	);
   908 	);
   890 
   909 
   891 	if ( is_wp_error( $result ) ) {
   910 	if ( is_wp_error( $result ) ) {
   892 		show_message( $result );
   911 		show_message( $result );
   893 		if ( 'up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code() ) {
   912 		if ( 'up_to_date' !== $result->get_error_code() && 'locked' !== $result->get_error_code() ) {
   894 			show_message( __( 'Installation failed.' ) );
   913 			show_message( __( 'Installation failed.' ) );
   895 		}
   914 		}
   896 		echo '</div>';
   915 		echo '</div>';
   897 		return;
   916 		return;
   898 	}
   917 	}
   915 		) . '</span>'
   934 		) . '</span>'
   916 	);
   935 	);
   917 	?>
   936 	?>
   918 	</div>
   937 	</div>
   919 	<script type="text/javascript">
   938 	<script type="text/javascript">
   920 	window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
   939 	window.location = '<?php echo esc_url( self_admin_url( 'about.php?updated' ) ); ?>';
   921 	</script>
   940 	</script>
   922 	<?php
   941 	<?php
   923 }
   942 }
   924 
   943 
   925 /**
   944 /**
  1006 			'title'   => __( 'Auto-updates' ),
  1025 			'title'   => __( 'Auto-updates' ),
  1007 			'content' => $help_tab_autoupdates,
  1026 			'content' => $help_tab_autoupdates,
  1008 		)
  1027 		)
  1009 	);
  1028 	);
  1010 
  1029 
  1011 	$help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-themes-auto-updates/">Learn more: Auto-updates documentation</a>' ) . '</p>';
  1030 	$help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/documentation/article/plugins-themes-auto-updates/">Documentation on Auto-updates</a>' ) . '</p>';
       
  1031 }
       
  1032 
       
  1033 $help_sidebar_rollback = '';
       
  1034 
       
  1035 if ( current_user_can( 'update_themes' ) || current_user_can( 'update_plugins' ) ) {
       
  1036 	$rollback_help = '<p>' . __( 'This feature will create a temporary backup of a plugin or theme before it is upgraded. This backup is used to restore the plugin or theme back to its previous state if there is an error during the update process.' ) . '</p>';
       
  1037 
       
  1038 	$rollback_help .= '<p>' . __( 'On systems with fewer resources, this may lead to server timeouts or resource limits being reached. If you encounter an issue during the update process, please create a support forum topic and reference <strong>Rollback</strong> in the issue title.' ) . '</p>';
       
  1039 
       
  1040 	get_current_screen()->add_help_tab(
       
  1041 		array(
       
  1042 			'id'      => 'rollback-plugins-themes',
       
  1043 			'title'   => __( 'Restore Plugin or Theme' ),
       
  1044 			'content' => $rollback_help,
       
  1045 		)
       
  1046 	);
       
  1047 
       
  1048 	$help_sidebar_rollback = '<p>' . __( '<a href="https://developer.wordpress.org/advanced-administration/wordpress/common-errors/">Common Errors</a>' ) . '</p>';
  1012 }
  1049 }
  1013 
  1050 
  1014 get_current_screen()->set_help_sidebar(
  1051 get_current_screen()->set_help_sidebar(
  1015 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  1052 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  1016 	'<p>' . __( '<a href="https://wordpress.org/support/article/dashboard-updates-screen/">Documentation on Updating WordPress</a>' ) . '</p>' .
  1053 	'<p>' . __( '<a href="https://wordpress.org/documentation/article/dashboard-updates-screen/">Documentation on Updating WordPress</a>' ) . '</p>' .
  1017 	$help_sidebar_autoupdates .
  1054 	$help_sidebar_autoupdates .
  1018 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
  1055 	'<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' .
       
  1056 	$help_sidebar_rollback
  1019 );
  1057 );
  1020 
  1058 
  1021 if ( 'upgrade-core' === $action ) {
  1059 if ( 'upgrade-core' === $action ) {
  1022 	// Force a update check when requested.
  1060 	// Force an update check when requested.
  1023 	$force_check = ! empty( $_GET['force-check'] );
  1061 	$force_check = ! empty( $_GET['force-check'] );
  1024 	wp_version_check( array(), $force_check );
  1062 	wp_version_check( array(), $force_check );
  1025 
  1063 
  1026 	require_once ABSPATH . 'wp-admin/admin-header.php';
  1064 	require_once ABSPATH . 'wp-admin/admin-header.php';
  1027 	?>
  1065 	?>
  1028 	<div class="wrap">
  1066 	<div class="wrap">
  1029 	<h1><?php _e( 'WordPress Updates' ); ?></h1>
  1067 	<h1><?php _e( 'WordPress Updates' ); ?></h1>
  1030 	<p><?php _e( 'Here you can find information about updates, set auto-updates and see what plugins or themes need updating.' ); ?></p>
  1068 	<p><?php _e( 'Updates may take several minutes to complete. If there is no feedback after 5 minutes, or if there are errors please refer to the Help section above.' ); ?></p>
  1031 
  1069 
  1032 	<?php
  1070 	<?php
  1033 	if ( $upgrade_error ) {
  1071 	if ( $upgrade_error ) {
  1034 		echo '<div class="error"><p>';
       
  1035 		if ( 'themes' === $upgrade_error ) {
  1072 		if ( 'themes' === $upgrade_error ) {
  1036 			_e( 'Please select one or more themes to update.' );
  1073 			$theme_updates = get_theme_updates();
       
  1074 			if ( ! empty( $theme_updates ) ) {
       
  1075 				wp_admin_notice(
       
  1076 					__( 'Please select one or more themes to update.' ),
       
  1077 					array(
       
  1078 						'additional_classes' => array( 'error' ),
       
  1079 					)
       
  1080 				);
       
  1081 			}
  1037 		} else {
  1082 		} else {
  1038 			_e( 'Please select one or more plugins to update.' );
  1083 			$plugin_updates = get_plugin_updates();
  1039 		}
  1084 			if ( ! empty( $plugin_updates ) ) {
  1040 		echo '</p></div>';
  1085 				wp_admin_notice(
       
  1086 					__( 'Please select one or more plugins to update.' ),
       
  1087 					array(
       
  1088 						'additional_classes' => array( 'error' ),
       
  1089 					)
       
  1090 				);
       
  1091 			}
       
  1092 		}
  1041 	}
  1093 	}
  1042 
  1094 
  1043 	$last_update_check = false;
  1095 	$last_update_check = false;
  1044 	$current           = get_site_transient( 'update_core' );
  1096 	$current           = get_site_transient( 'update_core' );
  1045 
  1097 
  1051 	/* translators: Current version of WordPress. */
  1103 	/* translators: Current version of WordPress. */
  1052 	printf( __( 'Current version: %s' ), get_bloginfo( 'version' ) );
  1104 	printf( __( 'Current version: %s' ), get_bloginfo( 'version' ) );
  1053 	echo '</h2>';
  1105 	echo '</h2>';
  1054 
  1106 
  1055 	echo '<p class="update-last-checked">';
  1107 	echo '<p class="update-last-checked">';
  1056 	/* translators: 1: Date, 2: Time. */
  1108 
  1057 	printf( __( 'Last checked on %1$s at %2$s.' ), date_i18n( __( 'F j, Y' ), $last_update_check ), date_i18n( __( 'g:i a T' ), $last_update_check ) );
  1109 	printf(
       
  1110 		/* translators: 1: Date, 2: Time. */
       
  1111 		__( 'Last checked on %1$s at %2$s.' ),
       
  1112 		/* translators: Last update date format. See https://www.php.net/manual/datetime.format.php */
       
  1113 		date_i18n( __( 'F j, Y' ), $last_update_check ),
       
  1114 		/* translators: Last update time format. See https://www.php.net/manual/datetime.format.php */
       
  1115 		date_i18n( __( 'g:i a T' ), $last_update_check )
       
  1116 	);
  1058 	echo ' <a href="' . esc_url( self_admin_url( 'update-core.php?force-check=1' ) ) . '">' . __( 'Check again.' ) . '</a>';
  1117 	echo ' <a href="' . esc_url( self_admin_url( 'update-core.php?force-check=1' ) ) . '">' . __( 'Check again.' ) . '</a>';
  1059 	echo '</p>';
  1118 	echo '</p>';
  1060 
  1119 
  1061 	if ( current_user_can( 'update_core' ) ) {
  1120 	if ( current_user_can( 'update_core' ) ) {
  1062 		core_auto_updates_settings();
  1121 		core_auto_updates_settings();