Ticket #39941: inline-js-patch.diff
| File inline-js-patch.diff, 14.6 KB (added by , 9 years ago) |
|---|
-
wp-admin/admin-footer.php
diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php index 2317a03bd..5aae58d88 100644
a b if ( function_exists('get_site_option') ) { 107 107 ?> 108 108 109 109 <div class="clear"></div></div><!-- wpwrap --> 110 < script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>110 <?php inline_js( "if(typeof wpOnload=='function')wpOnload();" ); ?> 111 111 </body> 112 112 </html> -
wp-admin/admin-header.php
diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index d5ceeccd6..b712ea67a 100644
a b wp_enqueue_script('utils'); 73 73 wp_enqueue_script( 'svg-painter' ); 74 74 75 75 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); 76 ?> 77 <script type="text/javascript"> 76 77 $ajaxurl = admin_url( 'admin-ajax.php', 'relative' ); 78 $thousands_separator = addslashes( $wp_locale->number_format['thousands_sep'] ); 79 $decimal_point = addslashes( $wp_locale->number_format['decimal_point'] ); 80 $is_rtl = (int) is_rtl(); 81 $js = <<<JS 78 82 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();}}}; 79 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', 80 pagenow = '<?php echo $current_screen->id; ?>', 81 typenow = '<?php echo $current_screen->post_type; ?>', 82 adminpage = '<?php echo $admin_body_class; ?>', 83 thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>', 84 decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>', 85 isRtl = <?php echo (int) is_rtl(); ?>; 86 </script> 83 var ajaxurl = '{$ajaxurl}', 84 pagenow = '{$current_screen->id}', 85 typenow = '{$current_screen->post_type}', 86 adminpage = '{$admin_body_class}', 87 thousandsSeparator = '{$thousands_separator}', 88 decimalPoint = '{$decimal_point}', 89 isRtl = {$is_rtl}; 90 JS; 91 inline_js($js); 92 ?> 87 93 <meta name="viewport" content="width=device-width,initial-scale=1.0"> 88 94 <?php 89 95 … … $admin_body_class .= ' no-customize-support no-svg'; 195 201 $admin_body_classes = apply_filters( 'admin_body_class', '' ); 196 202 ?> 197 203 <body class="wp-admin wp-core-ui no-js <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>"> 198 < script type="text/javascript">199 document.body.className = document.body.className.replace('no-js','js');200 </script>204 <?php 205 inline_js("document.body.className = document.body.className.replace('no-js','js');"); 206 ?> 201 207 202 208 <?php 203 209 // Make sure the customize body classes are correct as early as possible. -
wp-admin/includes/class-wp-list-table.php
diff --git a/wp-admin/includes/class-wp-list-table.php b/wp-admin/includes/class-wp-list-table.php index dedfec934..67b8e2d20 100644
a b class WP_List_Table { 1372 1372 ) 1373 1373 ); 1374 1374 1375 printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args) );1375 inline_js( sprintf( "list_args = %s;", wp_json_encode( $args ) ) ); 1376 1376 } 1377 1377 } -
wp-admin/includes/misc.php
diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 679b9ac5d..e2b21b0fd 100644
a b function wp_color_scheme_settings() { 713 713 $icon_colors = array( 'base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff' ); 714 714 } 715 715 716 echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";716 inline_js( 'var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ) ) . ';' ); 717 717 } 718 718 719 719 /** … … function wp_admin_canonical_url() { 911 911 $filtered_url = remove_query_arg( $removable_query_args, $current_url ); 912 912 ?> 913 913 <link id="wp-admin-canonical" rel="canonical" href="<?php echo esc_url( $filtered_url ); ?>" /> 914 <script> 914 <?php 915 $js = <<<JS 915 916 if ( window.history.replaceState ) { 916 917 window.history.replaceState( null, null, document.getElementById( 'wp-admin-canonical' ).href + window.location.hash ); 917 918 } 918 </script> 919 <?php 919 JS; 920 inline_js($js); 920 921 } 921 922 922 923 /** -
wp-includes/class-wp-editor.php
diff --git a/wp-includes/class-wp-editor.php b/wp-includes/class-wp-editor.php index 83777cfd8..b3d7d99f4 100644
a b final class _WP_Editors { 1219 1219 * @param array $mce_settings TinyMCE settings array. 1220 1220 */ 1221 1221 do_action( 'before_wp_tiny_mce', self::$mce_settings ); 1222 ?>1223 1222 1224 <script type="text/javascript"> 1223 $baseurl = self::$baseurl; 1224 $drag_drop_upload = self::$drag_drop_upload ? 'dragDropUpload: true,' : ''; 1225 $ref = self::_parse_init( $ref ); 1226 $js = <<<JS 1225 1227 tinyMCEPreInit = { 1226 baseURL: "<?php echo self::$baseurl; ?>", 1227 suffix: "<?php echo $suffix; ?>", 1228 <?php 1229 1230 if ( self::$drag_drop_upload ) { 1231 echo 'dragDropUpload: true,'; 1232 } 1233 1234 ?> 1235 mceInit: <?php echo $mceInit; ?>, 1236 qtInit: <?php echo $qtInit; ?>, 1237 ref: <?php echo self::_parse_init( $ref ); ?>, 1228 baseURL: "{$baseurl}", 1229 suffix: "{$suffix}", 1230 {$drag_drop_upload} 1231 mceInit: {$mceInit}, 1232 qtInit: {$qtInit}, 1233 ref: {$ref}, 1238 1234 load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');} 1239 1235 }; 1240 </script> 1241 <?php 1236 JS; 1237 inline_js( $js ); 1242 1238 1243 1239 $baseurl = self::$baseurl; 1244 1240 // Load tinymce.js when running from /src, else load wp-tinymce.js.gz (production) or tinymce.min.js (SCRIPT_DEBUG) … … final class _WP_Editors { 1270 1266 */ 1271 1267 do_action( 'wp_tiny_mce_init', self::$mce_settings ); 1272 1268 1273 ?> 1274 <script type="text/javascript"> 1275 <?php 1269 $js = ''; 1276 1270 1277 1271 if ( self::$ext_plugins ) 1278 echoself::$ext_plugins . "\n";1272 $js .= self::$ext_plugins . "\n"; 1279 1273 1280 1274 if ( ! is_admin() ) 1281 echo'var ajaxurl = "' . admin_url( 'admin-ajax.php', 'relative' ) . '";';1275 $js .= 'var ajaxurl = "' . admin_url( 'admin-ajax.php', 'relative' ) . '";'; 1282 1276 1283 ?> 1277 $js .= <<<JS 1284 1278 1285 1279 ( function() { 1286 var init, id, $wrap;1280 var init, id, \$wrap; 1287 1281 1288 1282 if ( typeof tinymce !== 'undefined' ) { 1289 1283 for ( id in tinyMCEPreInit.mceInit ) { 1290 1284 init = tinyMCEPreInit.mceInit[id]; 1291 $wrap = tinymce.$( '#wp-' + id + '-wrap' );1285 \$wrap = tinymce.\$( '#wp-' + id + '-wrap' ); 1292 1286 1293 if ( ( $wrap.hasClass( 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( id ) ) && ! init.wp_skip_init ) {1287 if ( ( \$wrap.hasClass( 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( id ) ) && ! init.wp_skip_init ) { 1294 1288 tinymce.init( init ); 1295 1289 1296 1290 if ( ! window.wpActiveEditor ) { … … final class _WP_Editors { 1310 1304 } 1311 1305 } 1312 1306 }()); 1313 </script> 1314 <?php 1307 JS; 1308 inline_js($js); 1315 1309 1316 1310 if ( in_array( 'wplink', self::$plugins, true ) || in_array( 'link', self::$qt_buttons, true ) ) { 1317 1311 self::wp_link_dialog(); -
wp-includes/class.wp-scripts.php
diff --git a/wp-includes/class.wp-scripts.php b/wp-includes/class.wp-scripts.php index 81634ece4..15bbd4fe7 100644
a b class WP_Scripts extends WP_Dependencies { 219 219 if ( !$echo ) 220 220 return $output; 221 221 222 echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5 223 echo "/* <![CDATA[ */\n"; 224 echo "$output\n"; 225 echo "/* ]]> */\n"; 226 echo "</script>\n"; 222 inline_js("/* <![CDATA[ */\n$output\n/* ]]> */\n"); 227 223 228 224 return true; 229 225 } … … class WP_Scripts extends WP_Dependencies { 277 273 $after_handle = $this->print_inline_script( $handle, 'after', false ); 278 274 279 275 if ( $before_handle ) { 280 $before_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $before_handle );276 $before_handle = inline_js( $before_handle, false ); 281 277 } 282 278 283 279 if ( $after_handle ) { 284 $after_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $after_handle );280 $after_handle = inline_js( $after_handle, false ); 285 281 } 286 282 287 283 if ( $this->do_concat ) { -
wp-includes/formatting.php
diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 7ad8020e3..b2bdde578 100644
a b function _print_emoji_detection_script() { 5074 5074 * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG 5075 5075 * and edit wp-emoji-loader.js directly. 5076 5076 */ 5077 ?> 5078 <script type="text/javascript"> 5079 window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>; 5080 !function(a,b,c){function d(a){var b,c,d,e,f=String.fromCharCode;if(!k||!k.fillText)return!1;switch(k.clearRect(0,0,j.width,j.height),k.textBaseline="top",k.font="600 32px Arial",a){case"flag":return k.fillText(f(55356,56826,55356,56819),0,0),!(j.toDataURL().length<3e3)&&(k.clearRect(0,0,j.width,j.height),k.fillText(f(55356,57331,65039,8205,55356,57096),0,0),b=j.toDataURL(),k.clearRect(0,0,j.width,j.height),k.fillText(f(55356,57331,55356,57096),0,0),c=j.toDataURL(),b!==c);case"emoji4":return k.fillText(f(55357,56425,55356,57341,8205,55357,56507),0,0),d=j.toDataURL(),k.clearRect(0,0,j.width,j.height),k.fillText(f(55357,56425,55356,57341,55357,56507),0,0),e=j.toDataURL(),d!==e}return!1}function e(a){var c=b.createElement("script");c.src=a,c.defer=c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f,g,h,i,j=b.createElement("canvas"),k=j.getContext&&j.getContext("2d");for(i=Array("flag","emoji4"),c.supports={everything:!0,everythingExceptFlag:!0},h=0;h<i.length;h++)c.supports[i[h]]=d(i[h]),c.supports.everything=c.supports.everything&&c.supports[i[h]],"flag"!==i[h]&&(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&c.supports[i[h]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&!c.supports.flag,c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.everything||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",g,!1),a.addEventListener("load",g,!1)):(a.attachEvent("onload",g),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings); 5081 </script> 5082 <?php 5077 inline_js('window._wpemojiSettings = '.wp_json_encode( $settings ).';!function(a,b,c){function d(a){var b,c,d,e,f=String.fromCharCode;if(!k||!k.fillText)return!1;switch(k.clearRect(0,0,j.width,j.height),k.textBaseline="top",k.font="600 32px Arial",a){case"flag":return k.fillText(f(55356,56826,55356,56819),0,0),!(j.toDataURL().length<3e3)&&(k.clearRect(0,0,j.width,j.height),k.fillText(f(55356,57331,65039,8205,55356,57096),0,0),b=j.toDataURL(),k.clearRect(0,0,j.width,j.height),k.fillText(f(55356,57331,55356,57096),0,0),c=j.toDataURL(),b!==c);case"emoji4":return k.fillText(f(55357,56425,55356,57341,8205,55357,56507),0,0),d=j.toDataURL(),k.clearRect(0,0,j.width,j.height),k.fillText(f(55357,56425,55356,57341,55357,56507),0,0),e=j.toDataURL(),d!==e}return!1}function e(a){var c=b.createElement("script");c.src=a,c.defer=c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f,g,h,i,j=b.createElement("canvas"),k=j.getContext&&j.getContext("2d");for(i=Array("flag","emoji4"),c.supports={everything:!0,everythingExceptFlag:!0},h=0;h<i.length;h++)c.supports[i[h]]=d(i[h]),c.supports.everything=c.supports.everything&&c.supports[i[h]],"flag"!==i[h]&&(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&c.supports[i[h]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&!c.supports.flag,c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.everything||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",g,!1),a.addEventListener("load",g,!1)):(a.attachEvent("onload",g),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings);'); 5083 5078 } 5084 5079 } 5085 5080 -
wp-includes/functions.php
diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 865c0d29b..eb52fbc9c 100644
a b function wp_cache_get_last_changed( $group ) { 5630 5630 5631 5631 return $last_changed; 5632 5632 } 5633 5634 /** 5635 * Documentation goes here. 5636 */ 5637 function inline_js( $javascript, $echo=true ) { 5638 $attributes = "type='text/javascript'"; 5639 $attributes = apply_filters('inline_js_attributes', $attributes); 5640 5641 $output = sprintf("<script %s>%s</script>", $attributes, $javascript); 5642 5643 if ( $echo ) { 5644 echo $output; 5645 } else { 5646 return $output; 5647 } 5648 } -
wp-includes/script-loader.php
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index b2e24d6fe..a61f7be79 100644
a b function _print_scripts() { 1139 1139 if ( $concat = trim( $wp_scripts->concat, ', ' ) ) { 1140 1140 1141 1141 if ( !empty($wp_scripts->print_code) ) { 1142 echo "\n<script type='text/javascript'>\n"; 1143 echo "/* <![CDATA[ */\n"; // not needed in HTML 5 1144 echo $wp_scripts->print_code; 1145 echo "/* ]]> */\n"; 1146 echo "</script>\n"; 1142 $js = "/* <![CDATA[ */\n"; // not needed in HTML 5 1143 $js .= $wp_scripts->print_code; 1144 $js .= "/* ]]> */\n"; 1145 inline_js($js); 1147 1146 } 1148 1147 1149 1148 $concat = str_split( $concat, 128 ); -
wp-includes/theme.php
diff --git a/wp-includes/theme.php b/wp-includes/theme.php index bf53205c2..6050185d8 100644
a b function wp_customize_support_script() { 3026 3026 </script> 3027 3027 <![endif]--> 3028 3028 <!--[if gte IE 9]><!--> 3029 <script type="text/javascript"> 3029 <?php 3030 $js = <<<JS 3030 3031 (function() { 3031 3032 var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)'); 3032 3033 <?php if ( $cross_domain ) : ?> 3034 request = (function(){ var xhr = new XMLHttpRequest(); return ('withCredentials' in xhr); })(); 3035 <?php else : ?> 3036 request = true; 3037 <?php endif; ?> 3038 3033 JS; 3034 if ( $cross_domain ) { 3035 $js .= "request = (function(){ var xhr = new XMLHttpRequest(); return ('withCredentials' in xhr); })();"; 3036 } else { 3037 $js .= "request = true;"; 3038 } 3039 3040 $js .= <<<JS 3039 3041 b[c] = b[c].replace( rcs, ' ' ); 3040 3042 // The customizer requires postMessage and CORS (if the site is cross domain) 3041 3043 b[c] += ( window.postMessage && request ? ' ' : ' no-' ) + cs; 3042 3044 }()); 3043 </script> 3045 JS; 3046 3047 inline_js($js); 3048 ?> 3044 3049 <!--<![endif]--> 3045 3050 <?php 3046 3051 }