Skip to content

Commit 47f2c42

Browse files
committed
Inline <script>s that are only printed in the admin for pages that are served with the HTML5 doctype absolutely do not need CDATA comments.
Props tw2113 for the initial patch. See #18788. git-svn-id: https://develop.svn.wordpress.org/trunk@31034 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5db95f2 commit 47f2c42

12 files changed

Lines changed: 0 additions & 45 deletions

File tree

src/wp-admin/custom-header.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ public function js_1() {
390390
?>
391391

392392
<script type="text/javascript">
393-
/* <![CDATA[ */
394393
(function($){
395394
var default_color = '<?php echo $default_color; ?>',
396395
header_text_fields;
@@ -433,7 +432,6 @@ function toggle_text() {
433432
<?php endif; ?>
434433
});
435434
})(jQuery);
436-
/* ]]> */
437435
</script>
438436
<?php
439437
}
@@ -445,7 +443,6 @@ function toggle_text() {
445443
*/
446444
public function js_2() { ?>
447445
<script type="text/javascript">
448-
/* <![CDATA[ */
449446
function onEndCrop( coords ) {
450447
jQuery( '#x1' ).val(coords.x);
451448
jQuery( '#y1' ).val(coords.y);
@@ -507,7 +504,6 @@ function onEndCrop( coords ) {
507504
}
508505
});
509506
});
510-
/* ]]> */
511507
</script>
512508
<?php
513509
}

src/wp-admin/export.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
function export_add_js() {
2525
?>
2626
<script type="text/javascript">
27-
//<![CDATA[
2827
jQuery(document).ready(function($){
2928
var form = $('#export-filters'),
3029
filters = form.find('.export-filters');
@@ -37,7 +36,6 @@ function export_add_js() {
3736
}
3837
});
3938
});
40-
//]]>
4139
</script>
4240
<?php
4341
}

src/wp-admin/includes/media.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,8 @@ function _cleanup_image_add_caption( $matches ) {
239239
function media_send_to_editor($html) {
240240
?>
241241
<script type="text/javascript">
242-
/* <![CDATA[ */
243242
var win = window.dialogArguments || opener || parent || top;
244243
win.send_to_editor('<?php echo addslashes($html); ?>');
245-
/* ]]> */
246244
</script>
247245
<?php
248246
exit;
@@ -448,11 +446,9 @@ function wp_iframe($content_func /* ... */) {
448446
wp_enqueue_style( 'ie' );
449447
?>
450448
<script type="text/javascript">
451-
//<![CDATA[
452449
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
453450
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
454451
isRtl = <?php echo (int) is_rtl(); ?>;
455-
//]]>
456452
</script>
457453
<?php
458454
/** This action is documented in wp-admin/admin-header.php */
@@ -682,10 +678,8 @@ function media_upload_form_handler() {
682678

683679
if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?>
684680
<script type="text/javascript">
685-
/* <![CDATA[ */
686681
var win = window.dialogArguments || opener || parent || top;
687682
win.tb_remove();
688-
/* ]]> */
689683
</script>
690684
<?php
691685
exit;
@@ -1946,15 +1940,13 @@ function media_upload_type_form($type = 'file', $errors = null, $id = null) {
19461940
<?php media_upload_form( $errors ); ?>
19471941

19481942
<script type="text/javascript">
1949-
//<![CDATA[
19501943
jQuery(function($){
19511944
var preloaded = $(".media-item.preloaded");
19521945
if ( preloaded.length > 0 ) {
19531946
preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
19541947
}
19551948
updateMediaForm();
19561949
});
1957-
//]]>
19581950
</script>
19591951
<div id="media-items"><?php
19601952

@@ -2009,7 +2001,6 @@ function media_upload_type_url_form($type = null, $errors = null, $id = null) {
20092001
<h3 class="media-title"><?php _e('Insert media from another website'); ?></h3>
20102002

20112003
<script type="text/javascript">
2012-
//<![CDATA[
20132004
var addExtImage = {
20142005

20152006
width : '',
@@ -2099,8 +2090,6 @@ function media_upload_type_url_form($type = null, $errors = null, $id = null) {
20992090
$('table.describe').toggleClass('not-image', $('#not-image').prop('checked') );
21002091
});
21012092
});
2102-
2103-
//]]>
21042093
</script>
21052094

21062095
<div id="media-items">

src/wp-admin/includes/ms.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,9 +955,7 @@ function can_edit_network( $site_id ) {
955955
function _thickbox_path_admin_subfolder() {
956956
?>
957957
<script type="text/javascript">
958-
//<![CDATA[
959958
var tb_pathToImage = "<?php echo includes_url( 'js/thickbox/loadingAnimation.gif', 'relative' ); ?>";
960-
//]]>
961959
</script>
962960
<?php
963961
}

src/wp-admin/includes/template.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,6 @@ function iframe_header( $title = '', $limit_styles = false ) {
15491549
wp_enqueue_style( 'colors' );
15501550
?>
15511551
<script type="text/javascript">
1552-
//<![CDATA[
15531552
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
15541553
function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
15551554
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
@@ -1559,7 +1558,6 @@ function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_r
15591558
thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
15601559
decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
15611560
isRtl = <?php echo (int) is_rtl(); ?>;
1562-
//]]>
15631561
</script>
15641562
<?php
15651563
/** This action is documented in wp-admin/admin-header.php */
@@ -1596,13 +1594,11 @@ function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_r
15961594
?>
15971595
<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
15981596
<script type="text/javascript">
1599-
//<![CDATA[
16001597
(function(){
16011598
var c = document.body.className;
16021599
c = c.replace(/no-js/, 'js');
16031600
document.body.className = c;
16041601
})();
1605-
//]]>
16061602
</script>
16071603
<?php
16081604
}
@@ -1729,7 +1725,6 @@ function _media_states( $post ) {
17291725
function compression_test() {
17301726
?>
17311727
<script type="text/javascript">
1732-
/* <![CDATA[ */
17331728
var testCompression = {
17341729
get : function(test) {
17351730
var x;
@@ -1776,7 +1771,6 @@ function compression_test() {
17761771
}
17771772
};
17781773
testCompression.check();
1779-
/* ]]> */
17801774
</script>
17811775
<?php
17821776
}
@@ -1975,7 +1969,6 @@ private static function print_js( $pointer_id, $selector, $args ) {
19751969

19761970
?>
19771971
<script type="text/javascript">
1978-
//<![CDATA[
19791972
(function($){
19801973
var options = <?php echo wp_json_encode( $args ); ?>, setup;
19811974

@@ -2001,7 +1994,6 @@ private static function print_js( $pointer_id, $selector, $args ) {
20011994
$(document).ready( setup );
20021995

20031996
})( jQuery );
2004-
//]]>
20051997
</script>
20061998
<?php
20071999
}

src/wp-admin/network/site-users.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@
177177
require( ABSPATH . 'wp-admin/admin-header.php' ); ?>
178178

179179
<script type="text/javascript">
180-
/* <![CDATA[ */
181180
var current_site_id = <?php echo $id; ?>;
182-
/* ]]> */
183181
</script>
184182

185183

src/wp-admin/options-general.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
function options_general_add_js() {
2929
?>
3030
<script type="text/javascript">
31-
//<![CDATA[
3231
jQuery(document).ready(function($){
3332
var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(),
3433
homeURL = ( <?php echo wp_json_encode( get_home_url() ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );
@@ -77,7 +76,6 @@ function options_general_add_js() {
7776
}
7877
});
7978
});
80-
//]]>
8179
</script>
8280
<?php
8381
}

src/wp-admin/options-permalink.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
function options_permalink_add_js() {
5555
?>
5656
<script type="text/javascript">
57-
//<![CDATA[
5857
jQuery(document).ready(function() {
5958
jQuery('.permalink-structure input:radio').change(function() {
6059
if ( 'custom' == this.value )
@@ -65,7 +64,6 @@ function options_permalink_add_js() {
6564
jQuery("#custom_selection").attr('checked', 'checked');
6665
});
6766
});
68-
//]]>
6967
</script>
7068
<?php
7169
}

src/wp-admin/options-reading.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
function options_reading_add_js() {
2424
?>
2525
<script type="text/javascript">
26-
//<![CDATA[
2726
jQuery(document).ready(function($){
2827
var section = $('#front-static-pages'),
2928
staticPage = section.find('input:radio[value="page"]'),
@@ -34,7 +33,6 @@ function options_reading_add_js() {
3433
check_disabled();
3534
section.find('input:radio').change(check_disabled);
3635
});
37-
//]]>
3836
</script>
3937
<?php
4038
}

src/wp-admin/press-this.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ function press_it() {
109109
switch ($_REQUEST['ajax']) {
110110
case 'video': ?>
111111
<script type="text/javascript">
112-
/* <![CDATA[ */
113112
jQuery('.select').click(function() {
114113
append_editor(jQuery('#embed-code').val());
115114
jQuery('#extra-fields').hide();
@@ -119,7 +118,6 @@ function press_it() {
119118
jQuery('#extra-fields').hide();
120119
jQuery('#extra-fields').html('');
121120
});
122-
/* ]]> */
123121
</script>
124122
<div class="postbox">
125123
<h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2>
@@ -132,14 +130,12 @@ function press_it() {
132130

133131
case 'photo_thickbox': ?>
134132
<script type="text/javascript">
135-
/* <![CDATA[ */
136133
jQuery('.cancel').click(function() {
137134
tb_remove();
138135
});
139136
jQuery('.select').click(function() {
140137
image_selector(this);
141138
});
142-
/* ]]> */
143139
</script>
144140
<h3 class="tb"><label for="tb_this_photo_description"><?php _e('Description') ?></label></h3>
145141
<div class="titlediv">
@@ -299,11 +295,9 @@ function image_selector(el) {
299295
?>
300296
<title><?php _e('Press This') ?></title>
301297
<script type="text/javascript">
302-
//<![CDATA[
303298
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
304299
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'press-this', isRtl = <?php echo (int) is_rtl(); ?>;
305300
var photostorage = false;
306-
//]]>
307301
</script>
308302

309303
<?php

0 commit comments

Comments
 (0)