-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Refactor <script> tag to be generated by wp_get_script_tag and related functions.
#498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Refactor <script> tag to be generated by wp_get_script_tag and related functions.
#498
Conversation
cda5081 to
cd28054
Compare
felixarntz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there are some WordPress coding standards violations in here: https://travis-ci.com/github/WordPress/wordpress-develop/jobs/378458383 Have you set up your local environment to lint for these?
src/wp-includes/functions.php
Outdated
| * @param string $javascript Inline JavaScript code. | ||
| * @param array $attributes Key-value pairs representing `<script>` tag attributes. | ||
| */ | ||
| do_action( 'wp_get_inline_script_tag', $javascript, $attributes ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ayesh I added the change you suggested. Would you mind giving me your opinion on this?
It can be used in the following way:
add_action(
'wp_get_inline_script_tag',
function ( $js ) {
$hash = sha256( $js );
header( "Content-Security-Policy: script-src 'sha256-$hash'" );
}
);Edit: the change was reverted; relevant discussion here.
<script> tag to be generated by wp_get_script_tag and related functions.
1c12606 to
609bdbe
Compare
8defd6c to
24c26b9
Compare
…s/script-loader.php`.
…s/widgets/class-wp-widget-categories.php`.
…ncludes/misc.php`.
…ncludes/meta-boxes.php`.
…ncludes/media.php`.
…ncludes/deprecated.php`.
…ncludes/class-wp-upgrader-skin.php`.
…ncludes/class-wp-themes-list-table.php`.
…ncludes/class-wp-list-table.php`.
…ncludes/class-wp-internal-pointers.php`.
…ncludes/class-custom-image-header.php`.
…ncludes/class-bulk-upgrader-skin.php`.
…ncludes/ajax-actions.php`.
…dit-tag-form.php`.
…dit-form-comment.php`.
…dit-form-advanced.php`.
…dmin-header.php`.
…dmin-footer.php`.
…s/functions.php`.
24c26b9 to
2420dc1
Compare
|
Closed with changeset https://core.trac.wordpress.org/changeset/50167 |
|
@hellofromtonya Actually, no. That commit only resolved #498. |
This PR uses the newly introduced script tag formatting functions introduced in #591 to generate every script tag.
I followed this guide on adopting CSP, considering the
strict-dynamicoption enabled.I made a plugin prototype that enables Strict CSP to test these changes.
Trac ticket: https://core.trac.wordpress.org/ticket/39941
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.