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.

when using wp_editor, I paste my text in the visual editor. If I switch to HTML editor, all of my tags are there. So far, no problem. When I update the thing, all of my tags appear in my visual editor and in HTML, they become something like :

<p><strong>

If I update again, the tags appear on my page. So i'm stuck in editing my text only one time. If I update more than one time, the tags appear and everything gets messed up.

Anyone got a clue of what's appening?

I'm using that line to create the wp_editor:

<?php $metabox->the_field('shortText'); ?>
<p>
    <label for="<?php $metabox->the_name(); ?>">Text</label>
    <?php wp_editor($metabox->get_the_value(), $metabox->get_the_name(), $settings); ?>
</p>

Thanks!

EDIT:

The problem is with

$metabox->get_the_value()

It parses the code with the tags, wich then messes up everything. Is there a way to parse the value in the HTML editor and not the visual editor?

ADDED SOURCE:

Input:

Faire des sorties de groupe et briser l’isolement. Venez vivre une activité entre gens qui vivent les mêmes choses, sentir la force du groupe plutôt que l’isolement.

Output (var_dump):

string(594) "<p><strong>Faire des sorties de groupe et briser l’isolement. Venez vivre une activité entre gens qui vivent les mêmes choses, sentir la force du groupe plutôt que l’isolement.</strong></p> <p><strong></strong>Le Regroupement vous propose des sorties de groupe pour faciliter le plaisir en vivant des expériences comme vivent les « autres familles normales ». Nos sorties sont dépourvues d’obstacles et se vivent sans les soucis de se faire identifier parmi le groupe.</p>"

And then the function get_the_value();

/**
 * @since    1.0
 * @access    public
 */
function get_the_value($n = NULL, $collection = FALSE)
{
    $this->_meta(NULL, TRUE);

    $value = null;

    if ($this->in_loop)
    {
        if(isset($this->meta[$this->name]))
        {
            $n = is_null($n) ? $this->subname : $n ;

            if(!is_null($n))
            {
                if ($collection)
                {
                    if(isset($this->meta[$this->name][$this->current]))
                    {
                        $value = $this->meta[$this->name][$this->current];
                    }
                }
                else
                {
                    if(isset($this->meta[$this->name][$this->current][$n]))
                    {
                        $value = $this->meta[$this->name][$this->current][$n];
                    }
                }
            }
            else
            {
                if ($collection)
                {
                    if(isset($this->meta[$this->name]))
                    {
                        $value = $this->meta[$this->name];
                    }
                }
                else
                {
                    if(isset($this->meta[$this->name][$this->current]))
                    {
                        $value = $this->meta[$this->name][$this->current];
                    }
                }
            }
        }
    }
    else
    {
        $n = is_null($n) ? $this->name : $n ;

        if(isset($this->meta[$n]))
        {
            $value = $this->meta[$n];
        }
    }

    if (is_string($value) || is_numeric($value))
    {
        if ($this->in_template)
        {
            return htmlentities($value, ENT_QUOTES, 'UTF-8');
        }
        else
        {
            // http://wordpress.org/support/topic/call-function-called-by-embed-shortcode-direct
            // http://phpdoc.wordpress.org/trunk/WordPress/Embed/WP_Embed.html#run_shortcode

            global $wp_embed;

            return do_shortcode($wp_embed->run_shortcode($value));
        }
    }
    else
    {
        // value can sometimes be an array
        return $value;
    }
}
share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

I ran into the same issue when making use of the new wp_editor function on an alchemy powered metabox. I did some searching and turned up a solution that makes use of "html_entity_decode". Take a look at the reference here: https://gist.github.com/1838037

share|improve this answer
    
An answer should be more than just a link to an external site. Please add a solution. –  toscho Apr 26 '12 at 16:17
    
Great! That looks like my problem right here. I'll take a look when I can. –  Elggetto Apr 26 '12 at 19:40
    
@Elggetto - You're welcome! That should work well for you! –  Jonathan Wold Apr 26 '12 at 21:02
add comment

Try changing

<?php wp_editor($metabox->get_the_value(), $metabox->get_the_name(), $settings); ?>

to

<?php wp_editor( esc_textarea( $metabox->get_the_value() ), $metabox->get_the_name(), $settings); ?>

share|improve this answer
    
Didn't work. I also tried wp_richedit_pre(), which did not work either. Instead of getting the tags, I get their codes : &lt;p&gt;&lt;strong&gt; –  Elggetto Apr 19 '12 at 14:47
    
I see two options here : Either run it into javascript when the page is loaded to take the tags and apply it to the visual editor, or be able to parse the result directly in the HTML editor and not the visual editor... –  Elggetto Apr 19 '12 at 14:51
    
Hrmm, can you post the source for $metabox->get_the_value() as well as a var_dump() on the results of a call to that method? What meta box class are you using? These things should help to get a solution. –  goto10 Apr 19 '12 at 15:13
    
Done. As you can see, the bold text from the visual (naturally) gets parsed in the string. Now, I want this string to be reconverted to rich text. Before inserted into my wp_editor. I have no idea how to do this. –  Elggetto Apr 19 '12 at 15:25
1  
Well, thank you sir. It's exactly my problem... I'll continue searching. If it gets an update, i'll post it here. –  Elggetto Apr 24 '12 at 15:22
show 3 more comments

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.