Skip to content

Commit 49d1ded

Browse files
committed
General: Remove support for IE conditional comments.
Remove the ability to enqueue scripts and styles wrapped in IE conditional comment tags. Conditional comment support was removed from IE in version 10 in 2012, and no core supported browser renders them in any way. IE9 has global usage approaching zero. WordPress dropped support for IE10 and below in version 4.8. Patch adds a deprecation notice if the conditional data argument is added. Scripts and styles are not printed, and neither are their dependencies if they are not required by other non-conditional scripts. Conditional dependencies are removed from core enqueues. Props jonsurrell, joedolson, shailu25, siliconforks, dmsnell, sabernhardt, rollybueno. Fixes #63821. git-svn-id: https://develop.svn.wordpress.org/trunk@60948 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 330deca commit 49d1ded

File tree

11 files changed

+83
-644
lines changed

11 files changed

+83
-644
lines changed

src/js/_enqueues/vendor/json2.js

Lines changed: 1 addition & 519 deletions
Large diffs are not rendered by default.

src/wp-includes/class-wp-dependencies.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@ public function add_data( $handle, $key, $value ) {
289289
if ( ! isset( $this->registered[ $handle ] ) ) {
290290
return false;
291291
}
292+
if ( 'conditional' === $key && '_required-conditional-dependency_' !== $value ) {
293+
_deprecated_argument(
294+
'WP_Dependencies->add_data()',
295+
'6.9.0',
296+
__( 'IE conditional comments are ignored by all supported browsers.' )
297+
);
298+
}
292299

293300
return $this->registered[ $handle ]->add_data( $key, $value );
294301
}

src/wp-includes/class-wp-scripts.php

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ public function do_item( $handle, $group = false ) {
292292
}
293293

294294
$obj = $this->registered[ $handle ];
295+
if ( $obj->extra['conditional'] ?? false ) {
296+
return false;
297+
}
295298

