Okay
  Public Ticket #3155439
Google Connection
Closed

Comments

  • Christian started the conversation

    Google-Maps script is loaded automatically via functions.php of the parent theme. Is there any way to delete the connection (maps.googleapis.com) to Google? When i block the script (for example with the Borlabs script blocker) the site shows a white page and no content any more. Because of privacy regulations in the EU we have a need to do that. Many thanks for your Support!
    Kind regards

    Christian

    Attached files:  Bildschirmfoto 2022-10-28 um 07.19.10.png

  •  234
    Elena replied

    Hi Christian,

    You should be able to prevent the GMaps script from loading this way:

    - Activate the child theme

    - Open the functions.php file of the child theme, and add this function:

    function hemma_dequeue_maps() {
    wp_dequeue_script( 'google-maps' );
    }
    add_action( 'wp_print_scripts', 'hemma_dequeue_maps' );

    - Save the file and upload to the server

    Best, Elena

  • Christian replied

    Hi Elena, thank you for you quick replay, but the code has no effect. I hope you can help me further.

    Kind regards

    Christian

    Attached files:  Bildschirmfoto 2022-10-28 um 08.40.42.png
      Bildschirmfoto 2022-10-28 um 08.41.53.png

  •  234
    Elena replied

    Please try with this:

    function hemma_dequeue_maps() {
    wp_dequeue_script( 'google-maps' );
    wp_deregister_script( 'google-maps' );
    }
    add_action( 'wp_print_scripts', 'hemma_dequeue_maps' );

  • Christian replied

    Hi, now i have a blank page but the connection was interrupted.

    Kind regards

    Christian

    Attached files:  Bildschirmfoto 2022-10-28 um 09.52.03.png

  •  234
    Elena replied

    Would you mind to provide access to your WP so I can have a look? If so, please make a PRIVATE ticket with credentials.

  •   Christian replied privately
  •  234
    Elena replied

    Let's use this in your child theme:

    function hemma_dequeue_maps() {
    wp_dequeue_script( 'google-maps' );
    wp_deregister_script( 'google-maps' );
    }
    add_action( 'wp_print_scripts', 'hemma_dequeue_maps' );

    function hemma_child_scripts() {
        wp_enqueue_style( 'hemma-child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array( 'hemma-style' ),
            wp_get_theme()->get('Version')
        );
    wp_enqueue_script( 'hemma-plugins-js', get_stylesheet_directory_uri() . '/js/plugins.js', array('jquery'), false, true );
    wp_enqueue_script( 'hemma-js', get_stylesheet_directory_uri() . '/js/main.js', array('jquery'), false, true );
    }
     add_action( 'wp_enqueue_scripts', 'hemma_child_scripts' );

    Then, in your child theme you need to add the js folder that I've attached (unzip it first).

    Best,

    Elena


    Attached files:  js.zip

  • Christian replied

    Hi Elena, this works perfect!! Many thanks!


    Kind regards

    Christian

  •  234
    Elena replied

    Sounds great!