wp_replace_insecure_home_url() – Replaces insecure HTTP URLs to the site in the given content, if configured to do so.

You appear to be a bot. Output may be restricted

Description

Replaces insecure HTTP URLs to the site in the given content, if configured to do so.

This function replaces all occurrences of the HTTP version of the site's URL with its HTTPS counterpart, if determined via {@see wp_should_replace_insecure_home_url()}.

Usage

$string = wp_replace_insecure_home_url( $content );

Parameters

$content
( string ) required – Content to replace URLs in.

Returns

string Filtered content.

Source

File name: wordpress/wp-includes/https-migration.php


Lines:

1 to 25 of 25
function wp_replace_insecure_home_url( $content ) {
  if ( ! wp_should_replace_insecure_home_url() ) {
    return $content;
  }

  $https_url = home_url( '', 'https' );
  $http_url  = str_replace( 'https://', 'http://', $https_url );

  // Also replace potentially escaped URL.
  $escaped_https_url = str_replace( '/', '\/', $https_url );
  $escaped_http_url  = str_replace( '/', '\/', $http_url );

  return str_replace(
    array(
      $http_url,
      $escaped_http_url,
    ),
    array(
      $https_url,
      $escaped_https_url,
    ),
    $content
  );
}
 

 View on GitHub View on Trac