Comments (13)
I can of course.
What about adding a filter like gtm4wp_get_csp_nonce and what is returned is added to the <script> tag?
from gtm4wp.
I'm just finishing my vacation time, will do the release next week
from gtm4wp.
Indeed, however 1.21 beta1 is now out, you can test it:
https://github.com/duracelltomi/gtm4wp/releases/tag/1.21.beta1
from gtm4wp.
This filter was removed because it introduced some security risks.
If you want to alter the container code in any way, you should turn off the container code in plugin options and add your own container code using the GTM4WP_WPACTION_AFTER_CONTAINER_CODE / gtm4wp_after_container_code filter which fires regardless of whether container code is turned on or off in plugin settings.
Just make sure to output the full header script.
from gtm4wp.
Datalayer script is making it impossible to add to CSP as hash, as it is dynamically created and it's different on every page:
<script data-cfasync="false" data-pagespeed-no-defer' . ( $has_html5_support ? ' type="text/javascript"' : '' ) . ( $add_cookiebot_ignore ? ' data-cookieconsent="ignore"' : '' ) . '>';
if ( '' !== $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] ) {
$gtm4wp_datalayer_data = array();
$gtm4wp_datalayer_data = (array) apply_filters( GTM4WP_WPFILTER_COMPILE_DATALAYER, $gtm4wp_datalayer_data );
echo '
var dataLayer_content = ' . wp_json_encode( $gtm4wp_datalayer_data, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK ) . ';';
echo '
' . esc_js( $gtm4wp_datalayer_name ) . '.push( dataLayer_content );';
}
echo '
</script>';
It is not the container itself, as it can be added to CSP as hash.
But what to do with datalayer script?
Wouldn't it be worth considering adding a filter for nonce?
from gtm4wp.
That would be great!
from gtm4wp.
I tried to help, so created a pull request here: #352
from gtm4wp.
Please review this branch: 7faf339
from gtm4wp.
Looking good @duracelltomi ! Thank you for your effort, this is indeed an improvement and a huge help to anyone who's using your plugin and dealing with CSP setup.
from gtm4wp.
@duracelltomi what's the status, would you like to release this update soon?
from gtm4wp.
@duracelltomi just wanted to follow up, will the release be public soon?
from gtm4wp.
If nothing extreme happens, tomorrow.
from gtm4wp.
Something extreme must have happened! :) @duracelltomi
from gtm4wp.
Related Issues (20)
- String vs id in view_item_details HOT 8
- Uncaught TypeError: Cannot read properties of null (reading 'scrollTop') HOT 2
- view_item only active if variations selected HOT 5
- EVENT PURCHASE DON'T FIRE ON LINK ORDER PAY WOOCOMMERCE HOT 24
- Add Custom Fields to datalayer HOT 8
- Clicking on a product only loads browser after 2-3 secondes. HOT 5
- DataLayer BUG in variable product HOT 7
- PHP Deprecated: Creation of dynamic property WhichBrowser\\Analyser\\Header\\Useragent::$data is deprecated HOT 1
- WebToffee plugin integration consent denied update HOT 1
- FacebookPixel template not working HOT 4
- Problem with random products in add to cart HOT 4
- Plugin blocks Link-Clicks HOT 3
- DataLayer not compliant with Google specifications. HOT 2
- GTM4WP - Category product links take seconds to open HOT 2
- add to cart doesn't fire HOT 1
- 1.18 -> 1.20.2 not tracking ecommerce events HOT 7
- Item categories have different & signs on view_item and view_item_list HOT 6
- Google Tag Assistant Suddenly Won't Connect HOT 1
- Integration with Partytown
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gtm4wp.