Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
b171b08
wp_get_script_tag() and wp_get_inline_script_tag()
enricocarraro Oct 13, 2020
9f0fccd
Move 'wp_script_attributes' filter out of wp_sanitize_script_attribut…
enricocarraro Oct 23, 2020
7b36c46
Restructure ifs in wp_sanitize_script_attributes().
enricocarraro Oct 23, 2020
65ed818
Docs: correct DocBlocks for wp_get_script_tag and related functions.
enricocarraro Oct 23, 2020
1e45f03
wp_get_script_tag() and wp_get_inline_script_tag()
enricocarraro Oct 13, 2020
3ea2f75
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
64c4a5d
Use wp_get_script_tag() and wp_get_inline_script_tag() in WP_Scripts.
enricocarraro Oct 14, 2020
16a8b04
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
2d034a8
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-login.p…
enricocarraro Oct 14, 2020
869a59e
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
5792ee3
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
ac07869
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
67415b0
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
27a8369
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
eb4e615
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
053f4b9
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
31be1c8
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
d9dab36
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
2459916
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
e8f62b6
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
6f0b742
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
0a0eb54
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
74e3c9b
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/u…
enricocarraro Oct 14, 2020
d4fae18
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/s…
enricocarraro Oct 14, 2020
06737ab
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/n…
enricocarraro Oct 14, 2020
da6ea76
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/n…
enricocarraro Oct 14, 2020
7ed73c6
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/n…
enricocarraro Oct 14, 2020
fdc306f
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
c929f4f
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
9cf69a4
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
af820e9
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
92f5af1
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
729f6aa
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
33a2005
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
c5c9954
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
0b884e3
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
a0311fa
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
55a63dc
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/u…
enricocarraro Oct 14, 2020
3860286
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
160b367
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
e330bc1
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
099f9f2
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
6a44f2a
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
f580482
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
ef7519a
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
8b103e0
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/i…
enricocarraro Oct 14, 2020
9d577be
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/e…
enricocarraro Oct 14, 2020
81d60f0
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/e…
enricocarraro Oct 14, 2020
9a2d957
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/e…
enricocarraro Oct 14, 2020
1d14499
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/e…
enricocarraro Oct 14, 2020
0c8f2cd
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/e…
enricocarraro Oct 14, 2020
30108c2
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/c…
enricocarraro Oct 14, 2020
fba70f7
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/a…
enricocarraro Oct 14, 2020
3f57e6f
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-admin/a…
enricocarraro Oct 14, 2020
12a65ff
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-activat…
enricocarraro Oct 14, 2020
2420dc1
Use wp_get_script_tag() and wp_get_inline_script_tag() in `wp-include…
enricocarraro Oct 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions src/wp-activate.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,7 @@ function wpmu_activate_stylesheet() {
?>
</div>
</div>
<script type="text/javascript">
var key_input = document.getElementById('key');
key_input && key_input.focus();
</script>
<?php

wp_print_inline_script_tag( "var key_input = document.getElementById('key');\nkey_input && key_input.focus();" );
get_footer( 'wp-activate' );
2 changes: 1 addition & 1 deletion src/wp-admin/admin-footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@
?>

<div class="clear"></div></div><!-- wpwrap -->
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
<?php wp_print_inline_script_tag( 'if(typeof wpOnload=="function")wpOnload();' ); ?>
</body>
</html>
30 changes: 14 additions & 16 deletions src/wp-admin/admin-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,17 @@
wp_enqueue_script( 'svg-painter' );

$admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
?>
<script type="text/javascript">
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();}}};
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
pagenow = '<?php echo $current_screen->id; ?>',
typenow = '<?php echo $current_screen->post_type; ?>',
adminpage = '<?php echo $admin_body_class; ?>',
thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
isRtl = <?php echo (int) is_rtl(); ?>;
</script>
<?php

$js = '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();}}};
var ajaxurl = "' . admin_url( 'admin-ajax.php', 'relative' ) . '",
pagenow = "' . $current_screen->id . '",
typenow = "' . $current_screen->post_type . '",
adminpage = "' . $admin_body_class . '",
thousandsSeparator = "' . addslashes( $wp_locale->number_format['thousands_sep'] ) . '",
decimalPoint = "' . addslashes( $wp_locale->number_format['decimal_point'] ) . '",
isRtl = ' . ( (int) is_rtl() ) . ';';

wp_print_inline_script_tag( $js );

/**
* Enqueue scripts for all admin pages.
Expand Down Expand Up @@ -232,11 +231,10 @@
$admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );
?>
<body class="wp-admin wp-core-ui no-js <?php echo $admin_body_classes; ?>">
<script type="text/javascript">
document.body.className = document.body.className.replace('no-js','js');
</script>

<?php

wp_print_inline_script_tag( 'document.body.className = document.body.className.replace("no-js","js");' );

// Make sure the customize body classes are correct as early as possible.
if ( current_user_can( 'customize' ) ) {
wp_customize_support_script();
Expand Down
15 changes: 6 additions & 9 deletions src/wp-admin/customize.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
);
ob_start();
?>
<?php wp_print_scripts( array( 'wp-util' ) ); ?>
<script>
wp.ajax.post( 'customize_save', <?php echo wp_json_encode( $request_args ); ?> );
</script>
<?php
wp_print_scripts( array( 'wp-util' ) );

wp_print_inline_script_tag( 'wp.ajax.post( "customize_save", ' . wp_json_encode( $request_args ) . ' );' );

$script = ob_get_clean();

wp_die(
Expand Down Expand Up @@ -148,13 +148,10 @@

?>
<title><?php echo esc_html( $admin_title ); ?></title>
<?php

<script type="text/javascript">
var ajaxurl = <?php echo wp_json_encode( admin_url( 'admin-ajax.php', 'relative' ) ); ?>,
pagenow = 'customize';
</script>
wp_print_inline_script_tag( 'var ajaxurl = ' . wp_json_encode( admin_url( 'admin-ajax.php', 'relative' ) ) . ', pagenow = "customize";' );

<?php
/**
* Fires when Customizer control styles are printed.
*
Expand Down
9 changes: 4 additions & 5 deletions src/wp-admin/edit-form-advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,7 @@
}
?>

<?php if ( ! wp_is_mobile() && post_type_supports( $post_type, 'title' ) && '' === $post->post_title ) : ?>
<script type="text/javascript">
try{document.post.title.focus();}catch(e){}
</script>
<?php endif; ?>
<?php
if ( ! wp_is_mobile() && post_type_supports( $post_type, 'title' ) && '' === $post->post_title ) {
wp_print_inline_script_tag( 'try{document.post.title.focus();}catch(e){}' );
}
10 changes: 4 additions & 6 deletions src/wp-admin/edit-form-comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@
</div>
</form>

<?php if ( ! wp_is_mobile() ) : ?>
<script type="text/javascript">
try{document.post.name.focus();}catch(e){}
</script>
<?php
endif;
<?php
if ( ! wp_is_mobile() ) {
wp_print_inline_script_tag( 'try{document.post.name.focus();}catch(e){}' );
}
10 changes: 4 additions & 6 deletions src/wp-admin/edit-tag-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@
</form>
</div>

<?php if ( ! wp_is_mobile() ) : ?>
<script type="text/javascript">
try{document.forms.edittag.name.focus();}catch(e){}
</script>
<?php
endif;
<?php
if ( ! wp_is_mobile() ) {
wp_print_inline_script_tag( 'try{document.forms.edittag.name.focus();}catch(e){}' );
}
10 changes: 4 additions & 6 deletions src/wp-admin/edit-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,10 @@

</div><!-- /wrap -->

<?php if ( ! wp_is_mobile() ) : ?>
<script type="text/javascript">
try{document.forms.addtag['tag-name'].focus();}catch(e){}
</script>
<?php
endif;
<?php
if ( ! wp_is_mobile() ) {
wp_print_inline_script_tag( 'try{document.forms.addtag["tag-name"].focus();}catch(e){}' );
}

$wp_list_table->inline_edit();

Expand Down
7 changes: 3 additions & 4 deletions src/wp-admin/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
* @since 3.5.0
*/
function export_add_js() {
?>
<script type="text/javascript">
$js = <<<'JS'
jQuery(document).ready(function($){
var form = $('#export-filters'),
filters = form.find('.export-filters');
Expand All @@ -38,8 +37,8 @@ function export_add_js() {
}
});
});
</script>
<?php
JS;
wp_print_inline_script_tag( $js );
}
add_action( 'admin_head', 'export_add_js' );

Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/ajax-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3740,7 +3740,7 @@ function wp_ajax_parse_embed() {
$script_src = includes_url( 'js/wp-embed.min.js' );
}

$return['head'] = '<script src="' . $script_src . '"></script>';
$return['head'] = wp_get_script_tag( array( 'src' => $script_src ) );
$return['sandbox'] = true;
}

Expand Down
8 changes: 4 additions & 4 deletions src/wp-admin/includes/class-bulk-upgrader-skin.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function error( $error ) {
}
$this->error = implode( ', ', $messages );
}
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
wp_print_inline_script_tag( 'jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();' );
}

/**
Expand All @@ -126,7 +126,7 @@ public function bulk_footer() {
public function before( $title = '' ) {
$this->in_loop = true;
printf( '<h2>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h2>', $title, $this->upgrader->update_current, $this->upgrader->update_count );
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').css("display", "inline-block");</script>';
wp_print_inline_script_tag( 'jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').css("display", "inline-block");' );
// This progress messages div gets moved via JavaScript when clicking on "Show details.".
echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr( $this->upgrader->update_current ) . '"><p>';
$this->flush_output();
Expand All @@ -144,7 +144,7 @@ public function after( $title = '' ) {
echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed'], $title ) . '</p></div>';
}

echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>';
wp_print_inline_script_tag( 'jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').show();' );
}
if ( $this->result && ! is_wp_error( $this->result ) ) {
if ( ! $this->error ) {
Expand All @@ -154,7 +154,7 @@ public function after( $title = '' ) {
'</p></div>';
}

echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
wp_print_inline_script_tag( 'jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>' );
}

$this->reset();
Expand Down
83 changes: 37 additions & 46 deletions src/wp-admin/includes/class-custom-image-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,9 @@ public function js_1() {
$default_color = '#' . $default_color;
}
}
?>
<script type="text/javascript">
$js = <<<JS
(function($){
var default_color = '<?php echo $default_color; ?>',
var default_color = '$default_color',
header_text_fields;

function pickColor(color) {
Expand Down Expand Up @@ -379,13 +378,13 @@ function toggle_text() {
}
});
$('#display-header-text').click( toggle_text );
<?php if ( ! display_header_text() ) : ?>
toggle_text();
<?php endif; ?>
JS;
$js .= ! display_header_text() ? 'toggle_text()' : '';
$js .= <<<JS
});
})(jQuery);
</script>
<?php
JS;
wp_print_inline_script_tag( $js );
}

/**
Expand All @@ -395,21 +394,20 @@ function toggle_text() {
*/
public function js_2() {

?>
<script type="text/javascript">
$js = '
function onEndCrop( coords ) {
jQuery( '#x1' ).val(coords.x);
jQuery( '#y1' ).val(coords.y);
jQuery( '#width' ).val(coords.w);
jQuery( '#height' ).val(coords.h);
jQuery( "#x1" ).val(coords.x);
jQuery( "#y1" ).val(coords.y);
jQuery( "#width" ).val(coords.w);
jQuery( "#height" ).val(coords.h);
}

jQuery(document).ready(function() {
var xinit = <?php echo absint( get_theme_support( 'custom-header', 'width' ) ); ?>;
var yinit = <?php echo absint( get_theme_support( 'custom-header', 'height' ) ); ?>;
var xinit = ' . absint( get_theme_support( 'custom-header', 'width' ) ) . '
var yinit = ' . absint( get_theme_support( 'custom-header', 'height' ) ) . '
var ratio = xinit / yinit;
var ximg = jQuery('img#upload').width();
var yimg = jQuery('img#upload').height();
var ximg = jQuery("img#upload").width();
var yimg = jQuery("img#upload").height();

if ( yimg < yinit || ximg < xinit ) {
if ( ximg / yimg > ratio ) {
Expand All @@ -421,45 +419,38 @@ function onEndCrop( coords ) {
}
}

jQuery('img#upload').imgAreaSelect({
jQuery("img#upload").imgAreaSelect({
handles: true,
keys: true,
show: true,
x1: 0,
y1: 0,
x2: xinit,
y2: yinit,
<?php
if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) ) {
?>
aspectRatio: xinit + ':' + yinit,
<?php
}
if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) {
?>
maxHeight: <?php echo get_theme_support( 'custom-header', 'height' ); ?>,
<?php
}
if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) {
?>
maxWidth: <?php echo get_theme_support( 'custom-header', 'width' ); ?>,
<?php
}
?>
y2: yinit,';

if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) ) {
$js .= 'aspectRatio: xinit + ":" + yinit,';
}
if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) {
$js .= 'maxHeight: ' . get_theme_support( 'custom-header', 'height' ) . ',';
}
if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) {
$js .= 'maxWidth: ' . get_theme_support( 'custom-header', 'width' ) . ',';
}
$js .= '
onInit: function () {
jQuery('#width').val(xinit);
jQuery('#height').val(yinit);
jQuery("#width").val(xinit);
jQuery("#height").val(yinit);
},
onSelectChange: function(img, c) {
jQuery('#x1').val(c.x1);
jQuery('#y1').val(c.y1);
jQuery('#width').val(c.width);
jQuery('#height').val(c.height);
jQuery("#x1").val(c.x1);
jQuery("#y1").val(c.y1);
jQuery("#width").val(c.width);
jQuery("#height").val(c.height);
}
});
});
</script>
<?php
});';
wp_print_inline_script_tag( $js );
}

/**
Expand Down
Loading