WordPress.org

Forums

Google Maps v3 Shortcode
Deregister plugin (5 posts)

  1. polyfade
    Member
    Posted 3 years ago #

    I only use this plugin (shortcode) on one page. Therefore, I do not need the calls to google's javascript api and related css called on every page. Is there a way to conditionally call the plugin without touching the plugin itself? Perhaps in the functions.php file? PHP is not my first language, so how would this literally be accomplished?

    Thanks in advance!

    http://wordpress.org/extend/plugins/google-maps-v3-shortcode/

  2. Bill Addison
    Member
    Posted 2 years ago #

    I have the exact same issue with this plugin. The plugin's code is being injected into the header of every page, but I'm using the shortcode on one page only.

  3. polyfade
    Member
    Posted 2 years ago #

    Bill,
    If this annoys you as much as it did me, I did the one thing you probably shouldn't do (especially if there's an update). I modified the plugin itself.

    In Google-Maps-v3-Shortcode.php, I removed the call to Google Maps API. I believe starting with line 13 – 23

    // Add the google maps api to header
    add_action('wp_head', 'gmaps_header');
    
    function gmaps_header() {
    	?>
    	<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    	<style type="text/css">
            .entry-content img {max-width: 100000%; /* override */}
        </style>
    	<?php
    }

    In you functions.php page add the following:

    function gmap() {
    if ( is_page( 'contact-us') ) {
    wp_register_script('googleMap', ('http://maps.google.com/maps/api/js?sensor=false'));
    wp_enqueue_script('googleMap'); }
    }
    add_action( 'wp_print_scripts', 'gmap');

    Replace 'contact-us' to whatever your page slug is called.

    Basically this adds the Google Maps API back in to only the page you have the map appear on.

  4. Bill Addison
    Member
    Posted 2 years ago #

    thanks man

  5. DaisyDesign
    Member
    Posted 2 years ago #

    It doesn't work for me! :(
    I have some problems with the rule:
    .entry-content img {max-width: 100000%; /* override */}
    It override my css file and affect every img on my site.

    How can I fix it?
    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Google Maps v3 Shortcode
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic