Use SSL for Twitter avatars when Wordpress is served via SSL

Started by piglet, October 28, 2014, 03:38:21 AM

previous topic - next topic
Go Down

piglet

We get warnings about mixed content, specifically non-SSL images, when our paged is served via SSL.

The following was our fix:

Step 1 was to add a utility function to translate these URLs, depending on the current SSL mode:

Code Select

--- inc/common.php.orig 2014-10-27 23:12:21.000000000 -0400
+++ inc/common.php      2014-10-27 23:32:41.000000000 -0400
@@ -237,4 +237,11 @@
         $v = str_replace("\n", null, $v);
        return $v;
        }
+
+       function xmt_fix_up_url_scheme($url){
+               if($_SERVER["HTTPS"] == "on")
+                       $url = preg_replace("/^http:/i", "https:", $url, 1);
+
+               return $url;
+       }
?>
\ No newline at end of file


Step 2 was to change the widget code to call the new function:

Code Select

--- theme/default/widget.php.orig       2014-10-27 23:16:34.000000000 -0400
+++ theme/default/widget.php    2014-10-27 23:30:56.000000000 -0400
@@ -45,6 +45,8 @@
                echo '<li class="tweet_list">';
                        if($xmt_acc[$acc]['cfg']['shw_hrl'])
                                echo '<hr/>';
+
+                       $row['author_img'] = xmt_fix_up_url_scheme($row['author_img']);  // Ensure SSL is used for external image, if needed

                        if($xmt_acc[$acc]['cfg']['avt_shw']){
                                echo '<a href="'.$row['author_url'].'" '.($xmt_acc[$acc]['cfg']['lnk_new_tab']?'target="_blank"':'').'><img class="tweet_avatar" src="'.$row['author_img'].'" alt="'.$row['author_name'].'"/></a>';


piglet

I'm hoping that the developers might incorporate the change into a later version, but I'm not sure if they still respond to suggestions that get posted here.

Koaloz

Quote from: piglet on October 28, 2014, 08:07:59 AM
I'm hoping that the developers might incorporate the change into a later version, but I'm not sure if they still respond to suggestions that get posted here.


Would be nice, but I don't know where they are, have not received a reply for almost a week now :/

Go Up