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 diff --git a/src/wp-includes/class-wp-dependencies.php b/src/wp-includes/class-wp-dependencies.php index ef9dfa7d5fd49..f0c1aaa371ed0 100644 --- a/src/wp-includes/class-wp-dependencies.php +++ b/src/wp-includes/class-wp-dependencies.php @@ -289,6 +289,13 @@ public function add_data( $handle, $key, $value ) { if ( ! isset( $this->registered[ $handle ] ) ) { return false; } + if ( 'conditional' === $key && '_required-conditional-dependency_' !== $value ) { + _deprecated_argument( + 'WP_Dependencies->add_data()', + '6.9.0', + __( 'IE conditional comments are ignored by all supported browsers.' ) + ); + } return $this->registered[ $handle ]->add_data( $key, $value ); } diff --git a/src/wp-includes/class-wp-scripts.php b/src/wp-includes/class-wp-scripts.php index 61ad4c8fbd630..ff226b5661425 100644 --- a/src/wp-includes/class-wp-scripts.php +++ b/src/wp-includes/class-wp-scripts.php @@ -292,6 +292,9 @@ public function do_item( $handle, $group = false ) { } $obj = $this->registered[ $handle ]; + if ( $obj->extra['conditional'] ?? false ) { + return false; + } if ( null === $obj->ver ) { $ver = ''; @@ -303,12 +306,9 @@ 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' ); if ( ! $this->is_delayed_strategy( $intended_strategy ) ) { $intended_strategy = ''; @@ -333,16 +333,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 = ''; } @@ -378,7 +373,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"; @@ -389,18 +384,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 ) { @@ -453,13 +438,14 @@ public function do_item( $handle, $group = false ) { if ( is_string( $actual_fetchpriority ) && 'auto' !== $actual_fetchpriority ) { $attr['fetchpriority'] = $actual_fetchpriority; } + if ( $original_fetchpriority !== $actual_fetchpriority ) { $attr['data-wp-fetchpriority'] = $original_fetchpriority; } - $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. @@ -851,6 +837,11 @@ public function add_data( $handle, $key, $value ) { return false; } + if ( 'conditional' === $key ) { + // If a dependency is declared by a conditional script, remove it. + $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 c81b60346f1b2..aebe4b38ab10a 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,16 +168,7 @@ 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'] : ''; - - if ( $conditional ) { - $ie_conditional_prefix = "\n"; - } - + $src = $obj->src; $inline_style = $this->print_inline_style( $handle, false ); if ( $inline_style ) { @@ -189,7 +183,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 +273,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; @@ -373,6 +363,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 parent::add_data( $handle, $key, $value ); + } + /** * Determines style dependencies. * diff --git a/src/wp-includes/css/wp-embed-template-ie.css b/src/wp-includes/css/wp-embed-template-ie.css index cec05c9eeb1f8..5a9bad3da03ab 100644 --- a/src/wp-includes/css/wp-embed-template-ie.css +++ b/src/wp-includes/css/wp-embed-template-ie.css @@ -1,19 +1 @@ -.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==); -} +/* Deprecated in WordPress 6.9 */ \ No newline at end of file diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php index 8cde1ebb99594..c143ffe4a455d 100644 --- a/src/wp-includes/embed.php +++ b/src/wp-includes/embed.php @@ -1056,7 +1056,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 69a1d96b1d198..f86b456d5f69a 100644 --- a/src/wp-includes/functions.wp-scripts.php +++ b/src/wp-includes/functions.wp-scripts.php @@ -435,9 +435,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 1170dc78ace41..129148fc194f6 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1043,7 +1043,7 @@ 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 ); @@ -1052,8 +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' ); - did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' ); + 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 ); @@ -1284,7 +1285,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 ); @@ -1504,7 +1505,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 ); @@ -1514,7 +1515,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 ); @@ -1646,9 +1647,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' ); @@ -1664,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 = ''; diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index bd4cbd27a49b4..c8059b4d4d7c5 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -1959,38 +1959,16 @@ 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 */ 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 ); - - // Go! - $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); - // No scripts left to print. $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); } @@ -2403,7 +2381,10 @@ public function test_wp_add_inline_script_after_with_concat() { } /** + * @expectedDeprecated WP_Dependencies->add_data() + * * @ticket 14853 + * @ticket 63821 */ public function test_wp_add_inline_script_after_and_before_with_concat_and_conditional() { global $wp_scripts; @@ -2411,17 +2392,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' ) ); @@ -2459,21 +2432,18 @@ public function test_wp_add_inline_script_after_with_concat_and_core_dependency( } /** + * @expectedDeprecated WP_Dependencies->add_data() + * * @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");' ); diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index d96fa401356b7..1b6e5dd9bc141 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -327,18 +327,11 @@ 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 = << - - - - -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; }' );