Make WordPress Core

Ticket #15782: 15782.2.diff

File 15782.2.diff, 8.4 KB (added by garyc40, 13 years ago)

remove redundant admin_script_globals() function

  • wp-admin/admin-header.php

    diff --git wp-admin/admin-header.php wp-admin/admin-header.php
    index ac79340..1a1e77b 100644
    if ( is_multisite() ) 
    4747wp_enqueue_script('utils');
    4848
    4949$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
    50 ?>
    51 <script type="text/javascript">
    52 //<![CDATA[
    53 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();}}};
    54 var userSettings = {
    55                 'url': '<?php echo SITECOOKIEPATH; ?>',
    56                 'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',
    57                 'time':'<?php echo time() ?>'
    58         },
    59         ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
    60         pagenow = '<?php echo $current_screen->id; ?>',
    61         typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>',
    62         adminpage = '<?php echo $admin_body_class; ?>',
    63         thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
    64         decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
    65         isRtl = <?php echo (int) is_rtl(); ?>;
    66 //]]>
    67 </script>
    68 <?php
    6950
    7051if ( in_array( $pagenow, array('post.php', 'post-new.php') ) ) {
    7152        add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
  • wp-admin/includes/media.php

    diff --git wp-admin/includes/media.php wp-admin/includes/media.php
    index 5a13bcc..7e345e6 100644
    if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( 
    315315        || ( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) ) )
    316316        wp_enqueue_style( 'media' );
    317317wp_enqueue_style( 'ie' );
    318 ?>
    319 <script type="text/javascript">
    320 //<![CDATA[
    321 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();}}};
    322 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time(); ?>'};
    323 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
    324 isRtl = <?php echo (int) is_rtl(); ?>;
    325 //]]>
    326 </script>
    327 <?php
     318
    328319do_action('admin_enqueue_scripts', 'media-upload-popup');
    329320do_action('admin_print_styles-media-upload-popup');
    330321do_action('admin_print_styles');
  • wp-admin/includes/template.php

    diff --git wp-admin/includes/template.php wp-admin/includes/template.php
    index b345c36..89e35ab 100644
    wp_enqueue_style( 'global' ); 
    15541554if ( ! $limit_styles )
    15551555        wp_enqueue_style( 'wp-admin' );
    15561556wp_enqueue_style( 'colors' );
    1557 ?>
    1558 <script type="text/javascript">
    1559 //<![CDATA[
    1560 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();}}};
    1561 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
    1562 var userSettings = {
    1563                 'url': '<?php echo SITECOOKIEPATH; ?>',
    1564                 'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',
    1565                 'time':'<?php echo time() ?>'
    1566         },
    1567         ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
    1568         pagenow = '<?php echo $current_screen->id; ?>',
    1569         typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>',
    1570         adminpage = '<?php echo $admin_body_class; ?>',
    1571         thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
    1572         decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
    1573         isRtl = <?php echo (int) is_rtl(); ?>;
    1574 //]]>
    1575 </script>
    1576 <?php
    15771557do_action('admin_enqueue_scripts', $hook_suffix);
    15781558do_action("admin_print_styles-$hook_suffix");
    15791559do_action('admin_print_styles');
  • wp-admin/press-this.php

    diff --git wp-admin/press-this.php wp-admin/press-this.php
    index aa4eb47..66e834a 100644
    die; 
    329329        wp_enqueue_script( 'post' );
    330330        wp_enqueue_script( 'editor' );
    331331?>
    332 <script type="text/javascript">
    333 //<![CDATA[
    334 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();}}};
    335 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'};
    336 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'press-this', isRtl = <?php echo (int) is_rtl(); ?>;
    337 var photostorage = false;
    338 //]]>
    339 </script>
    340 
     332<?php admin_script_init( '', array( 'pagenow' => 'press-this', 'photostorage' => false ) ) ?>
    341333<?php
    342334        do_action('admin_print_styles');
    343335        do_action('admin_print_scripts');
  • wp-includes/functions.wp-scripts.php

    diff --git wp-includes/functions.wp-scripts.php wp-includes/functions.wp-scripts.php
    index af2055d..bf842c8 100644
    function wp_script_is( $handle, $list = 'queue' ) { 
    144144                return true;
    145145
    146146        return $query;
    147 }
     147}
     148 No newline at end of file
  • wp-includes/script-loader.php

    diff --git wp-includes/script-loader.php wp-includes/script-loader.php
    index ef51ed5..6ed86cc 100644
    function print_admin_styles() { 
    761761        return $wp_styles->done;
    762762}
    763763
     764function admin_addLoadEvent() {
     765        ?>
     766        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();}}};
     767        <?php
     768}
     769
     770function admin_script_init( $hook_suffix = '', $set_globals = array() ) {
     771        global $wp_locale;
     772        $current_user = wp_get_current_user();
     773        $current_screen = get_current_screen();
     774        $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
     775        $defaults = array(
     776                'userSettings' => array(
     777                        'url' => SITECOOKIEPATH,
     778                        'uid' => $current_user->ID,
     779                        'time' => time(),
     780                ),
     781                'ajaxurl' => admin_url( 'admin-ajax.php' ),
     782                'adminpage' => $admin_body_class,
     783                'thousandsSeparator' => addslashes( $wp_locale->number_format['thousands_sep'] ),
     784                'decimalPoint' => addslashes( $wp_locale->number_format['decimal_point'] ),
     785                'isRtl' => (int) is_rtl(),
     786        );
     787       
     788        if ( $current_screen ) {
     789                $defaults['pagenow'] = $current_screen->id;
     790                if ( isset( $current_screen->post_type ) ) {
     791                        $defaults['typenow'] = $current_screen->post_type;
     792                }
     793        }
     794       
     795        $globals = wp_parse_args( $set_globals, $defaults );
     796       
     797        ?>
     798        <script type="text/javascript">
     799        //<![CDATA[
     800        <?php admin_addLoadEvent(); ?>
     801        function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
     802        <?php
     803                $outputs = array();
     804                echo 'var ';
     805                foreach ( $globals as $name => $value ) {
     806                        $value = json_encode( $value );
     807                       
     808                        $outputs[] = "{$name} = {$value}";
     809                }
     810               
     811                echo implode( ",\n\t", $outputs ) . ";\n";
     812        ?>
     813        //]]>
     814        </script>
     815        <?php
     816}
     817
    764818function script_concat_settings() {
    765819        global $concatenate_scripts, $compress_scripts, $compress_css;
    766820
    add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); 
    791845
    792846add_action( 'wp_default_styles', 'wp_default_styles' );
    793847add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
     848
     849add_action( 'admin_enqueue_scripts', 'admin_script_init', 1, 1 );
     850 No newline at end of file
  • wp-login.php

    diff --git wp-login.php wp-login.php
    index ab9cff5..f983aa3 100644
    function wp_shake_js() { 
    147147                return;
    148148?>
    149149<script type="text/javascript">
    150 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();}}};
     150<?php admin_addLoadEvent(); ?>
    151151function s(id,pos){g(id).left=pos+'px';}
    152152function g(id){return document.getElementById(id).style;}
    153153function shake(id,a,d){c=a.shift();s(id,c);if(a.length>0){setTimeout(function(){shake(id,a,d);},d);}else{try{g(id).position='static';wp_attempt_focus();}catch(e){}}}