Gonzalo Alatorre

Forum Replies Created

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • in reply to: Google map not displaying on events or venue pages #1147763
    Gonzalo Alatorre
    Participant

    Hi Cliff,

    Yes, there are other, non-Events pages where we’re using Google Maps and so need to have the GMaps API script loaded for those.

    Right now, the solution in my last post has it working so that the API script is only being loaded once per page, My comment with that solution was that it may not be the most optimal way of doing it.

    I tried dequeuing the script that The Events Calendar was adding, but couldn’t get that to work.

    I saw in a couple of other forum threads that as far back as 2014 you guys were looking at adding some functionality into The Events Calendar settings to enable/disable the loading of the GMaps script(s), for those cases where the script is already being added, either by another plugin or in the theme itself, but haven’t seen any updates to that so far.

    Where we are now is that the original issues are effectively resolved. I just didn’t set it as resolved as I was wondering if there was a more elegant way that could be recommended of dealing with the GMamps script loading than what I’d outlined.

    If not, then I can certainly close off this thread.

    Thanks

    in reply to: Google map not displaying on events or venue pages #1147348
    Gonzalo Alatorre
    Participant

    So I tried removing the script using:

    function pp_dequeue_unnecessary_scripts() {
      wp_dequeue_script( 'tribe_events_google_maps_api' );
      wp_deregister_script( 'tribe_events_google_maps_api' );
    }
    add_action( 'wp_print_scripts', 'pp_dequeue_unnecessary_scripts', 100 );

    But that doesn’t work.

    There’s likely a better way, but what I was able to get working was tweaking how I enqueue our version of the maps API to be

    if (!is_singular(array('tribe_events', 'tribe_venue', 'tribe_organizer'))) {
      if (is_post_type_archive(array('tribe_events'))) {
    		  
      }
      else {
        wp_enqueue_script('googlemaps');
      }
    }

    It doesn’t like !is_post_type_archive(array(‘tribe_events’))

    in reply to: Google map not displaying on events or venue pages #1144379
    Gonzalo Alatorre
    Participant

    OK, issue with the maps not loading has been fixed.

    The issue was that Paid Memberships Pro does not have a built in method for moving the placement of the required signup field asterisk * for the default/required Username, E-mail address and Password membership fields.

    We used the following to manually add the asterisk beside the labels for those field elements:

    function change_checkout_details( $translated_text, $text, $domain ) {
        switch ( $translated_text ) {
          case 'Username' : //select the word/sentence you would like to change
            $translated_text = __( 'Username *', 'pmpro' ); //change text to 'Username *'
          break;
          case 'E-mail Address' :
            $translated_text = __( 'E-mail Address *', 'pmpro' );
          break;
          case 'Confirm E-mail Address' :
            $translated_text = __( 'Confirm E-mail Address *', 'pmpro' );
          break;
          case 'Choose a password (8-40 characters)' :
            $translated_text = __( 'Choose a password (8-40 characters) *', 'pmpro' );
          break;
          case 'Confirm Password' :
            $translated_text = __( 'Confirm Password *', 'pmpro' );
          break;
        }
        return $translated_text;
    }
    add_filter( 'gettext', 'change_checkout_details', 20, 3 );

    And that’s what was conflicting with the Events Calendar map snippet in the reply above.

    To fix this, we’ve changed it so the add_filter is only being run on the specific membership checkout page:

    function checkPageID(){
    	$currentPost = get_post();
    	if ( $currentPost->ID == "50") {
    		add_filter( 'gettext', 'change_checkout_details', 20, 3 );
    	}
    }
    add_action( 'the_post', 'checkPageID' );

    With this in place, the maps on the Events Calendar pages are now displaying properly.

    It would still be great to prevent Events Calendar from adding the Google maps api script, so that we can use our own.

    in reply to: Google map not displaying on events or venue pages #1144315
    Gonzalo Alatorre
    Participant

    OK, looks like it’s the file the-events-calendar\src\views\modules\map.php

    if ( ! defined( 'ABSPATH' ) ) {
    	die( '-1' );
    }
    
    $style = apply_filters( 'tribe_events_embedded_map_style', "height: $height; width: $width", $index );
    ?>
    <div id="tribe-events-gmap-<?php esc_attr_e( $index ) ?>" style="<?php esc_attr_e( $style ) ?>"></div>

    And the $index var is conflicting with something from Paid Memberships Pro.

    Will see if I can sort that out with them.

    In the meantime, is there a way that we can easily prevent The Events Calendar (Pro, and Filter Bar) from loading the Google Maps api script completely? The script will be enqueued by our custom theme rather than the plugin, so that we can use maps on other pages as needed?

    in reply to: Google map not displaying on events or venue pages #1143045
    Gonzalo Alatorre
    Participant

    Hi Geoff,
    I’ve removed the version of the GM api script that I was enqueuing. On the Events Calendar related pages, the map still doesn’t load, and on the other, non-Events pages maps are no longer loading, which you can see if you click the Branches menu.

    Thanks,
    Kevin

    in reply to: Google map not displaying on events or venue pages #1142729
    Gonzalo Alatorre
    Participant

    Hi Geoff,

    Just checked back in here to see if there was any news on this and realized that the follow up reply I’d sent to your last message isn’t there, explaining why I hadn’t heard anything. Not sure what happend to my reply, so I’ll add it again.

    I’ve tested the user account I created for you to access and can confirm that it is now working correctly.

    The primary issue is still that the maps are not displaying on the Events Calendar related pages (single event, venue, etc) and I’m not sure why. There aren’t any script errors in the console.

    The secondary issue is relating to the loading (or not) of the Google Maps api script. On other pages of the site, we’re also displaying Google Maps and so need to ensure that the Google Maps api script is loaded. As Events Calendar (Pro) loads the api script on its related pages only, that means that when I load it in the template for the other pages, it gets doubled up on the Events Calendar pages. So for that reason, I’ve set up my script to enqueue on pages OTHER THAN Events Calendar related pages. This is working using

    wp_register_script('googlemaps', 'https://maps.googleapis.com/maps/api/js?key=AIzaSyDyAZ99za_vXoHJVoIYZzB3zTtB3pwirto',['jquery'],null,true);
         
    if (!is_singular(array('tribe_events', 'tribe_venue', 'tribe_organizer'))) {
        wp_enqueue_script('googlemaps');
    }

    but only on the single pages. On the main Events archive page it’s still loading your version and mine and is causing the “You have included the Google Maps API multiple times on this page. This may cause unexpected errors.” error in the console. So I’m still working at figuring out how to not add my version of the script to that particular page and was wondering if you had an idea on that. Otherwise, how can I go about having the Events Calendar version not load at all, and we’ll just load it from our theme on all pages instead?

    Thanks,
    Kevin

    in reply to: Google map not displaying on events or venue pages #1140593
    Gonzalo Alatorre
    Participant

    This reply is private.

    in reply to: Google map not displaying on events or venue pages #1139956
    Gonzalo Alatorre
    Participant

    This reply is private.

Viewing 8 posts - 1 through 8 (of 8 total)