Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

TinyMCE Problem on Custom Options Page WordPress

  • SOLVED

I have created a Custom Options Page for my theme. I've also integrated the TinyMCE Editor for all my textareas.

I've added this code...

add_filter('admin_head','ShowTinyMCE');
function ShowTinyMCE() {
wp_enqueue_script( 'common' );
wp_enqueue_script( 'jquery-color' );
wp_print_scripts('editor');
if (function_exists('add_thickbox')) add_thickbox();
wp_print_scripts('media-upload');
if (function_exists('wp_tiny_mce')) wp_tiny_mce();
wp_admin_css();
wp_enqueue_script('utils');
do_action("admin_print_styles-post-php");
do_action('admin_print_styles');
}


And I've used this... to display the TextArea

<div id="poststuff">
<?php
the_editor("$content", "content", "", true);
?>
</div>


Here's my problem...

When the line.. if (function_exists('wp_tiny_mce')) wp_tiny_mce(); is added all my P and BR tags are gone from the editor. They do not show in the HTML tab when viewed and are stripped when saved.

So I need to know what to add to get them back or how to fix this. I actually need the P tags and BR as well.

I've tried using....
wp_tiny_mce();

this by itself didn't work.

I've tried...

add_filter('content','wpautop');

still no luck.

any ideas of why when adding wp_tiny_mce that it actually strips <p> and <br> the plugin.

Again, this is NOT on saving. They just DO NOT appear.

It seems this happens when switching from Visual to HTML.

Any help would be great.

Answers (3)

2010-11-25

Denzel Chia answers:

hi,

Tinymce editor will strip all p and br tags when saved into WordPress Database, which is the same for the normal post content.

in order to get back the p and br tags, use wpautop() for the variable before assigning the retrieved option value back to text area or used on theme template.

example code

$content = get_option('value_saved');
$content = wpautop($content);
//do what you want with $content


Please tell me if you need me to code directly into your theme options.

Thanks.


Denzel Chia comments:

Hi,

You can email me a zip copy of your theme to [email protected], if you want me to fix your codes directly. I had done it before, please see this thread http://wpquestions.com/question/show/id/995
I am sure I can do it again.

Thanks


Denzel Chia comments:

Hi,

I had send you the modified sidebaroptin.php in my reply email to you.

These are the modified codes in it to process your saved tinymce option data.


<div id="sidebar2">
<?php
$content = get_option('wtf_optinbox');
$content = do_shortcode($content);
$content = wpautop($content);
echo $content;
?>
</div>


There is nothing wrong with your tinymce editor.
It is the normal behavior for tinymce editor, not to show p tags in it.
You need to process the retrieve option data with at least wpautop, so as to get the correct formatting.

Please see the attached screenshot for fixed paragraph output formating in your sidebar.

There is additional information in my reply email to you.

Thanks.

Denzel