Make WordPress Core

Changeset 18464


Ignore:
Timestamp:
07/25/2011 12:36:06 AM (14 years ago)
Author:
azaozz
Message:

Use json_encode() for adding script data (formerly l10n). Add the same functionality to WP_Styles for adding inline css after a stylesheet has been outputted. See #11520

Location:
trunk
Files:
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/load-styles.php

    r17630 r18464  
    126126    }
    127127
    128     $out .= str_replace( '../images/', 'images/', $content );
     128    if ( strpos( $style->src, '/wp-includes/css/' ) === 0 )
     129        $out .= str_replace( '../images/', '../wp-includes/images/', $content );
     130    else
     131        $out .= str_replace( '../images/', 'images/', $content );
    129132}
    130133
  • trunk/wp-includes/class.wp-scripts.php

    r18446 r18464  
    4848    }
    4949
     50    // Deprecated since 3.3, see print_script_data()
    5051    function print_scripts_l10n( $handle, $echo = true ) {
    51         if ( empty($this->registered[$handle]->extra['l10n']) || empty($this->registered[$handle]->extra['l10n'][0]) || !is_array($this->registered[$handle]->extra['l10n'][1]) )
    52             return false;
    53 
    54         $object_name = $this->registered[$handle]->extra['l10n'][0];
    55 
    56         $data = "var $object_name = {\n";
    57         $eol = '';
    58         foreach ( $this->registered[$handle]->extra['l10n'][1] as $var => $val ) {
    59             if ( 'l10n_print_after' == $var ) {
    60                 $after = $val;
    61                 continue;
     52        _deprecated_function( __FUNCTION__, '3.3', 'print_script_data()' );
     53        return $this->print_script_data( $handle, $echo, true );
     54    }
     55
     56    function print_script_data( $handle, $echo = true, $_l10n = false ) {
     57        if ( empty($this->registered[$handle]->extra['data']) )
     58            return false;
     59
     60        if ( $_l10n ) {
     61            $name = $this->registered[$handle]->extra['l10n'][0];
     62            $data = $this->registered[$handle]->extra['l10n'][1];
     63            $after = '';
     64
     65            if ( is_array($data) && isset($data['l10n_print_after']) ) {
     66                $after = $data['l10n_print_after'];
     67                unset($data['l10n_print_after']);
    6268            }
    63             $data .= "$eol\t$var: \"" . esc_js( $val ) . '"';
    64             $eol = ",\n";
    65         }
    66         $data .= "\n};\n";
    67         $data .= isset($after) ? "$after\n" : '';
    68 
    69         if ( $echo ) {
    70             echo "<script type='text/javascript'>\n";
    71             echo "/* <![CDATA[ */\n";
    72             echo $data;
    73             echo "/* ]]> */\n";
    74             echo "</script>\n";
    75             return true;
     69            $output = "var $name = " . json_encode($data) . "; $after\n";
    7670        } else {
    77             return $data;
    78         }
     71            foreach ( (array) $this->registered[$handle]->extra['data'] as $name => $data ) {
     72                $output = "var $name = " . json_encode($data) . ";\n";
     73            }
     74        }
     75
     76        if ( !$echo )
     77            return $output;
     78
     79        echo "<script type='text/javascript'>\n";
     80        echo "/* <![CDATA[ */\n"; // not needed in HTML 5
     81        echo $output;
     82        echo "\n/* ]]> */";
     83        echo "\n</script>\n";
     84
     85        return true;
    7986    }
    8087
     
    104111            $srce = apply_filters( 'script_loader_src', $src, $handle );
    105112            if ( $this->in_default_dir($srce) ) {
    106                 $this->print_code .= $this->print_scripts_l10n( $handle, false );
     113                $this->print_code .= $this->print_script_data( $handle, false );
    107114                $this->concat .= "$handle,";
    108115                $this->concat_version .= "$handle$ver";
     
    114121        }
    115122
    116         $this->print_scripts_l10n( $handle );
     123        $this->print_script_data( $handle );
    117124        if ( !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
    118125            $src = $this->base_url . $src;
     
    132139
    133140    /**
    134      * Localizes a script
     141     * Localizes a script (Deprecated)
    135142     *
    136143     * Localizes only if script has already been added
    137144     *
    138      * @param string $handle Script name
    139      * @param string $object_name Name of JS object to hold l10n info
    140      * @param array $l10n Array of JS var name => localized string
    141      * @return bool Successful localization
     145     * @since
     146     * @deprecated WP 3.3
    142147     */
    143148    function localize( $handle, $object_name, $l10n ) {
    144         if ( !$object_name || !$l10n )
    145             return false;
    146         return $this->add_data( $handle, 'l10n', array( $object_name, $l10n ) );
     149        _deprecated_function( __FUNCTION__, '3.3', 'add_script_data()' );
     150        return $this->add_script_data( $handle, $object_name, $l10n );
     151    }
     152
     153    /**
     154     * Add extra Javascript
     155     *
     156     * Only if script has already been added.
     157     *
     158     * @param string $handle Script name
     159     * @param string $name Name of JS object to hold the data
     160     * @param array $data Associative array of JS name => value
     161     * @return bool Successful or not
     162     */
     163    function add_script_data( $handle, $name, $data ) {
     164        if ( !$name || !is_array($data) )
     165            return false;
     166
     167        if ( !empty( $this->registered[$handle]->extra['data'][$name] ) )
     168            $data = array_merge( $data, (array) $this->registered[$handle]->extra['data'][$name] );
     169
     170        return $this->add_data( $handle, 'data', array( $name => $data ) );
    147171    }
    148172
  • trunk/wp-includes/class.wp-styles.php

    r18446 r18464  
    2626    var $do_concat = false;
    2727    var $print_html = '';
     28    var $print_code = '';
    2829    var $default_dirs;
    2930
     
    3637            return false;
    3738
    38         if ( null === $this->registered[$handle]->ver )
     39        $obj = $this->registered[$handle];
     40        if ( null === $obj->ver )
    3941            $ver = '';
    4042        else
    41             $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
     43            $ver = $obj->ver ? $obj->ver : $this->default_version;
    4244
    4345        if ( isset($this->args[$handle]) )
     
    4547
    4648        if ( $this->do_concat ) {
    47             if ( $this->in_default_dir($this->registered[$handle]->src) && !isset($this->registered[$handle]->extra['conditional']) && !isset($this->registered[$handle]->extra['alt']) ) {
     49            if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) {
    4850                $this->concat .= "$handle,";
    4951                $this->concat_version .= "$handle$ver";
     52
     53                if ( !empty($this->registered[$handle]->extra['data']) )
     54                    $this->print_code .= $this->registered[$handle]->extra['data'];
     55
    5056                return true;
    5157            }
    5258        }
    5359
    54         if ( isset($this->registered[$handle]->args) )
    55             $media = esc_attr( $this->registered[$handle]->args );
     60        if ( isset($obj->args) )
     61            $media = esc_attr( $obj->args );
    5662        else
    5763            $media = 'all';
    5864
    59         $href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle );
    60         $rel = isset($this->registered[$handle]->extra['alt']) && $this->registered[$handle]->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
    61         $title = isset($this->registered[$handle]->extra['title']) ? "title='" . esc_attr( $this->registered[$handle]->extra['title'] ) . "'" : '';
     65        $href = $this->_css_href( $obj->src, $ver, $handle );
     66        $rel = isset($obj->extra['alt']) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
     67        $title = isset($obj->extra['title']) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : '';
    6268
    6369        $end_cond = $tag = '';
    64         if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) {
    65             $tag .= "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n";
     70        if ( isset($obj->extra['conditional']) && $obj->extra['conditional'] ) {
     71            $tag .= "<!--[if {$obj->extra['conditional']}]>\n";
    6672            $end_cond = "<![endif]-->\n";
    6773        }
    6874
    6975        $tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle );
    70         if ( 'rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl'] ) {
    71             if ( is_bool( $this->registered[$handle]->extra['rtl'] ) ) {
    72                 $suffix = isset( $this->registered[$handle]->extra['suffix'] ) ? $this->registered[$handle]->extra['suffix'] : '';
    73                 $rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $this->registered[$handle]->src , $ver, "$handle-rtl" ));
     76        if ( 'rtl' === $this->text_direction && isset($obj->extra['rtl']) && $obj->extra['rtl'] ) {
     77            if ( is_bool( $obj->extra['rtl'] ) ) {
     78                $suffix = isset( $obj->extra['suffix'] ) ? $obj->extra['suffix'] : '';
     79                $rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $obj->src , $ver, "$handle-rtl" ));
    7480            } else {
    75                 $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" );
     81                $rtl_href = $this->_css_href( $obj->extra['rtl'], $ver, "$handle-rtl" );
    7682            }
    7783
     
    8187        $tag .= $end_cond;
    8288
    83         if ( $this->do_concat )
     89        if ( $this->do_concat ) {
    8490            $this->print_html .= $tag;
    85         else
     91            $this->print_html .= $this->print_inline_style( $handle, false );
     92        } else {
    8693            echo $tag;
     94            $this->print_inline_style( $handle );
     95        }
    8796
    88         // Could do something with $this->registered[$handle]->extra here to print out extra CSS rules
    89 //      echo "<style type='text/css'>\n";
    90 //      echo "/* <![CDATA[ */\n";
    91 //      echo "/* ]]> */\n";
    92 //      echo "</style>\n";
     97        return true;
     98    }
     99
     100    function add_inline_style( $handle, $data ) {
     101        if ( !$data )
     102            return false;
     103
     104        if ( !empty( $this->registered[$handle]->extra['data'] ) )
     105            $data .= "\n" . $this->registered[$handle]->extra['data'];
     106
     107        return $this->add_data( $handle, 'data', $data );
     108    }
     109
     110    function print_inline_style( $handle, $echo = true ) {
     111        if ( empty($this->registered[$handle]->extra['data']) )
     112            return false;
     113
     114        $output = $this->registered[$handle]->extra['data'];
     115
     116        if ( !$echo )
     117            return $output;
     118
     119        echo "<style type='text/css'>\n";
     120        echo "$output\n";
     121        echo "</style>\n";
    93122
    94123        return true;
  • trunk/wp-includes/deprecated.php

    r18254 r18464  
    26162616    return true;
    26172617}
     2618
     2619/**
     2620 * Localizes a script.
     2621 *
     2622 * Localizes only if script has already been added.
     2623 *
     2624 * @since r16
     2625 * @deprecated WP 3.3
     2626 * @see wp_add_script_data()
     2627 */
     2628function wp_localize_script( $handle, $object_name, $l10n ) {
     2629    _deprecated_function( __FUNCTION__, '3.3', 'wp_add_script_data()' );
     2630    return wp_add_script_data( $handle, $object_name, $l10n );
     2631}
     2632
  • trunk/wp-includes/functions.wp-scripts.php

    r15601 r18464  
    2727    if ( !is_a($wp_scripts, 'WP_Scripts') ) {
    2828        if ( !$handles )
    29             return array(); // No need to instantiate if nothing's there.
     29            return array(); // No need to instantiate if nothing is there.
    3030        else
    3131            $wp_scripts = new WP_Scripts();
     
    3636
    3737/**
    38  * Register new JavaScript file.
     38 * Register new Javascript file.
    3939 *
    4040 * @since r16
     
    5757
    5858/**
    59  * Localizes a script.
     59 * Adds extra Javascript.
    6060 *
    61  * Localizes only if script has already been added.
    62  *
    63  * @since r16
    64  * @see WP_Scripts::localize()
     61 * Works only if the script has already been added.
     62 * Accepts an associative array $data and creates JS object:
     63 * "$name" = {
     64 *   key: value,
     65 *   key: value,
     66 *   ...
     67 * }
     68 * The $name is passed directly so it should be qualified JS variable /[a-zA-Z0-9_]+/
     69 * The $data array is JSON encoded. If called more than once for the same $handle, with the same $name,
     70 * the object would contain all values. In that case if two or more keys are the same,
     71 * the first value is kept and subsequent values are ignored.
     72 *
     73 * @since 3.3
     74 * @see WP_Scripts::add_script_data()
    6575 */
    66 function wp_localize_script( $handle, $object_name, $l10n ) {
     76function wp_add_script_data( $handle, $name, $data ) {
    6777    global $wp_scripts;
    6878    if ( !is_a($wp_scripts, 'WP_Scripts') )
    6979        return false;
    7080
    71     return $wp_scripts->localize( $handle, $object_name, $l10n );
     81    return $wp_scripts->add_script_data( $handle, $name, $data );
    7282}
    7383
  • trunk/wp-includes/functions.wp-styles.php

    r15601 r18464  
    2626    if ( !is_a($wp_styles, 'WP_Styles') ) {
    2727        if ( !$handles )
    28             return array(); // No need to instantiate if nothing's there.
     28            return array(); // No need to instantiate if nothing is there.
    2929        else
    3030            $wp_styles = new WP_Styles();
     
    3232
    3333    return $wp_styles->do_items( $handles );
     34}
     35
     36/**
     37 * Adds extra CSS.
     38 *
     39 * Works only if the stylesheet has already been added.
     40 * Accepts a string $data containing the CSS.
     41 *
     42 * @since 3.3
     43 * @see WP_Scripts::add_inline_style()
     44 */
     45function wp_add_inline_style( $handle, $data ) {
     46    global $wp_styles;
     47    if ( !is_a($wp_styles, 'WP_Styles') )
     48        return false;
     49
     50    return $wp_styles->add_inline_style( $handle, $data );
    3451}
    3552
  • trunk/wp-includes/script-loader.php

    r18453 r18464  
    5959    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
    6060
    61     // Always ensure that we have the convertEntities function
    62     $scripts->add( 'l10n', "/wp-includes/js/l10n$suffix.js", false, '20101110' );
    63     $scripts->enqueue( 'l10n' );
    64 
    6561    $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' );
    6662
    6763    $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20110711' );
    6864    $scripts->add_data( 'common', 'group', 1 );
    69     $scripts->localize( 'common', 'commonL10n', array(
    70         'warnDelete' => __("You are about to permanently delete the selected items.\n  'Cancel' to stop, 'OK' to delete."),
    71         'l10n_print_after' => 'try{convertEntities(commonL10n);}catch(e){};'
     65    $scripts->add_script_data( 'common', 'commonL10n', array(
     66        'warnDelete' => __("You are about to permanently delete the selected items.\n  'Cancel' to stop, 'OK' to delete.")
    7267    ) );
    7368
     
    7772    $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", false, '20110502' );
    7873    $scripts->add_data( 'quicktags', 'group', 1 );
    79     $scripts->localize( 'quicktags', 'quicktagsL10n', array(
     74    $scripts->add_script_data( 'quicktags', 'quicktagsL10n', array(
    8075        'quickLinks' => __('(Quick Links)'),
    8176        'wordLookup' => __('Enter a word to look up:'),
     
    8883        'enterImageDescription' => __('Enter a description of the image'),
    8984        'fullscreen' => __('fullscreen'),
    90         'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') ),
    91         'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};'
     85        'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') )
    9286    ) );
    9387
     
    10498    $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), '20091119' );
    10599    $scripts->add_data( 'wp-ajax-response', 'group', 1 );
    106     $scripts->localize( 'wp-ajax-response', 'wpAjax', array(
     100    $scripts->add_script_data( 'wp-ajax-response', 'wpAjax', array(
    107101        'noPerm' => __('You do not have permission to do that.'),
    108         'broken' => __('An unidentified error has occurred.'),
    109         'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};'
     102        'broken' => __('An unidentified error has occurred.')
    110103    ) );
    111104
     
    193186    $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20110528');
    194187    $scripts->add_data( 'thickbox', 'group', 1 );
    195     $scripts->localize( 'thickbox', 'thickboxL10n', array(
     188    $scripts->add_script_data( 'thickbox', 'thickboxL10n', array(
    196189            'next' => __('Next &gt;'),
    197190            'prev' => __('&lt; Prev'),
     
    201194            'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
    202195            'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
    203             'closeImage' => includes_url('js/thickbox/tb-close.png'),
    204             'l10n_print_after' => 'try{convertEntities(thickboxL10n);}catch(e){};'
     196            'closeImage' => includes_url('js/thickbox/tb-close.png')
    205197    ) );
    206198
     
    226218        $max_upload_size = __('not configured');
    227219    // these error messages came from the sample swfupload js, they might need changing.
    228     $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array(
     220    $scripts->add_script_data( 'swfupload-handlers', 'swfuploadL10n', array(
    229221            'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
    230222            'file_exceeds_size_limit' => __('This file exceeds the maximum upload size for this site.'),
     
    243235            'crunching' => __('Crunching&hellip;'),
    244236            'deleted' => __('moved to the trash.'),
    245             'error_uploading' => __('&#8220;%s&#8221; has failed to upload due to an error'),
    246             'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};',
     237            'error_uploading' => __('&#8220;%s&#8221; has failed to upload due to an error')
    247238    ) );
    248239
     
    256247    $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20101027' );
    257248    $scripts->add_data( 'password-strength-meter', 'group', 1 );
    258     $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
     249    $scripts->add_script_data( 'password-strength-meter', 'pwsL10n', array(
    259250        'empty' => __('Strength indicator'),
    260251        'short' => __('Very weak'),
     
    263254        'good' => _x('Medium', 'password strength'),
    264255        'strong' => __('Strong'),
    265         'mismatch' => __('Mismatch'),
    266         'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
     256        'mismatch' => __('Mismatch')
    267257    ) );
    268258
     
    275265    $scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), '20110528' );
    276266    $scripts->add_data( 'wplink', 'group', 1 );
    277     $scripts->localize( 'wplink', 'wpLinkL10n', array(
     267    $scripts->add_script_data( 'wplink', 'wpLinkL10n', array(
    278268        'title' => __('Insert/edit link'),
    279269        'update' => __('Update'),
    280270        'save' => __('Add Link'),
    281271        'noTitle' => __('(no title)'),
    282         'noMatchesFound' => __('No matches found.'),
    283         'l10n_print_after' => 'try{convertEntities(wpLinkL10n);}catch(e){};',
     272        'noMatchesFound' => __('No matches found.')
    284273    ) );
    285274
     
    293282        $scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' );
    294283        $scripts->add_data( 'ajaxcat', 'group', 1 );
    295         $scripts->localize( 'ajaxcat', 'catL10n', array(
     284        $scripts->add_script_data( 'ajaxcat', 'catL10n', array(
    296285            'add' => esc_attr(__('Add')),
    297             'how' => __('Separate multiple categories with commas.'),
    298             'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};'
     286            'how' => __('Separate multiple categories with commas.')
    299287        ) );
    300288
     
    304292        $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('jquery', 'wp-ajax-response'), '20110429' );
    305293        $scripts->add_data( 'admin-tags', 'group', 1 );
    306         $scripts->localize( 'admin-tags', 'tagsl10n', array(
     294        $scripts->add_script_data( 'admin-tags', 'tagsl10n', array(
    307295            'noPerm' => __('You do not have permission to do that.'),
    308             'broken' => __('An unidentified error has occurred.'),
    309             'l10n_print_after' => 'try{convertEntities(tagsl10n);}catch(e){};'
     296            'broken' => __('An unidentified error has occurred.')
    310297        ));
    311298
     
    315302        $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'jquery-query'), '20110602' );
    316303        $scripts->add_data( 'admin-comments', 'group', 1 );
    317         $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
     304        $scripts->add_script_data( 'admin-comments', 'adminCommentsL10n', array(
    318305            'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
    319306            'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']),
     
    330317        $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110524' );
    331318        $scripts->add_data( 'post', 'group', 1 );
    332         $scripts->localize( 'post', 'postL10n', array(
     319        $scripts->add_script_data( 'post', 'postL10n', array(
    333320            'tagsUsed' =>  __('Tags used on this post:'),
    334321            'add' => esc_attr(__('Add')),
     
    353340            'password' => __('Password Protected'),
    354341            'privatelyPublished' => __('Privately Published'),
    355             'published' => __('Published'),
    356             'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};'
     342            'published' => __('Published')
    357343        ) );
    358344
     
    362348        $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array('jquery'), '20110429' );
    363349        $scripts->add_data( 'comment', 'group', 1 );
    364         $scripts->localize( 'comment', 'commentL10n', array(
     350        $scripts->add_script_data( 'comment', 'commentL10n', array(
    365351            'cancel' => __('Cancel'),
    366352            'edit' => __('Edit'),
    367             'submittedOn' => __('Submitted on:'),
    368             'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};'
     353            'submittedOn' => __('Submitted on:')
    369354        ) );
    370355
     
    388373        $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), '20110609' );
    389374        $scripts->add_data( 'inline-edit-post', 'group', 1 );
    390         $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
     375        $scripts->add_script_data( 'inline-edit-post', 'inlineEditL10n', array(
    391376            'error' => __('Error while saving the changes.'),
    392377            'ntdeltitle' => __('Remove From Bulk Edit'),
    393             'notitle' => __('(no title)'),
    394             'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
     378            'notitle' => __('(no title)')
    395379        ) );
    396380
    397381        $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), '20110609' );
    398382        $scripts->add_data( 'inline-edit-tax', 'group', 1 );
    399         $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
    400             'error' => __('Error while saving the changes.'),
    401             'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
     383        $scripts->add_script_data( 'inline-edit-tax', 'inlineEditL10n', array(
     384            'error' => __('Error while saving the changes.')
    402385        ) );
    403386
    404387        $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'thickbox' ), '20110113' );
    405388        $scripts->add_data( 'plugin-install', 'group', 1 );
    406         $scripts->localize( 'plugin-install', 'plugininstallL10n', array(
     389        $scripts->add_script_data( 'plugin-install', 'plugininstallL10n', array(
    407390            'plugin_information' => __('Plugin Information:'),
    408             'ays' => __('Are you sure you want to install this plugin?'),
    409             'l10n_print_after' => 'try{convertEntities(plugininstallL10n);}catch(e){};'
     391            'ays' => __('Are you sure you want to install this plugin?')
    410392        ) );
    411393
     
    428410        $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), '20100518' );
    429411        $scripts->add_data( 'set-post-thumbnail', 'group', 1 );
    430         $scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array(
     412        $scripts->add_script_data( 'set-post-thumbnail', 'setPostThumbnailL10n', array(
    431413            'setThumbnail' => __( 'Use as featured image' ),
    432414            'saving' => __( 'Saving...' ),
    433415            'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
    434             'done' => __( 'Done' ),
    435             'l10n_print_after' => 'try{convertEntities(setPostThumbnailL10n);}catch(e){};'
     416            'done' => __( 'Done' )
    436417        ) );
    437418
    438419        // Navigation Menus
    439420        $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array('jquery-ui-sortable'), '20110524' );
    440         $scripts->localize( 'nav-menu', 'navMenuL10n', array(
     421        $scripts->add_script_data( 'nav-menu', 'navMenuL10n', array(
    441422            'noResultsFound' => _x('No results found.', 'search results'),
    442423            'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
    443             'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
    444             'l10n_print_after' => 'try{convertEntities(navMenuL10n);}catch(e){};'
     424            'saveAlert' => __('The changes you made will be lost if you navigate away from this page.')
    445425        ) );
    446426
     
    475455    $styles->default_version = get_bloginfo( 'version' );
    476456    $styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
    477     $styles->default_dirs = array('/wp-admin/', '/wp-includes/');
     457    $styles->default_dirs = array('/wp-admin/', '/wp-includes/css/');
    478458
    479459    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
     
    559539function wp_just_in_time_script_localization() {
    560540
    561     wp_localize_script( 'autosave', 'autosaveL10n', array(
     541    wp_add_script_data( 'autosave', 'autosaveL10n', array(
    562542        'autosaveInterval' => AUTOSAVE_INTERVAL,
    563543        'savingText' => __('Saving Draft&#8230;'),
    564         'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
    565         'l10n_print_after' => 'try{convertEntities(autosaveL10n);}catch(e){};'
     544        'saveAlert' => __('The changes you made will be lost if you navigate away from this page.')
    566545    ) );
    567546
     
    636615
    637616    script_concat_settings();
    638     $wp_scripts->do_items( 'l10n' );
    639617    $wp_scripts->do_concat = $concatenate_scripts;
    640618    $wp_scripts->do_head_items();
     
    648626
    649627/**
    650  * Prints the scripts that were queued for the footer on admin pages.
     628 * Prints the scripts that were queued for the footer or too late for the HTML head.
    651629 *
    652630 * @since 2.8
     
    654632function print_footer_scripts() {
    655633    global $wp_scripts, $concatenate_scripts;
    656 
    657     if ( ! did_action('wp_print_footer_scripts') )
    658         do_action('wp_print_footer_scripts');
    659634
    660635    if ( !is_a($wp_scripts, 'WP_Scripts') )
     
    672647}
    673648
     649/**
     650 * @internal use
     651 */
    674652function _print_scripts() {
    675653    global $wp_scripts, $compress_scripts;
     
    682660
    683661        if ( !empty($wp_scripts->print_code) ) {
    684             echo "<script type='text/javascript'>\n";
    685             echo "/* <![CDATA[ */\n";
     662            echo "\n<script type='text/javascript'>\n";
     663            echo "/* <![CDATA[ */\n"; // not needed in HTML 5
    686664            echo $wp_scripts->print_code;
    687665            echo "/* ]]> */\n";
     
    719697
    720698/**
    721  * Prints the scripts that were queued for the footer on the front end.
     699 * Hooks to print the scripts and styles in the footer.
    722700 *
    723701 * @since 2.8
     
    726704    print_late_styles();
    727705    print_footer_scripts();
     706
     707    if ( !is_admin() )
     708        do_action('wp_print_footer_scripts');
     709
    728710    return true;
    729711}
     
    741723}
    742724
     725/**
     726 * Prints the styles queue in the HTML head on admin pages.
     727 *
     728 * @since 2.8
     729 */
    743730function print_admin_styles() {
    744731    global $wp_styles, $concatenate_scripts, $compress_css;
     
    762749}
    763750
     751/**
     752 * Prints the styles that were queued too late for the HTML head.
     753 *
     754 * @since 3.3
     755 */
    764756function print_late_styles() {
    765757    global $wp_styles, $concatenate_scripts;
     
    778770}
    779771
     772/**
     773 * @internal use
     774 */
    780775function _print_styles() {
    781776    global $wp_styles, $compress_css;
     
    790785        $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . "&ver=$ver";
    791786        echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n";
     787
     788        if ( !empty($wp_styles->print_code) ) {
     789            echo "<style type='text/css'>\n";
     790            echo $wp_styles->print_code;
     791            echo "\n</style>\n";
     792        }
    792793    }
    793794
     
    796797}
    797798
     799/**
     800 * Determine the concatenation and compression settings for scripts and styles.
     801 *
     802 * @since 2.8
     803 */
    798804function script_concat_settings() {
    799805    global $concatenate_scripts, $compress_scripts, $compress_css;
Note: See TracChangeset for help on using the changeset viewer.