Can't use wp_footer on one page where I need a map. Any work-arounds?

Home Forums MapPress Support Can't use wp_footer on one page where I need a map. Any work-arounds?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #12318
    michaelnason
    Participant

      Hi,

      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

      #12320
      Chris
      Keymaster

        Hi,

        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.

         

        #12321
        michaelnason
        Participant

          Hi 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?

          #12329
          Chris
          Keymaster

            Hi,

            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

             

            #12330
            michaelnason
            Participant

              Thanks, 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?

              #12331
              Chris
              Keymaster

                Hi,

                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.

                 

                #12332
                michaelnason
                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.

                  #12334
                  Chris
                  Keymaster

                    Hi, try:

                    echo $mappress->l10n();

                  Viewing 8 posts - 1 through 8 (of 8 total)
                  • You must be logged in to reply to this topic.