Cookie block helper function added warning message
-
Hello, I guess I made too many edits to the previous post, not sure if it is still up, so posting it again with needed edits from my site. Apologize if it is a duplicate, I just don’t want this not be seen.
I have added cookie block helper function to the functions.php page and noticed a warning in WordPress Dashboard and any other admin page. Though, that error does not show up on the site itself. Does it mean cookie function doesn’t work and will not block cookies?
Warning message (XXX is used to not disclose folder names)
“Cannot modify header information – headers already sent by (output started at /home/XXX/public_html/wp-content/themes/XXX/functions.php:64) in /home/XXX/public_html/wp-admin/includes/misc.php on line 1116”Also, no longer cannot login to wordpress, this is the warning message:
“Warning: Cannot modify header information – headers already sent by (output started at /home/XXX/public_html/wp-content/themes/XXX/functions.php:60) in /home/XXX/public_html/wp-includes/pluggable.php on line 1216”This is how functions.php file looks: (XXX is used to not disclose sensitive info)
<?php add_action( 'wp_enqueue_scripts', 'XXX_child_theme_scripts' ); function XXX_child_theme_scripts() { wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' ); } //Cookie Opt-Out code for GDPR //Google Analytics add_action( 'wp_head', 'my_google_opt_out' ); function my_google_opt_out() { if ( is_allowed_cookie( '_ga' ) ) { ?> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'XX-XXXXXXXXX-X', 'auto'); ga('send', 'pageview'); </script> <?php } } //SharpSpring Analytics add_action( 'wp_head', 'my_sharpspring_opt_out' ); function my_sharpspring_opt_out() { if ( is_allowed_cookie( '_ss' ) ) { ?> <script type="text/javascript"> var _ss = _ss || []; _ss.push(['_setDomain', 'XXXXXX']); _ss.push(['_setAccount', 'XXXXXX']); _ss.push(['_trackPageView']); (function() { var ss = document.createElement('script'); ss.type = 'text/javascript'; ss.async = true; ss.src = ('https:' == document.location.protocol ? 'https://' : 'https://') + 'XXXXX/ss.js?ver=1.1.1'; var scr = document.getElementsByTagName('script')[0]; scr.parentNode.insertBefore(ss, scr); })(); </script> <?php } } ?>
- The topic ‘Cookie block helper function added warning message’ is closed to new replies.