Ticket #11520: 11520-3.patch
File 11520-3.patch, 20.6 KB (added by , 13 years ago) |
---|
-
wp-admin/load-styles.php
125 125 $content .= get_file($rtl_path) . "\n"; 126 126 } 127 127 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 ); 129 132 } 130 133 131 134 header('Content-Type: text/css'); -
wp-includes/class.wp-scripts.php
47 47 return $this->do_items( $handles, $group ); 48 48 } 49 49 50 // Deprecated, see print_added_js() 50 51 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 $this->print_added_js( $handle, $echo, true ); 53 } 54 55 function print_added_js( $handle, $echo = true, $_l10n = false ) { 56 if ( empty($this->registered[$handle]->extra['data']) ) 52 57 return false; 53 58 54 $object_name = $this->registered[$handle]->extra['l10n'][0]; 59 if ( $_l10n ) { 60 $name = $this->registered[$handle]->extra['l10n'][0]; 61 $data = $this->registered[$handle]->extra['l10n'][1]; 62 $after = ''; 55 63 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; 64 if ( is_array($data) && isset($data['l10n_print_after']) ) { 65 $after = $data['l10n_print_after']; 66 unset($data['l10n_print_after']); 62 67 } 63 $data .= "$eol\t$var: \"" . esc_js( $val ) . '"'; 64 $eol = ",\n"; 68 $output = "var $name = " . json_encode($data) . "; $after\n"; 69 } else { 70 foreach ( (array) $this->registered[$handle]->extra['data'] as $name => $data ) { 71 $output = "var $name = " . json_encode($data) . ";\n"; 72 } 65 73 } 66 $data .= "\n};\n";67 $data .= isset($after) ? "$after\n" : '';68 74 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 }75 if ( !$echo ) 76 return $output; 77 78 echo "<script type='text/javascript'>\n"; 79 echo "/* <![CDATA[ */\n"; 80 echo $output; 81 echo "/* ]]> */\n"; 82 echo "</script>\n"; 83 84 return true; 79 85 } 80 86 81 87 function do_item( $handle, $group = false ) { … … 103 109 if ( $this->do_concat ) { 104 110 $srce = apply_filters( 'script_loader_src', $src, $handle ); 105 111 if ( $this->in_default_dir($srce) ) { 106 $this->print_code .= $this->print_ scripts_l10n( $handle, false );112 $this->print_code .= $this->print_added_js( $handle, false ); 107 113 $this->concat .= "$handle,"; 108 114 $this->concat_version .= "$handle$ver"; 109 115 return true; … … 113 119 } 114 120 } 115 121 116 $this->print_ scripts_l10n( $handle );122 $this->print_added_js( $handle ); 117 123 if ( !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) { 118 124 $src = $this->base_url . $src; 119 125 } … … 131 137 } 132 138 133 139 /** 134 * Localizes a script 140 * Localizes a script (Deprecated) 135 141 * 136 142 * Localizes only if script has already been added 137 143 * … … 141 147 * @return bool Successful localization 142 148 */ 143 149 function localize( $handle, $object_name, $l10n ) { 144 if ( !$object_name || !$l10n ) 150 return $this->add_js( $handle, $object_name, $l10n ); 151 } 152 153 /** 154 * Add extra Javascript 155 * 156 * Only if script has already been added. Produces a Javascript object: 157 * $name = { 158 * name: value 159 * } 160 * 161 * @param string $handle Script name 162 * @param string $name Name of JS object to hold the data 163 * @param array $data Associative array of JS name => value 164 * @return bool Successful or not 165 */ 166 function add_js( $handle, $name, $data ) { 167 if ( !$name || !is_array($data) ) 145 168 return false; 146 return $this->add_data( $handle, 'l10n', array( $object_name, $l10n ) ); 169 170 if ( !empty( $this->registered[$handle]->extra['data'][$name] ) ) 171 $data = array_merge( $data, (array) $this->registered[$handle]->extra['data'][$name] ); 172 173 return $this->add_data( $handle, 'data', array( $name => $data ) ); 147 174 } 148 175 149 176 function set_group( $handle, $recursion, $group = false ) { -
wp-includes/functions.wp-scripts.php
56 56 } 57 57 58 58 /** 59 * Localizes a script. 59 * Localizes a script. (Deprecated) 60 60 * 61 61 * Localizes only if script has already been added. 62 62 * … … 64 64 * @see WP_Scripts::localize() 65 65 */ 66 66 function wp_localize_script( $handle, $object_name, $l10n ) { 67 return wp_add_js( $handle, $object_name, $l10n ); 68 } 69 70 /** 71 * Adds extra Javascript. 72 * 73 * Only if the script has already been added. 74 * 75 * @since 76 * @see WP_Scripts::add_js() 77 */ 78 function wp_add_js( $handle, $name, $data ) { 67 79 global $wp_scripts; 68 80 if ( !is_a($wp_scripts, 'WP_Scripts') ) 69 81 return false; 70 82 71 return $wp_scripts-> localize( $handle, $object_name, $l10n);83 return $wp_scripts->add_js( $handle, $name, $data ); 72 84 } 73 85 74 86 /** -
wp-includes/js/l10n.dev.js
1 //Used to ensure that Entities used in L10N strings are correct2 function convertEntities(o) {3 var c, v;4 c = function(s) {5 if (/&[^;]+;/.test(s)) {6 var e = document.createElement("div");7 e.innerHTML = s;8 return !e.firstChild ? s : e.firstChild.nodeValue;9 }10 return s;11 }12 13 if ( typeof o === 'string' ) {14 return c(o);15 } else if ( typeof o === 'object' ) {16 for (v in o) {17 if ( typeof o[v] === 'string' ) {18 o[v] = c(o[v]);19 }20 }21 }22 return o;23 }24 No newline at end of file -
wp-includes/js/l10n.js
1 function convertEntities(b){var d,a;d=function(c){if(/&[^;]+;/.test(c)){var f=document.createElement("div");f.innerHTML=c;return !f.firstChild?c:f.firstChild.nodeValue}return c};if(typeof b==="string"){return d(b)}else{if(typeof b==="object"){for(a in b){if(typeof b[a]==="string"){b[a]=d(b[a])}}}}return b};2 No newline at end of file -
wp-includes/script-loader.php
58 58 59 59 $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : ''; 60 60 61 // Always ensure that we have the convertEntities function62 $scripts->add( 'l10n', "/wp-includes/js/l10n$suffix.js", false, '20101110' );63 $scripts->enqueue( 'l10n' );64 65 61 $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' ); 66 62 67 63 $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20110711' ); 68 64 $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_js( 'common', 'commonL10n', array( 66 'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete.") 72 67 ) ); 73 68 74 69 $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", false, '1.6.1' ); … … 76 71 77 72 $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", false, '20110502' ); 78 73 $scripts->add_data( 'quicktags', 'group', 1 ); 79 $scripts-> localize( 'quicktags', 'quicktagsL10n', array(74 $scripts->add_js( 'quicktags', 'quicktagsL10n', array( 80 75 'quickLinks' => __('(Quick Links)'), 81 76 'wordLookup' => __('Enter a word to look up:'), 82 77 'dictionaryLookup' => esc_attr(__('Dictionary lookup')), … … 87 82 'enterImageURL' => __('Enter the URL of the image'), 88 83 'enterImageDescription' => __('Enter a description of the image'), 89 84 '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') ) 92 86 ) ); 93 87 94 88 $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' ); … … 103 97 104 98 $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), '20091119' ); 105 99 $scripts->add_data( 'wp-ajax-response', 'group', 1 ); 106 $scripts-> localize( 'wp-ajax-response', 'wpAjax', array(100 $scripts->add_js( 'wp-ajax-response', 'wpAjax', array( 107 101 '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.') 110 103 ) ); 111 104 112 105 $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20110524' ); … … 192 185 193 186 $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20110528'); 194 187 $scripts->add_data( 'thickbox', 'group', 1 ); 195 $scripts-> localize( 'thickbox', 'thickboxL10n', array(188 $scripts->add_js( 'thickbox', 'thickboxL10n', array( 196 189 'next' => __('Next >'), 197 190 'prev' => __('< Prev'), 198 191 'image' => __('Image'), … … 200 193 'close' => __('Close'), 201 194 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'), 202 195 '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') 205 197 ) ); 206 198 207 199 $scripts->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop$suffix.js", array('jquery'), '0.9.8-20110113'); … … 225 217 if ( empty($max_upload_size) ) 226 218 $max_upload_size = __('not configured'); 227 219 // these error messages came from the sample swfupload js, they might need changing. 228 $scripts-> localize( 'swfupload-handlers', 'swfuploadL10n', array(220 $scripts->add_js( 'swfupload-handlers', 'swfuploadL10n', array( 229 221 'queue_limit_exceeded' => __('You have attempted to queue too many files.'), 230 222 'file_exceeds_size_limit' => __('This file exceeds the maximum upload size for this site.'), 231 223 'zero_byte_file' => __('This file is empty. Please try another.'), … … 242 234 'dismiss' => __('Dismiss'), 243 235 'crunching' => __('Crunching…'), 244 236 'deleted' => __('moved to the trash.'), 245 'error_uploading' => __('“%s” has failed to upload due to an error'), 246 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};', 237 'error_uploading' => __('“%s” has failed to upload due to an error') 247 238 ) ); 248 239 249 240 $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", false, '20090102'); … … 255 246 256 247 $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20101027' ); 257 248 $scripts->add_data( 'password-strength-meter', 'group', 1 ); 258 $scripts-> localize( 'password-strength-meter', 'pwsL10n', array(249 $scripts->add_js( 'password-strength-meter', 'pwsL10n', array( 259 250 'empty' => __('Strength indicator'), 260 251 'short' => __('Very weak'), 261 252 'bad' => __('Weak'), 262 253 /* translators: password strength */ 263 254 'good' => _x('Medium', 'password strength'), 264 255 'strong' => __('Strong'), 265 'mismatch' => __('Mismatch'), 266 'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};' 256 'mismatch' => __('Mismatch') 267 257 ) ); 268 258 269 259 $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20110628' ); … … 274 264 275 265 $scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), '20110528' ); 276 266 $scripts->add_data( 'wplink', 'group', 1 ); 277 $scripts-> localize( 'wplink', 'wpLinkL10n', array(267 $scripts->add_js( 'wplink', 'wpLinkL10n', array( 278 268 'title' => __('Insert/edit link'), 279 269 'update' => __('Update'), 280 270 'save' => __('Add Link'), 281 271 'noTitle' => __('(no title)'), 282 'noMatchesFound' => __('No matches found.'), 283 'l10n_print_after' => 'try{convertEntities(wpLinkL10n);}catch(e){};', 272 'noMatchesFound' => __('No matches found.') 284 273 ) ); 285 274 286 275 $scripts->add( 'wpdialogs', "/wp-includes/js/tinymce/plugins/wpdialogs/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), '20110528' ); … … 292 281 if ( is_admin() ) { 293 282 $scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' ); 294 283 $scripts->add_data( 'ajaxcat', 'group', 1 ); 295 $scripts-> localize( 'ajaxcat', 'catL10n', array(284 $scripts->add_js( 'ajaxcat', 'catL10n', array( 296 285 '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.') 299 287 ) ); 300 288 301 289 $scripts->add( 'admin-categories', "/wp-admin/js/categories$suffix.js", array('wp-lists'), '20091201' ); … … 303 291 304 292 $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('jquery', 'wp-ajax-response'), '20110429' ); 305 293 $scripts->add_data( 'admin-tags', 'group', 1 ); 306 $scripts-> localize( 'admin-tags', 'tagsl10n', array(294 $scripts->add_js( 'admin-tags', 'tagsl10n', array( 307 295 '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.') 310 297 )); 311 298 312 299 $scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20110429' ); … … 314 301 315 302 $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'jquery-query'), '20110602' ); 316 303 $scripts->add_data( 'admin-comments', 'group', 1 ); 317 $scripts-> localize( 'admin-comments', 'adminCommentsL10n', array(304 $scripts->add_js( 'admin-comments', 'adminCommentsL10n', array( 318 305 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 319 306 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']), 320 307 'replyApprove' => __( 'Approve and Reply' ), … … 329 316 330 317 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110524' ); 331 318 $scripts->add_data( 'post', 'group', 1 ); 332 $scripts-> localize( 'post', 'postL10n', array(319 $scripts->add_js( 'post', 'postL10n', array( 333 320 'tagsUsed' => __('Tags used on this post:'), 334 321 'add' => esc_attr(__('Add')), 335 322 'addTag' => esc_attr(__('Add new Tag')), … … 352 339 'publicSticky' => __('Public, Sticky'), 353 340 'password' => __('Password Protected'), 354 341 'privatelyPublished' => __('Privately Published'), 355 'published' => __('Published'), 356 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};' 342 'published' => __('Published') 357 343 ) ); 358 344 359 345 $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), '20110524' ); … … 361 347 362 348 $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array('jquery'), '20110429' ); 363 349 $scripts->add_data( 'comment', 'group', 1 ); 364 $scripts-> localize( 'comment', 'commentL10n', array(350 $scripts->add_js( 'comment', 'commentL10n', array( 365 351 'cancel' => __('Cancel'), 366 352 'edit' => __('Edit'), 367 'submittedOn' => __('Submitted on:'), 368 'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};' 353 'submittedOn' => __('Submitted on:') 369 354 ) ); 370 355 371 356 $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20110414' ); … … 387 372 388 373 $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), '20110609' ); 389 374 $scripts->add_data( 'inline-edit-post', 'group', 1 ); 390 $scripts-> localize( 'inline-edit-post', 'inlineEditL10n', array(375 $scripts->add_js( 'inline-edit-post', 'inlineEditL10n', array( 391 376 'error' => __('Error while saving the changes.'), 392 377 'ntdeltitle' => __('Remove From Bulk Edit'), 393 'notitle' => __('(no title)'), 394 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' 378 'notitle' => __('(no title)') 395 379 ) ); 396 380 397 381 $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), '20110609' ); 398 382 $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_js( 'inline-edit-tax', 'inlineEditL10n', array( 384 'error' => __('Error while saving the changes.') 402 385 ) ); 403 386 404 387 $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'thickbox' ), '20110113' ); 405 388 $scripts->add_data( 'plugin-install', 'group', 1 ); 406 $scripts-> localize( 'plugin-install', 'plugininstallL10n', array(389 $scripts->add_js( 'plugin-install', 'plugininstallL10n', array( 407 390 '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?') 410 392 ) ); 411 393 412 394 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); … … 427 409 428 410 $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), '20100518' ); 429 411 $scripts->add_data( 'set-post-thumbnail', 'group', 1 ); 430 $scripts-> localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array(412 $scripts->add_js( 'set-post-thumbnail', 'setPostThumbnailL10n', array( 431 413 'setThumbnail' => __( 'Use as featured image' ), 432 414 'saving' => __( 'Saving...' ), 433 415 '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' ) 436 417 ) ); 437 418 438 419 // Navigation Menus 439 420 $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_js( 'nav-menu', 'navMenuL10n', array( 441 422 'noResultsFound' => _x('No results found.', 'search results'), 442 423 '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.') 445 425 ) ); 446 426 447 427 $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('farbtastic'), '20110511' ); … … 474 454 $styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : ''; 475 455 $styles->default_version = get_bloginfo( 'version' ); 476 456 $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/'); 478 458 479 459 $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : ''; 480 460 … … 558 538 */ 559 539 function wp_just_in_time_script_localization() { 560 540 561 wp_ localize_script( 'autosave', 'autosaveL10n', array(541 wp_add_js( 'autosave', 'autosaveL10n', array( 562 542 'autosaveInterval' => AUTOSAVE_INTERVAL, 563 543 'savingText' => __('Saving Draft…'), 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.') 566 545 ) ); 567 546 568 547 } … … 635 614 $wp_scripts = new WP_Scripts(); 636 615 637 616 script_concat_settings(); 638 $wp_scripts->do_items( 'l10n' );639 617 $wp_scripts->do_concat = $concatenate_scripts; 640 618 $wp_scripts->do_head_items(); 641 619