296299
if ( null === $obj->ver ) {
297300
$ver = '';
@@ -303,12 +306,9 @@ public function do_item( $handle, $group = false ) {
303306
$ver = $ver ? $ver . '&' . $this->args[ $handle ] : $this->args[ $handle ];
304307
}
305308

306-
$src = $obj->src;
307-
$strategy = $this->get_eligible_loading_strategy( $handle );
308-
$intended_strategy = (string) $this->get_data( $handle, 'strategy' );
309-
$ie_conditional_prefix = '';
310-
$ie_conditional_suffix = '';
311-
$conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';
309+
$src = $obj->src;
310+
$strategy = $this->get_eligible_loading_strategy( $handle );
311+
$intended_strategy = (string) $this->get_data( $handle, 'strategy' );
312312

313313
if ( ! $this->is_delayed_strategy( $intended_strategy ) ) {
314314
$intended_strategy = '';
@@ -333,16 +333,11 @@ public function do_item( $handle, $group = false ) {
333333
return false;
334334
}
335335

336-
if ( $conditional ) {
337-
$ie_conditional_prefix = "<!--[if {$conditional}]>\n";
338-
$ie_conditional_suffix = "<![endif]-->\n";
339-
}
340-
341336
$before_script = $this->get_inline_script_tag( $handle, 'before' );
342337
$after_script = $this->get_inline_script_tag( $handle, 'after' );
343338

344339
if ( $before_script || $after_script ) {
345-
$inline_script_tag = $ie_conditional_prefix . $before_script . $after_script . $ie_conditional_suffix;
340+
$inline_script_tag = $before_script . $after_script;
346341
} else {
347342
$inline_script_tag = '';
348343
}
@@ -378,7 +373,7 @@ public function do_item( $handle, $group = false ) {
378373
// Have to print the so-far concatenated scripts right away to maintain the right order.
379374
_print_scripts();
380375
$this->reset();
381-
} elseif ( $this->in_default_dir( $filtered_src ) && ! $conditional ) {
376+
} elseif ( $this->in_default_dir( $filtered_src ) ) {
382377
$this->print_code .= $this->print_extra_script( $handle, false );
383378
$this->concat .= "$handle,";
384379
$this->concat_version .= "$handle$ver";
@@ -389,18 +384,8 @@ public function do_item( $handle, $group = false ) {
389384
}
390385
}
391386

392-
$has_conditional_data = $conditional && $this->get_data( $handle, 'data' );
393-
394-
if ( $has_conditional_data ) {
395-
echo $ie_conditional_prefix;
396-
}
397-
398387
$this->print_extra_script( $handle );
399388

400-
if ( $has_conditional_data ) {
401-
echo $ie_conditional_suffix;
402-
}
403-
404389
// A single item may alias a set of items, by having dependencies, but no source.
405390
if ( ! $src ) {
406391
if ( $inline_script_tag ) {
@@ -453,13 +438,14 @@ public function do_item( $handle, $group = false ) {
453438
if ( is_string( $actual_fetchpriority ) && 'auto' !== $actual_fetchpriority ) {
454439
$attr['fetchpriority'] = $actual_fetchpriority;
455440
}
441+
456442
if ( $original_fetchpriority !== $actual_fetchpriority ) {
457443
$attr['data-wp-fetchpriority'] = $original_fetchpriority;
458444
}
459445

460-
$tag = $translations . $ie_conditional_prefix . $before_script;
446+
$tag = $translations . $before_script;
461447
$tag .= wp_get_script_tag( $attr );
462-
$tag .= $after_script . $ie_conditional_suffix;
448+
$tag .= $after_script;
463449

464450
/**
465451
* Filters the HTML script tag of an enqueued script.
@@ -851,6 +837,11 @@ public function add_data( $handle, $key, $value ) {
851837
return false;
852838
}
853839

840+
if ( 'conditional' === $key ) {
841+
// If a dependency is declared by a conditional script, remove it.
842+
$this->registered[ $handle ]->deps = array();
843+
}
844+
854845
if ( 'strategy' === $key ) {
855846
if ( ! empty( $value ) && ! $this->is_delayed_strategy( $value ) ) {
856847
_doing_it_wrong(

src/wp-includes/class-wp-styles.php

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ public function do_item( $handle, $group = false ) {
154154
}
155155

156156
$obj = $this->registered[ $handle ];
157+
if ( $obj->extra['conditional'] ?? false ) {
157158

159+
return false;
160+
}
158161
if ( null === $obj->ver ) {
159162
$ver = '';
160163
} else {
@@ -165,16 +168,7 @@ public function do_item( $handle, $group = false ) {
165168
$ver = $ver ? $ver . '&amp;' . $this->args[ $handle ] : $this->args[ $handle ];
166169
}
167170

168-
$src = $obj->src;
169-
$ie_conditional_prefix = '';
170-
$ie_conditional_suffix = '';
171-
$conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';
172-
173-
if ( $conditional ) {
174-
$ie_conditional_prefix = "<!--[if {$conditional}]>\n";
175-
$ie_conditional_suffix = "<![endif]-->\n";
176-
}
177-
171+
$src = $obj->src;
178172
$inline_style = $this->print_inline_style( $handle, false );
179173

180174
if ( $inline_style ) {
@@ -189,7 +183,7 @@ public function do_item( $handle, $group = false ) {
189183
}
190184

191185
if ( $this->do_concat ) {
192-
if ( $this->in_default_dir( $src ) && ! $conditional && ! isset( $obj->extra['alt'] ) ) {
186+
if ( $this->in_default_dir( $src ) && ! isset( $obj->extra['alt'] ) ) {
193187
$this->concat .= "$handle,";
194188
$this->concat_version .= "$handle$ver";
195189

@@ -279,17 +273,13 @@ public function do_item( $handle, $group = false ) {
279273
}
280274

281275
if ( $this->do_concat ) {
282-
$this->print_html .= $ie_conditional_prefix;
283276
$this->print_html .= $tag;
284277
if ( $inline_style_tag ) {
285278
$this->print_html .= $inline_style_tag;
286279
}
287-
$this->print_html .= $ie_conditional_suffix;
288280
} else {
289-
echo $ie_conditional_prefix;
290281
echo $tag;
291282
$this->print_inline_style( $handle );
292-
echo $ie_conditional_suffix;
293283
}
294284

295285
return true;
@@ -373,6 +363,28 @@ public function print_inline_style( $handle, $display = true ) {
373363
return true;
374364
}
375365

366+
/**
367+
* Overrides the add_data method from WP_Dependencies, to allow unsetting dependencies for conditional styles.
368+
*
369+
* @since 6.9.0
370+
*
371+
* @param string $handle Name of the item. Should be unique.
372+
* @param string $key The data key.
373+
* @param mixed $value The data value.
374+
* @return bool True on success, false on failure.
375+
*/
376+
public function add_data( $handle, $key, $value ) {
377+
if ( ! isset( $this->registered[ $handle ] ) ) {
378+
return false;
379+
}
380+
381+
if ( 'conditional' === $key ) {
382+
$this->registered[ $handle ]->deps = array();
383+
}
384+
385+
return parent::add_data( $handle, $key, $value );
386+
}
387+
376388
/**
377389
* Determines style dependencies.
378390
*
Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1 @@
1-
.dashicons-no {
2-
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAQAAAAngNWGAAAAcElEQVR4AdXRVxmEMBAGwJMQCUhAIhKQECmRsFJwMFfp7HfP/E8pk0173CuKpt/0R+WaBaaZqogLagBMuh+DdoKbyRCwqZ/SnM0R5oQuZ2UHS8Z6k23qPxZCTrV5UlHMi8bsfHVXP7K/GXZHaTO7S54CWLdHlN2YIwAAAABJRU5ErkJggg==);
3-
}
4-
5-
.dashicons-admin-comments {
6-
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAATUlEQVR4AWMYWqCpvUcAiA8A8X9iMFStAD4DG0AKScQNVDZw1MBRAwvIMLCA5jmFlCD4AMQGlOTtBgoNwzQQ3TCKDaTcMMxYN2AYVgAAYPKsEBxN0PIAAAAASUVORK5CYII=);
7-
}
8-
9-
.wp-embed-comments a:hover .dashicons-admin-comments {
10-
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAATElEQVR4AWMYYqB4lQAQHwDi/8RgqFoBfAY2gBSSiBuobOCogaMGFpBhYAEdcwrhIPgAxAaU5O0GCg3DNBDdMIoNpNwwzFg3YBhWAABG71qAFYcFqgAAAABJRU5ErkJggg==);
11-
}
12-
13-
.dashicons-share {
14-
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAc0lEQVR4AWMYfqCpvccAiBcA8X8gfgDEBZQaeAFkGBoOoMR1/7HgDeQa2ECZgQiDHID4AMwAor0MCmBoQP+HBnwAskFQdgBRkQJViGk7wiAHUr21AYdhDTA1dDOQHl6mPFLokmwoT9j0z3qUFw70L77oDwAiuzCIub1XpQAAAABJRU5ErkJggg==);
15-
}
16-
17-
.wp-embed-share-dialog-open:hover .dashicons-share {
18-
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAc0lEQVR4AWMYhqB4lQEQLwDi/0D8AIgLKDXwAsgwNBxAiev+Y8EbyDWwgTIDEQY5APEBmAFEexkUwNCA/g8N+ABkg6DsAKIiBaoQ03aEQQ6kemsDDsMaYEroZiA9vEx5pNAl2VCesOmf9SgvHOhffNEfAAAMqPR5IEZH5wAAAABJRU5ErkJggg==);
19-
}
1+
/* Deprecated in WordPress 6.9 */

src/wp-includes/embed.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,6 @@ function wp_embed_excerpt_attachment( $content ) {
10561056
* @since 4.4.0
10571057
*/
10581058
function enqueue_embed_scripts() {
1059-
wp_enqueue_style( 'wp-embed-template-ie' );
10601059

10611060
/**
10621061
* Fires when scripts and styles are enqueued for the embed iframe.

src/wp-includes/functions.wp-scripts.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,10 @@ function wp_script_is( $handle, $status = 'enqueued' ) {
435435
* Works only if the script has already been registered.
436436
*
437437
* Possible values for $key and $value:
438-
* 'conditional' string Comments for IE 6, lte IE 7, etc.
438+
* 'strategy' string 'defer' or 'async'.
439439
*
440440
* @since 4.2.0
441+
* @since 6.9.0 Updated possible values to remove reference to 'conditional' and add 'strategy'.
441442
*
442443
* @see WP_Dependencies::add_data()
443444
*

src/wp-includes/functions.wp-styles.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ function wp_style_is( $handle, $status = 'enqueued' ) {
220220
* Works only if the stylesheet has already been registered.
221221
*
222222
* Possible values for $key and $value:
223-
* 'conditional' string Comments for IE 6, lte IE 7 etc.
224223
* 'rtl' bool|string To declare an RTL stylesheet.
225224
* 'suffix' string Optional suffix, used in combination with RTL.
226225
* 'alt' bool For rel="alternate stylesheet".
@@ -233,10 +232,12 @@ function wp_style_is( $handle, $status = 'enqueued' ) {
233232
* @since 3.6.0
234233
* @since 5.8.0 Added 'path' as an official value for $key.
235234
* See {@see wp_maybe_inline_styles()}.
235+
* @since 6.9.0 'conditional' value changed. If the 'conditional' parameter is present
236+
* the stylesheet will be ignored.
236237
*
237238
* @param string $handle Name of the stylesheet.
238239
* @param string $key Name of data point for which we're storing a value.
239-
* Accepts 'conditional', 'rtl' and 'suffix', 'alt', 'title' and 'path'.
240+
* Accepts 'rtl' and 'suffix', 'alt', 'title' and 'path'.
240241
* @param mixed $value String containing the CSS data to be added.
241242
* @return bool True on success, false on failure.
242243
*/

src/wp-includes/script-loader.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ function wp_default_scripts( $scripts ) {
10431043
$scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'clipboard', 'jquery', 'plupload', 'underscore', 'wp-a11y', 'wp-i18n' ) );
10441044
did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
10451045

1046-
$scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 );
1046+
$scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'media-models' ), false, 1 );
10471047
did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n );
10481048

10491049
$scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 );
@@ -1052,8 +1052,9 @@ function wp_default_scripts( $scripts ) {
10521052
$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.
10531053
}
10541054

1055+
// Not used in core, obsolete. Registered for backward compatibility.
10551056
$scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' );
1056-
did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' );
1057+
did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', '_required-conditional-dependency_' );
10571058

10581059
$scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.13.7', 1 );
10591060
$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 ) {
12841285
// JS-only version of hoverintent (no dependencies).
12851286
$scripts->add( 'hoverintent-js', '/wp-includes/js/hoverintent-js.min.js', array(), '2.2.1', 1 );
12861287

1287-
$scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 );
1288+
$scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'underscore' ), false, 1 );
12881289
$scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 );
12891290
$scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'wp-a11y', 'customize-base' ), false, 1 );
12901291
$scripts->add( 'customize-models', '/wp-includes/js/customize-models.js', array( 'underscore', 'backbone' ), false, 1 );
@@ -1504,7 +1505,7 @@ function wp_default_scripts( $scripts ) {
15041505
$scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery', 'clipboard', 'wp-i18n', 'wp-a11y' ), false, 1 );
15051506
$scripts->set_translations( 'media' );
15061507

1507-
$scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'json2', 'imgareaselect', 'wp-a11y' ), false, 1 );
1508+
$scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'imgareaselect', 'wp-a11y' ), false, 1 );
15081509
$scripts->set_translations( 'image-edit' );
15091510

