I.m trying to add custom JS code to $init section throught the template.php, for eaxample:
$init['setup'] = 'function(ed){ alert(123); }';

But in HTML code it escapes with quotes like:
setup : "function(ed){ alert(123); }"

While digging into module I found such code in $init preparation:

  // Don't wrap the JS init in quotes for boolean values or functions.
  if (strtolower($v) != 'true' && strtolower($v) != 'false' && $v[0] != '{') {
    $v = '"'. $v .'"';
  }

It says that it should filter functions out, but it don't. I think it should be like this:

  // Don't wrap the JS init in quotes for boolean values or functions.
  if (strtolower($v) != 'true' && strtolower($v) != 'false' && strpos($v, 'function') !== 0) {
    $v = '"'. $v .'"';
  }

This code checks if function is in right beginning of the string. Also, I've prepared a patch to solve this issue quickly.

Thanks.

CommentFileSizeAuthor
tinymce_init_functions.patch601 bytesneochief

Comments

nicoloye’s picture

Issue summary: View changes
Status: Active » Closed (outdated)