In my wordpress theme, I have a custom options panel with textareas that utilize the tinymce script included with wordpress.
This was working fine until I upgraded to the latest version of wordpress (3.2). Now the editor still works, however it is removing all paragraph and line-break tags once I save my code. While putting my text into the editor, it looks great and shows all line breaks in the preview, but once I save it those are all gone. Other tags (b, img, a) seem to be working fine.
Now this may be an issue with wordpress, but on the same hand the wordpress upgrade also included the newest and latest version of Tinymce, so that may be causing the issue.
When I disable the Tinymce editor and use standard textareas, all the tags and line breaks get saved no problem.
EDIT: Got it working. Needed to wrap
my output values in wpautop() before
saving. So now my value is
wpautop($output[$option_array[‘id’]]);
Here is the code I am using to initiate the Tinymce editor:
<?php
wp_tiny_mce( false , // true makes the editor "teeny"
array(
'theme' => 'advanced',
'skin' => 'default',
'theme_advanced_resizing' => 'false',
'theme_advanced_path' => 'false',
'theme_advanced_buttons2' => '',
'theme_advanced_buttons1' => 'code,bold,italic,underline,|,justifyleft,justifycenter,justifyright,forecolor,fontsizeselect,link,unlink,image',
'width' => '650px',
'media_strict' => 'false',
'valid_elements' => '*',
'extended_valid_elements' => '*',
)
);
?>
4 Answers
You may need to use one of the following configuration parameters:
// Don't remove line breaks
'remove_linebreaks' => false;
// Convert newline characters to BR tags
'convert_newlines_to_brs' => true;
WordPress passes an $init
argument array to TinyMCE that sets the opposite value for each of these parameters.
I assume you can pass them directly in your wp_tiny_mce()
argument array, but I’ve not tried; I pass them as array parameters for a custom filter of the TinyMCE $init
array.