Skip to content

Instantly share code, notes, and snippets.

@curt
Last active July 3, 2018 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curt/e867346acb33a1d24c8fc1e79f416e37 to your computer and use it in GitHub Desktop.
Save curt/e867346acb33a1d24c8fc1e79f416e37 to your computer and use it in GitHub Desktop.
WordPress plugin that replaces http: with https: in any content containing the home URL wherever found in content requested via https.
<?php
/**
* Plugin Name: AF7KQ Replace Home URLs
* Plugin URI: https://gist.github.com/curt/e867346acb33a1d24c8fc1e79f416e37
* Description: Replaces http: URL containing the home URL with https: URL
* Version: 0.0.1
* Author: Curt Gilman
* Author URI: https://af7kq.com/
*/
add_filter( 'the_content', 'af7kq_filter_replace_home_urls' );
function af7kq_filter_replace_home_urls( $content ) {
if( is_ssl() ) {
$content = str_replace( set_url_scheme( home_url(), 'http' ), set_url_scheme( home_url(), 'https' ), $content);
}
return $content;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment