WordPress.org

Make WordPress Core

Ticket #24907: 24907.2.patch

File 24907.2.patch, 1.4 KB (added by c3mdigital, 8 years ago)

json encode javascript variables output in admin header

  • wp-admin/admin-header.php

     
    5050?>
    5151<script type="text/javascript">
    5252addLoadEvent = 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();}}};
    53 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
    54         pagenow = '<?php echo $current_screen->id; ?>',
    55         typenow = '<?php echo $current_screen->post_type; ?>',
    56         adminpage = '<?php echo $admin_body_class; ?>',
    57         thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
    58         decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
     53var ajaxurl = <?php echo json_encode( admin_url( 'admin-ajax.php', 'relative' ) ) ?>,
     54        pagenow = <?php echo json_encode( $current_screen->id ); ?>,
     55        typenow = <?php echo json_encode( $current_screen->post_type ); ?>,
     56        adminpage = <?php echo json_encode( $admin_body_class ); ?>,
     57        thousandsSeparator = <?php echo json_encode( addslashes( $wp_locale->number_format['thousands_sep'] ) ); ?>,
     58        decimalPoint = <?php echo json_encode( addslashes( $wp_locale->number_format['decimal_point'] ) ); ?>,
    5959        isRtl = <?php echo (int) is_rtl(); ?>;
    6060</script>
    6161<?php