wp_editor and WPAlchemy messes up tags when updating

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.

Read More

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;
    }
}

Related posts

Leave a Reply

2 comments

  1. 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); ?>