wp/wp-admin/includes/class-wp-site-health.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
   262 			'description' => '',
   262 			'description' => '',
   263 			'actions'     => '',
   263 			'actions'     => '',
   264 			'test'        => 'wordpress_version',
   264 			'test'        => 'wordpress_version',
   265 		);
   265 		);
   266 
   266 
   267 		$core_current_version = get_bloginfo( 'version' );
   267 		$core_current_version = wp_get_wp_version();
   268 		$core_updates         = get_core_updates();
   268 		$core_updates         = get_core_updates();
   269 
   269 
   270 		if ( ! is_array( $core_updates ) ) {
   270 		if ( ! is_array( $core_updates ) ) {
   271 			$result['status'] = 'recommended';
   271 			$result['status'] = 'recommended';
   272 
   272 
   726 	public function get_test_php_version() {
   726 	public function get_test_php_version() {
   727 		$response = wp_check_php_version();
   727 		$response = wp_check_php_version();
   728 
   728 
   729 		$result = array(
   729 		$result = array(
   730 			'label'       => sprintf(
   730 			'label'       => sprintf(
   731 				/* translators: %s: The current PHP version. */
   731 				/* translators: %s: The recommended PHP version. */
   732 				__( 'Your site is running the current version of PHP (%s)' ),
   732 				__( 'Your site is running a recommended version of PHP (%s)' ),
   733 				PHP_VERSION
   733 				PHP_VERSION
   734 			),
   734 			),
   735 			'status'      => 'good',
   735 			'status'      => 'good',
   736 			'badge'       => array(
   736 			'badge'       => array(
   737 				'label' => __( 'Performance' ),
   737 				'label' => __( 'Performance' ),
   744 					__( 'PHP is one of the programming languages used to build WordPress. Newer versions of PHP receive regular security updates and may increase your site’s performance. The minimum recommended version of PHP is %s.' ),
   744 					__( 'PHP is one of the programming languages used to build WordPress. Newer versions of PHP receive regular security updates and may increase your site’s performance. The minimum recommended version of PHP is %s.' ),
   745 					$response ? $response['recommended_version'] : ''
   745 					$response ? $response['recommended_version'] : ''
   746 				)
   746 				)
   747 			),
   747 			),
   748 			'actions'     => sprintf(
   748 			'actions'     => sprintf(
   749 				'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
   749 				'<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
   750 				esc_url( wp_get_update_php_url() ),
   750 				esc_url( wp_get_update_php_url() ),
   751 				__( 'Learn more about updating PHP' ),
   751 				__( 'Learn more about updating PHP' ),
   752 				/* translators: Hidden accessibility text. */
   752 				/* translators: Hidden accessibility text. */
   753 				__( '(opens in a new tab)' )
   753 				__( '(opens in a new tab)' )
   754 			),
   754 			),
   890 				sprintf(
   890 				sprintf(
   891 					/* translators: 1: Link to the hosting group page about recommended PHP modules. 2: Additional link attributes. 3: Accessibility text. */
   891 					/* translators: 1: Link to the hosting group page about recommended PHP modules. 2: Additional link attributes. 3: Accessibility text. */
   892 					__( 'The WordPress Hosting Team maintains a list of those modules, both recommended and required, in <a href="%1$s" %2$s>the team handbook%3$s</a>.' ),
   892 					__( 'The WordPress Hosting Team maintains a list of those modules, both recommended and required, in <a href="%1$s" %2$s>the team handbook%3$s</a>.' ),
   893 					/* translators: Localized team handbook, if one exists. */
   893 					/* translators: Localized team handbook, if one exists. */
   894 					esc_url( __( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions' ) ),
   894 					esc_url( __( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions' ) ),
   895 					'target="_blank" rel="noopener"',
   895 					'target="_blank"',
   896 					sprintf(
   896 					sprintf(
   897 						'<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span>',
   897 						'<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span>',
   898 						/* translators: Hidden accessibility text. */
   898 						/* translators: Hidden accessibility text. */
   899 						__( '(opens in a new tab)' )
   899 						__( '(opens in a new tab)' )
   900 					)
   900 					)
   921 				'function' => 'finfo_file',
   921 				'function' => 'finfo_file',
   922 				'required' => false,
   922 				'required' => false,
   923 			),
   923 			),
   924 			'hash'      => array(
   924 			'hash'      => array(
   925 				'function' => 'hash',
   925 				'function' => 'hash',
   926 				'required' => false,
   926 				'required' => true,
   927 			),
   927 			),
   928 			'imagick'   => array(
   928 			'imagick'   => array(
   929 				'extension' => 'imagick',
   929 				'extension' => 'imagick',
   930 				'required'  => false,
   930 				'required'  => false,
   931 			),
   931 			),
  1216 			'description' => sprintf(
  1216 			'description' => sprintf(
  1217 				'<p>%s</p>',
  1217 				'<p>%s</p>',
  1218 				__( 'The SQL server is a required piece of software for the database WordPress uses to store all your site&#8217;s content and settings.' )
  1218 				__( 'The SQL server is a required piece of software for the database WordPress uses to store all your site&#8217;s content and settings.' )
  1219 			),
  1219 			),
  1220 			'actions'     => sprintf(
  1220 			'actions'     => sprintf(
  1221 				'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  1221 				'<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  1222 				/* translators: Localized version of WordPress requirements if one exists. */
  1222 				/* translators: Localized version of WordPress requirements if one exists. */
  1223 				esc_url( __( 'https://wordpress.org/about/requirements/' ) ),
  1223 				esc_url( __( 'https://wordpress.org/about/requirements/' ) ),
  1224 				__( 'Learn more about what WordPress requires to run.' ),
  1224 				__( 'Learn more about what WordPress requires to run.' ),
  1225 				/* translators: Hidden accessibility text. */
  1225 				/* translators: Hidden accessibility text. */
  1226 				__( '(opens in a new tab)' )
  1226 				__( '(opens in a new tab)' )
  1333 					)
  1333 					)
  1334 				)
  1334 				)
  1335 			);
  1335 			);
  1336 
  1336 
  1337 			$result['actions'] = sprintf(
  1337 			$result['actions'] = sprintf(
  1338 				'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  1338 				'<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  1339 				/* translators: Localized Support reference. */
  1339 				/* translators: Localized Support reference. */
  1340 				esc_url( __( 'https://wordpress.org/support/forums/' ) ),
  1340 				esc_url( __( 'https://wordpress.org/support/forums/' ) ),
  1341 				__( 'Get help resolving this issue.' ),
  1341 				__( 'Get help resolving this issue.' ),
  1342 				/* translators: Hidden accessibility text. */
  1342 				/* translators: Hidden accessibility text. */
  1343 				__( '(opens in a new tab)' )
  1343 				__( '(opens in a new tab)' )
  1371 			'description' => sprintf(
  1371 			'description' => sprintf(
  1372 				'<p>%s</p>',
  1372 				'<p>%s</p>',
  1373 				__( 'Debug mode is often enabled to gather more details about an error or site failure, but may contain sensitive information which should not be available on a publicly available website.' )
  1373 				__( 'Debug mode is often enabled to gather more details about an error or site failure, but may contain sensitive information which should not be available on a publicly available website.' )
  1374 			),
  1374 			),
  1375 			'actions'     => sprintf(
  1375 			'actions'     => sprintf(
  1376 				'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  1376 				'<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  1377 				/* translators: Documentation explaining debugging in WordPress. */
  1377 				/* translators: Documentation explaining debugging in WordPress. */
  1378 				esc_url( __( 'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/' ) ),
  1378 				esc_url( __( 'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/' ) ),
  1379 				__( 'Learn more about debugging in WordPress.' ),
  1379 				__( 'Learn more about debugging in WordPress.' ),
  1380 				/* translators: Hidden accessibility text. */
  1380 				/* translators: Hidden accessibility text. */
  1381 				__( '(opens in a new tab)' )
  1381 				__( '(opens in a new tab)' )
  1453 			'description' => sprintf(
  1453 			'description' => sprintf(
  1454 				'<p>%s</p>',
  1454 				'<p>%s</p>',
  1455 				__( '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.' )
  1455 				__( '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.' )
  1456 			),
  1456 			),
  1457 			'actions'     => sprintf(
  1457 			'actions'     => sprintf(
  1458 				'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  1458 				'<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  1459 				esc_url( $default_update_url ),
  1459 				esc_url( $default_update_url ),
  1460 				__( 'Learn more about why you should use HTTPS' ),
  1460 				__( 'Learn more about why you should use HTTPS' ),
  1461 				/* translators: Hidden accessibility text. */
  1461 				/* translators: Hidden accessibility text. */
  1462 				__( '(opens in a new tab)' )
  1462 				__( '(opens in a new tab)' )
  1463 			),
  1463 			),
  1537 					$default_direct_update_url = add_query_arg( 'action', 'update_https', wp_nonce_url( admin_url( 'site-health.php' ), 'wp_update_https' ) );
  1537 					$default_direct_update_url = add_query_arg( 'action', 'update_https', wp_nonce_url( admin_url( 'site-health.php' ), 'wp_update_https' ) );
  1538 					$direct_update_url         = wp_get_direct_update_https_url();
  1538 					$direct_update_url         = wp_get_direct_update_https_url();
  1539 
  1539 
  1540 					if ( ! empty( $direct_update_url ) ) {
  1540 					if ( ! empty( $direct_update_url ) ) {
  1541 						$result['actions'] = sprintf(
  1541 						$result['actions'] = sprintf(
  1542 							'<p class="button-container"><a class="button button-primary" href="%1$s" target="_blank" rel="noopener">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  1542 							'<p class="button-container"><a class="button button-primary" href="%1$s" target="_blank">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  1543 							esc_url( $direct_update_url ),
  1543 							esc_url( $direct_update_url ),
  1544 							__( 'Update your site to use HTTPS' ),
  1544 							__( 'Update your site to use HTTPS' ),
  1545 							/* translators: Hidden accessibility text. */
  1545 							/* translators: Hidden accessibility text. */
  1546 							__( '(opens in a new tab)' )
  1546 							__( '(opens in a new tab)' )
  1547 						);
  1547 						);
  1556 			} else {
  1556 			} else {
  1557 				// If host-specific "Update HTTPS" URL is provided, include a link.
  1557 				// If host-specific "Update HTTPS" URL is provided, include a link.
  1558 				$update_url = wp_get_update_https_url();
  1558 				$update_url = wp_get_update_https_url();
  1559 				if ( $update_url !== $default_update_url ) {
  1559 				if ( $update_url !== $default_update_url ) {
  1560 					$result['description'] .= sprintf(
  1560 					$result['description'] .= sprintf(
  1561 						'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  1561 						'<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  1562 						esc_url( $update_url ),
  1562 						esc_url( $update_url ),
  1563 						__( 'Talk to your web host about supporting HTTPS for your website.' ),
  1563 						__( 'Talk to your web host about supporting HTTPS for your website.' ),
  1564 						/* translators: Hidden accessibility text. */
  1564 						/* translators: Hidden accessibility text. */
  1565 						__( '(opens in a new tab)' )
  1565 						__( '(opens in a new tab)' )
  1566 					);
  1566 					);
  1815 	 * @since 6.3.0
  1815 	 * @since 6.3.0
  1816 	 *
  1816 	 *
  1817 	 * @return array The test results.
  1817 	 * @return array The test results.
  1818 	 */
  1818 	 */
  1819 	public function get_test_available_updates_disk_space() {
  1819 	public function get_test_available_updates_disk_space() {
  1820 		$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR . '/upgrade/' ) : false;
  1820 		$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR ) : false;
  1821 
  1821 
  1822 		$result = array(
  1822 		$result = array(
  1823 			'label'       => __( 'Disk space available to safely perform updates' ),
  1823 			'label'       => __( 'Disk space available to safely perform updates' ),
  1824 			'status'      => 'good',
  1824 			'status'      => 'good',
  1825 			'badge'       => array(
  1825 			'badge'       => array(
  1884 			'actions'     => '',
  1884 			'actions'     => '',
  1885 			'test'        => 'update_temp_backup_writable',
  1885 			'test'        => 'update_temp_backup_writable',
  1886 		);
  1886 		);
  1887 
  1887 
  1888 		if ( ! function_exists( 'WP_Filesystem' ) ) {
  1888 		if ( ! function_exists( 'WP_Filesystem' ) ) {
  1889 			require_once ABSPATH . '/wp-admin/includes/file.php';
  1889 			require_once ABSPATH . 'wp-admin/includes/file.php';
  1890 		}
  1890 		}
  1891 
  1891 
  1892 		ob_start();
  1892 		ob_start();
  1893 		$credentials = request_filesystem_credentials( '' );
  1893 		$credentials = request_filesystem_credentials( '' );
  1894 		ob_end_clean();
  1894 		ob_end_clean();
  2362 				esc_url( admin_url( 'options-permalink.php' ) ),
  2362 				esc_url( admin_url( 'options-permalink.php' ) ),
  2363 				__( 'Flush permalinks' )
  2363 				__( 'Flush permalinks' )
  2364 			);
  2364 			);
  2365 		} else {
  2365 		} else {
  2366 			$result['actions'] .= sprintf(
  2366 			$result['actions'] .= sprintf(
  2367 				'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  2367 				'<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  2368 				__( 'https://developer.wordpress.org/rest-api/frequently-asked-questions/#why-is-authentication-not-working' ),
  2368 				__( 'https://developer.wordpress.org/rest-api/frequently-asked-questions/#why-is-authentication-not-working' ),
  2369 				__( 'Learn how to configure the Authorization header.' ),
  2369 				__( 'Learn how to configure the Authorization header.' ),
  2370 				/* translators: Hidden accessibility text. */
  2370 				/* translators: Hidden accessibility text. */
  2371 				__( '(opens in a new tab)' )
  2371 				__( '(opens in a new tab)' )
  2372 			);
  2372 			);
  2395 			'description' => wp_kses_post( $description ),
  2395 			'description' => wp_kses_post( $description ),
  2396 			'test'        => 'page_cache',
  2396 			'test'        => 'page_cache',
  2397 			'status'      => 'good',
  2397 			'status'      => 'good',
  2398 			'label'       => '',
  2398 			'label'       => '',
  2399 			'actions'     => sprintf(
  2399 			'actions'     => sprintf(
  2400 				'<p><a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  2400 				'<p><a href="%1$s" target="_blank" rel="noreferrer">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  2401 				__( 'https://developer.wordpress.org/advanced-administration/performance/optimization/#caching' ),
  2401 				__( 'https://developer.wordpress.org/advanced-administration/performance/optimization/#caching' ),
  2402 				__( 'Learn more about page cache' ),
  2402 				__( 'Learn more about page cache' ),
  2403 				/* translators: Hidden accessibility text. */
  2403 				/* translators: Hidden accessibility text. */
  2404 				__( '(opens in a new tab)' )
  2404 				__( '(opens in a new tab)' )
  2405 			),
  2405 			),
  2521 			'description' => sprintf(
  2521 			'description' => sprintf(
  2522 				'<p>%s</p>',
  2522 				'<p>%s</p>',
  2523 				__( 'A persistent object cache makes your site&#8217;s database more efficient, resulting in faster load times because WordPress can retrieve your site&#8217;s content and settings much more quickly.' )
  2523 				__( 'A persistent object cache makes your site&#8217;s database more efficient, resulting in faster load times because WordPress can retrieve your site&#8217;s content and settings much more quickly.' )
  2524 			),
  2524 			),
  2525 			'actions'     => sprintf(
  2525 			'actions'     => sprintf(
  2526 				'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  2526 				'<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
  2527 				esc_url( $action_url ),
  2527 				esc_url( $action_url ),
  2528 				__( 'Learn more about persistent object caching.' ),
  2528 				__( 'Learn more about persistent object caching.' ),
  2529 				/* translators: Hidden accessibility text. */
  2529 				/* translators: Hidden accessibility text. */
  2530 				__( '(opens in a new tab)' )
  2530 				__( '(opens in a new tab)' )
  2531 			),
  2531 			),
  2669 		 */
  2669 		 */
  2670 		$result['description'] = apply_filters( 'site_status_autoloaded_options_limit_description', $result['description'] );
  2670 		$result['description'] = apply_filters( 'site_status_autoloaded_options_limit_description', $result['description'] );
  2671 
  2671 
  2672 		$result['actions'] = sprintf(
  2672 		$result['actions'] = sprintf(
  2673 			/* translators: 1: HelpHub URL, 2: Link description. */
  2673 			/* translators: 1: HelpHub URL, 2: Link description. */
  2674 			'<p><a target="_blank" rel="noopener" href="%1$s">%2$s</a></p>',
  2674 			'<p><a target="_blank" href="%1$s">%2$s</a></p>',
  2675 			esc_url( __( 'https://developer.wordpress.org/advanced-administration/performance/optimization/#autoloaded-options' ) ),
  2675 			esc_url( __( 'https://developer.wordpress.org/advanced-administration/performance/optimization/#autoloaded-options' ) ),
  2676 			__( 'More info about optimizing autoloaded options' )
  2676 			__( 'More info about optimizing autoloaded options' )
  2677 		);
  2677 		);
  2678 
  2678 
  2679 		/**
  2679 		/**