Add the HTTPS protocol to the Google Tag Manager path if it is path relative.
<?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