-
AuthorPosts
-
May 8, 2023 at 12:42 pm #1406733
I’m troubleshooting a double instantiation of google maps on my admin site.
I’ve disabled google maps as follows: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.18Thanks
- This topic was modified 1 year, 6 months ago by webservantnaoz.
- This topic was modified 1 year, 6 months ago by webservantnaoz.
May 9, 2023 at 5:08 am #1406826Hey 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,
IsmaelMay 21, 2023 at 3:54 am #1408046Hi 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
May 23, 2023 at 4:52 am #1408215Hi,
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,
IsmaelMay 23, 2023 at 9:07 am #1408227Thanks Ishmael. First filter avf_skip_enqueue_scripts_backend_gmaps does the job.
May 24, 2023 at 5:02 am #1408372 -
AuthorPosts
- The topic ‘Disable Google Maps does not prevent conditional load script activation’ is closed to new replies.