Move convertEntities js function into the BackPress scriptloader. Fixes #8505 props sambauers.

git-svn-id: http://svn.automattic.com/wordpress/trunk@10086 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2008-12-06 09:54:24 +00:00
parent 7ac8d16de1
commit 55968bde15
2 changed files with 19 additions and 20 deletions

View File

@ -29,26 +29,6 @@ wp_admin_css( 'css/ie' );
<script type="text/javascript">
//<![CDATA[
addLoadEvent = 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();}}};
function convertEntities(o) {
var 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 (var v in o) {
if ( typeof o[v] === 'string' )
o[v] = c(o[v]);
}
return o;
};
//]]>
</script>
<?php

View File

@ -44,6 +44,25 @@ class WP_Scripts extends WP_Dependencies {
echo "<script type='text/javascript'>\n";
echo "/* <![CDATA[ */\n";
echo "function convertEntities(o) {\n";
echo " var c = function(s) {\n";
echo " if (/&[^;]+;/.test(s)) {\n";
echo " var e = document.createElement('div');\n";
echo " e.innerHTML = s;\n";
echo " return !e.firstChild ? s : e.firstChild.nodeValue;\n";
echo " }\n";
echo " return s;\n";
echo " }\n";
echo " if ( typeof o === 'string' ) {\n";
echo " return c(o);\n";
echo " } else if ( typeof o === 'object' ) {\n";
echo " for (var v in o) {\n";
echo " if ( typeof o[v] === 'string' )\n";
echo " o[v] = c(o[v]);\n";
echo " }\n";
echo " }\n";
echo " return o;\n";
echo "};\n";
echo "\t$object_name = {\n";
$eol = '';
foreach ( $this->registered[$handle]->extra['l10n'][1] as $var => $val ) {