Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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' => '*',
)
);


?>
share|improve this question
    
[See my answer here:][1] [1]: wordpress.stackexchange.com/questions/22296/… –  Steven Zahm Aug 4 '11 at 2:14

4 Answers 4

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.

share|improve this answer
    
I added it, but it does not seem to make a difference in the actual output of the stored text. Once I add those parameters to my array, this is what I see in the source code that its generating: pastie.org/2178029 Is it not setting those options properly? –  Levi Jul 7 '11 at 15:08
1  
Nevermind, I found the answer. wordpress.stackexchange.com/questions/15394/… Thanks for helping though. I appreciate it –  Levi Jul 7 '11 at 15:23
    
Oh, that's great! :) –  Chip Bennett Jul 7 '11 at 15:44

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:

'plugins' => 'paste'

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:

'inlinepopups', 'spellchecker', 'tabfocus', 'paste', 'media', 'wordpress', 'wpfullscreen', 'wpeditimage', 'wpgallery', 'wplink', 'wpdialogs'
share|improve this answer

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.

share|improve this answer

Maybe this can help:

http://codex.wordpress.org/Function_Reference/wpautop

share|improve this answer
1  
Read the entire question. He referenced wpautop in the question itself. Linking back to the Codex is not an answer. –  EAMann Nov 18 '11 at 16:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.