• 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.

Viewing 1 replies (of 1 total)
  • Theme Author presscustomizr

    (@nikeo)

    Hi @scottdeluzio, thanks for posting this trick. I might include this fix in the next release of the theme.

    However, I would rather propose another way to do it since it is not recommended to copy and override important parts of the core code in a child theme. Using the hooks API of the theme is simpler (and safer) in most of the cases.

    Since the fav icon method returns a value with a WordPress filter, you can use this hook the following way in the functions.php of your child theme.

    add_filter('tc_fav_src' , 'ssl_fav');
    function ssl_fav($fav_src) {
      if ( ! is_ssl() )
        return $fav_src;
      return str_replace('https://', 'https://', $fav_src);
      //(In this case, replacing https:// by https:// should also remove the insecure content warning.)
      //works also with preg_replace;
    }

    it uses is_ssl() documented here : https://codex.www.ads-software.com/Function_Reference/is_ssl

    Best regards and enjoy the theme!

Viewing 1 replies (of 1 total)
  • The topic ‘Remove http: from Favicon URL’ is closed to new replies.