Created
February 13, 2021 22:03
-
-
Save 2ndkauboy/bcab679895b7be376c5b9ebc35897165 to your computer and use it in GitHub Desktop.
Add the HTTPS protocol to the Google Tag Manager path if it is path relative.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Google Analytics for WordPress Security Fix | |
* | |
* @package gafwsf | |
* @author Bernhard Kau | |
* @license GPLv3 | |
* | |
* @wordpress-plugin | |
* Plugin Name: Google Analytics for WordPress Security Fix | |
https://gist.github.com/2ndkauboy/bcab679895b7be376c5b9ebc35897165 | |
* Description: Add the HTTPS protocol to the Google Tag Manager path if it is path relative. | |
* Version: 1.0.0 | |
* Author: Bernhard Kau | |
* Author URI: https://kau-boys.de | |
* Text Domain: gafwsf | |
* License: GPLv3 | |
* License URI: https://www.gnu.org/licenses/gpl-3.0.txt | |
*/ | |
/** | |
* Add the HTTPS protocol to the Google Tag Manager path if it is path relative. | |
* | |
* @param string $src The current Google Tag Manager Tag path. | |
* | |
* @return string | |
*/ | |
function gafwsf_gtag_src( $src ) { | |
if ( 0 === strpos( $src, '//' ) ) { | |
$src = 'https:' . $src; | |
} | |
return $src; | |
} | |
add_filter( 'monsterinsights_frontend_output_gtag_src', 'gafwsf_gtag_src' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment