Key-value pairs representing <script> tag attributes.
Only the attribute name is added to the <script> tag for entries with a boolean value, and that are true.
var wporgFunctionReferenceI18n = {“copy”:”Copy”,”copied”:”Code copied”,”expand”:”Expand code”,”collapse”:”Collapse code”,”sourceFile”:”wp-includes/script-loader.php”};
//# sourceURL=wporg-developer-function-reference-js-extra
var quicktagsL10n = {“closeAllOpenTags”:”Close all open tags”,”closeTags”:”close tags”,”enterURL”:”Enter the URL”,”enterImageURL”:”Enter the URL of the image”,”enterImageDescription”:”Enter a description of the image”,”textdirection”:”text direction”,”toggleTextdirection”:”Toggle Editor Text Direction”,”dfw”:”Distraction-free writing mode”,”strong”:”Bold”,”strongClose”:”Close bold tag”,”em”:”Italic”,”emClose”:”Close italic tag”,”link”:”Insert link”,”blockquote”:”Blockquote”,”blockquoteClose”:”Close blockquote tag”,”del”:”Deleted text (strikethrough)”,”delClose”:”Close deleted text tag”,”ins”:”Inserted text”,”insClose”:”Close inserted text tag”,”image”:”Insert image”,”ul”:”Bulleted list”,”ulClose”:”Close bulleted list tag”,”ol”:”Numbered list”,”olClose”:”Close numbered list tag”,”li”:”List item”,”liClose”:”Close list item tag”,”code”:”Code”,”codeClose”:”Close code tag”,”more”:”Insert Read More tag”};
//# sourceURL=quicktags-js-extra
var wporg_note_preview = {“ajaxurl”:”https://developer.wordpress.org/wp-admin/admin-ajax.php”,”nonce”:”de3c1c9510″,”preview”:”preview note”,”preview_empty”:”Nothing to preview”,”is_admin”:””};
//# sourceURL=wporg-developer-preview-js-extra
Skip to note 2 content
Matt Radford
If you want to harden your website against supply chain attacks, you can use this filter to add Subresource integrity checking to a script.
For example, for Select2 script at v4.0.9 from cdnjs.com, you would copy the SRI hash from https://cdnjs.com/libraries/select2/4.0.9, and add it as an attribute to the script.
Then check for the select2-js ID, and that it is delivered by CDNJS, before adding the SRI attributes.
/** * Add Subresource Integrity check to CDNJS Select2 script. * * @param array $attr Attributes of each script. * * @return array $attr Attributes of each script. */ function wpdocs_script_subresource_integrity( array $attr ): array { if ( empty( $attr['id'] ) || empty( $attr['src'] ) ) { return $attr; } if ( 'select2-js' === $attr['id'] && str_contains( $attr['src'], 'cdnjs.cloudflare.com' ) ) { $attr['integrity'] = 'sha512-9p/L4acAjbjIaaGXmZf0Q2bV42HetlCLbv8EP0z3rLbQED2TAFUlDvAezy7kumYqg5T8jHtDdlm1fgIsr5QzKg=='; $attr['crossorigin'] = 'anonymous'; } return $attr; } add_filter( 'wp_script_attributes', 'wpdocs_script_subresource_integrity', 10, 1 );