From 9eb50418034ae2e467b076c22755eb0b0b96efe4 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Fri, 15 Aug 2025 18:39:46 -0500 Subject: [PATCH 01/30] Remove support for IE conditional scripts and styles Returns false if conditional scripts or styles are identified; updates comments; removes files that were only loaded conditionally. --- Gruntfile.js | 1 - src/js/_enqueues/vendor/json2.js | 519 ------------------- src/wp-includes/class-wp-scripts.php | 37 +- src/wp-includes/class-wp-styles.php | 17 +- src/wp-includes/css/wp-embed-template-ie.css | 19 - src/wp-includes/embed.php | 1 - src/wp-includes/functions.wp-scripts.php | 3 +- src/wp-includes/functions.wp-styles.php | 5 +- src/wp-includes/script-loader.php | 13 +- tests/phpunit/tests/dependencies/scripts.php | 25 +- tests/phpunit/tests/dependencies/styles.php | 1 - 11 files changed, 29 insertions(+), 612 deletions(-) delete mode 100644 src/js/_enqueues/vendor/json2.js delete mode 100644 src/wp-includes/css/wp-embed-template-ie.css diff --git a/Gruntfile.js b/Gruntfile.js index a577b0711dacb..1844a9574df3a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -644,7 +644,6 @@ module.exports = function(grunt) { // Exceptions. '!wp-includes/css/dashicons.css', '!wp-includes/css/wp-embed-template.css', - '!wp-includes/css/wp-embed-template-ie.css' ] }, colors: { diff --git a/src/js/_enqueues/vendor/json2.js b/src/js/_enqueues/vendor/json2.js deleted file mode 100644 index 7f685256288f8..0000000000000 --- a/src/js/_enqueues/vendor/json2.js +++ /dev/null @@ -1,519 +0,0 @@ -/* - json2.js - 2015-05-03 - - Public Domain. - - NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. - - See http://www.JSON.org/js.html - - - This code should be minified before deployment. - See http://javascript.crockford.com/jsmin.html - - USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO - NOT CONTROL. - - - This file creates a global JSON object containing two methods: stringify - and parse. This file is provides the ES5 JSON capability to ES3 systems. - If a project might run on IE8 or earlier, then this file should be included. - This file does nothing on ES5 systems. - - JSON.stringify(value, replacer, space) - value any JavaScript value, usually an object or array. - - replacer an optional parameter that determines how object - values are stringified for objects. It can be a - function or an array of strings. - - space an optional parameter that specifies the indentation - of nested structures. If it is omitted, the text will - be packed without extra whitespace. If it is a number, - it will specify the number of spaces to indent at each - level. If it is a string (such as '\t' or ' '), - it contains the characters used to indent at each level. - - This method produces a JSON text from a JavaScript value. - - When an object value is found, if the object contains a toJSON - method, its toJSON method will be called and the result will be - stringified. A toJSON method does not serialize: it returns the - value represented by the name/value pair that should be serialized, - or undefined if nothing should be serialized. The toJSON method - will be passed the key associated with the value, and this will be - bound to the value - - For example, this would serialize Dates as ISO strings. - - Date.prototype.toJSON = function (key) { - function f(n) { - // Format integers to have at least two digits. - return n < 10 - ? '0' + n - : n; - } - - return this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z'; - }; - - You can provide an optional replacer method. It will be passed the - key and value of each member, with this bound to the containing - object. The value that is returned from your method will be - serialized. If your method returns undefined, then the member will - be excluded from the serialization. - - If the replacer parameter is an array of strings, then it will be - used to select the members to be serialized. It filters the results - such that only members with keys listed in the replacer array are - stringified. - - Values that do not have JSON representations, such as undefined or - functions, will not be serialized. Such values in objects will be - dropped; in arrays they will be replaced with null. You can use - a replacer function to replace those with JSON values. - JSON.stringify(undefined) returns undefined. - - The optional space parameter produces a stringification of the - value that is filled with line breaks and indentation to make it - easier to read. - - If the space parameter is a non-empty string, then that string will - be used for indentation. If the space parameter is a number, then - the indentation will be that many spaces. - - Example: - - text = JSON.stringify(['e', {pluribus: 'unum'}]); - // text is '["e",{"pluribus":"unum"}]' - - - text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); - // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' - - text = JSON.stringify([new Date()], function (key, value) { - return this[key] instanceof Date - ? 'Date(' + this[key] + ')' - : value; - }); - // text is '["Date(---current time---)"]' - - - JSON.parse(text, reviver) - This method parses a JSON text to produce an object or array. - It can throw a SyntaxError exception. - - The optional reviver parameter is a function that can filter and - transform the results. It receives each of the keys and values, - and its return value is used instead of the original value. - If it returns what it received, then the structure is not modified. - If it returns undefined then the member is deleted. - - Example: - - // Parse the text. Values that look like ISO date strings will - // be converted to Date objects. - - myData = JSON.parse(text, function (key, value) { - var a; - if (typeof value === 'string') { - a = -/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); - if (a) { - return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], - +a[5], +a[6])); - } - } - return value; - }); - - myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { - var d; - if (typeof value === 'string' && - value.slice(0, 5) === 'Date(' && - value.slice(-1) === ')') { - d = new Date(value.slice(5, -1)); - if (d) { - return d; - } - } - return value; - }); - - - This is a reference implementation. You are free to copy, modify, or - redistribute. -*/ - -/*jslint - eval, for, this -*/ - -/*property - JSON, apply, call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, - getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, - lastIndex, length, parse, prototype, push, replace, slice, stringify, - test, toJSON, toString, valueOf -*/ - - -// Create a JSON object only if one does not already exist. We create the -// methods in a closure to avoid creating global variables. - -if (typeof JSON !== 'object') { - JSON = {}; -} - -(function () { - 'use strict'; - - var rx_one = /^[\],:{}\s]*$/, - rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, - rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, - rx_four = /(?:^|:|,)(?:\s*\[)+/g, - rx_escapable = /[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; - - function f(n) { - // Format integers to have at least two digits. - return n < 10 - ? '0' + n - : n; - } - - function this_value() { - return this.valueOf(); - } - - if (typeof Date.prototype.toJSON !== 'function') { - - Date.prototype.toJSON = function () { - - return isFinite(this.valueOf()) - ? this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z' - : null; - }; - - Boolean.prototype.toJSON = this_value; - Number.prototype.toJSON = this_value; - String.prototype.toJSON = this_value; - } - - var gap, - indent, - meta, - rep; - - - function quote(string) { - -// If the string contains no control characters, no quote characters, and no -// backslash characters, then we can safely slap some quotes around it. -// Otherwise we must also replace the offending characters with safe escape -// sequences. - - rx_escapable.lastIndex = 0; - return rx_escapable.test(string) - ? '"' + string.replace(rx_escapable, function (a) { - var c = meta[a]; - return typeof c === 'string' - ? c - : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }) + '"' - : '"' + string + '"'; - } - - - function str(key, holder) { - -// Produce a string from holder[key]. - - var i, // The loop counter. - k, // The member key. - v, // The member value. - length, - mind = gap, - partial, - value = holder[key]; - -// If the value has a toJSON method, call it to obtain a replacement value. - - if (value && typeof value === 'object' && - typeof value.toJSON === 'function') { - value = value.toJSON(key); - } - -// If we were called with a replacer function, then call the replacer to -// obtain a replacement value. - - if (typeof rep === 'function') { - value = rep.call(holder, key, value); - } - -// What happens next depends on the value's type. - - switch (typeof value) { - case 'string': - return quote(value); - - case 'number': - -// JSON numbers must be finite. Encode non-finite numbers as null. - - return isFinite(value) - ? String(value) - : 'null'; - - case 'boolean': - case 'null': - -// If the value is a boolean or null, convert it to a string. Note: -// typeof null does not produce 'null'. The case is included here in -// the remote chance that this gets fixed someday. - - return String(value); - -// If the type is 'object', we might be dealing with an object or an array or -// null. - - case 'object': - -// Due to a specification blunder in ECMAScript, typeof null is 'object', -// so watch out for that case. - - if (!value) { - return 'null'; - } - -// Make an array to hold the partial results of stringifying this object value. - - gap += indent; - partial = []; - -// Is the value an array? - - if (Object.prototype.toString.apply(value) === '[object Array]') { - -// The value is an array. Stringify every element. Use null as a placeholder -// for non-JSON values. - - length = value.length; - for (i = 0; i < length; i += 1) { - partial[i] = str(i, value) || 'null'; - } - -// Join all of the elements together, separated with commas, and wrap them in -// brackets. - - v = partial.length === 0 - ? '[]' - : gap - ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' - : '[' + partial.join(',') + ']'; - gap = mind; - return v; - } - -// If the replacer is an array, use it to select the members to be stringified. - - if (rep && typeof rep === 'object') { - length = rep.length; - for (i = 0; i < length; i += 1) { - if (typeof rep[i] === 'string') { - k = rep[i]; - v = str(k, value); - if (v) { - partial.push(quote(k) + ( - gap - ? ': ' - : ':' - ) + v); - } - } - } - } else { - -// Otherwise, iterate through all of the keys in the object. - - for (k in value) { - if (Object.prototype.hasOwnProperty.call(value, k)) { - v = str(k, value); - if (v) { - partial.push(quote(k) + ( - gap - ? ': ' - : ':' - ) + v); - } - } - } - } - -// Join all of the member texts together, separated with commas, -// and wrap them in braces. - - v = partial.length === 0 - ? '{}' - : gap - ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' - : '{' + partial.join(',') + '}'; - gap = mind; - return v; - } - } - -// If the JSON object does not yet have a stringify method, give it one. - - if (typeof JSON.stringify !== 'function') { - meta = { // table of character substitutions - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"': '\\"', - '\\': '\\\\' - }; - JSON.stringify = function (value, replacer, space) { - -// The stringify method takes a value and an optional replacer, and an optional -// space parameter, and returns a JSON text. The replacer can be a function -// that can replace values, or an array of strings that will select the keys. -// A default replacer method can be provided. Use of the space parameter can -// produce text that is more easily readable. - - var i; - gap = ''; - indent = ''; - -// If the space parameter is a number, make an indent string containing that -// many spaces. - - if (typeof space === 'number') { - for (i = 0; i < space; i += 1) { - indent += ' '; - } - -// If the space parameter is a string, it will be used as the indent string. - - } else if (typeof space === 'string') { - indent = space; - } - -// If there is a replacer, it must be a function or an array. -// Otherwise, throw an error. - - rep = replacer; - if (replacer && typeof replacer !== 'function' && - (typeof replacer !== 'object' || - typeof replacer.length !== 'number')) { - throw new Error('JSON.stringify'); - } - -// Make a fake root object containing our value under the key of ''. -// Return the result of stringifying the value. - - return str('', {'': value}); - }; - } - - -// If the JSON object does not yet have a parse method, give it one. - - if (typeof JSON.parse !== 'function') { - JSON.parse = function (text, reviver) { - -// The parse method takes a text and an optional reviver function, and returns -// a JavaScript value if the text is a valid JSON text. - - var j; - - function walk(holder, key) { - -// The walk method is used to recursively walk the resulting structure so -// that modifications can be made. - - var k, v, value = holder[key]; - if (value && typeof value === 'object') { - for (k in value) { - if (Object.prototype.hasOwnProperty.call(value, k)) { - v = walk(value, k); - if (v !== undefined) { - value[k] = v; - } else { - delete value[k]; - } - } - } - } - return reviver.call(holder, key, value); - } - - -// Parsing happens in four stages. In the first stage, we replace certain -// Unicode characters with escape sequences. JavaScript handles many characters -// incorrectly, either silently deleting them, or treating them as line endings. - - text = String(text); - rx_dangerous.lastIndex = 0; - if (rx_dangerous.test(text)) { - text = text.replace(rx_dangerous, function (a) { - return '\\u' + - ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }); - } - -// In the second stage, we run the text against regular expressions that look -// for non-JSON patterns. We are especially concerned with '()' and 'new' -// because they can cause invocation, and '=' because it can cause mutation. -// But just to be safe, we want to reject all unexpected forms. - -// We split the second stage into 4 regexp operations in order to work around -// crippling inefficiencies in IE's and Safari's regexp engines. First we -// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we -// replace all simple value tokens with ']' characters. Third, we delete all -// open brackets that follow a colon or comma or that begin the text. Finally, -// we look to see that the remaining characters are only whitespace or ']' or -// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. - - if ( - rx_one.test( - text - .replace(rx_two, '@') - .replace(rx_three, ']') - .replace(rx_four, '') - ) - ) { - -// In the third stage we use the eval function to compile the text into a -// JavaScript structure. The '{' operator is subject to a syntactic ambiguity -// in JavaScript: it can begin a block or an object literal. We wrap the text -// in parens to eliminate the ambiguity. - - j = eval('(' + text + ')'); - -// In the optional fourth stage, we recursively walk the new structure, passing -// each name/value pair to a reviver function for possible transformation. - - return typeof reviver === 'function' - ? walk({'': j}, '') - : j; - } - -// If the text is not JSON parseable, then a SyntaxError is thrown. - - throw new SyntaxError('JSON.parse'); - }; - } -}()); \ No newline at end of file diff --git a/src/wp-includes/class-wp-scripts.php b/src/wp-includes/class-wp-scripts.php index 77dff94c0497a..94801b8b220e0 100644 --- a/src/wp-includes/class-wp-scripts.php +++ b/src/wp-includes/class-wp-scripts.php @@ -289,12 +289,14 @@ public function do_item( $handle, $group = false ) { $ver = $ver ? $ver . '&' . $this->args[ $handle ] : $this->args[ $handle ]; } - $src = $obj->src; - $strategy = $this->get_eligible_loading_strategy( $handle ); - $intended_strategy = (string) $this->get_data( $handle, 'strategy' ); - $ie_conditional_prefix = ''; - $ie_conditional_suffix = ''; - $conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : ''; + $src = $obj->src; + $strategy = $this->get_eligible_loading_strategy( $handle ); + $intended_strategy = (string) $this->get_data( $handle, 'strategy' ); + $conditional = isset( $obj->extra['conditional'] ) ? true : false; + if ( $conditional ) { + + return false; + } if ( ! $this->is_delayed_strategy( $intended_strategy ) ) { $intended_strategy = ''; @@ -319,16 +321,11 @@ public function do_item( $handle, $group = false ) { return false; } - if ( $conditional ) { - $ie_conditional_prefix = "\n"; - } - $before_script = $this->get_inline_script_tag( $handle, 'before' ); $after_script = $this->get_inline_script_tag( $handle, 'after' ); if ( $before_script || $after_script ) { - $inline_script_tag = $ie_conditional_prefix . $before_script . $after_script . $ie_conditional_suffix; + $inline_script_tag = $before_script . $after_script; } else { $inline_script_tag = ''; } @@ -364,7 +361,7 @@ public function do_item( $handle, $group = false ) { // Have to print the so-far concatenated scripts right away to maintain the right order. _print_scripts(); $this->reset(); - } elseif ( $this->in_default_dir( $filtered_src ) && ! $conditional ) { + } elseif ( $this->in_default_dir( $filtered_src ) ) { $this->print_code .= $this->print_extra_script( $handle, false ); $this->concat .= "$handle,"; $this->concat_version .= "$handle$ver"; @@ -375,18 +372,8 @@ public function do_item( $handle, $group = false ) { } } - $has_conditional_data = $conditional && $this->get_data( $handle, 'data' ); - - if ( $has_conditional_data ) { - echo $ie_conditional_prefix; - } - $this->print_extra_script( $handle ); - if ( $has_conditional_data ) { - echo $ie_conditional_suffix; - } - // A single item may alias a set of items, by having dependencies, but no source. if ( ! $src ) { if ( $inline_script_tag ) { @@ -425,9 +412,9 @@ public function do_item( $handle, $group = false ) { if ( $intended_strategy ) { $attr['data-wp-strategy'] = $intended_strategy; } - $tag = $translations . $ie_conditional_prefix . $before_script; + $tag = $translations . $before_script; $tag .= wp_get_script_tag( $attr ); - $tag .= $after_script . $ie_conditional_suffix; + $tag .= $after_script; /** * Filters the HTML script tag of an enqueued script. diff --git a/src/wp-includes/class-wp-styles.php b/src/wp-includes/class-wp-styles.php index e64378be5fc8d..a046260cf5b00 100644 --- a/src/wp-includes/class-wp-styles.php +++ b/src/wp-includes/class-wp-styles.php @@ -165,14 +165,11 @@ public function do_item( $handle, $group = false ) { $ver = $ver ? $ver . '&' . $this->args[ $handle ] : $this->args[ $handle ]; } - $src = $obj->src; - $ie_conditional_prefix = ''; - $ie_conditional_suffix = ''; - $conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : ''; - + $src = $obj->src; + $conditional = isset( $obj->extra['conditional'] ) ? true : false; if ( $conditional ) { - $ie_conditional_prefix = "\n"; + + return false; } $inline_style = $this->print_inline_style( $handle, false ); @@ -189,7 +186,7 @@ public function do_item( $handle, $group = false ) { } if ( $this->do_concat ) { - if ( $this->in_default_dir( $src ) && ! $conditional && ! isset( $obj->extra['alt'] ) ) { + if ( $this->in_default_dir( $src ) && ! isset( $obj->extra['alt'] ) ) { $this->concat .= "$handle,"; $this->concat_version .= "$handle$ver"; @@ -279,17 +276,13 @@ public function do_item( $handle, $group = false ) { } if ( $this->do_concat ) { - $this->print_html .= $ie_conditional_prefix; $this->print_html .= $tag; if ( $inline_style_tag ) { $this->print_html .= $inline_style_tag; } - $this->print_html .= $ie_conditional_suffix; } else { - echo $ie_conditional_prefix; echo $tag; $this->print_inline_style( $handle ); - echo $ie_conditional_suffix; } return true; diff --git a/src/wp-includes/css/wp-embed-template-ie.css b/src/wp-includes/css/wp-embed-template-ie.css deleted file mode 100644 index cec05c9eeb1f8..0000000000000 --- a/src/wp-includes/css/wp-embed-template-ie.css +++ /dev/null @@ -1,19 +0,0 @@ -.dashicons-no { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAQAAAAngNWGAAAAcElEQVR4AdXRVxmEMBAGwJMQCUhAIhKQECmRsFJwMFfp7HfP/E8pk0173CuKpt/0R+WaBaaZqogLagBMuh+DdoKbyRCwqZ/SnM0R5oQuZ2UHS8Z6k23qPxZCTrV5UlHMi8bsfHVXP7K/GXZHaTO7S54CWLdHlN2YIwAAAABJRU5ErkJggg==); -} - -.dashicons-admin-comments { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAATUlEQVR4AWMYWqCpvUcAiA8A8X9iMFStAD4DG0AKScQNVDZw1MBRAwvIMLCA5jmFlCD4AMQGlOTtBgoNwzQQ3TCKDaTcMMxYN2AYVgAAYPKsEBxN0PIAAAAASUVORK5CYII=); -} - -.wp-embed-comments a:hover .dashicons-admin-comments { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAATElEQVR4AWMYYqB4lQAQHwDi/8RgqFoBfAY2gBSSiBuobOCogaMGFpBhYAEdcwrhIPgAxAaU5O0GCg3DNBDdMIoNpNwwzFg3YBhWAABG71qAFYcFqgAAAABJRU5ErkJggg==); -} - -.dashicons-share { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAc0lEQVR4AWMYfqCpvccAiBcA8X8gfgDEBZQaeAFkGBoOoMR1/7HgDeQa2ECZgQiDHID4AMwAor0MCmBoQP+HBnwAskFQdgBRkQJViGk7wiAHUr21AYdhDTA1dDOQHl6mPFLokmwoT9j0z3qUFw70L77oDwAiuzCIub1XpQAAAABJRU5ErkJggg==); -} - -.wp-embed-share-dialog-open:hover .dashicons-share { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAc0lEQVR4AWMYhqB4lQEQLwDi/0D8AIgLKDXwAsgwNBxAiev+Y8EbyDWwgTIDEQY5APEBmAFEexkUwNCA/g8N+ABkg6DsAKIiBaoQ03aEQQ6kemsDDsMaYEroZiA9vEx5pNAl2VCesOmf9SgvHOhffNEfAAAMqPR5IEZH5wAAAABJRU5ErkJggg==); -} diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php index 6ef190d0ea600..9d66a4abd85d4 100644 --- a/src/wp-includes/embed.php +++ b/src/wp-includes/embed.php @@ -1055,7 +1055,6 @@ function wp_embed_excerpt_attachment( $content ) { * @since 4.4.0 */ function enqueue_embed_scripts() { - wp_enqueue_style( 'wp-embed-template-ie' ); /** * Fires when scripts and styles are enqueued for the embed iframe. diff --git a/src/wp-includes/functions.wp-scripts.php b/src/wp-includes/functions.wp-scripts.php index 1be1822aa7c3d..bda3e05e8db13 100644 --- a/src/wp-includes/functions.wp-scripts.php +++ b/src/wp-includes/functions.wp-scripts.php @@ -425,9 +425,10 @@ function wp_script_is( $handle, $status = 'enqueued' ) { * Works only if the script has already been registered. * * Possible values for $key and $value: - * 'conditional' string Comments for IE 6, lte IE 7, etc. + * 'strategy' string 'defer' or 'async'. * * @since 4.2.0 + * @since 6.9.0 Updated possible values to remove reference to 'conditional' and add 'strategy'. * * @see WP_Dependencies::add_data() * diff --git a/src/wp-includes/functions.wp-styles.php b/src/wp-includes/functions.wp-styles.php index ad5f574dd84c0..f84b931866818 100644 --- a/src/wp-includes/functions.wp-styles.php +++ b/src/wp-includes/functions.wp-styles.php @@ -220,7 +220,6 @@ function wp_style_is( $handle, $status = 'enqueued' ) { * Works only if the stylesheet has already been registered. * * Possible values for $key and $value: - * 'conditional' string Comments for IE 6, lte IE 7 etc. * 'rtl' bool|string To declare an RTL stylesheet. * 'suffix' string Optional suffix, used in combination with RTL. * 'alt' bool For rel="alternate stylesheet". @@ -233,10 +232,12 @@ function wp_style_is( $handle, $status = 'enqueued' ) { * @since 3.6.0 * @since 5.8.0 Added 'path' as an official value for $key. * See {@see wp_maybe_inline_styles()}. + * @since 6.9.0 'conditional' value changed. If the 'conditional' parameter is present + * the stylesheet will be ignored. * * @param string $handle Name of the stylesheet. * @param string $key Name of data point for which we're storing a value. - * Accepts 'conditional', 'rtl' and 'suffix', 'alt', 'title' and 'path'. + * Accepts 'rtl' and 'suffix', 'alt', 'title' and 'path'. * @param mixed $value String containing the CSS data to be added. * @return bool True on success, false on failure. */ diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 54193c841c7c3..e34a13f017829 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1041,15 +1041,12 @@ function wp_default_scripts( $scripts ) { $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'clipboard', 'jquery', 'plupload', 'underscore', 'wp-a11y', 'wp-i18n' ) ); did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n ); - $scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 ); + $scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'media-models' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n ); $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 ); did_action( 'init' ) && $scripts->add_data( 'comment-reply', 'strategy', 'async' ); - $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' ); - did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' ); - $scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.13.7', 1 ); $scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.6.0', 1 ); @@ -1278,7 +1275,7 @@ function wp_default_scripts( $scripts ) { // JS-only version of hoverintent (no dependencies). $scripts->add( 'hoverintent-js', '/wp-includes/js/hoverintent-js.min.js', array(), '2.2.1', 1 ); - $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 ); + $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'underscore' ), false, 1 ); $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 ); $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'wp-a11y', 'customize-base' ), false, 1 ); $scripts->add( 'customize-models', '/wp-includes/js/customize-models.js', array( 'underscore', 'backbone' ), false, 1 ); @@ -1498,7 +1495,7 @@ function wp_default_scripts( $scripts ) { $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery', 'clipboard', 'wp-i18n', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'media' ); - $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'json2', 'imgareaselect', 'wp-a11y' ), false, 1 ); + $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'imgareaselect', 'wp-a11y' ), false, 1 ); $scripts->set_translations( 'image-edit' ); $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 ); @@ -1508,7 +1505,7 @@ function wp_default_scripts( $scripts ) { * Navigation Menus: Adding underscore as a dependency to utilize _.debounce * see https://core.trac.wordpress.org/ticket/42321 */ - $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'json2', 'underscore' ) ); + $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'underscore' ) ); $scripts->set_translations( 'nav-menu' ); $scripts->add( 'custom-header', '/wp-admin/js/custom-header.js', array( 'jquery-masonry' ), false, 1 ); @@ -1640,9 +1637,7 @@ function wp_default_styles( $styles ) { $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) ); $styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) ); $styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) ); - $styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" ); $styles->add( 'wp-empty-template-alert', "/wp-includes/css/wp-empty-template-alert$suffix.css" ); - $styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' ); // External libraries and friends. $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' ); diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index d00c77b5a1f6c..c2f22a2d771e7 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -1630,6 +1630,8 @@ public function test_wp_script_add_data_with_data_key() { /** * Testing `wp_script_add_data` with the conditional key. + * + * @since 6.9.0 Conditional comments should now return an empty string. * * @ticket 16024 */ @@ -1637,28 +1639,7 @@ public function test_wp_script_add_data_with_conditional_key() { // Enqueue and add conditional comments. wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null ); wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ); - $expected = "\n"; - - // Go! - $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); - - // No scripts left to print. - $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); - } - - /** - * Testing `wp_script_add_data` with both the data & conditional keys. - * - * @ticket 16024 - */ - public function test_wp_script_add_data_with_data_and_conditional_keys() { - // Enqueue and add data plus conditional comments for both. - wp_enqueue_script( 'test-conditional-with-data', 'example.com', array(), null ); - wp_script_add_data( 'test-conditional-with-data', 'data', 'testing' ); - wp_script_add_data( 'test-conditional-with-data', 'conditional', 'lt IE 9' ); - $expected = "\n"; - $expected .= "\n"; - $expected = str_replace( "'", '"', $expected ); + $expected = ''; // Go! $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index 9cb6283c488d5..1a1757b88a050 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -337,7 +337,6 @@ public function test_conditional_inline_styles_are_also_conditional() { CSS; wp_enqueue_style( 'handle', 'http://example.com', array(), 1 ); - wp_style_add_data( 'handle', 'conditional', 'IE' ); wp_add_inline_style( 'handle', 'a { color: blue; }' ); $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_styles' ) ); From caf0887fa068bd441d11c94af7f9ec6155a41e6b Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Fri, 15 Aug 2025 18:42:10 -0500 Subject: [PATCH 02/30] Update scripts.php --- tests/phpunit/tests/dependencies/scripts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index c2f22a2d771e7..4d7c3253494d5 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -1630,7 +1630,7 @@ public function test_wp_script_add_data_with_data_key() { /** * Testing `wp_script_add_data` with the conditional key. - * + * * @since 6.9.0 Conditional comments should now return an empty string. * * @ticket 16024 From 1bd20aea1bc19578fb510bbf598d2c0e66b0b8f5 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Mon, 18 Aug 2025 10:12:27 -0500 Subject: [PATCH 03/30] Update tests to expect empty results for conditional scripts and their dependencies. --- tests/phpunit/tests/dependencies/scripts.php | 33 ++++++-------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index 4d7c3253494d5..91e8212242b64 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -2055,6 +2055,7 @@ public function test_wp_add_inline_script_after_with_concat() { /** * @ticket 14853 + * @ticket 63821 */ public function test_wp_add_inline_script_after_and_before_with_concat_and_conditional() { global $wp_scripts; @@ -2062,17 +2063,9 @@ public function test_wp_add_inline_script_after_and_before_with_concat_and_condi $wp_scripts->do_concat = true; $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php. - $expected_localized = "\n"; - $expected_localized = str_replace( "'", '"', $expected_localized ); - - $expected = "\n"; - $expected = str_replace( "'", '"', $expected ); + // Conditional scripts should not output. + $expected_localized = ''; + $expected = ''; wp_enqueue_script( 'test-example', 'example.com', array(), null ); wp_localize_script( 'test-example', 'testExample', array( 'foo' => 'bar' ) ); @@ -2111,20 +2104,16 @@ public function test_wp_add_inline_script_after_with_concat_and_core_dependency( /** * @ticket 36392 + * @ticket 63821 */ public function test_wp_add_inline_script_after_with_concat_and_conditional_and_core_dependency() { - global $wp_scripts, $wp_version; + global $wp_scripts; wp_default_scripts( $wp_scripts ); $wp_scripts->base_url = ''; $wp_scripts->do_concat = true; - - $expected = "\n"; - $expected .= "\n"; + $expected = ''; wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); wp_add_inline_script( 'test-example', 'console.log("after");' ); @@ -2138,19 +2127,17 @@ public function test_wp_add_inline_script_after_with_concat_and_conditional_and_ /** * @ticket 36392 + * @ticket 63821 */ public function test_wp_add_inline_script_before_with_concat_and_core_dependency() { - global $wp_scripts, $wp_version; + global $wp_scripts; wp_default_scripts( $wp_scripts ); wp_default_packages( $wp_scripts ); $wp_scripts->base_url = ''; $wp_scripts->do_concat = true; - - $expected = "\n"; - $expected .= "\n"; - $expected .= "\n"; + $expected = ''; wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); From e4d171790fad2b2628187c081f311a10e3496899 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Mon, 18 Aug 2025 13:55:50 -0500 Subject: [PATCH 04/30] Update conditional inline styles test --- tests/phpunit/tests/dependencies/styles.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index 1a1757b88a050..33696991f0d03 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -327,16 +327,9 @@ public function test_unnecessary_style_tags() { * stylesheets are also conditional. */ public function test_conditional_inline_styles_are_also_conditional() { - $expected = << - - - - -CSS; + $expected = ''; wp_enqueue_style( 'handle', 'http://example.com', array(), 1 ); + wp_style_add_data( 'handle', 'conditional', 'IE' ); wp_add_inline_style( 'handle', 'a { color: blue; }' ); $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_styles' ) ); From 5fb72b7ebbe51698908ff81f0af58932f946cfa5 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Mon, 18 Aug 2025 14:34:49 -0500 Subject: [PATCH 05/30] Unset dependencies for conditional scripts. Prevent dependencies from being added when only required by a conditional script or style. --- src/wp-includes/class-wp-scripts.php | 4 ++++ src/wp-includes/class-wp-styles.php | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/wp-includes/class-wp-scripts.php b/src/wp-includes/class-wp-scripts.php index 94801b8b220e0..46e8b62ca0bcf 100644 --- a/src/wp-includes/class-wp-scripts.php +++ b/src/wp-includes/class-wp-scripts.php @@ -792,6 +792,10 @@ public function add_data( $handle, $key, $value ) { return false; } + if ( 'conditional' === $key ) { + $this->registered[ $handle ]->deps = array(); + } + if ( 'strategy' === $key ) { if ( ! empty( $value ) && ! $this->is_delayed_strategy( $value ) ) { _doing_it_wrong( diff --git a/src/wp-includes/class-wp-styles.php b/src/wp-includes/class-wp-styles.php index a046260cf5b00..6a3e179ecce7b 100644 --- a/src/wp-includes/class-wp-styles.php +++ b/src/wp-includes/class-wp-styles.php @@ -346,6 +346,28 @@ public function print_inline_style( $handle, $display = true ) { return true; } + /** + * Overrides the add_data method from WP_Dependencies, to allow unsetting dependencies for conditional styles. + * + * @since 6.9.0 + * + * @param string $handle Name of the item. Should be unique. + * @param string $key The data key. + * @param mixed $value The data value. + * @return bool True on success, false on failure. + */ + public function add_data( $handle, $key, $value ) { + if ( ! isset( $this->registered[ $handle ] ) ) { + return false; + } + + if ( 'conditional' === $key ) { + $this->registered[ $handle ]->deps = array(); + } + + return $this->registered[ $handle ]->add_data( $key, $value ); + } + /** * Determines style dependencies. * From 22fe20cfeddd3ef9494281840dbf046952fe58b4 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Tue, 19 Aug 2025 18:41:09 -0500 Subject: [PATCH 06/30] Restore concat_and_core_dependency test Accidentally changed this one, but it's not a conditional test. --- tests/phpunit/tests/dependencies/scripts.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index 91e8212242b64..29076cb4dd925 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -2130,14 +2130,17 @@ public function test_wp_add_inline_script_after_with_concat_and_conditional_and_ * @ticket 63821 */ public function test_wp_add_inline_script_before_with_concat_and_core_dependency() { - global $wp_scripts; + global $wp_scripts, $wp_version; wp_default_scripts( $wp_scripts ); wp_default_packages( $wp_scripts ); $wp_scripts->base_url = ''; $wp_scripts->do_concat = true; - $expected = ''; + + $expected = "\n"; + $expected .= "\n"; + $expected .= "\n"; wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); From f2011cdc95a9369a5e6e865e2e004b8593a97ff3 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Tue, 19 Aug 2025 18:41:43 -0500 Subject: [PATCH 07/30] Remove ticket ref --- tests/phpunit/tests/dependencies/scripts.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index 29076cb4dd925..541d028518f92 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -2127,7 +2127,6 @@ public function test_wp_add_inline_script_after_with_concat_and_conditional_and_ /** * @ticket 36392 - * @ticket 63821 */ public function test_wp_add_inline_script_before_with_concat_and_core_dependency() { global $wp_scripts, $wp_version; From f4b1ccb7f6b2396743693d111976da1035ab46d9 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Thu, 21 Aug 2025 17:57:19 -0500 Subject: [PATCH 08/30] Update src/wp-includes/class-wp-scripts.php Co-authored-by: Jon Surrell --- src/wp-includes/class-wp-scripts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-scripts.php b/src/wp-includes/class-wp-scripts.php index 46e8b62ca0bcf..c42c0255d0960 100644 --- a/src/wp-includes/class-wp-scripts.php +++ b/src/wp-includes/class-wp-scripts.php @@ -292,7 +292,7 @@ public function do_item( $handle, $group = false ) { $src = $obj->src; $strategy = $this->get_eligible_loading_strategy( $handle ); $intended_strategy = (string) $this->get_data( $handle, 'strategy' ); - $conditional = isset( $obj->extra['conditional'] ) ? true : false; + $conditional = (bool) ( $obj->extra['conditional'] ?? false ); if ( $conditional ) { return false; From 69b243aed724afe8dfd78c5a13b12bf3c4f2bf77 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Thu, 21 Aug 2025 17:57:26 -0500 Subject: [PATCH 09/30] Update src/wp-includes/class-wp-styles.php Co-authored-by: Jon Surrell --- src/wp-includes/class-wp-styles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-styles.php b/src/wp-includes/class-wp-styles.php index 6a3e179ecce7b..72645d6a3e89d 100644 --- a/src/wp-includes/class-wp-styles.php +++ b/src/wp-includes/class-wp-styles.php @@ -166,7 +166,7 @@ public function do_item( $handle, $group = false ) { } $src = $obj->src; - $conditional = isset( $obj->extra['conditional'] ) ? true : false; + $conditional = (bool) ( $obj->extra['conditional'] ?? false ); if ( $conditional ) { return false; From b0cfbc8846450472affd8aa385f9382b8cfe85fd Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Thu, 21 Aug 2025 17:57:34 -0500 Subject: [PATCH 10/30] Update tests/phpunit/tests/dependencies/scripts.php Co-authored-by: Jon Surrell --- tests/phpunit/tests/dependencies/scripts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index 541d028518f92..5c0b0e4a788cb 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -1638,7 +1638,7 @@ public function test_wp_script_add_data_with_data_key() { public function test_wp_script_add_data_with_conditional_key() { // Enqueue and add conditional comments. wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null ); - wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ); + $this->assertFalse( wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ) ); $expected = ''; // Go! From 9d5da03276a0220cd2d123225195e09156efc7d6 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Thu, 21 Aug 2025 17:57:41 -0500 Subject: [PATCH 11/30] Update tests/phpunit/tests/dependencies/scripts.php Co-authored-by: Jon Surrell --- tests/phpunit/tests/dependencies/scripts.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index 5c0b0e4a788cb..d1e37939e0546 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -1639,10 +1639,9 @@ public function test_wp_script_add_data_with_conditional_key() { // Enqueue and add conditional comments. wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null ); $this->assertFalse( wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ) ); - $expected = ''; - // Go! - $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); +// Go! +$this->assertEqualHTML( '', get_echo( 'wp_print_scripts' ) ); // No scripts left to print. $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); From 141b5bc63dd936a9077e72ea2077f053ce459e73 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Thu, 21 Aug 2025 18:03:58 -0500 Subject: [PATCH 12/30] Move dependency exits earlier per suggestion --- src/wp-includes/class-wp-scripts.php | 8 ++++---- src/wp-includes/class-wp-styles.php | 11 ++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/wp-includes/class-wp-scripts.php b/src/wp-includes/class-wp-scripts.php index c42c0255d0960..5e776baf7c13e 100644 --- a/src/wp-includes/class-wp-scripts.php +++ b/src/wp-includes/class-wp-scripts.php @@ -278,6 +278,10 @@ public function do_item( $handle, $group = false ) { } $obj = $this->registered[ $handle ]; + if ( $obj->extra['conditional'] ?? false ) { + + return false; + } if ( null === $obj->ver ) { $ver = ''; @@ -292,11 +296,7 @@ public function do_item( $handle, $group = false ) { $src = $obj->src; $strategy = $this->get_eligible_loading_strategy( $handle ); $intended_strategy = (string) $this->get_data( $handle, 'strategy' ); - $conditional = (bool) ( $obj->extra['conditional'] ?? false ); - if ( $conditional ) { - return false; - } if ( ! $this->is_delayed_strategy( $intended_strategy ) ) { $intended_strategy = ''; diff --git a/src/wp-includes/class-wp-styles.php b/src/wp-includes/class-wp-styles.php index 72645d6a3e89d..8d247072bcc0d 100644 --- a/src/wp-includes/class-wp-styles.php +++ b/src/wp-includes/class-wp-styles.php @@ -154,7 +154,10 @@ public function do_item( $handle, $group = false ) { } $obj = $this->registered[ $handle ]; + if ( $obj->extra['conditional'] ?? false ) { + return false; + } if ( null === $obj->ver ) { $ver = ''; } else { @@ -165,13 +168,7 @@ public function do_item( $handle, $group = false ) { $ver = $ver ? $ver . '&' . $this->args[ $handle ] : $this->args[ $handle ]; } - $src = $obj->src; - $conditional = (bool) ( $obj->extra['conditional'] ?? false ); - if ( $conditional ) { - - return false; - } - + $src = $obj->src; $inline_style = $this->print_inline_style( $handle, false ); if ( $inline_style ) { From 0df6ba1d2c2987caa668584846a4b4d3f8c28ee9 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Fri, 22 Aug 2025 18:54:20 -0500 Subject: [PATCH 13/30] Code style --- src/wp-includes/class-wp-scripts.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wp-includes/class-wp-scripts.php b/src/wp-includes/class-wp-scripts.php index 5e776baf7c13e..337c98004ce0f 100644 --- a/src/wp-includes/class-wp-scripts.php +++ b/src/wp-includes/class-wp-scripts.php @@ -297,7 +297,6 @@ public function do_item( $handle, $group = false ) { $strategy = $this->get_eligible_loading_strategy( $handle ); $intended_strategy = (string) $this->get_data( $handle, 'strategy' ); - if ( ! $this->is_delayed_strategy( $intended_strategy ) ) { $intended_strategy = ''; } From 64f11e10c0437ebab628c7e92b17ae9798c7ee8b Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Fri, 22 Aug 2025 18:54:34 -0500 Subject: [PATCH 14/30] Fix test_wp_script_add_data_with_conditional_key --- tests/phpunit/tests/dependencies/scripts.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index d1e37939e0546..5b3c9ad96169a 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -1638,11 +1638,8 @@ public function test_wp_script_add_data_with_data_key() { public function test_wp_script_add_data_with_conditional_key() { // Enqueue and add conditional comments. wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null ); - $this->assertFalse( wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ) ); - -// Go! -$this->assertEqualHTML( '', get_echo( 'wp_print_scripts' ) ); - + wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ); + // No scripts left to print. $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); } From ede759b106ebf3049168921f0c0fcb78e9246d41 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Mon, 1 Sep 2025 15:00:28 -0500 Subject: [PATCH 15/30] Remove space --- tests/phpunit/tests/dependencies/scripts.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index 5b3c9ad96169a..f18ae5106cd6a 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -1639,7 +1639,6 @@ public function test_wp_script_add_data_with_conditional_key() { // Enqueue and add conditional comments. wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null ); wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ); - // No scripts left to print. $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); } From 383493413bea7cd7b6034797c6c8dbb2b1d3bee3 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Mon, 1 Sep 2025 15:04:26 -0500 Subject: [PATCH 16/30] Add comment about removal of conditional dependencies --- src/wp-includes/class-wp-scripts.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/class-wp-scripts.php b/src/wp-includes/class-wp-scripts.php index 337c98004ce0f..fd45fb9e8bda9 100644 --- a/src/wp-includes/class-wp-scripts.php +++ b/src/wp-includes/class-wp-scripts.php @@ -792,6 +792,7 @@ public function add_data( $handle, $key, $value ) { } if ( 'conditional' === $key ) { + // If a dependency is declared by a conditional script, remove it. $this->registered[ $handle ]->deps = array(); } From 1b5181a499295e49dbd768abd145f2be06de9fb1 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Mon, 1 Sep 2025 15:07:40 -0500 Subject: [PATCH 17/30] Add a deprecated argument for conditional keys --- src/wp-includes/class-wp-dependencies.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wp-includes/class-wp-dependencies.php b/src/wp-includes/class-wp-dependencies.php index ef9dfa7d5fd49..05b3d6d69ebd0 100644 --- a/src/wp-includes/class-wp-dependencies.php +++ b/src/wp-includes/class-wp-dependencies.php @@ -289,6 +289,14 @@ public function add_data( $handle, $key, $value ) { if ( ! isset( $this->registered[ $handle ] ) ) { return false; } + if ( 'conditional' === $key ) { + _deprecated_argument( + 'WP_Dependencies->add_data()', + '6.9.0', + /* translators: 1: WPLANG, 2: wp-config.php */ + sprintf( __( 'The %1$s argument is no longer supported for inline scripts or styles.' ), 'conditional' ) + ); + } return $this->registered[ $handle ]->add_data( $key, $value ); } From d083a48e36abd1fa7075f09ac4fb871ed4934616 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Mon, 1 Sep 2025 15:47:32 -0500 Subject: [PATCH 18/30] Add expect deprecation to tests. --- tests/phpunit/tests/dependencies/scripts.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index f18ae5106cd6a..cd91d32548753 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -1636,6 +1636,9 @@ public function test_wp_script_add_data_with_data_key() { * @ticket 16024 */ public function test_wp_script_add_data_with_conditional_key() { + $this->expectDeprecation(); + $this->expectDeprecationMessageMatches( 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.' ); + // Enqueue and add conditional comments. wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null ); wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ); @@ -2058,6 +2061,9 @@ public function test_wp_add_inline_script_after_and_before_with_concat_and_condi $wp_scripts->do_concat = true; $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php. + $this->expectDeprecation(); + $this->expectDeprecationMessageMatches( 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.' ); + // Conditional scripts should not output. $expected_localized = ''; $expected = ''; @@ -2103,6 +2109,8 @@ public function test_wp_add_inline_script_after_with_concat_and_core_dependency( */ public function test_wp_add_inline_script_after_with_concat_and_conditional_and_core_dependency() { global $wp_scripts; + $this->expectDeprecation(); + $this->expectDeprecationMessageMatches( 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.' ); wp_default_scripts( $wp_scripts ); From ab365f1a753b3085b34861de95d3c0bf72541614 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Wed, 3 Sep 2025 21:58:43 -0500 Subject: [PATCH 19/30] expectDeprecation is not the appropriate method. --- tests/phpunit/tests/dependencies/scripts.php | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index cd91d32548753..ceb5e5dbe4d68 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -1636,14 +1636,11 @@ public function test_wp_script_add_data_with_data_key() { * @ticket 16024 */ public function test_wp_script_add_data_with_conditional_key() { - $this->expectDeprecation(); - $this->expectDeprecationMessageMatches( 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.' ); - // Enqueue and add conditional comments. wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null ); wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ); // No scripts left to print. - $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); + $this->assertSame( 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.', get_echo( 'wp_print_scripts' ) ); } /** @@ -2061,12 +2058,9 @@ public function test_wp_add_inline_script_after_and_before_with_concat_and_condi $wp_scripts->do_concat = true; $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php. - $this->expectDeprecation(); - $this->expectDeprecationMessageMatches( 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.' ); - // Conditional scripts should not output. - $expected_localized = ''; - $expected = ''; + $expected_localized = 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.'; + $expected = 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.'; wp_enqueue_script( 'test-example', 'example.com', array(), null ); wp_localize_script( 'test-example', 'testExample', array( 'foo' => 'bar' ) ); @@ -2109,14 +2103,11 @@ public function test_wp_add_inline_script_after_with_concat_and_core_dependency( */ public function test_wp_add_inline_script_after_with_concat_and_conditional_and_core_dependency() { global $wp_scripts; - $this->expectDeprecation(); - $this->expectDeprecationMessageMatches( 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.' ); - wp_default_scripts( $wp_scripts ); $wp_scripts->base_url = ''; $wp_scripts->do_concat = true; - $expected = ''; + $expected = 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.'; wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); wp_add_inline_script( 'test-example', 'console.log("after");' ); From 63dd8a7b23490fa2d4925c66a8eb63faf1d4e358 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Wed, 3 Sep 2025 22:04:37 -0500 Subject: [PATCH 20/30] Remove translator comment; this string does not require arguments. --- src/wp-includes/class-wp-dependencies.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-dependencies.php b/src/wp-includes/class-wp-dependencies.php index 05b3d6d69ebd0..4c8adf6041396 100644 --- a/src/wp-includes/class-wp-dependencies.php +++ b/src/wp-includes/class-wp-dependencies.php @@ -293,8 +293,7 @@ public function add_data( $handle, $key, $value ) { _deprecated_argument( 'WP_Dependencies->add_data()', '6.9.0', - /* translators: 1: WPLANG, 2: wp-config.php */ - sprintf( __( 'The %1$s argument is no longer supported for inline scripts or styles.' ), 'conditional' ) + __( 'The conditional argument is no longer supported for inline scripts or styles.' ) ); } From 21934fd8bbc55e97a3420211e2fffa9f5c427d0a Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Wed, 3 Sep 2025 22:08:17 -0500 Subject: [PATCH 21/30] Update src/wp-includes/class-wp-styles.php Co-authored-by: Jon Surrell --- src/wp-includes/class-wp-styles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-styles.php b/src/wp-includes/class-wp-styles.php index 8d247072bcc0d..16889d2bc1abb 100644 --- a/src/wp-includes/class-wp-styles.php +++ b/src/wp-includes/class-wp-styles.php @@ -362,7 +362,7 @@ public function add_data( $handle, $key, $value ) { $this->registered[ $handle ]->deps = array(); } - return $this->registered[ $handle ]->add_data( $key, $value ); + return parent::add_data( $handle, $key, $value ); } /** From bf35196e27dd303be998e17d6042b65969808e17 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Wed, 3 Sep 2025 22:08:55 -0500 Subject: [PATCH 22/30] Update class-wp-styles.php --- src/wp-includes/class-wp-styles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-styles.php b/src/wp-includes/class-wp-styles.php index 16889d2bc1abb..65b2d4df386be 100644 --- a/src/wp-includes/class-wp-styles.php +++ b/src/wp-includes/class-wp-styles.php @@ -362,7 +362,7 @@ public function add_data( $handle, $key, $value ) { $this->registered[ $handle ]->deps = array(); } - return parent::add_data( $handle, $key, $value ); + return parent::add_data( $handle, $key, $value ); } /** From bcc89177b361cd47e954a64172cca04c2c4e684a Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Wed, 3 Sep 2025 22:30:07 -0500 Subject: [PATCH 23/30] Remove that. Interestingly, this failed in a completely different way than it did before. --- tests/phpunit/tests/dependencies/scripts.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index 4be0fa75c2bec..ef7c787611f5c 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -1773,7 +1773,7 @@ public function test_wp_script_add_data_with_conditional_key() { wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null ); wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ); // No scripts left to print. - $this->assertSame( 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.', get_echo( 'wp_print_scripts' ) ); + $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); } /** @@ -2192,8 +2192,8 @@ public function test_wp_add_inline_script_after_and_before_with_concat_and_condi $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php. // Conditional scripts should not output. - $expected_localized = 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.'; - $expected = 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.'; + $expected_localized = ''; + $expected = ''; wp_enqueue_script( 'test-example', 'example.com', array(), null ); wp_localize_script( 'test-example', 'testExample', array( 'foo' => 'bar' ) ); @@ -2240,7 +2240,7 @@ public function test_wp_add_inline_script_after_with_concat_and_conditional_and_ $wp_scripts->base_url = ''; $wp_scripts->do_concat = true; - $expected = 'Function WP_Dependencies->add_data() was called with an argument that is deprecated since version 6.9.0! The conditional argument is no longer supported for inline scripts or styles.'; + $expected = ''; wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); wp_add_inline_script( 'test-example', 'console.log("after");' ); From cae85c8371b000e69a974c36984100390f914264 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 5 Sep 2025 16:04:47 +0200 Subject: [PATCH 24/30] Add @expectedDeprecated annotation to tests --- tests/phpunit/tests/dependencies/scripts.php | 6 ++++++ tests/phpunit/tests/dependencies/styles.php | 2 ++ 2 files changed, 8 insertions(+) diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index ef7c787611f5c..79a8fe2da6573 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -1764,6 +1764,8 @@ public function test_wp_script_add_data_with_data_key() { /** * Testing `wp_script_add_data` with the conditional key. * + * @expectedDeprecated WP_Dependencies->add_data() + * * @since 6.9.0 Conditional comments should now return an empty string. * * @ticket 16024 @@ -2182,6 +2184,8 @@ public function test_wp_add_inline_script_after_with_concat() { } /** + * @expectedDeprecated WP_Dependencies->add_data() + * * @ticket 14853 * @ticket 63821 */ @@ -2231,6 +2235,8 @@ public function test_wp_add_inline_script_after_with_concat_and_core_dependency( } /** + * @expectedDeprecated WP_Dependencies->add_data() + * * @ticket 36392 * @ticket 63821 */ diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index 33696991f0d03..34a45c8b9fd5c 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -325,6 +325,8 @@ public function test_unnecessary_style_tags() { /** * Test to make sure that inline styles attached to conditional * stylesheets are also conditional. + * + * @expectedDeprecated WP_Dependencies->add_data() */ public function test_conditional_inline_styles_are_also_conditional() { $expected = ''; From 7e9191180ecf84f6ff57c41481b4438ec6209cda Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Mon, 29 Sep 2025 10:26:50 -0500 Subject: [PATCH 25/30] Update deprecation notice text --- src/wp-includes/class-wp-dependencies.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-dependencies.php b/src/wp-includes/class-wp-dependencies.php index 4c8adf6041396..59a5b4b41b90c 100644 --- a/src/wp-includes/class-wp-dependencies.php +++ b/src/wp-includes/class-wp-dependencies.php @@ -293,7 +293,7 @@ public function add_data( $handle, $key, $value ) { _deprecated_argument( 'WP_Dependencies->add_data()', '6.9.0', - __( 'The conditional argument is no longer supported for inline scripts or styles.' ) + __( 'IE conditional comments are ignored by all supported browsers.' ) ); } From 9541e3c6f529163e076f34e648f20df95d30c518 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Mon, 29 Sep 2025 10:35:30 -0500 Subject: [PATCH 26/30] Restore json2.js, register with backward compatibility comment. --- src/js/_enqueues/vendor/json2.js | 519 ++++++++++++++++++++++++++++++ src/wp-includes/script-loader.php | 3 + 2 files changed, 522 insertions(+) create mode 100644 src/js/_enqueues/vendor/json2.js diff --git a/src/js/_enqueues/vendor/json2.js b/src/js/_enqueues/vendor/json2.js new file mode 100644 index 0000000000000..7f685256288f8 --- /dev/null +++ b/src/js/_enqueues/vendor/json2.js @@ -0,0 +1,519 @@ +/* + json2.js + 2015-05-03 + + Public Domain. + + NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. + + See http://www.JSON.org/js.html + + + This code should be minified before deployment. + See http://javascript.crockford.com/jsmin.html + + USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO + NOT CONTROL. + + + This file creates a global JSON object containing two methods: stringify + and parse. This file is provides the ES5 JSON capability to ES3 systems. + If a project might run on IE8 or earlier, then this file should be included. + This file does nothing on ES5 systems. + + JSON.stringify(value, replacer, space) + value any JavaScript value, usually an object or array. + + replacer an optional parameter that determines how object + values are stringified for objects. It can be a + function or an array of strings. + + space an optional parameter that specifies the indentation + of nested structures. If it is omitted, the text will + be packed without extra whitespace. If it is a number, + it will specify the number of spaces to indent at each + level. If it is a string (such as '\t' or ' '), + it contains the characters used to indent at each level. + + This method produces a JSON text from a JavaScript value. + + When an object value is found, if the object contains a toJSON + method, its toJSON method will be called and the result will be + stringified. A toJSON method does not serialize: it returns the + value represented by the name/value pair that should be serialized, + or undefined if nothing should be serialized. The toJSON method + will be passed the key associated with the value, and this will be + bound to the value + + For example, this would serialize Dates as ISO strings. + + Date.prototype.toJSON = function (key) { + function f(n) { + // Format integers to have at least two digits. + return n < 10 + ? '0' + n + : n; + } + + return this.getUTCFullYear() + '-' + + f(this.getUTCMonth() + 1) + '-' + + f(this.getUTCDate()) + 'T' + + f(this.getUTCHours()) + ':' + + f(this.getUTCMinutes()) + ':' + + f(this.getUTCSeconds()) + 'Z'; + }; + + You can provide an optional replacer method. It will be passed the + key and value of each member, with this bound to the containing + object. The value that is returned from your method will be + serialized. If your method returns undefined, then the member will + be excluded from the serialization. + + If the replacer parameter is an array of strings, then it will be + used to select the members to be serialized. It filters the results + such that only members with keys listed in the replacer array are + stringified. + + Values that do not have JSON representations, such as undefined or + functions, will not be serialized. Such values in objects will be + dropped; in arrays they will be replaced with null. You can use + a replacer function to replace those with JSON values. + JSON.stringify(undefined) returns undefined. + + The optional space parameter produces a stringification of the + value that is filled with line breaks and indentation to make it + easier to read. + + If the space parameter is a non-empty string, then that string will + be used for indentation. If the space parameter is a number, then + the indentation will be that many spaces. + + Example: + + text = JSON.stringify(['e', {pluribus: 'unum'}]); + // text is '["e",{"pluribus":"unum"}]' + + + text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); + // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' + + text = JSON.stringify([new Date()], function (key, value) { + return this[key] instanceof Date + ? 'Date(' + this[key] + ')' + : value; + }); + // text is '["Date(---current time---)"]' + + + JSON.parse(text, reviver) + This method parses a JSON text to produce an object or array. + It can throw a SyntaxError exception. + + The optional reviver parameter is a function that can filter and + transform the results. It receives each of the keys and values, + and its return value is used instead of the original value. + If it returns what it received, then the structure is not modified. + If it returns undefined then the member is deleted. + + Example: + + // Parse the text. Values that look like ISO date strings will + // be converted to Date objects. + + myData = JSON.parse(text, function (key, value) { + var a; + if (typeof value === 'string') { + a = +/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); + if (a) { + return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], + +a[5], +a[6])); + } + } + return value; + }); + + myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { + var d; + if (typeof value === 'string' && + value.slice(0, 5) === 'Date(' && + value.slice(-1) === ')') { + d = new Date(value.slice(5, -1)); + if (d) { + return d; + } + } + return value; + }); + + + This is a reference implementation. You are free to copy, modify, or + redistribute. +*/ + +/*jslint + eval, for, this +*/ + +/*property + JSON, apply, call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, + getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, + lastIndex, length, parse, prototype, push, replace, slice, stringify, + test, toJSON, toString, valueOf +*/ + + +// Create a JSON object only if one does not already exist. We create the +// methods in a closure to avoid creating global variables. + +if (typeof JSON !== 'object') { + JSON = {}; +} + +(function () { + 'use strict'; + + var rx_one = /^[\],:{}\s]*$/, + rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, + rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, + rx_four = /(?:^|:|,)(?:\s*\[)+/g, + rx_escapable = /[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, + rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; + + function f(n) { + // Format integers to have at least two digits. + return n < 10 + ? '0' + n + : n; + } + + function this_value() { + return this.valueOf(); + } + + if (typeof Date.prototype.toJSON !== 'function') { + + Date.prototype.toJSON = function () { + + return isFinite(this.valueOf()) + ? this.getUTCFullYear() + '-' + + f(this.getUTCMonth() + 1) + '-' + + f(this.getUTCDate()) + 'T' + + f(this.getUTCHours()) + ':' + + f(this.getUTCMinutes()) + ':' + + f(this.getUTCSeconds()) + 'Z' + : null; + }; + + Boolean.prototype.toJSON = this_value; + Number.prototype.toJSON = this_value; + String.prototype.toJSON = this_value; + } + + var gap, + indent, + meta, + rep; + + + function quote(string) { + +// If the string contains no control characters, no quote characters, and no +// backslash characters, then we can safely slap some quotes around it. +// Otherwise we must also replace the offending characters with safe escape +// sequences. + + rx_escapable.lastIndex = 0; + return rx_escapable.test(string) + ? '"' + string.replace(rx_escapable, function (a) { + var c = meta[a]; + return typeof c === 'string' + ? c + : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); + }) + '"' + : '"' + string + '"'; + } + + + function str(key, holder) { + +// Produce a string from holder[key]. + + var i, // The loop counter. + k, // The member key. + v, // The member value. + length, + mind = gap, + partial, + value = holder[key]; + +// If the value has a toJSON method, call it to obtain a replacement value. + + if (value && typeof value === 'object' && + typeof value.toJSON === 'function') { + value = value.toJSON(key); + } + +// If we were called with a replacer function, then call the replacer to +// obtain a replacement value. + + if (typeof rep === 'function') { + value = rep.call(holder, key, value); + } + +// What happens next depends on the value's type. + + switch (typeof value) { + case 'string': + return quote(value); + + case 'number': + +// JSON numbers must be finite. Encode non-finite numbers as null. + + return isFinite(value) + ? String(value) + : 'null'; + + case 'boolean': + case 'null': + +// If the value is a boolean or null, convert it to a string. Note: +// typeof null does not produce 'null'. The case is included here in +// the remote chance that this gets fixed someday. + + return String(value); + +// If the type is 'object', we might be dealing with an object or an array or +// null. + + case 'object': + +// Due to a specification blunder in ECMAScript, typeof null is 'object', +// so watch out for that case. + + if (!value) { + return 'null'; + } + +// Make an array to hold the partial results of stringifying this object value. + + gap += indent; + partial = []; + +// Is the value an array? + + if (Object.prototype.toString.apply(value) === '[object Array]') { + +// The value is an array. Stringify every element. Use null as a placeholder +// for non-JSON values. + + length = value.length; + for (i = 0; i < length; i += 1) { + partial[i] = str(i, value) || 'null'; + } + +// Join all of the elements together, separated with commas, and wrap them in +// brackets. + + v = partial.length === 0 + ? '[]' + : gap + ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' + : '[' + partial.join(',') + ']'; + gap = mind; + return v; + } + +// If the replacer is an array, use it to select the members to be stringified. + + if (rep && typeof rep === 'object') { + length = rep.length; + for (i = 0; i < length; i += 1) { + if (typeof rep[i] === 'string') { + k = rep[i]; + v = str(k, value); + if (v) { + partial.push(quote(k) + ( + gap + ? ': ' + : ':' + ) + v); + } + } + } + } else { + +// Otherwise, iterate through all of the keys in the object. + + for (k in value) { + if (Object.prototype.hasOwnProperty.call(value, k)) { + v = str(k, value); + if (v) { + partial.push(quote(k) + ( + gap + ? ': ' + : ':' + ) + v); + } + } + } + } + +// Join all of the member texts together, separated with commas, +// and wrap them in braces. + + v = partial.length === 0 + ? '{}' + : gap + ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' + : '{' + partial.join(',') + '}'; + gap = mind; + return v; + } + } + +// If the JSON object does not yet have a stringify method, give it one. + + if (typeof JSON.stringify !== 'function') { + meta = { // table of character substitutions + '\b': '\\b', + '\t': '\\t', + '\n': '\\n', + '\f': '\\f', + '\r': '\\r', + '"': '\\"', + '\\': '\\\\' + }; + JSON.stringify = function (value, replacer, space) { + +// The stringify method takes a value and an optional replacer, and an optional +// space parameter, and returns a JSON text. The replacer can be a function +// that can replace values, or an array of strings that will select the keys. +// A default replacer method can be provided. Use of the space parameter can +// produce text that is more easily readable. + + var i; + gap = ''; + indent = ''; + +// If the space parameter is a number, make an indent string containing that +// many spaces. + + if (typeof space === 'number') { + for (i = 0; i < space; i += 1) { + indent += ' '; + } + +// If the space parameter is a string, it will be used as the indent string. + + } else if (typeof space === 'string') { + indent = space; + } + +// If there is a replacer, it must be a function or an array. +// Otherwise, throw an error. + + rep = replacer; + if (replacer && typeof replacer !== 'function' && + (typeof replacer !== 'object' || + typeof replacer.length !== 'number')) { + throw new Error('JSON.stringify'); + } + +// Make a fake root object containing our value under the key of ''. +// Return the result of stringifying the value. + + return str('', {'': value}); + }; + } + + +// If the JSON object does not yet have a parse method, give it one. + + if (typeof JSON.parse !== 'function') { + JSON.parse = function (text, reviver) { + +// The parse method takes a text and an optional reviver function, and returns +// a JavaScript value if the text is a valid JSON text. + + var j; + + function walk(holder, key) { + +// The walk method is used to recursively walk the resulting structure so +// that modifications can be made. + + var k, v, value = holder[key]; + if (value && typeof value === 'object') { + for (k in value) { + if (Object.prototype.hasOwnProperty.call(value, k)) { + v = walk(value, k); + if (v !== undefined) { + value[k] = v; + } else { + delete value[k]; + } + } + } + } + return reviver.call(holder, key, value); + } + + +// Parsing happens in four stages. In the first stage, we replace certain +// Unicode characters with escape sequences. JavaScript handles many characters +// incorrectly, either silently deleting them, or treating them as line endings. + + text = String(text); + rx_dangerous.lastIndex = 0; + if (rx_dangerous.test(text)) { + text = text.replace(rx_dangerous, function (a) { + return '\\u' + + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); + }); + } + +// In the second stage, we run the text against regular expressions that look +// for non-JSON patterns. We are especially concerned with '()' and 'new' +// because they can cause invocation, and '=' because it can cause mutation. +// But just to be safe, we want to reject all unexpected forms. + +// We split the second stage into 4 regexp operations in order to work around +// crippling inefficiencies in IE's and Safari's regexp engines. First we +// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we +// replace all simple value tokens with ']' characters. Third, we delete all +// open brackets that follow a colon or comma or that begin the text. Finally, +// we look to see that the remaining characters are only whitespace or ']' or +// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. + + if ( + rx_one.test( + text + .replace(rx_two, '@') + .replace(rx_three, ']') + .replace(rx_four, '') + ) + ) { + +// In the third stage we use the eval function to compile the text into a +// JavaScript structure. The '{' operator is subject to a syntactic ambiguity +// in JavaScript: it can begin a block or an object literal. We wrap the text +// in parens to eliminate the ambiguity. + + j = eval('(' + text + ')'); + +// In the optional fourth stage, we recursively walk the new structure, passing +// each name/value pair to a reviver function for possible transformation. + + return typeof reviver === 'function' + ? walk({'': j}, '') + : j; + } + +// If the text is not JSON parseable, then a SyntaxError is thrown. + + throw new SyntaxError('JSON.parse'); + }; + } +}()); \ No newline at end of file diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 12923186ea5ed..f2d826d832e06 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1052,6 +1052,9 @@ function wp_default_scripts( $scripts ) { $scripts->add_data( 'comment-reply', 'fetchpriority', 'low' ); // In Chrome this is automatically low due to the async strategy, but in Firefox and Safari the priority is normal/medium. } + // Not used in core, obsolete. Registered for backward compatibility. + $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' ); + $scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.13.7', 1 ); $scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.6.0', 1 ); From 56682c325c96171bd0ef2082cc2cb8bd615efa84 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 2 Oct 2025 15:49:37 +0200 Subject: [PATCH 27/30] Remove extra empty line --- src/wp-includes/class-wp-scripts.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wp-includes/class-wp-scripts.php b/src/wp-includes/class-wp-scripts.php index e37592048d834..a42928d9aa262 100644 --- a/src/wp-includes/class-wp-scripts.php +++ b/src/wp-includes/class-wp-scripts.php @@ -293,7 +293,6 @@ public function do_item( $handle, $group = false ) { $obj = $this->registered[ $handle ]; if ( $obj->extra['conditional'] ?? false ) { - return false; } From 681b3b6a1e9bb8f81093e8de2ff3a577442b2722 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 2 Oct 2025 15:54:46 +0200 Subject: [PATCH 28/30] Add bypass mechanism for doing it wrong --- src/wp-includes/class-wp-dependencies.php | 2 +- src/wp-includes/script-loader.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-dependencies.php b/src/wp-includes/class-wp-dependencies.php index 59a5b4b41b90c..f0c1aaa371ed0 100644 --- a/src/wp-includes/class-wp-dependencies.php +++ b/src/wp-includes/class-wp-dependencies.php @@ -289,7 +289,7 @@ public function add_data( $handle, $key, $value ) { if ( ! isset( $this->registered[ $handle ] ) ) { return false; } - if ( 'conditional' === $key ) { + if ( 'conditional' === $key && '_required-conditional-dependency_' !== $value ) { _deprecated_argument( 'WP_Dependencies->add_data()', '6.9.0', diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index b76fbc019d27b..040325935f3c9 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1054,6 +1054,7 @@ function wp_default_scripts( $scripts ) { // Not used in core, obsolete. Registered for backward compatibility. $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' ); + did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', '_required-conditional-dependency_' ); $scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.13.7', 1 ); $scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.6.0', 1 ); From 104c0769c6a01695554c4735a134b795e701c064 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Thu, 2 Oct 2025 17:01:01 -0500 Subject: [PATCH 29/30] Empty json2 --- src/js/_enqueues/vendor/json2.js | 520 +------------------------------ 1 file changed, 1 insertion(+), 519 deletions(-) diff --git a/src/js/_enqueues/vendor/json2.js b/src/js/_enqueues/vendor/json2.js index 7f685256288f8..708252bd5915a 100644 --- a/src/js/_enqueues/vendor/json2.js +++ b/src/js/_enqueues/vendor/json2.js @@ -1,519 +1 @@ -/* - json2.js - 2015-05-03 - - Public Domain. - - NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. - - See http://www.JSON.org/js.html - - - This code should be minified before deployment. - See http://javascript.crockford.com/jsmin.html - - USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO - NOT CONTROL. - - - This file creates a global JSON object containing two methods: stringify - and parse. This file is provides the ES5 JSON capability to ES3 systems. - If a project might run on IE8 or earlier, then this file should be included. - This file does nothing on ES5 systems. - - JSON.stringify(value, replacer, space) - value any JavaScript value, usually an object or array. - - replacer an optional parameter that determines how object - values are stringified for objects. It can be a - function or an array of strings. - - space an optional parameter that specifies the indentation - of nested structures. If it is omitted, the text will - be packed without extra whitespace. If it is a number, - it will specify the number of spaces to indent at each - level. If it is a string (such as '\t' or ' '), - it contains the characters used to indent at each level. - - This method produces a JSON text from a JavaScript value. - - When an object value is found, if the object contains a toJSON - method, its toJSON method will be called and the result will be - stringified. A toJSON method does not serialize: it returns the - value represented by the name/value pair that should be serialized, - or undefined if nothing should be serialized. The toJSON method - will be passed the key associated with the value, and this will be - bound to the value - - For example, this would serialize Dates as ISO strings. - - Date.prototype.toJSON = function (key) { - function f(n) { - // Format integers to have at least two digits. - return n < 10 - ? '0' + n - : n; - } - - return this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z'; - }; - - You can provide an optional replacer method. It will be passed the - key and value of each member, with this bound to the containing - object. The value that is returned from your method will be - serialized. If your method returns undefined, then the member will - be excluded from the serialization. - - If the replacer parameter is an array of strings, then it will be - used to select the members to be serialized. It filters the results - such that only members with keys listed in the replacer array are - stringified. - - Values that do not have JSON representations, such as undefined or - functions, will not be serialized. Such values in objects will be - dropped; in arrays they will be replaced with null. You can use - a replacer function to replace those with JSON values. - JSON.stringify(undefined) returns undefined. - - The optional space parameter produces a stringification of the - value that is filled with line breaks and indentation to make it - easier to read. - - If the space parameter is a non-empty string, then that string will - be used for indentation. If the space parameter is a number, then - the indentation will be that many spaces. - - Example: - - text = JSON.stringify(['e', {pluribus: 'unum'}]); - // text is '["e",{"pluribus":"unum"}]' - - - text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); - // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' - - text = JSON.stringify([new Date()], function (key, value) { - return this[key] instanceof Date - ? 'Date(' + this[key] + ')' - : value; - }); - // text is '["Date(---current time---)"]' - - - JSON.parse(text, reviver) - This method parses a JSON text to produce an object or array. - It can throw a SyntaxError exception. - - The optional reviver parameter is a function that can filter and - transform the results. It receives each of the keys and values, - and its return value is used instead of the original value. - If it returns what it received, then the structure is not modified. - If it returns undefined then the member is deleted. - - Example: - - // Parse the text. Values that look like ISO date strings will - // be converted to Date objects. - - myData = JSON.parse(text, function (key, value) { - var a; - if (typeof value === 'string') { - a = -/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); - if (a) { - return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], - +a[5], +a[6])); - } - } - return value; - }); - - myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { - var d; - if (typeof value === 'string' && - value.slice(0, 5) === 'Date(' && - value.slice(-1) === ')') { - d = new Date(value.slice(5, -1)); - if (d) { - return d; - } - } - return value; - }); - - - This is a reference implementation. You are free to copy, modify, or - redistribute. -*/ - -/*jslint - eval, for, this -*/ - -/*property - JSON, apply, call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, - getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, - lastIndex, length, parse, prototype, push, replace, slice, stringify, - test, toJSON, toString, valueOf -*/ - - -// Create a JSON object only if one does not already exist. We create the -// methods in a closure to avoid creating global variables. - -if (typeof JSON !== 'object') { - JSON = {}; -} - -(function () { - 'use strict'; - - var rx_one = /^[\],:{}\s]*$/, - rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, - rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, - rx_four = /(?:^|:|,)(?:\s*\[)+/g, - rx_escapable = /[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; - - function f(n) { - // Format integers to have at least two digits. - return n < 10 - ? '0' + n - : n; - } - - function this_value() { - return this.valueOf(); - } - - if (typeof Date.prototype.toJSON !== 'function') { - - Date.prototype.toJSON = function () { - - return isFinite(this.valueOf()) - ? this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z' - : null; - }; - - Boolean.prototype.toJSON = this_value; - Number.prototype.toJSON = this_value; - String.prototype.toJSON = this_value; - } - - var gap, - indent, - meta, - rep; - - - function quote(string) { - -// If the string contains no control characters, no quote characters, and no -// backslash characters, then we can safely slap some quotes around it. -// Otherwise we must also replace the offending characters with safe escape -// sequences. - - rx_escapable.lastIndex = 0; - return rx_escapable.test(string) - ? '"' + string.replace(rx_escapable, function (a) { - var c = meta[a]; - return typeof c === 'string' - ? c - : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }) + '"' - : '"' + string + '"'; - } - - - function str(key, holder) { - -// Produce a string from holder[key]. - - var i, // The loop counter. - k, // The member key. - v, // The member value. - length, - mind = gap, - partial, - value = holder[key]; - -// If the value has a toJSON method, call it to obtain a replacement value. - - if (value && typeof value === 'object' && - typeof value.toJSON === 'function') { - value = value.toJSON(key); - } - -// If we were called with a replacer function, then call the replacer to -// obtain a replacement value. - - if (typeof rep === 'function') { - value = rep.call(holder, key, value); - } - -// What happens next depends on the value's type. - - switch (typeof value) { - case 'string': - return quote(value); - - case 'number': - -// JSON numbers must be finite. Encode non-finite numbers as null. - - return isFinite(value) - ? String(value) - : 'null'; - - case 'boolean': - case 'null': - -// If the value is a boolean or null, convert it to a string. Note: -// typeof null does not produce 'null'. The case is included here in -// the remote chance that this gets fixed someday. - - return String(value); - -// If the type is 'object', we might be dealing with an object or an array or -// null. - - case 'object': - -// Due to a specification blunder in ECMAScript, typeof null is 'object', -// so watch out for that case. - - if (!value) { - return 'null'; - } - -// Make an array to hold the partial results of stringifying this object value. - - gap += indent; - partial = []; - -// Is the value an array? - - if (Object.prototype.toString.apply(value) === '[object Array]') { - -// The value is an array. Stringify every element. Use null as a placeholder -// for non-JSON values. - - length = value.length; - for (i = 0; i < length; i += 1) { - partial[i] = str(i, value) || 'null'; - } - -// Join all of the elements together, separated with commas, and wrap them in -// brackets. - - v = partial.length === 0 - ? '[]' - : gap - ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' - : '[' + partial.join(',') + ']'; - gap = mind; - return v; - } - -// If the replacer is an array, use it to select the members to be stringified. - - if (rep && typeof rep === 'object') { - length = rep.length; - for (i = 0; i < length; i += 1) { - if (typeof rep[i] === 'string') { - k = rep[i]; - v = str(k, value); - if (v) { - partial.push(quote(k) + ( - gap - ? ': ' - : ':' - ) + v); - } - } - } - } else { - -// Otherwise, iterate through all of the keys in the object. - - for (k in value) { - if (Object.prototype.hasOwnProperty.call(value, k)) { - v = str(k, value); - if (v) { - partial.push(quote(k) + ( - gap - ? ': ' - : ':' - ) + v); - } - } - } - } - -// Join all of the member texts together, separated with commas, -// and wrap them in braces. - - v = partial.length === 0 - ? '{}' - : gap - ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' - : '{' + partial.join(',') + '}'; - gap = mind; - return v; - } - } - -// If the JSON object does not yet have a stringify method, give it one. - - if (typeof JSON.stringify !== 'function') { - meta = { // table of character substitutions - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"': '\\"', - '\\': '\\\\' - }; - JSON.stringify = function (value, replacer, space) { - -// The stringify method takes a value and an optional replacer, and an optional -// space parameter, and returns a JSON text. The replacer can be a function -// that can replace values, or an array of strings that will select the keys. -// A default replacer method can be provided. Use of the space parameter can -// produce text that is more easily readable. - - var i; - gap = ''; - indent = ''; - -// If the space parameter is a number, make an indent string containing that -// many spaces. - - if (typeof space === 'number') { - for (i = 0; i < space; i += 1) { - indent += ' '; - } - -// If the space parameter is a string, it will be used as the indent string. - - } else if (typeof space === 'string') { - indent = space; - } - -// If there is a replacer, it must be a function or an array. -// Otherwise, throw an error. - - rep = replacer; - if (replacer && typeof replacer !== 'function' && - (typeof replacer !== 'object' || - typeof replacer.length !== 'number')) { - throw new Error('JSON.stringify'); - } - -// Make a fake root object containing our value under the key of ''. -// Return the result of stringifying the value. - - return str('', {'': value}); - }; - } - - -// If the JSON object does not yet have a parse method, give it one. - - if (typeof JSON.parse !== 'function') { - JSON.parse = function (text, reviver) { - -// The parse method takes a text and an optional reviver function, and returns -// a JavaScript value if the text is a valid JSON text. - - var j; - - function walk(holder, key) { - -// The walk method is used to recursively walk the resulting structure so -// that modifications can be made. - - var k, v, value = holder[key]; - if (value && typeof value === 'object') { - for (k in value) { - if (Object.prototype.hasOwnProperty.call(value, k)) { - v = walk(value, k); - if (v !== undefined) { - value[k] = v; - } else { - delete value[k]; - } - } - } - } - return reviver.call(holder, key, value); - } - - -// Parsing happens in four stages. In the first stage, we replace certain -// Unicode characters with escape sequences. JavaScript handles many characters -// incorrectly, either silently deleting them, or treating them as line endings. - - text = String(text); - rx_dangerous.lastIndex = 0; - if (rx_dangerous.test(text)) { - text = text.replace(rx_dangerous, function (a) { - return '\\u' + - ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }); - } - -// In the second stage, we run the text against regular expressions that look -// for non-JSON patterns. We are especially concerned with '()' and 'new' -// because they can cause invocation, and '=' because it can cause mutation. -// But just to be safe, we want to reject all unexpected forms. - -// We split the second stage into 4 regexp operations in order to work around -// crippling inefficiencies in IE's and Safari's regexp engines. First we -// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we -// replace all simple value tokens with ']' characters. Third, we delete all -// open brackets that follow a colon or comma or that begin the text. Finally, -// we look to see that the remaining characters are only whitespace or ']' or -// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. - - if ( - rx_one.test( - text - .replace(rx_two, '@') - .replace(rx_three, ']') - .replace(rx_four, '') - ) - ) { - -// In the third stage we use the eval function to compile the text into a -// JavaScript structure. The '{' operator is subject to a syntactic ambiguity -// in JavaScript: it can begin a block or an object literal. We wrap the text -// in parens to eliminate the ambiguity. - - j = eval('(' + text + ')'); - -// In the optional fourth stage, we recursively walk the new structure, passing -// each name/value pair to a reviver function for possible transformation. - - return typeof reviver === 'function' - ? walk({'': j}, '') - : j; - } - -// If the text is not JSON parseable, then a SyntaxError is thrown. - - throw new SyntaxError('JSON.parse'); - }; - } -}()); \ No newline at end of file +// Deprecated in WordPress 6.9. \ No newline at end of file From 14c196bbc3e4b27a72ae4e058b6b64c70361bf28 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Thu, 2 Oct 2025 17:06:40 -0500 Subject: [PATCH 30/30] Restore empty wp-embed-template-ie.css and enqueue with exempted conditional --- Gruntfile.js | 1 + src/wp-includes/css/wp-embed-template-ie.css | 1 + src/wp-includes/script-loader.php | 2 ++ 3 files changed, 4 insertions(+) create mode 100644 src/wp-includes/css/wp-embed-template-ie.css diff --git a/Gruntfile.js b/Gruntfile.js index 2c4942f56642a..729f1117522e4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -644,6 +644,7 @@ module.exports = function(grunt) { // Exceptions. '!wp-includes/css/dashicons.css', '!wp-includes/css/wp-embed-template.css', + '!wp-includes/css/wp-embed-template-ie.css' ] }, colors: { diff --git a/src/wp-includes/css/wp-embed-template-ie.css b/src/wp-includes/css/wp-embed-template-ie.css new file mode 100644 index 0000000000000..5a9bad3da03ab --- /dev/null +++ b/src/wp-includes/css/wp-embed-template-ie.css @@ -0,0 +1 @@ +/* Deprecated in WordPress 6.9 */ \ No newline at end of file diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 040325935f3c9..aca0363cba800 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1663,6 +1663,8 @@ function wp_default_styles( $styles ) { $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.css', array(), '0.9.15' ); $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle. $styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6. + $styles->add( 'wp-embed-template-ie', false ); + $styles->add_data( 'wp-embed-template-ie', 'conditional', '_required-conditional-dependency_' ); // Noto Serif is no longer used by core, but may be relied upon by themes and plugins. $fonts_url = '';