diff --git a/wp-admin/includes/class-wp-site-health.php b/wp-admin/includes/class-wp-site-health.php index 9d3a455f23..c2f10fa72d 100644 --- a/wp-admin/includes/class-wp-site-health.php +++ b/wp-admin/includes/class-wp-site-health.php @@ -1502,6 +1502,8 @@ class WP_Site_Health { // always rely on the latest results. wp_update_https_detection_errors(); + $default_update_url = wp_get_default_update_https_url(); + $result = array( 'label' => __( 'Your website is using an active HTTPS connection' ), 'status' => 'good', @@ -1514,9 +1516,8 @@ class WP_Site_Health { __( 'An HTTPS connection is a more secure way of browsing the web. Many services now have HTTPS as a requirement. HTTPS allows you to take advantage of new features that can increase site speed, improve search rankings, and gain the trust of your visitors by helping to protect their online privacy.' ) ), 'actions' => sprintf( - '
', - /* translators: Documentation explaining HTTPS and why it should be used. */ - esc_url( __( 'https://wordpress.org/support/article/why-should-i-use-https/' ) ), + '', + esc_url( $default_update_url ), __( 'Learn more about why you should use HTTPS' ), /* translators: Accessibility text. */ __( '(opens in a new tab)' ) @@ -1580,16 +1581,54 @@ class WP_Site_Health { __( 'HTTPS is already supported for your website.' ) ); - $result['actions'] = sprintf( - '', - esc_url( admin_url( 'options-general.php' ) ), - __( 'Update your site addresses' ) - ); + if ( defined( 'WP_HOME' ) || defined( 'WP_SITEURL' ) ) { + $result['description'] .= sprintf( + '%s
', + sprintf( + /* translators: 1: wp-config.php, 2: WP_HOME, 3: WP_SITEURL */ + __( 'However, your WordPress Address is currently controlled by a PHP constant and therefore cannot be updated. You need to edit your %1$s and remove or update the definitions of %2$s and %3$s.' ), + 'wp-config.php
',
+ 'WP_HOME
',
+ 'WP_SITEURL
'
+ )
+ );
+ } elseif ( current_user_can( 'update_https' ) ) {
+ $default_direct_update_url = add_query_arg( 'action', 'update_https', wp_nonce_url( admin_url( 'site-health.php' ), 'wp_update_https' ) );
+ $direct_update_url = wp_get_direct_update_https_url();
+
+ if ( ! empty( $direct_update_url ) ) {
+ $result['actions'] = sprintf(
+ ' ',
+ esc_url( $direct_update_url ),
+ __( 'Update your site to use HTTPS' ),
+ /* translators: Accessibility text. */
+ __( '(opens in a new tab)' )
+ );
+ } else {
+ $result['actions'] = sprintf(
+ ' ',
+ esc_url( $default_direct_update_url ),
+ __( 'Update your site to use HTTPS' )
+ );
+ }
+ }
} else {
- $result['description'] .= sprintf(
- '%s
', - __( 'Talk to your web host about supporting HTTPS for your website.' ) - ); + // If host-specific "Update HTTPS" URL is provided, include a link. + $update_url = wp_get_update_https_url(); + if ( $update_url !== $default_update_url ) { + $result['description'] .= sprintf( + '', + esc_url( $update_url ), + __( 'Talk to your web host about supporting HTTPS for your website.' ), + /* translators: Accessibility text. */ + __( '(opens in a new tab)' ) + ); + } else { + $result['description'] .= sprintf( + '%s
', + __( 'Talk to your web host about supporting HTTPS for your website.' ) + ); + } } } elseif ( ! wp_is_https_supported() ) { // If the website is using HTTPS, but HTTPS is actually not supported, inform the user about the potential diff --git a/wp-admin/site-health.php b/wp-admin/site-health.php index b7cc728ef6..be81b957b3 100644 --- a/wp-admin/site-health.php +++ b/wp-admin/site-health.php @@ -14,6 +14,8 @@ if ( isset( $_GET['tab'] ) && 'debug' === $_GET['tab'] ) { /** WordPress Administration Bootstrap */ require_once __DIR__ . '/admin.php'; +wp_reset_vars( array( 'action' ) ); + $title = __( 'Site Health Status' ); if ( ! current_user_can( 'view_site_health_checks' ) ) { @@ -27,6 +29,23 @@ if ( ! class_exists( 'WP_Site_Health' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; } +if ( 'update_https' === $action ) { + check_admin_referer( 'wp_update_https' ); + + if ( ! current_user_can( 'update_https' ) ) { + wp_die( __( 'Sorry, you are not allowed to update this site to HTTPS.' ), 403 ); + } + + if ( ! wp_is_https_supported() ) { + wp_die( __( 'It looks like HTTPS is not supported for your website at this point.' ) ); + } + + $result = wp_update_urls_to_https(); + + wp_redirect( add_query_arg( 'https_updated', (int) $result, wp_get_referer() ) ); + exit; +} + $health_check_site_status = WP_Site_Health::get_instance(); // Start by checking if this is a special request checking for the existence of certain filters. @@ -41,6 +60,20 @@ require_once ABSPATH . 'wp-admin/admin-header.php'; + +