Home › Forums › MapPress Support › Can't use wp_footer on one page where I need a map. Any work-arounds?
- This topic has 7 replies, 2 voices, and was last updated 10 years, 5 months ago by
Chris.
-
AuthorPosts
-
April 21, 2013 at 3:17 pm #12318
michaelnason
ParticipantHi,
I’m using MapPress in combination with the GroupBuyingSite plugin (GBS for short – http://www.groupbuyingsite.com). I’ve integrated the plugins together pretty nicely, but there is one template that does not call wp_footer (for good reason). Maps on those pages are not displaying…yet.
Can anyone suggest any alternatives? Can I hardcode the stylesheet/script enqueues into that template? If so, what would be the best way to do that?
Thank you,
Michael
April 21, 2013 at 5:41 pm #12320Chris
KeymasterHi,
Just to be clear, wp_footer() only loads scripts in the footer. It doesn’t actually display the blog footer – that’s done by get_footer() instead.
Were you thinking of get_footer()?
If that’s not the problem and you really can’t call wp_footer(), then you could possibly just trigger action ‘wp_print_footer_scripts’ instead, e.g. do_action(‘wp_print_footer_scripts’). That calls the internal function to queue all the scripts.
April 21, 2013 at 8:51 pm #12321michaelnason
ParticipantHi Chris,
Thanks. The page I’m having trouble with is a receipt-type page that is meant to be printed. The template for this view does not call wp_footer(), and no external scripts or stylesheets are loaded.
If I add wp_footer() or do_action(‘wp_print_footer_scripts’), then my site’s stylesheet and all other scripts are loaded even though they should not be on this view (including mappress’s).
Is there a way to selectively load MapPress resources for this template, or any other way I can work around this limitation?
April 22, 2013 at 5:14 am #12329Chris
KeymasterHi,
I don’t think WordPress offers any way to output only specific queued scripts.
You could take a look at a normal page with a map and just copy the google/mappress script tags into your checkout page template. Call the MapPress print_maps() function to output the map data after those tags:
<?php
global $mappress;
$mappress->print_maps();
?>Perhaps there’s a way to conditionally not load the other scripts on the checkout page? Or you could dequeue them before the wp_footer() call:
http://codex.wordpress.org/Function_Reference/wp_dequeue_script
April 22, 2013 at 6:03 am #12330michaelnason
ParticipantThanks, I got it working!
Right now, I just copied var mappl10n from a different page with a map on it. Is that unwise? Should I dynamically generate this content? How?
April 22, 2013 at 6:35 am #12331Chris
KeymasterHi,
I assume you just copied over the script tags? I forgot about mappl10n, though – you can output it by calling $mappress->l10n();
I still think it would be better to just deuque/deregister the scripts you don’t want, though – that way if MapPress changes you won’t need to re-do the checkout page.
April 22, 2013 at 6:58 am #12332michaelnason
Participant$mappress->l10n(); isn’t outputting anything for me for some reason:
<?php
global $mappress;
$mappress->l10n();
$mappress->print_maps();
?>I agree this isn’t an ideal setup, but I need to get this sorted for launch. We’ll develop a smarter way to do this soon after.
April 22, 2013 at 7:01 am #12334Chris
KeymasterHi, try:
echo $mappress->l10n();
-
AuthorPosts
- You must be logged in to reply to this topic.