Viewing 6 replies - 1 through 6 (of 6 total)
  • This problem bugs me a lot also.. it’s not a problem with this plugin in particular but really with the WordPress framework.
    Anyway I had your exact same issue and came up with this hack:
    At the very bottom of mappress.php (in the plugin dir), put a clause similar to the following:

    //MODIFICATION: only load on certain pages
    if (stripos($_SERVER['REQUEST_URI'], 'my-page-name') !== false) {
    	// Create new instance of the plugin
    	$mappress = new mappress();
    }

    Of course change my-page-name to the URL/partial name of your page. You can’t use post IDs or other such things at this point since we have not yet entered “the loop”.
    This is just a quick & dirty hack but it does work.. ideally someday in the future this sort of thing could be properly built into WordPress.

    Remember that if you update the plugin you will need to re-patch mappress.php

    I forgot this needs to be active on admin pages, here’s an updated version:

    //MODIFICATION: only load on certain pages
    $allowed_pages = array('/wp-admin', '/my-page-name');
    foreach ($allowed_pages as $page) {
    	if (stripos($_SERVER['REQUEST_URI'], $page) !== false) {
    		$mappress = new mappress(); // Create new instance of the plugin
    		break;
    	}
    }

    If anyone can think up a nicer implementation please do post it.

    Thread Starter jjprather

    (@jjprather)

    To clarify – that updated code from your last posting goes into mappress.php?

    Yep right at the bottom, instead of the following line:
    $mappress = new mappress();

    Also it might be best to rename the $post variable to something else like $a_page to avoid overwriting the global $post variable.

    Hi Folks,

    I’ll be releasing a new version of MapPress (1.4.5) in the next few days. In the new version the Javascript will automatically load only on pages that actually have a map.

    Please take a look – there are a lot of other great new features as well!

    -Chris

    the problem still occurs on version 1.5.8.8
    on my setup. i first tried the function from jstar198, but it seems not to work with urls like “http://domain.com”. so it broke my front page for some reason.

    i just made it into an if statement like this:

    if(substr_count(strtolower($_SERVER[‘REQUEST_URI’]), ‘/maps’) || substr_count(strtolower($_SERVER[‘REQUEST_URI’]), ‘/wp-admin’)) $mappress = new mappress();

    not sure if it works on your setup, but it does for me.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: MapPress Easy Google Maps] JS files only on pages/posts implementing MapPress’ is closed to new replies.