var/www/html/wordpress_bak/wp-includes | uid:33
https-detection.php [X]
<?php
/**
 * HTTPS detection functions.
 *
 * @package WordPress
 * @since 5.7.0
 */

/**
 * Checks whether the website is using HTTPS.
 *
 * This is based on whether both the home and site URL are using HTTPS.
 *
 * @since 5.7.0
 * @see wp_is_home_url_using_https()
 * @see wp_is_site_url_using_https()
 *
 * @return bool True if using HTTPS, false otherwise.
 */
function wp_is_using_https() {
	if ( ! wp_is_home_url_using_https() ) {
		return false;
	}

	return wp_is_site_url_using_https();
}

/**
 * Checks whether the current site URL is using HTTPS.
 *
 * @since 5.7.0
 * @see home_url()
 *
 * @return bool True if using HTTPS, false otherwise.
 */
function wp_is_home_url_using_https() {
	return 'https' === wp_parse_url( home_url(), PHP_URL_SCHEME );
}

/**
 * Checks whether the current site's URL where WordPress is stored is using HTTPS.
 *
 * This checks the URL where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder)
 * are accessible.
 *
 * @since 5.7.0
 * @see site_url()
 *
 * @return bool True if using HTTPS, false otherwise.
 */
function wp_is_site_url_using_https() {
	/*
	 * Use direct option access for 'siteurl' and manually run the 'site_url'
	 * filter because `site_url()` will adjust the scheme based on what the
	 * current request is using.
	 */
	/** This filter is documented in wp-includes/link-template.php */
	$site_url = apply_filters( 'site_url', get_option( 'siteurl' ), '', null, null );

	return 'https' === wp_parse_url( $site_url, PHP_URL_SCHEME );
}

/**
 * Checks whether HTTPS is supported for the server and domain.
 *
 * This function makes an HTTP request through `wp_get_https_detection_errors()`
 * to check for HTTPS support. As this process can be resource-intensive,
 * it should be used cautiously, especially in performance-sensitive environments,
 * to avoid potential latency issues.
 *
 * @since 5.7.0
 *
 * @return bool True if HTTPS is supported, false otherwise.
 */
function wp_is_https_supported() {
	$https_detection_errors = wp_get_https_detection_errors();

	// If there are errors, HTTPS is not supported.
	return empty( $https_detection_errors );
}

/**
 * Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors.
 *
 * This function checks for HTTPS support by making an HTTP request. As this process can be resource-intensive,
 * it should be used cautiously, especially in performance-sensitive environments.
 * It is called when HTTPS support needs to be validated.
 *
 * @since 6.4.0
 * @access private
 *
 * @return array An array containing potential detection errors related to HTTPS, or an empty array if no errors are found.
 */
function wp_get_https_detection_errors() {
	/**
	 * Short-circuits the process of detecting errors related to HTTPS support.
	 *
	 * Returning a `WP_Error` from the filter will effectively short-circuit the default logic of trying a remote
	 * request to the site over HTTPS, storing the errors array from the returned `WP_Error` instead.
	 *
	 * @since 6.4.0
	 *
	 * @param null|WP_Error $pre Error object to short-circuit detection,
	 *                           or null to continue with the default behavior.
	 */
	$support_errors = apply_filters( 'pre_wp_get_https_detection_errors', null );
	if ( is_wp_error( $support_errors ) ) {
		return $support_errors->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(
				'https_request_failed',
				__( 'HTTPS request failed.' )
			);
		} else {
			$support_errors->add(
				'ssl_verification_failed',
				__( 'SSL verification failed.' )
			);
		}

		$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_local_html_output( wp_remote_retrieve_body( $response ) ) ) {
			$support_errors->add( 'bad_response_source', __( 'It looks like the response did not come from this site.' ) );
		}
	}

	return $support_errors->errors;
}

/**
 * Checks whether a given HTML string is likely an output from this WordPress site.
 *
 * This function attempts to check for various common WordPress patterns whether they are included in the HTML string.
 * Since any of these actions may be disabled through third-party code, this function may also return null to indicate
 * that it was not possible to determine ownership.
 *
 * @since 5.7.0
 * @access private
 *
 * @param string $html Full HTML output string, e.g. from a HTTP response.
 * @return bool|null True/false for whether HTML was generated by this site, null if unable to determine.
 */
