#7969 closed defect (bug) (wontfix)
filter tiny_mce_before_init + $initArray + JS objects
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | TinyMCE | Keywords: | tinymce, $initArray, settings |
| Focuses: | Cc: |
Description
Hello,
currently, when we use the filter tiny_mce_before_init, returned values are systematically wrapped between quotes. It is impossible to pass an object to TinyMCE settings with that system.
Is there any way to deal with them ?
It's there in the tiny_mce_config.php :
foreach ( $initArray as $k => $v )
$mce_options .= $k . ':"' . $v . '",';
Suggestion:
foreach ( $initArray as $k => $v )
$mce_options .= $k . ':' . is_array($v) ? '{'.implode(',', $v).'}' : '"'.$v.'"' . ',';
Or if it's an array, convert it recursively to JSON for even an easier usage.
Change History (2)
Note: See
TracTickets for help on using
tickets.
The TinyMCE init object is build as a php array first and this filter is applied to that array, so any php array function can be performed on it. The only requirement is that the returned array is flat (not multi-dimensional).
As there are only a few settings in TinyMCE that accept comma separated values, it is very easy to join (implode) them before passing them to the filter. That makes the whole process easier to use for the next plugin that manipulates the array (all filters in WordPress can be used multiple times by different plugins).