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' => '*',
)
);
?>
You may need to use one of the following configuration parameters:
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.I don’t load the full editor but controlling which TinyMCE plugins are loaded does the trick. For example, for my purposes I only need the paste plugin so I added:
to the array.
I do not know for sure which plugin causes the p and br tags top be removed, but thru some trial and error or digging thru the code of the plugins you can find which one not to include. Here are the plugins loaded by default:
When displaying your values on the frontend, run it through the filter: ‘the_content’. There is also a function that must be called prior to prepare the content in the text input.
Maybe this can help:
http://codex.wordpress.org/Function_Reference/wpautop