WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Site_Health::can_perform_loopback() public WP 5.2.0

Run a loopback test on our site.

Loopbacks are what WordPress uses to communicate with itself to start up WP_Cron, scheduled posts, make sure plugin or theme edits don't cause site failures and similar.

Это метод класса: WP_Site_Health{}

Хуки из метода
Возвращает

Объект. The test results.

Использование

$WP_Site_Health = new WP_Site_Health();
$WP_Site_Health->can_perform_loopback();

Список изменений

С версии 5.2.0 Введена.

Код WP_Site_Health::can_perform_loopback() WP 5.5.1

wp-admin/includes/class-wp-site-health.php
<?php
function can_perform_loopback() {
	$cookies = wp_unslash( $_COOKIE );
	$timeout = 10;
	$headers = array(
		'Cache-Control' => 'no-cache',
	);
	/** This filter is documented in wp-includes/class-wp-http-streams.php */
	$sslverify = apply_filters( 'https_local_ssl_verify', false );

	// Include Basic auth in loopback requests.
	if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) {
		$headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
	}

	$url = admin_url();

	$r = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout', 'sslverify' ) );

	if ( is_wp_error( $r ) ) {
		return (object) array(
			'status'  => 'critical',
			'message' => sprintf(
				'%s<br>%s',
				__( 'The loopback request to your site failed, this means features relying on them are not currently working as expected.' ),
				sprintf(
					/* translators: 1: The WordPress error message. 2: The WordPress error code. */
					__( 'Error: %1$s (%2$s)' ),
					$r->get_error_message(),
					$r->get_error_code()
				)
			),
		);
	}

	if ( 200 !== wp_remote_retrieve_response_code( $r ) ) {
		return (object) array(
			'status'  => 'recommended',
			'message' => sprintf(
				/* translators: %d: The HTTP response code returned. */
				__( 'The loopback request returned an unexpected http status code, %d, it was not possible to determine if this will prevent features from working as expected.' ),
				wp_remote_retrieve_response_code( $r )
			),
		);
	}

	return (object) array(
		'status'  => 'good',
		'message' => __( 'The loopback request to your site completed successfully.' ),
	);
}