<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[48295] trunk: Script Loader: Add id attributes to script assets.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/48295">48295</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/48295","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>TimothyBlynJacobs</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-07-04 16:52:49 +0000 (Sat, 04 Jul 2020)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Script Loader: Add id attributes to script assets.
This commit adds a unique ID attribute to script loader generated <script> tags as well as related <script> tags for inline JavaScript, translations, or parameters.
This is a first step in adding support for lazy loading scripts and styles, but for now is only used to assist in debugging generated output.
Props dd32, spacedmonkey.
See <a href="https://core.trac.wordpress.org/ticket/48654">#48654</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpscriptsphp">trunk/src/wp-includes/class.wp-scripts.php</a></li>
<li><a href="#trunktestsphpunittestsdependenciesscriptsphp">trunk/tests/phpunit/tests/dependencies/scripts.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpscriptsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class.wp-scripts.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class.wp-scripts.php 2020-07-04 14:43:32 UTC (rev 48294)
+++ trunk/src/wp-includes/class.wp-scripts.php 2020-07-04 16:52:49 UTC (rev 48295)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -227,7 +227,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $output;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo "<script{$this->type_attr}>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf( "<script%s id='%s-js-extra'>\n", $this->type_attr, esc_attr( $handle ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // CDATA is not needed for HTML 5.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->type_attr ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -298,11 +298,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $after_handle = $this->print_inline_script( $handle, 'after', false );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $before_handle ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $before_handle = sprintf( "<script%s>\n%s\n</script>\n", $this->type_attr, $before_handle );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $before_handle = sprintf( "<script%s id='%s-js-before'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $before_handle );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $after_handle ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $after_handle = sprintf( "<script%s>\n%s\n</script>\n", $this->type_attr, $after_handle );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $after_handle = sprintf( "<script%s id='%s-js-after'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $after_handle );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $before_handle || $after_handle ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -366,7 +366,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $translations = $this->print_translations( $handle, false );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $translations ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $translations = sprintf( "<script%s>\n%s\n</script>\n", $this->type_attr, $translations );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $translations = sprintf( "<script%s id='%s-js-translations'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $translations );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $this->content_url && 0 === strpos( $src, $this->content_url ) ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -385,7 +385,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $tag = $translations . $cond_before . $before_handle;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag .= sprintf( "<script%s src='%s'></script>\n", $this->type_attr, $src );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $tag .= sprintf( "<script%s src='%s' id='%s-js'></script>\n", $this->type_attr, $src, esc_attr( $handle ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $tag .= $after_handle . $cond_after;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -458,7 +458,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $output = trim( implode( "\n", $output ), "\n" );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $echo ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( "<script%s>\n%s\n</script>\n", $this->type_attr, $output );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf( "<script%s id='%s-js-%s'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), esc_attr( $position ), $output );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $output;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -595,7 +595,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> JS;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $echo ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( "<script%s>\n%s\n</script>\n", $this->type_attr, $output );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf( "<script%s id='%s-js-translations'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $output );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $output;
</span></span></pre></div>
<a id="trunktestsphpunittestsdependenciesscriptsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/dependencies/scripts.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/dependencies/scripts.php 2020-07-04 14:43:32 UTC (rev 48294)
+++ trunk/tests/phpunit/tests/dependencies/scripts.php 2020-07-04 16:52:49 UTC (rev 48295)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -17,7 +17,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['wp_scripts']->default_version = get_bloginfo( 'version' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->wp_scripts_print_translations_output = <<<JS
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<script type='text/javascript'>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<script type='text/javascript' id='__HANDLE__-js-translations'>
</ins><span class="cx" style="display: block; padding: 0 10px"> ( function( domain, translations ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var localeData = translations.locale_data[ domain ] || translations.locale_data.messages;
</span><span class="cx" style="display: block; padding: 0 10px"> localeData[""].domain = domain;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -46,10 +46,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'empty-deps-null-version', 'example.com', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $ver = get_bloginfo( 'version' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='http://example.com?ver=$ver'></script>\n";
- $expected .= "<script type='text/javascript' src='http://example.com?ver=$ver'></script>\n";
- $expected .= "<script type='text/javascript' src='http://example.com?ver=1.2'></script>\n";
- $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' src='http://example.com?ver=$ver' id='no-deps-no-version-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='http://example.com?ver=$ver' id='empty-deps-no-version-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='http://example.com?ver=1.2' id='empty-deps-version-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='http://example.com' id='empty-deps-null-version-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -69,7 +69,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'empty-deps-no-version', 'example.com' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $ver = get_bloginfo( 'version' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script src='http://example.com?ver=$ver'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script src='http://example.com?ver=$ver' id='empty-deps-no-version-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -90,24 +90,24 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Try with an HTTP reference.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'jquery-http', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver' id='jquery-http-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Try with an HTTPS reference.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'jquery-https', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver' id='jquery-https-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Try with an automatic protocol reference (//).
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'jquery-doubleslash', '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver' id='jquery-doubleslash-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Try with a local resource and an automatic protocol reference (//).
</span><span class="cx" style="display: block; padding: 0 10px"> $url = '//my_plugin/script.js';
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'plugin-script', $url );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='$url?ver=$ver'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='$url?ver=$ver' id='plugin-script-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Try with a bad protocol.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'jquery-ftp', 'ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='{$wp_scripts->base_url}ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='{$wp_scripts->base_url}ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver' id='jquery-ftp-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Go!
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -150,8 +150,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Enqueue and add data.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-only-data', 'example.com', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_script_add_data( 'test-only-data', 'data', 'testing' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript'>\n/* <![CDATA[ */\ntesting\n/* ]]> */\n</script>\n";
- $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' id='test-only-data-js-extra'>\n/* <![CDATA[ */\ntesting\n/* ]]> */\n</script>\n";
+ $expected .= "<script type='text/javascript' src='http://example.com' id='test-only-data-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Go!
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -169,7 +169,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Enqueue and add conditional comments.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<!--[if gt IE 7]>\n<script type='text/javascript' src='http://example.com'></script>\n<![endif]-->\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<!--[if gt IE 7]>\n<script type='text/javascript' src='http://example.com' id='test-only-conditional-js'></script>\n<![endif]-->\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Go!
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -188,8 +188,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-conditional-with-data', 'example.com', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_script_add_data( 'test-conditional-with-data', 'data', 'testing' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_script_add_data( 'test-conditional-with-data', 'conditional', 'lt IE 9' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<!--[if lt IE 9]>\n<script type='text/javascript'>\n/* <![CDATA[ */\ntesting\n/* ]]> */\n</script>\n<![endif]-->\n";
- $expected .= "<!--[if lt IE 9]>\n<script type='text/javascript' src='http://example.com'></script>\n<![endif]-->\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<!--[if lt IE 9]>\n<script type='text/javascript' id='test-conditional-with-data-js-extra'>\n/* <![CDATA[ */\ntesting\n/* ]]> */\n</script>\n<![endif]-->\n";
+ $expected .= "<!--[if lt IE 9]>\n<script type='text/javascript' src='http://example.com' id='test-conditional-with-data-js'></script>\n<![endif]-->\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Go!
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -207,7 +207,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Enqueue and add an invalid key.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-invalid', 'example.com', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_script_add_data( 'test-invalid', 'invalid', 'testing' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='http://example.com'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' src='http://example.com' id='test-invalid-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Go!
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -230,8 +230,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 35229
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_wp_register_script_with_handle_without_source() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='http://example.com?ver=1'></script>\n";
- $expected .= "<script type='text/javascript' src='http://example.com?ver=2'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' src='http://example.com?ver=1' id='handle-one-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='http://example.com?ver=2' id='handle-two-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_register_script( 'handle-one', 'http://example.com', array(), 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_register_script( 'handle-two', 'http://example.com', array(), 2 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -319,9 +319,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $header = get_echo( 'wp_print_head_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $footer = get_echo( 'wp_print_footer_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected_header = "<script type='text/javascript' src='/child-footer.js'></script>\n";
- $expected_header .= "<script type='text/javascript' src='/child-head.js'></script>\n";
- $expected_footer = "<script type='text/javascript' src='/parent.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected_header = "<script type='text/javascript' src='/child-footer.js' id='child-footer-js'></script>\n";
+ $expected_header .= "<script type='text/javascript' src='/child-head.js' id='child-head-js'></script>\n";
+ $expected_footer = "<script type='text/javascript' src='/parent.js' id='parent-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected_header, $header );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected_footer, $footer );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -340,9 +340,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $header = get_echo( 'wp_print_head_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $footer = get_echo( 'wp_print_footer_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected_header = "<script type='text/javascript' src='/child-head.js'></script>\n";
- $expected_footer = "<script type='text/javascript' src='/child-footer.js'></script>\n";
- $expected_footer .= "<script type='text/javascript' src='/parent.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected_header = "<script type='text/javascript' src='/child-head.js' id='child-head-js'></script>\n";
+ $expected_footer = "<script type='text/javascript' src='/child-footer.js' id='child-footer-js'></script>\n";
+ $expected_footer .= "<script type='text/javascript' src='/parent.js' id='parent-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected_header, $header );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected_footer, $footer );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -366,14 +366,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $header = get_echo( 'wp_print_head_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $footer = get_echo( 'wp_print_footer_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected_header = "<script type='text/javascript' src='/child-head.js'></script>\n";
- $expected_header .= "<script type='text/javascript' src='/grandchild-head.js'></script>\n";
- $expected_header .= "<script type='text/javascript' src='/child2-head.js'></script>\n";
- $expected_header .= "<script type='text/javascript' src='/parent-header.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected_header = "<script type='text/javascript' src='/child-head.js' id='child-head-js'></script>\n";
+ $expected_header .= "<script type='text/javascript' src='/grandchild-head.js' id='grandchild-head-js'></script>\n";
+ $expected_header .= "<script type='text/javascript' src='/child2-head.js' id='child2-head-js'></script>\n";
+ $expected_header .= "<script type='text/javascript' src='/parent-header.js' id='parent-header-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected_footer = "<script type='text/javascript' src='/child-footer.js'></script>\n";
- $expected_footer .= "<script type='text/javascript' src='/child2-footer.js'></script>\n";
- $expected_footer .= "<script type='text/javascript' src='/parent-footer.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected_footer = "<script type='text/javascript' src='/child-footer.js' id='child-footer-js'></script>\n";
+ $expected_footer .= "<script type='text/javascript' src='/child2-footer.js' id='child2-footer-js'></script>\n";
+ $expected_footer .= "<script type='text/javascript' src='/parent-footer.js' id='parent-footer-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected_header, $header );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected_footer, $footer );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -403,8 +403,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example', 'example.com', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -416,8 +416,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example', 'example.com', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("after");' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='http://example.com'></script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -430,9 +430,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("after");' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -445,7 +445,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -458,7 +458,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("after");' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -472,8 +472,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("after");' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
+ $expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -488,9 +488,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("after");' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("after");' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript'>\nconsole.log(\"before\");\nconsole.log(\"before\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\nconsole.log(\"after\");\n</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\nconsole.log(\"before\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\nconsole.log(\"after\");\n</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -504,10 +504,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("after");' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n/* ]]> */\n</script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n/* ]]> */\n</script>\n";
+ $expected .= "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -529,11 +529,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'two', 'console.log("before two");', 'before' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $ver = get_bloginfo( 'version' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript'>\nconsole.log(\"before one\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='/directory/one.js?ver={$ver}'></script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"before two\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='/directory/two.js?ver={$ver}'></script>\n";
- $expected .= "<script type='text/javascript' src='/directory/three.js?ver={$ver}'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' id='one-js-before'>\nconsole.log(\"before one\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='/directory/one.js?ver={$ver}' id='one-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='two-js-before'>\nconsole.log(\"before two\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='/directory/two.js?ver={$ver}' id='two-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='/directory/three.js?ver={$ver}' id='three-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -554,10 +554,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'one', 'console.log("before one");', 'before' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $ver = get_bloginfo( 'version' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript'>\nconsole.log(\"before one\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='/directory/one.js?ver={$ver}'></script>\n";
- $expected .= "<script type='text/javascript' src='/directory/two.js?ver={$ver}'></script>\n";
- $expected .= "<script type='text/javascript' src='/directory/three.js?ver={$ver}'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' id='one-js-before'>\nconsole.log(\"before one\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='/directory/one.js?ver={$ver}' id='one-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='/directory/two.js?ver={$ver}' id='two-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='/directory/three.js?ver={$ver}' id='three-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -581,11 +581,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $ver = get_bloginfo( 'version' );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=one&ver={$ver}'></script>\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='/directory/two.js?ver={$ver}'></script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"after two\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='/directory/three.js?ver={$ver}'></script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"after three\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='/directory/four.js?ver={$ver}'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='/directory/two.js?ver={$ver}' id='two-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='two-js-after'>\nconsole.log(\"after two\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='/directory/three.js?ver={$ver}' id='three-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='three-js-after'>\nconsole.log(\"after three\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='/directory/four.js?ver={$ver}' id='four-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -600,13 +600,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_localized = "<!--[if gte IE 9]>\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected_localized .= "<script type='text/javascript'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n/* ]]> */\n</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected_localized .= "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n/* ]]> */\n</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected_localized .= "<![endif]-->\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<!--[if gte IE 9]>\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<![endif]-->\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example', 'example.com', array(), null );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -633,8 +633,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $ver = get_bloginfo( 'version' );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate&ver={$ver}'></script>\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("after");' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -659,8 +659,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $ver = get_bloginfo( 'version' );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate&ver={$ver}'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<!--[if gte IE 9]>\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<![endif]-->\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -687,8 +687,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $ver = get_bloginfo( 'version' );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate&ver={$ver}'></script>\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -713,15 +713,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $ver = get_bloginfo( 'version' );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate&ver={$ver}'></script>\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='http://example.com'></script>\n";
- $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/vendor/wp-polyfill.min.js'></script>\n";
- $expected .= "<script type='text/javascript'>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/vendor/wp-polyfill.min.js' id='wp-polyfill-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='wp-polyfill-js-after'>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected .= "( 'fetch' in window ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-fetch.min.js\"></scr' + 'ipt>' );( document.contains ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-node-contains.min.js\"></scr' + 'ipt>' );( window.DOMRect ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-dom-rect.min.js\"></scr' + 'ipt>' );( window.URL && window.URL.prototype && window.URLSearchParams ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-url.min.js\"></scr' + 'ipt>' );( window.FormData && window.FormData.prototype.keys ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-formdata.m
in.js\"></scr' + 'ipt>' );( Element.prototype.matches && Element.prototype.closest ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-element-closest.min.js\"></scr' + 'ipt>' );\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "</script>\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/dom-ready.min.js'></script>\n";
- $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/i18n.min.js'></script>\n";
- $expected .= "<script type='text/javascript'>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/dom-ready.min.js' id='wp-dom-ready-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/i18n.min.js' id='wp-i18n-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='wp-a11y-js-translations'>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected .= "( function( domain, translations ) {\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= " var localeData = translations.locale_data[ domain ] || translations.locale_data.messages;\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= " localeData[\"\"].domain = domain;\n";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -728,9 +728,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= " wp.i18n.setLocaleData( localeData, domain );\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "} )( \"default\", { \"locale_data\": { \"messages\": { \"\": {} } } } );\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "</script>\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/a11y.min.js'></script>\n";
- $expected .= "<script type='text/javascript' src='http://example2.com'></script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/a11y.min.js' id='wp-a11y-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='http://example2.com' id='test-example2-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='test-example2-js-after'>\nconsole.log(\"after\");\n</script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -767,8 +767,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_scripts->base_url = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_scripts->do_concat = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected_tail = "<script type='text/javascript' src='/customize-dependency.js'></script>\n";
- $expected_tail .= "<script type='text/javascript'>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected_tail = "<script type='text/javascript' src='/customize-dependency.js' id='customize-dependency-js'></script>\n";
+ $expected_tail .= "<script type='text/javascript' id='customize-dependency-js-after'>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected_tail .= "tryCustomizeDependency()\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_tail .= "</script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -779,7 +779,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $print_scripts = get_echo( 'wp_print_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $print_scripts .= get_echo( '_print_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tail = substr( $print_scripts, strrpos( $print_scripts, "<script type='text/javascript' src='/customize-dependency.js'>" ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $tail = substr( $print_scripts, strrpos( $print_scripts, "<script type='text/javascript' src='/customize-dependency.js' id='customize-dependency-js'>" ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected_tail, $tail );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -799,11 +799,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'four', '/wp-includes/js/script4.js' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $ver = get_bloginfo( 'version' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='/wp-includes/js/script.js?ver={$ver}'></script>\n";
- $expected .= "<script type='text/javascript'>\nconsole.log(\"after one\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='/wp-includes/js/script2.js?ver={$ver}'></script>\n";
- $expected .= "<script type='text/javascript' src='/wp-includes/js/script3.js?ver={$ver}'></script>\n";
- $expected .= "<script type='text/javascript' src='/wp-includes/js/script4.js?ver={$ver}'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' src='/wp-includes/js/script.js?ver={$ver}' id='one-js'></script>\n";
+ $expected .= "<script type='text/javascript' id='one-js-after'>\nconsole.log(\"after one\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='/wp-includes/js/script2.js?ver={$ver}' id='two-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='/wp-includes/js/script3.js?ver={$ver}' id='three-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='/wp-includes/js/script4.js?ver={$ver}' id='four-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -825,9 +825,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $ver = get_bloginfo( 'version' );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=one,two&ver={$ver}'></script>\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript'>\nconsole.log(\"before three\");\n</script>\n";
- $expected .= "<script type='text/javascript' src='/wp-includes/js/script3.js?ver={$ver}'></script>\n";
- $expected .= "<script type='text/javascript' src='/wp-includes/js/script4.js?ver={$ver}'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' id='three-js-before'>\nconsole.log(\"before three\");\n</script>\n";
+ $expected .= "<script type='text/javascript' src='/wp-includes/js/script3.js?ver={$ver}' id='three-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='/wp-includes/js/script4.js?ver={$ver}' id='four-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -840,19 +840,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example', '/wp-includes/js/script.js', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_script_translations( 'test-example', 'default', DIR_TESTDATA . '/languages' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js' id='wp-i18n-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected .= str_replace(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> '__DOMAIN__',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '__HANDLE__',
</ins><span class="cx" style="display: block; padding: 0 10px"> '__JSON_TRANSLATIONS__',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'default',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'test-example',
</ins><span class="cx" style="display: block; padding: 0 10px"> file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> $this->wp_scripts_print_translations_output
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js' id='test-example-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -865,19 +867,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'plugin-example', '/wp-content/plugins/my-plugin/js/script.js', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_script_translations( 'plugin-example', 'internationalized-plugin', DIR_TESTDATA . '/languages/plugins' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js' id='wp-i18n-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected .= str_replace(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> '__DOMAIN__',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '__HANDLE__',
</ins><span class="cx" style="display: block; padding: 0 10px"> '__JSON_TRANSLATIONS__',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'internationalized-plugin',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'plugin-example',
</ins><span class="cx" style="display: block; padding: 0 10px"> file_get_contents( DIR_TESTDATA . '/languages/plugins/internationalized-plugin-en_US-2f86cb96a0233e7cb3b6f03ad573be0b.json' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> $this->wp_scripts_print_translations_output
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='/wp-content/plugins/my-plugin/js/script.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='/wp-content/plugins/my-plugin/js/script.js' id='plugin-example-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -890,19 +894,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'theme-example', '/wp-content/themes/my-theme/js/script.js', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_script_translations( 'theme-example', 'internationalized-theme', DIR_TESTDATA . '/languages/themes' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js' id='wp-i18n-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected .= str_replace(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> '__DOMAIN__',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '__HANDLE__',
</ins><span class="cx" style="display: block; padding: 0 10px"> '__JSON_TRANSLATIONS__',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'internationalized-theme',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'theme-example',
</ins><span class="cx" style="display: block; padding: 0 10px"> file_get_contents( DIR_TESTDATA . '/languages/themes/internationalized-theme-en_US-2f86cb96a0233e7cb3b6f03ad573be0b.json' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> $this->wp_scripts_print_translations_output
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='/wp-content/themes/my-theme/js/script.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='/wp-content/themes/my-theme/js/script.js' id='theme-example-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -915,19 +921,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'script-handle', '/wp-admin/js/script.js', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_script_translations( 'script-handle', 'admin', DIR_TESTDATA . '/languages/' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js' id='wp-i18n-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected .= str_replace(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> '__DOMAIN__',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '__HANDLE__',
</ins><span class="cx" style="display: block; padding: 0 10px"> '__JSON_TRANSLATIONS__',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'admin',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'script-handle',
</ins><span class="cx" style="display: block; padding: 0 10px"> file_get_contents( DIR_TESTDATA . '/languages/admin-en_US-script-handle.json' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> $this->wp_scripts_print_translations_output
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='/wp-admin/js/script.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='/wp-admin/js/script.js' id='script-handle-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -955,19 +963,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example', '/wp-admin/js/script.js', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_script_translations( 'test-example', 'admin', DIR_TESTDATA . '/languages/' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js' id='wp-i18n-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected .= str_replace(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> '__DOMAIN__',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '__HANDLE__',
</ins><span class="cx" style="display: block; padding: 0 10px"> '__JSON_TRANSLATIONS__',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'admin',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'test-example',
</ins><span class="cx" style="display: block; padding: 0 10px"> '{ "locale_data": { "messages": { "": {} } } }',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> $this->wp_scripts_print_translations_output
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='/wp-admin/js/script.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='/wp-admin/js/script.js' id='test-example-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -982,19 +992,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js' id='wp-i18n-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected .= str_replace(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> '__DOMAIN__',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '__HANDLE__',
</ins><span class="cx" style="display: block; padding: 0 10px"> '__JSON_TRANSLATIONS__',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'default',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'test-example',
</ins><span class="cx" style="display: block; padding: 0 10px"> file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> $this->wp_scripts_print_translations_output
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js' id='test-example-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1009,20 +1021,22 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example', '/wp-includes/js/script2.js', array( 'test-dependency' ), null );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js' id='wp-i18n-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected .= str_replace(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> '__DOMAIN__',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '__HANDLE__',
</ins><span class="cx" style="display: block; padding: 0 10px"> '__JSON_TRANSLATIONS__',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'default',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'test-dependency',
</ins><span class="cx" style="display: block; padding: 0 10px"> file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> $this->wp_scripts_print_translations_output
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n";
- $expected .= "<script type='text/javascript' src='/wp-includes/js/script2.js'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js' id='test-dependency-js'></script>\n";
+ $expected .= "<script type='text/javascript' src='/wp-includes/js/script2.js' id='test-example-js'></script>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>