XHanch Studio Log in | Register | Cart

Forum

Notifications
Clear all

Use SSL for Twitter avatars when Wordpress is served via SSL

4 Posts
2 Users
0 Likes
2,766 Views
(@piglet)
Posts: 2
New Member
Topic starter
 

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:


--- 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:


--- 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>';
 
Posted : 28/10/2014 10:38 am
(@korra)
Posts: 2
New Member
 

Thanks for this information :)!

 
Posted : 28/10/2014 2:47 pm
(@piglet)
Posts: 2
New Member
Topic starter
 

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.

 
Posted : 28/10/2014 3:07 pm
(@korra)
Posts: 2
New Member
 

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 :/

 
Posted : 28/10/2014 3:12 pm
Share:

× Close Menu