Remove http: from Favicon URL
-
This isn’t a support request, but I wanted to post a solution to a problem I was having, and perhaps suggest that this (or something similar) makes it’s way into the theme’s code.
I have SSL on my site, and when pages load I was getting the insecure content on page (yellow) notice in the address bar. It turns out the only issue was the favicon that was uploaded through the theme was being called on the page at https://mysite.com/wp-content/uploads/2014/07/favicon.ico
To fix this I wanted to remove the http: from the URL so it would just be: //mysite.com/wp-content/uploads/2014/07/favicon.ico
In my child-theme, I copied in theme file /inc/parts/class-header-header_main.php
Around line 77 in the
function tc_favicon_display()
, I changed this:if ( false !== strpos( $saved_path , '/wp-content/' ) ) { $url = $saved_path ; } else { $url = $upload_dir['baseurl'] . $saved_path; } $url = apply_filters( 'tc_fav_src' , $url );
To this:
if ( false !== strpos( $saved_path , '/wp-content/' ) ) { $fullurl = $saved_path ; $url = preg_replace('#^https?:#', '', $fullurl); } else { $fullurl = $upload_dir['baseurl'] . $saved_path; $url = preg_replace('#^https?:#', '', $fullurl); } $fullurl = apply_filters( 'tc_fav_src' , $url ); $url = preg_replace('#^https?:#', '', $fullurl);
I’m sure there is a better way to do this – haven’t given it much time, but it does work.
Hope this helps if anyone else is having a similar issue.
- The topic ‘Remove http: from Favicon URL’ is closed to new replies.