function wp_is_local_html_output( $html ) {
	// 1. Check if HTML includes the site's Really Simple Discovery link.
	if ( has_action( 'wp_head', 'rsd_link' ) ) {
		$pattern = preg_replace( '#^https?:(?=//)#', '', esc_url( site_url( 'xmlrpc.php?rsd', 'rpc' ) ) ); // See rsd_link().
		return str_contains( $html, $pattern );
	}

	// 2. Check if HTML includes the site's REST API link.
	if ( has_action( 'wp_head', 'rest_output_link_wp_head' ) ) {
		// Try both HTTPS and HTTP since the URL depends on context.
		$pattern = preg_replace( '#^https?:(?=//)#', '', esc_url( get_rest_url() ) ); // See rest_output_link_wp_head().
		return str_contains( $html, $pattern );
	}

	// Otherwise the result cannot be determined.
	return null;
}
abilities-api/-O R D
assets/-O R D
block-bindings/-O R D
block-patterns/-O R D
block-supports/-O R D
blocks/-O R D
certificates/-O R D
css/-O R D
customize/-O R D
fonts/-O R D
html-api/-O R D
ID3/-O R D
images/-O R D
interactivity-api/-O R D
IXR/-O R D
js/-O R D
l10n/-O R D
php-compat/-O R D
PHPMailer/-O R D
pomo/-O R D
Requests/-O R D
rest-api/-O R D
SimplePie/-O R D
sitemaps/-O R D
sodium_compat/-O R D
style-engine/-O R D
Text/-O R D
theme-compat/-O R D
widgets/-O R D
abilities-api.php23.8KV E R D
abilities.php7.8KV E R D
admin-bar.php36.1KV E R D
atomlib.php11.9KV E R D
author-template.php18.9KV E R D
block-bindings.php7.3KV E R D
block-editor.php28.6KV E R D
block-i18n.json316V E R D
block-patterns.php12.9KV E R D
block-template-utils.php61KV E R D
block-template.php15KV E R D
blocks.php112KV E R D
bookmark-template.php12.5KV E R D
bookmark.php15.1KV E R D
cache-compat.php9.8KV E R D
cache.php13.2KV E R D
canonical.php33.8KV E R D
capabilities.php42.6KV E R D
category-template.php55.7KV E R D
category.php12.5KV E R D
class-avif-info.php28.9KV E R D
class-feed.php539V E R D
class-http.php367V E R D
class-IXR.php2.6KV E R D
class-json.php42.7KV E R D
class-oembed.php401V E R D
class-phpass.php6.6KV E R D
class-phpmailer.php664V E R D
class-pop3.php20.6KV E R D
class-requests.php2.2KV E R D
class-simplepie.php453V E R D
class-smtp.php457V E R D
class-snoopy.php36.8KV E R D
class-walker-category-dropdown.php2.4KV E R D
class-walker-category.php8.3KV E R D
class-walker-comment.php13.9KV E R D
class-walker-nav-menu.php11.8KV E R D
class-walker-page-dropdown.php2.6KV E R D
class-walker-page.php7.4KV E R D
class-wp-admin-bar.php17.5KV E R D
class-wp-ajax-response.php5.1KV E R D
class-wp-application-passwords.php16.7KV E R D
class-wp-block-bindings-registry.php8.3KV E R D
class-wp-block-bindings-source.php2.9KV E R D
class-wp-block-editor-context.php1.3KV E R D
class-wp-block-list.php4.6KV E R D
class-wp-block-metadata-registry.php11.6KV E R D
class-wp-block-parser-block.php2.5KV E R D
class-wp-block-parser-frame.php2KV E R D
class-wp-block-parser.php11.2KV E R D
class-wp-block-pattern-categories-registry.php5.3KV E R D
class-wp-block-patterns-registry.php11KV E R D
class-wp-block-processor.php68.3KV E R D
class-wp-block-styles-registry.php6.3KV E R D
class-wp-block-supports.php5.5KV E R D
class-wp-block-template.php2KV E R D
class-wp-block-templates-registry.php7KV E R D
class-wp-block-type-registry.php4.9KV E R D
class-wp-block-type.php16.9KV E R D
class-wp-block.php24.2KV E R D
class-wp-classic-to-block-menu-converter.php4KV E R D
class-wp-comment-query.php47.7KV E R D
class-wp-comment.php9.2KV E R D
class-wp-customize-control.php25.5KV E R D
class-wp-customize-manager.php198.4KV E R D
class-wp-customize-nav-menus.php56.7KV E R D
class-wp-customize-panel.php10.5KV E R D
class-wp-customize-section.php10.9KV E R D
class-wp-customize-setting.php29.3KV E R D
class-wp-customize-widgets.php70.9KV E R D
class-wp-date-query.php35.3KV E R D
class-wp-dependencies.php16.6KV E R D
class-wp-dependency.php2.6KV E R D
class-wp-duotone.php39.8KV E R D
class-wp-editor.php70.6KV E R D
class-wp-embed.php15.6KV E R D
class-wp-error.php7.3KV E R D
class-wp-exception.php253V E R D
class-wp-fatal-error-handler.php8KV E R D
class-wp-feed-cache-transient.php3.2KV E R D
class-wp-feed-cache.php969V E R D
class-wp-hook.php16.3KV E R D
class-wp-http-cookie.php7.2KV E R D
class-wp-http-curl.php13KV E R D
class-wp-http-encoding.php6.5KV E R D
class-wp-http-ixr-client.php3.4KV E R D
class-wp-http-proxy.php5.8KV E R D
class-wp-http-requests-hooks.php2KV E R D
class-wp-http-requests-response.php4.3KV E R D
class-wp-http-response.php2.9KV E R D
class-wp-http-streams.php16.5KV E R D
class-wp-http.php40.6KV E R D
class-wp-image-editor-gd.php20.2KV E R D
class-wp-image-editor-imagick.php36.1KV E R D
class-wp-image-editor.php17KV E R D
class-wp-list-util.php7.3KV E R D
class-wp-locale-switcher.php6.6KV E R D
class-wp-locale.php16.5KV E R D
class-wp-matchesmapregex.php1.8KV E R D
class-wp-meta-query.php29.8KV E R D
class-wp-metadata-lazyloader.php6.7KV E R D
class-wp-navigation-fallback.php9KV E R D
class-wp-network-query.php19.4KV E R D
class-wp-network.php12KV E R D
class-wp-object-cache.php17.1KV E R D
class-wp-oembed-controller.php6.7KV E R D
class-wp-oembed.php30.9KV E R D
class-wp-paused-extensions-storage.php5KV E R D
class-wp-phpmailer.php4.2KV E R D
class-wp-plugin-dependencies.php24.7KV E R D
class-wp-post-type.php30KV E R D
class-wp-post.php6.3KV E R D
class-wp-query.php159.9KV E R D
class-wp-recovery-mode-cookie-service.php6.7KV E R D
class-wp-recovery-mode-email-service.php10.9KV E R D
class-wp-recovery-mode-key-service.php4.8KV E R D
class-wp-recovery-mode-link-service.php3.4KV E R D
class-wp-recovery-mode.php11.2KV E R D
class-wp-rewrite.php62.2KV E R D
class-wp-role.php2.5KV E R D
class-wp-roles.php9.2KV E R D
class-wp-script-modules.php32.1KV E R D
class-wp-scripts.php34KV E R D
class-wp-session-tokens.php7.1KV E R D
class-wp-simplepie-file.php3.5KV E R D
class-wp-simplepie-sanitize-kses.php1.9KV E R D
class-wp-site-query.php30.9KV E R D
class-wp-site.php7.3KV E R D
class-wp-speculation-rules.php7.4KV E R D
class-wp-styles.php12.5KV E R D
class-wp-tax-query.php19.1KV E R D
class-wp-taxonomy.php18.1KV E R D
class-wp-term-query.php40KV E R D
class-wp-term.php5.2KV E R D
class-wp-text-diff-renderer-inline.php979V E R D
class-wp-text-diff-renderer-table.php18.4KV E R D
class-wp-textdomain-registry.php10.2KV E R D
class-wp-theme-json-data.php1.8KV E R D
class-wp-theme-json-resolver.php34.9KV E R D
class-wp-theme-json-schema.php7.2KV E R D
class-wp-theme-json.php160.5KV E R D
class-wp-theme.php64.3KV E R D
class-wp-token-map.php27.9KV E R D
class-wp-url-pattern-prefixer.php4.7KV E R D
class-wp-user-meta-session-tokens.php2.9KV E R D
class-wp-user-query.php43.1KV E R D
class-wp-user-request.php2.3KV E R D
class-wp-user.php22.5KV E R D
class-wp-walker.php13KV E R D
class-wp-widget-factory.php3.3KV E R D
class-wp-widget.php18KV E R D
class-wp-xmlrpc-server.php210.4KV E R D
class-wp.php25.9KV E R D
class-wpdb.php115.8KV E R D
class.wp-dependencies.php373V E R D
class.wp-scripts.php343V E R D
class.wp-styles.php338V E R D
comment-template.php100.7KV E R D
comment.php130.9KV E R D
compat-utf8.php19.1KV E R D
compat.php17.4KV E R D
cron.php42KV E R D
date.php400V E R D
default-constants.php11.1KV E R D
default-filters.php37KV E R D
default-widgets.php2.2KV E R D
deprecated.php188.1KV E R D
embed-template.php338V E R D
embed.php38KV E R D
error-protection.php4KV E R D
feed-atom-comments.php5.4KV E R D
feed-atom.php3KV E R D
feed-rdf.php2.6KV E R D
feed-rss.php1.2KV E R D
feed-rss2-comments.php4KV E R D
feed-rss2.php3.7KV E R D
feed.php24.6KV E R D
fonts.php9.6KV E R D
formatting.php346.4KV E R D
functions.php281.8KV E R D
functions.wp-scripts.php15KV E R D
functions.wp-styles.php8.4KV E R D
general-template.php168.9KV E R D
global-styles-and-settings.php20.7KV E R D
http.php25.3KV E R D
https-detection.php5.7KV E R D
https-migration.php4.6KV E R D
kses.php81.7KV E R D
l10n.php67.2KV E R D
link-template.php156.4KV E R D
load.php55.2KV E R D
locale.php162V E R D
media-template.php61.7KV E R D
media.php216.1KV E R D
meta.php65KV E R D
ms-blogs.php25.2KV E R D
ms-default-constants.php4.8KV E R D
ms-default-filters.php6.5KV E R D
ms-deprecated.php21.2KV E R D
ms-files.php2.8KV E R D
ms-functions.php89.7KV E R D
ms-load.php19.4KV E R D
ms-network.php3.7KV E R D
ms-settings.php4.1KV E R D
ms-site.php40.7KV E R D
nav-menu-template.php25.4KV E R D
nav-menu.php43.3KV E R D
option.php102.6KV E R D
pluggable-deprecated.php6.2KV E R D
pluggable.php124.5KV E R D
plugin.php35.6KV E R D
post-formats.php6.9KV E R D
post-template.php67KV E R D
post-thumbnail-template.php10.6KV E R D
post.php289.1KV E R D
query.php36.2KV E R D
registration-functions.php200V E R D
registration.php200V E R D
rest-api.php98.3KV E R D
revision.php30KV E R D
rewrite.php19KV E R D
robots-template.php5.1KV E R D
rss-functions.php255V E R D
rss.php22.7KV E R D
script-loader.php154.6KV E R D
script-modules.php9.7KV E R D
session.php258V E R D
shortcodes.php23.5KV E R D
sitemaps.php3.2KV E R D
speculative-loading.php8.4KV E R D
spl-autoload-compat.php441V E R D
style-engine.php7.4KV E R D
taxonomy.php172.9KV E R D
template-canvas.php544V E R D
template-loader.php4.2KV E R D
template.php36KV E R D
theme-i18n.json1.7KV E R D
theme-previews.php2.8KV E R D
theme-templates.php6.1KV E R D
theme.json8.7KV E R D
theme.php131.8KV E R D
update.php37.5KV E R D
user.php173.9KV E R D
utf8.php7.1KV E R D
vars.php6.4KV E R D
version.php1.1KV E R D
widgets.php69.5KV E R D
wp-db.php445V E R D
wp-diff.php799V E R D