Instantly share code, notes, and snippets.

Embed
What would you like to do?
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