Question

I have an error generated from thickbox loading on every page including the admin area. This is being printed into the html

<script type='text/javascript'>
<![CDATA[ */ var thickboxL10n = {
next: "Next &gt;", prev: "&lt; Prev",image: 
"Image",  of: "of", close: "Close", 
noiframes: "This feature requires inline frames. You have iframes disabled or your browser does not support them." }; 
try{convertEntities(thickboxL10n);}catch(e){}; /* ]]> */ </script> 

I would not really care but it is breaking firefox which sucks when the project is mid-development. The problem is here:

convertEntities is not defined

Line 55 try{convertEntities(thickboxL10n);}catch(e){};

I tried to just stop it with a function

 function conditional_thickbox() {
  global $post;
  if (is_singular() &&
    strpos($post->post_content,'class="thickbox"') !== false) {
      wp_enqueue_script('thickbox');
      wp_enqueue_style('thickbox');
  }
}
add_action('wp_print_styles','conditional_thickbox');

That works well but it removes from everywhere and I realized this is a dependency for Wordpress image upload functionality.

I think I found the fix here :

http://core.trac.wordpress.org/attachment/ticket/16227/convertEntities-Firebug-Fix.diff

Which requires me hacking the core, any ideas on the best way to fix this ?

Was it helpful?

Solution

The convertEntities function was defined in utils.js, but if you use script concatenation this file would be included after it is needed. Because it was in a try-catch clause, the error was not (always) noticed.

The solution is to include the convertEntities function before this code is loaded. In WordPress 3.1 this is now included in l10n.js, which you cannot disable. A quick and dirty solution would be to copy this code and write it at the top of each page, so you are sure it is available.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top