Make WordPress Core

Changeset 10135


Ignore:
Timestamp:
12/09/2008 02:50:28 AM (17 years ago)
Author:
azaozz
Message:

Fix external dependencies in class.wp-scripts.php, fixes #8505

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-header.php

    r10086 r10135  
    3030//<![CDATA[
    3131addLoadEvent = 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();}}};
     32
     33function convertEntities(o) {
     34    var c = function(s) {
     35        if (/&[^;]+;/.test(s)) {
     36            var e = document.createElement("div");
     37            e.innerHTML = s;
     38            return !e.firstChild ? s : e.firstChild.nodeValue;
     39        }
     40        return s;
     41    }
     42
     43    if ( typeof o === 'string' )
     44        return c(o);
     45    else if ( typeof o === 'object' )
     46        for (var v in o) {
     47            if ( typeof o[v] === 'string' )
     48                o[v] = c(o[v]);
     49        }
     50    return o;
     51};
    3252//]]>
    3353</script>
  • trunk/wp-includes/class.wp-scripts.php

    r10086 r10135  
    4545        echo "<script type='text/javascript'>\n";
    4646        echo "/* <![CDATA[ */\n";
    47         echo "function convertEntities(o) {\n";
    48         echo "  var c = function(s) {\n";
    49         echo "      if (/&[^;]+;/.test(s)) {\n";
    50         echo "          var e = document.createElement('div');\n";
    51         echo "          e.innerHTML = s;\n";
    52         echo "          return !e.firstChild ? s : e.firstChild.nodeValue;\n";
    53         echo "      }\n";
    54         echo "      return s;\n";
    55         echo "  }\n";
    56         echo "  if ( typeof o === 'string' ) {\n";
    57         echo "      return c(o);\n";
    58         echo "  } else if ( typeof o === 'object' ) {\n";
    59         echo "      for (var v in o) {\n";
    60         echo "          if ( typeof o[v] === 'string' )\n";
    61         echo "              o[v] = c(o[v]);\n";
    62         echo "      }\n";
    63         echo "  }\n";
    64         echo "  return o;\n";
    65         echo "};\n";
    6647        echo "\t$object_name = {\n";
    6748        $eol = '';
    6849        foreach ( $this->registered[$handle]->extra['l10n'][1] as $var => $val ) {
     50            if ( 'l10n_print_after' == $var ) {
     51                $after = $val;
     52                continue;
     53            }
    6954            echo "$eol\t\t$var: \"" . js_escape( $val ) . '"';
    7055            $eol = ",\n";
    7156        }
    7257        echo "\n\t}\n";
    73         echo "try{convertEntities($object_name);}catch(e){};\n";
     58        echo isset($after) ? "\t$after\n" : '';
    7459        echo "/* ]]> */\n";
    7560        echo "</script>\n";
  • trunk/wp-includes/script-loader.php

    r10133 r10135  
    5555        'enterURL' => __('Enter the URL'),
    5656        'enterImageURL' => __('Enter the URL of the image'),
    57         'enterImageDescription' => __('Enter a description of the image')
     57        'enterImageDescription' => __('Enter a description of the image'),
     58        'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};'
    5859    ) );
    5960
     
    7374    $scripts->localize( 'wp-ajax-response', 'wpAjax', array(
    7475        'noPerm' => __('You do not have permission to do that.'),
    75         'broken' => __('An unidentified error has occurred.')
     76        'broken' => __('An unidentified error has occurred.'),
     77        'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};'
    7678    ) );
    7779
     
    128130            'dismiss' => __('Dismiss'),
    129131            'crunching' => __('Crunching&hellip;'),
    130             'deleted' => __('Deleted')
     132            'deleted' => __('Deleted'),
     133            'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};'
    131134    ) );
    132135
     
    144147        $scripts->localize( 'ajaxcat', 'catL10n', array(
    145148            'add' => attribute_escape(__('Add')),
    146             'how' => __('Separate multiple categories with commas.')
     149            'how' => __('Separate multiple categories with commas.'),
     150            'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};'
    147151        ) );
    148152        $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20081117' );
     
    155159            'bad' => __('Weak'),
    156160            'good' => _c('Medium|password strength'),
    157             'strong' => __('Strong')
     161            'strong' => __('Strong'),
     162            'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
    158163        ) );
    159164        $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20081206' );
     
    172177            'requestFile' => admin_url('admin-ajax.php'),
    173178            'save' => __('Save'),
    174             'cancel' => __('Cancel')
     179            'cancel' => __('Cancel'),
     180            'l10n_print_after' => 'try{convertEntities(slugL10n);}catch(e){};'
    175181        ) );
    176182        $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20081128' );
     
    197203            'password' => __('Password Protected'),
    198204            'privatelyPublished' => __('Privately Published'),
    199             'published' => __('Published')
     205            'published' => __('Published'),
     206            'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};'
    200207        ) );
    201208        $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox'), '20081128' );
     
    217224            'password' => __('Password Protected'),
    218225            'privatelyPublished' => __('Privately Published'),
    219             'published' => __('Published')
     226            'published' => __('Published'),
     227            'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};'
    220228        ) );
    221229        $scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20080925' );
     
    224232            'cancel' => __('Cancel'),
    225233            'edit' => __('Edit'),
    226             'submittedOn' => __('Submitted on:')
     234            'submittedOn' => __('Submitted on:'),
     235            'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};'
    227236        ) );
    228237        $scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20081127' );
     
    235244            'cancel' => __('Cancel'),
    236245            'lameReminder' => __('Remember to click the "Save Changes" button at the bottom of the Current Widgets column after you\'re all done!'),
    237             'lamerReminder' => __("You're about to leave without having saved your changes!")
     246            'lamerReminder' => __("You're about to leave without having saved your changes!"),
     247            'l10n_print_after' => 'try{convertEntities(widgetsL10n);}catch(e){};'
    238248        ));
    239249
    240250        $scripts->add( 'word-count', '/wp-admin/js/word-count.js', array( 'jquery' ), '20080423' );
    241251        $scripts->localize( 'word-count', 'wordCountL10n', array(
    242             'count' => __('Word count: %d')
     252            'count' => __('Word count: %d'),
     253            'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};'
    243254        ));
    244255
     
    246257        $scripts->localize( 'wp-gears', 'wpGearsL10n', array(
    247258            'updateCompleted' => __('Update completed.'),
    248             'error' => __('Error:')
     259            'error' => __('Error:'),
     260            'l10n_print_after' => 'try{convertEntities(wpGearsL10n);}catch(e){};'
    249261        ));
    250262
     
    255267            'error' => __('Error while saving the changes.'),
    256268            'ntdeltitle' => __('Remove From Bulk Edit'),
    257             'notitle' => __('(no title)')
     269            'notitle' => __('(no title)'),
     270            'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
    258271        ) );
    259272
    260273        $scripts->add( 'inline-edit-tax', '/wp-admin/js/inline-edit-tax.js', array( 'jquery', 'jquery-form' ), '20081206' );
    261274        $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
    262             'error' => __('Error while saving the changes.')
     275            'error' => __('Error while saving the changes.'),
     276            'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
    263277        ) );
    264278
    265279        $scripts->add( 'plugin-install', '/wp-admin/js/plugin-install.js', array( 'thickbox', 'jquery' ), '20080803' );
    266280        $scripts->localize( 'plugin-install', 'plugininstallL10n', array(
    267             'plugin_information' => __('Plugin Information:')
     281            'plugin_information' => __('Plugin Information:'),
     282            'l10n_print_after' => 'try{convertEntities(plugininstallL10n);}catch(e){};'
    268283        ) );
    269284
     
    371386        'previewPostText' => __('Preview this Post'),
    372387        'requestFile' => admin_url('admin-ajax.php'),
    373         'savingText' => __('Saving Draft&#8230;')
     388        'savingText' => __('Saving Draft&#8230;'),
     389        'l10n_print_after' => 'try{convertEntities(autosaveL10n);}catch(e){};'
    374390    ) );
    375391
Note: See TracChangeset for help on using the changeset viewer.