• Resolved ppwebox

    (@ppwebox)


    As others have had this issue with Modern Events Calendar plugin and its Google Maps function either always loading or not at all despite full user consent (yes to statistic cookies), here’s a new request to solve this issue.

    First Google Maps was always loaded regardless of user consent. Then I added the MEC gmap link [/wp-content/plugins/modern-events-calendar/assets/js/googlemap.js] to the Script Center to block in Category Statistics with Placeholder enabled. Now nothing is loaded at all, not even a placeholder, if I agree to statistical cookies in the banner. Caches cleared etc. Seems complianz is promising too much for what in reality requires extensive customizing.

    jarnovos actually had provided a link [https://raw.githubusercontent.com/Really-Simple-Plugins/complianz-integrations/master/webnus-modern-events-calendar.php] to a snippet to solve the problem a year ago but that link has vanished for no good reason. Why do you post solutions and then delete them later?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Jarno Vos

    (@jarnovos)

    Hi @ppwebox,

    Each Map plugin has its differences and may therefore require a separate integration. Aside of googlemap.js, there are a number of other MEC scripts that you would have to block (and some dependencies are necessary as well). That’s likely why the integration you created doesn’t behave as expected.

    The integration that I mentioned in that year old thread is still there, the URL had changed though; due to the GitHub folder structure being updated.

    https://raw.githubusercontent.com/Really-Simple-Plugins/complianz-integrations/master/Google%20Maps/webnus-modern-events-calendar.php

    You can place it as a .php file in the /wp-content/mu-plugins/ folder.

    Kind regards, Jarno

    Thread Starter ppwebox

    (@ppwebox)

    Thanks Jarno, this script works perfectly with Webnus MEC as far as I can see.

    Plugin Contributor Jarno Vos

    (@jarnovos)

    Hi @ppwebox,

    Appreciate the quick confirmation, glad to hear that it works well for you!

    If you’re happy with the plugin and our support, it would be really great if you could consider casting a review about the plugin here: https://wordpress.org/support/plugin/complianz-gdpr/reviews/

    Kind regards, Jarno

    Thread Starter ppwebox

    (@ppwebox)

    Hi Jarno

    While analyzing a client site (with Modern Events Calendar installed) for page load improvement I noticed that your script is loading Google Maps on every page which is bad for performance!

    Would it be possible to modify the script to only load Google Maps on shop pages where the URL slug contains “/events/”? I tried the check in the cmplz_known_script_tags filter but Maps is still loading.

    function cmplz_webnus_modern_events_googlemaps_script( $tags ) {
    $tags[] = array(
    ‘name’ => ‘google-maps’,
    ‘placeholder’ => ‘google-maps’,
    ‘category’ => ‘statistics’,
    ‘urls’ => array(
    ‘richmarker’,
    ‘maps.googleapis.com/maps/api/js’,
    ‘googlemap.js’,
    ‘function mec_init_gmap’,
    ‘mecGoogleMaps’,
    ),
    ‘enable_placeholder’ => ‘1’,
    ‘placeholder_class’ => ‘mec-googlemap-details’,
    ‘enable_dependency’ => ‘1’,
    ‘dependency’ => [
    //’wait-for-this-script’ => ‘script-that-should-wait’
    ‘maps.googleapis.com/maps/api/js’ => ‘googlemap.js’,
    ‘googlemap.js’ => ‘richmarker’,
    ‘richmarker’ => ‘function mec_init_gmap’,
    ‘richmarker’ => ‘mecGoogleMaps’,
    ],
    );
    return $tags;
    }
    add_filter( ‘cmplz_known_script_tags’, ‘cmplz_webnus_modern_events_googlemaps_script’ );

    • Add services to the list of detected items, so it will get set as default, and will be added to the notice about it
    • @param $services
    • @return array
      */
      function cmplz_webnus_detected_services( $services ) {
      global $wp;
      $url_slug = add_query_arg( array(), $wp->request );
      $url_slug = ‘/’ . $url_slug;
      if ( strpos($url_slug, ‘/events/’) !== false && ! in_array( ‘google-maps’, $services ) ) {
      $services[] = ‘google-maps’;
      } return $services;
      }
      add_filter( ‘cmplz_detected_services’, ‘cmplz_webnus_detected_services’ );
    Plugin Contributor Jarno Vos

    (@jarnovos)

    Hi @ppwebox,

    The above snippet doesn’t enqueue the Google Maps scripts on its’ own, it blocks the ones that are loaded by the MEC plugin.

    Kind regards, Jarno

    Thread Starter ppwebox

    (@ppwebox)

    Thanks for the clarification. But why omit that it is Complianz that is actually loading Google Maps on ever page (this site only really uses it on one singe page)?

    Proof is in the html source code of every page:

    <script  type="text/plain" data-service="google-maps" data-category="statistics"  data-cmplz-src="//maps.googleapis.com/maps/api/js?libraries=places&amp;key=AIzaSyAI2EabN_2uN0AzVPflalJuBuJ6Yn8aAyE&amp;language=de&amp;region=DE&amp;ver=7.4.0.1703811086" id="googlemap-js"></script>

    So again: how can this senseless GMaps loading be circumvented and only load when it is actually called by the Modern Events Calendar plugin on the specific page? Complianz is seriously affecting page speed performance here!

    Plugin Contributor Jarno Vos

    (@jarnovos)

    Hi @ppwebox,

    As mentioned, Complianz does not enqueue this script on the page. It merely modifies (blocks) the above script, which is enqueued by MEC itself.

    You can check it yourself, disable Complianz for a brief moment and check the page again. You should find that the same script is still there, just without the Complianz consent parameters included now that it’s no longer active & blocking the script.

    Kind regards, Jarno

    Thread Starter ppwebox

    (@ppwebox)

    Thanks Jarno, this is the case, indeed. Once again, the culprit is Modern Events Calendar.

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

The topic ‘Google Maps via Modern Events Calendar’ is closed to new replies.