Ticket #11520: print_scripts_l10n.2.diff
File print_scripts_l10n.2.diff, 8.1 KB (added by , 14 years ago) |
---|
-
wp-includes/class.wp-scripts.php
48 48 } 49 49 50 50 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]))51 if ( empty($this->registered[$handle]->extra['l10n']) || empty($this->registered[$handle]->extra['l10n'][0]) ) 52 52 return false; 53 53 54 54 $object_name = $this->registered[$handle]->extra['l10n'][0]; 55 $data = $this->registered[$handle]->extra['l10n'][1]; 55 56 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; 62 } 63 $data .= "$eol\t$var: \"" . esc_js( $val ) . '"'; 64 $eol = ",\n"; 65 } 66 $data .= "\n};\n"; 67 $data .= isset($after) ? "$after\n" : ''; 57 $output = "var $object_name = " . json_encode($data) . "; $after\n"; 68 58 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; 76 } else { 77 return $data; 78 } 59 if ( !$echo ) 60 return $output; 61 62 echo "<script type='text/javascript'>\n"; 63 echo "/* <![CDATA[ */\n"; 64 echo $output; 65 echo "/* ]]> */\n"; 66 echo "</script>\n"; 67 return true; 79 68 } 80 69 81 70 function do_item( $handle, $group = false ) { -
wp-includes/script-loader.php
68 68 $scripts->add_data( 'common', 'group', 1 ); 69 69 $scripts->localize( 'common', 'commonL10n', array( 70 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){};'72 71 ) ); 73 72 74 73 $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", false, '1.6.1' ); … … 86 85 'enterURL' => __('Enter the URL'), 87 86 'enterImageURL' => __('Enter the URL of the image'), 88 87 'enterImageDescription' => __('Enter a description of the image'), 89 'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};'90 88 ) ); 91 89 92 90 $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' ); … … 100 98 $scripts->localize( 'wp-ajax-response', 'wpAjax', array( 101 99 'noPerm' => __('You do not have permission to do that.'), 102 100 'broken' => __('An unidentified error has occurred.'), 103 'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};'104 101 ) ); 105 102 106 103 $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20110327' ); … … 193 190 'of' => __('of'), 194 191 'close' => __('Close'), 195 192 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'), 196 'l10n_print_after' => 'try{convertEntities(thickboxL10n);}catch(e){};'197 193 ) ); 198 194 199 195 … … 236 232 'crunching' => __('Crunching…'), 237 233 'deleted' => __('moved to the trash.'), 238 234 'error_uploading' => __('“%s” has failed to upload due to an error'), 239 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};',240 235 ) ); 241 236 242 237 $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", false, '20090102'); … … 256 251 'good' => _x('Medium', 'password strength'), 257 252 'strong' => __('Strong'), 258 253 'mismatch' => __('Mismatch'), 259 'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'260 254 ) ); 261 255 262 256 $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20110113' ); … … 271 265 'save' => __('Add Link'), 272 266 'noTitle' => __('(no title)'), 273 267 'noMatchesFound' => __('No matches found.'), 274 'l10n_print_after' => 'try{convertEntities(wpLinkL10n);}catch(e){};',275 268 ) ); 276 269 277 270 $scripts->add( 'wpdialogs-popup', "/wp-includes/js/tinymce/plugins/wpdialogs/js/popup$suffix.js", array( 'jquery-ui-dialog' ), '20101119' ); … … 282 275 $scripts->localize( 'ajaxcat', 'catL10n', array( 283 276 'add' => esc_attr(__('Add')), 284 277 'how' => __('Separate multiple categories with commas.'), 285 'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};'286 278 ) ); 287 279 288 280 $scripts->add( 'admin-categories', "/wp-admin/js/categories$suffix.js", array('wp-lists'), '20091201' ); … … 293 285 $scripts->localize( 'admin-tags', 'tagsl10n', array( 294 286 'noPerm' => __('You do not have permission to do that.'), 295 287 'broken' => __('An unidentified error has occurred.'), 296 'l10n_print_after' => 'try{convertEntities(tagsl10n);}catch(e){};'297 288 )); 298 289 299 290 $scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' ); … … 338 329 'password' => __('Password Protected'), 339 330 'privatelyPublished' => __('Privately Published'), 340 331 'published' => __('Published'), 341 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};'342 332 ) ); 343 333 344 334 $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), '20090526' ); … … 350 340 'cancel' => __('Cancel'), 351 341 'edit' => __('Edit'), 352 342 'submittedOn' => __('Submitted on:'), 353 'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};'354 343 ) ); 355 344 356 345 $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20090516' ); … … 365 354 $scripts->add_data( 'word-count', 'group', 1 ); 366 355 $scripts->localize( 'word-count', 'wordCountL10n', array( 367 356 'count' => __('Word count: %d'), 368 'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};'369 357 )); 370 358 371 359 $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'thickbox' ), '20110118' ); … … 380 368 'error' => __('Error while saving the changes.'), 381 369 'ntdeltitle' => __('Remove From Bulk Edit'), 382 370 'notitle' => __('(no title)'), 383 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'384 371 ) ); 385 372 386 373 $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), '20100615' ); 387 374 $scripts->add_data( 'inline-edit-tax', 'group', 1 ); 388 375 $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array( 389 376 'error' => __('Error while saving the changes.'), 390 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'391 377 ) ); 392 378 393 379 $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'thickbox' ), '20110113' ); … … 395 381 $scripts->localize( 'plugin-install', 'plugininstallL10n', array( 396 382 'plugin_information' => __('Plugin Information:'), 397 383 'ays' => __('Are you sure you want to install this plugin?'), 398 'l10n_print_after' => 'try{convertEntities(plugininstallL10n);}catch(e){};'399 384 ) ); 400 385 401 386 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); … … 421 406 'saving' => __( 'Saving...' ), 422 407 'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ), 423 408 'done' => __( 'Done' ), 424 'l10n_print_after' => 'try{convertEntities(setPostThumbnailL10n);}catch(e){};'425 409 ) ); 426 410 427 411 // Navigation Menus … … 430 414 'noResultsFound' => _x('No results found.', 'search results'), 431 415 'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ), 432 416 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'), 433 'l10n_print_after' => 'try{convertEntities(navMenuL10n);}catch(e){};'434 417 ) ); 435 418 436 419 $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('farbtastic'), '20101025' ); … … 554 537 'requestFile' => admin_url('admin-ajax.php'), 555 538 'savingText' => __('Saving Draft…'), 556 539 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'), 557 'l10n_print_after' => 'try{convertEntities(autosaveL10n);}catch(e){};'558 540 ) ); 559 541 560 542 }