From 583ac68a4410efd46a463a2d57e6f9e38a5aa428 Mon Sep 17 00:00:00 2001 From: westi Date: Wed, 10 Nov 2010 21:53:30 +0000 Subject: [PATCH] Move the l10n helper function into a seperate js file so we can always output it first. Fixes #15124. git-svn-id: http://svn.automattic.com/wordpress/trunk@16282 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/utils.dev.js | 22 ---------------------- wp-admin/js/utils.js | 2 +- wp-includes/class.wp-scripts.php | 3 +++ wp-includes/js/l10n.dev.js | 23 +++++++++++++++++++++++ wp-includes/js/l10n.js | 1 + wp-includes/script-loader.php | 7 ++++++- 6 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 wp-includes/js/l10n.dev.js create mode 100644 wp-includes/js/l10n.js diff --git a/wp-admin/js/utils.dev.js b/wp-admin/js/utils.dev.js index 3f6925bfe..30446c1de 100644 --- a/wp-admin/js/utils.dev.js +++ b/wp-admin/js/utils.dev.js @@ -1,26 +1,4 @@ // utility functions -function convertEntities(o) { - var c, v; - c = function(s) { - if (/&[^;]+;/.test(s)) { - var e = document.createElement("div"); - e.innerHTML = s; - return !e.firstChild ? s : e.firstChild.nodeValue; - } - return s; - } - - if ( typeof o === 'string' ) { - return c(o); - } else if ( typeof o === 'object' ) { - for (v in o) { - if ( typeof o[v] === 'string' ) { - o[v] = c(o[v]); - } - } - } - return o; -} var wpCookies = { // The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL. diff --git a/wp-admin/js/utils.js b/wp-admin/js/utils.js index 13a06d3a0..598c2db37 100644 --- a/wp-admin/js/utils.js +++ b/wp-admin/js/utils.js @@ -1 +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}var wpCookies={each:function(d,a,c){var e,b;if(!d){return 0}c=c||d;if(typeof(d.length)!="undefined"){for(e=0,b=d.length;edefault_dirs ) return true; + if ( 0 === strpos( $src, '/wp-includes/js/l10n' ) ) + return false; + foreach ( (array) $this->default_dirs as $test ) { if ( 0 === strpos($src, $test) ) return true; diff --git a/wp-includes/js/l10n.dev.js b/wp-includes/js/l10n.dev.js new file mode 100644 index 000000000..96fca671e --- /dev/null +++ b/wp-includes/js/l10n.dev.js @@ -0,0 +1,23 @@ +//Used to ensure that Entities used in L10N strings are correct +function convertEntities(o) { + var c, v; + c = function(s) { + if (/&[^;]+;/.test(s)) { + var e = document.createElement("div"); + e.innerHTML = s; + return !e.firstChild ? s : e.firstChild.nodeValue; + } + return s; + } + + if ( typeof o === 'string' ) { + return c(o); + } else if ( typeof o === 'object' ) { + for (v in o) { + if ( typeof o[v] === 'string' ) { + o[v] = c(o[v]); + } + } + } + return o; +} \ No newline at end of file diff --git a/wp-includes/js/l10n.js b/wp-includes/js/l10n.js new file mode 100644 index 000000000..db2e81475 --- /dev/null +++ b/wp-includes/js/l10n.js @@ -0,0 +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}; \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index ca1e6d157..e6933062d 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -58,7 +58,11 @@ function wp_default_scripts( &$scripts ) { $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : ''; - $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' ); + // Always ensure that we have the convertEntities function + $scripts->add( 'l10n', "/wp-includes/js/l10n$suffix.js", false, '20101110' ); + $scripts->enqueue( 'l10n' ); + + $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' ); $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20101007' ); $scripts->add_data( 'common', 'group', 1 ); @@ -622,6 +626,7 @@ function print_head_scripts() { $wp_scripts = new WP_Scripts(); script_concat_settings(); + $wp_scripts->do_item( 'l10n' ); $wp_scripts->do_concat = $concatenate_scripts; $wp_scripts->do_head_items();