WordPress.org

Ready to get started?Download WordPress

Forums

WP Google Maps
Patch: HTTPS Support (2 posts)

  1. Alexander Gieg
    Member
    Posted 1 year ago #

    I noticed a small problem with your plugins when a page with a map was loaded via HTTPS in that Google complained the page had insecure items, asking whether to load them or not. Looking at your code I noticed this happens because the JavaScript is loaded directly from "http://maps.google.com/..." at wpGoogleMaps.php lines 213, 315 and 615. I attempted then manually loading it from https://maps.google.com, and it worked, so I figured a simple fix would to do the same thing Google itself does when loading Google Analytics, by changing those three lines from:

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

    to:

    <script type="text/javascript">
    	var gmapsJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
    	document.write(unescape("%3Cscript src='" + gmapsJsHost + "maps.google.com/maps/api/js?sensor=false' type='text/javascript'%3E%3C/script%3E"));
    </script>

    I tested this on 5.01 and it works perfectly: no more complaints from Google Chrome when loading the page from the HTTPS version!

    I hope this helps. It'd be nice to have this added to the official plugin!

    PS.: Naturally, an even simpler version would be:

    <script type="text/javascript">document.write(unescape("%3Cscript src='" + document.location.protocol + "//maps.google.com/maps/api/js?sensor=false' type='text/javascript'%3E%3C/script%3E"));</script>

    http://wordpress.org/extend/plugins/wp-google-maps/

  2. WPGMaps
    Member
    Plugin Author

    Posted 1 year ago #

    Thank you so much for this Alexander! I will implement this in v5.02 - MUCH appreciated!

    Kind regards
    Nick

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags