Last update at :2024-06-16,Edit by888u
Many overseas themes and plug-ins have built-in Google Maps API calling functions. Although the Google Maps API is loaded asynchronously, it does increase the total loading time of the page. This feature is not used on most websites. We can disable this feature in order to improve the website opening speed. Today we share how to disable the Google Maps API in WordPress without a plug-in.
- /*
- * Disable Google Maps API
- */
- function disable_google_map_api($load_google_map_api) {
- $load_google_map_api = false;
- return $load_google_map_api;
- }
- $plugins = get_option('active_plugins');
- $required_plugin = 'auto-location-pro/auto-location.php';
- if ( in_array( $required_plugin , $plugins ) ) {
- add_filter('avf_load_google_map_api', 'disable_google_map_api', 10, 1);
- }
Add the above script code to the functions.php file in your current theme.
We can also disable Google Maps calls for the entire site using the code below:
- add_filter( 'avf_load_google_map_api', '__return_false' );
Similarly write functions.php and save. Using this code will not only disable the Google Map calling function of the entire site, but also disable embedded web pages containing maps. However, in the end, you still need to actually check whether the Google Maps API is banned. If it still loads, you need to find other solutions. Some functions are added directly to the web page code. You need to find this file and delete these calling codes.
Recommended site search: expired registered domain name query, Shanghai domain name registration, foreign vps server rental, foreign server rental price, foreign trade host, Hong Kong IP, foreign virtual host, Hong Kong cn2 server, website virtual host space, query whether the domain name is registered,
发表评论