Filter hook 'site_url'

in WP Core File wp-includes/https-detection.php at line 58

View Source

site_url

Filter Hook
Description
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. / 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.

Hook Information

File Location wp-includes/https-detection.php View on GitHub
Hook Type Filter
Line Number 58

Hook Parameters

This hook doesn't accept any parameters.

Usage Examples

Basic Usage
<?php
// Hook into site_url
add_filter('site_url', 'my_custom_filter');

function my_custom_filter() {
    // Your custom filtering logic here
    return 'modified_value';
}

Source Code Context

wp-includes/https-detection.php:58 - How this hook is used in WordPress core
<?php
  53  	 * Use direct option access for 'siteurl' and manually run the 'site_url'
  54  	 * filter because `site_url()` will adjust the scheme based on what the
  55  	 * current request is using.
  56  	 */
  57  	/** This filter is documented in wp-includes/link-template.php */
  58  	$site_url = apply_filters( 'site_url', get_option( 'siteurl' ), '', null, null );
  59  
  60  	return 'https' === wp_parse_url( $site_url, PHP_URL_SCHEME );
  61  }
  62  
  63  /**

PHP Documentation

<?php
/**
 * 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.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 0
  • File: wp-includes/https-detection.php
Related Hooks

Related hooks will be displayed here in future updates.