15101511
$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 ) {
15141515
* Navigation Menus: Adding underscore as a dependency to utilize _.debounce
15151516
* see https://core.trac.wordpress.org/ticket/42321
15161517
*/
1517-
$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' ) );
1518+
$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' ) );
15181519
$scripts->set_translations( 'nav-menu' );
15191520

15201521
$scripts->add( 'custom-header', '/wp-admin/js/custom-header.js', array( 'jquery-masonry' ), false, 1 );
@@ -1646,9 +1647,7 @@ function wp_default_styles( $styles ) {
16461647
$styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) );
16471648
$styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) );
16481649
$styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) );
1649-
$styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" );
16501650
$styles->add( 'wp-empty-template-alert', "/wp-includes/css/wp-empty-template-alert$suffix.css" );
1651-
$styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' );
16521651

16531652
// External libraries and friends.
16541653
$styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' );
@@ -1664,6 +1663,8 @@ function wp_default_styles( $styles ) {
16641663
$styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.css', array(), '0.9.15' );
16651664
$styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle.
16661665
$styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6.
1666+
$styles->add( 'wp-embed-template-ie', false );
1667+
$styles->add_data( 'wp-embed-template-ie', 'conditional', '_required-conditional-dependency_' );
16671668

16681669
// Noto Serif is no longer used by core, but may be relied upon by themes and plugins.
16691670
$fonts_url = '';

0 commit comments

Comments
 (0)