Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_update_https_detection_errors ›

Seit5.7.0
Veraltetn/v
wp_update_https_detection_errors ( Keine Parameter )
Zugriff:
  • private
Definiert in:
Codex:

Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors.

This internal function is called by a regular Cron hook to ensure HTTPS support is detected and maintained.


Quellcode

function wp_update_https_detection_errors() {
	$support_errors = new WP_Error();

	$response = wp_remote_request(
		home_url( '/', 'https' ),
		array(
			'headers'   => array(
				'Cache-Control' => 'no-cache',
			),
			'sslverify' => true,
		)
	);

	if ( is_wp_error( $response ) ) {
		$unverified_response = wp_remote_request(
			home_url( '/', 'https' ),
			array(
				'headers'   => array(
					'Cache-Control' => 'no-cache',
				),
				'sslverify' => false,
			)
		);

		if ( is_wp_error( $unverified_response ) ) {
			$support_errors->add(
				$unverified_response->get_error_code(),
				$unverified_response->get_error_message()
			);
		} else {
			$support_errors->add(
				'ssl_verification_failed',
				$response->get_error_message()
			);
		}

		$response = $unverified_response;
	}

	if ( ! is_wp_error( $response ) ) {
		if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
			$support_errors->add( 'bad_response_code', wp_remote_retrieve_response_message( $response ) );
		} elseif ( false === wp_is_owned_html_output( wp_remote_retrieve_body( $response ) ) ) {
			$support_errors->add( 'bad_response_source', __( 'It looks like the response did not come from this site.' ) );
		}
	}

	update_option( 'https_detection_errors', $support_errors->errors );
}