Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1406733

    I’m troubleshooting a double instantiation of google maps on my admin site.
    I’ve disabled google maps as follows:

    disabled

    In my admin page I still see the following:

    
     /* <![CDATA[ */
    var avia_framework_globals = avia_framework_globals || {};
    	avia_framework_globals.gmap_api = '';
    	avia_framework_globals.gmap_version = '3.52';
    	avia_framework_globals.gmap_maps_loaded = 'https://maps.googleapis.com/maps/api/js?v=3.52&callback=aviaOnGoogleMapsLoaded';
    	avia_framework_globals.gmap_builder_maps_loaded = 'https://maps.googleapis.com/maps/api/js?v=3.52&callback=av_builder_maps_loaded';
    	avia_framework_globals.gmap_backend_maps_loaded = 'https://maps.googleapis.com/maps/api/js?v=3.52&callback=av_backend_maps_loaded';
    	avia_framework_globals.gmap_source = 'https://maps.googleapis.com/maps/api/js?v=3.52';
    	...
    /* ]]> */
    ...
    <script src="https://maps.googleapis.com/maps/api/js?v=3.52&callback=aviaOnGoogleMapsLoaded" id="avia-google-maps-api-js"></script>

    I don’t require google maps for the theme at all, so by modifying class-gmaps.php as follows I remove the collision:

      public function handler_wp_register_scripts()
                    {
    return;
                            $vn = avia_get_theme_version();
                            $min_js = avia_minify_extension( 'js' );
    ...

    This seems to be a bug but would like clarification whether there is anything else I can do to prevent maps load.

    Theme Details:
    Your current Enfold Theme Version Number is 5.6
    Your PHP version: 8.1.18

    Thanks

    #1406826

    Hey webservantnaoz,

    Thank you for the inquiry.

    Once Google Maps is disabled from the theme options, the map scripts should not load. However, if you want to completely disable the map API, you can add the following filter to your functions.php file:

    function avf_disable_google_map_api($load_google_map_api) {
            $load_google_map_api = false;
            return $load_google_map_api;
    }
    add_filter('avf_load_google_map_api', 'avf_disable_google_map_api', 10, 1);

    Best regards,
    Ismael

    #1408046

    Hi Ismael,

    I used the fix from this post: https://kriesi.at/support/reply/1396490/

    I couldn’t even find a reference to the above filter:

    
    grep -R avf_load_google_map_api *
    framework/php/class-gmaps.php:           * true if loading of google script was canceled with filter 'avf_load_google_map_api_prohibited'
    framework/php/class-gmaps.php:           * true if loading of google script was canceled with filter 'avf_load_google_map_api_prohibited'
    framework/php/class-gmaps.php:                          $loading_prohibited = apply_filters( 'avf_load_google_map_api_prohibited', false );
    framework/php/class-gmaps.php:                                  apply_filters_deprecated( 'avf_load_google_map_api_prohibited', array( false ),'4.5.7.1', false, __( 'Filter was replaced by theme option', 'avia_framework' ) );
    

    This does appear to be a bug – unless there is some other reason we would load the gmaps scripts on the backend when you’ve disabled it in the theme.

    What’s the best way to make this fix permanent, I’m assuming a functions.php gets overwritten at some stage?

    Thanks

    #1408215

    Hi,

    Try to insert these additional filters to prevent the registration of the backend scripts.

    add_filter("avf_skip_enqueue_scripts_backend_gmaps", function($skip) {
       return "skip_loading";
    }, 10, 1);
    
    add_filter("avf_load_google_map_api_prohibited", function($prohibit) {
       return true;
    }, 10, 1);
    

    You can find these filters in the enfold/framework/php/class-gmaps.php file, within the handler_wp_admin_footer function.

    Best regards,
    Ismael

    #1408227

    Thanks Ishmael. First filter avf_skip_enqueue_scripts_backend_gmaps does the job.

    #1408372

    Hi,

    Excellent! Delighted to hear that the solution worked for you. If you have any more questions or need further assistance with the theme, please don’t hesitate to start a new thread.

    Have a nice day.

    Best regards,
    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Disable Google Maps does not prevent conditional load script activation’ is closed to new replies.