Escaping Quotes

For some reason when i try to put like a embeded video my video has slashes inside the code, but if I add it in the template itself then the code is fine i was told its “escaping quotes” anyhow this is what i have.

Functions file

Read More
<?php
    add_action ( 'edit_category_form_fields', 'extra_category_fields');
    function extra_category_fields( $tag ) {    //check for existing featured ID
        $t_id = $tag->term_id;
        $cat_meta = get_option( "category_$t_id");
?>

            <textarea name="Cat_meta[extra4]" id="Cat_meta[extra4]" style="width:60%;"><?php echo $cat_meta['extra4'] ? $cat_meta['extra4'] : ''; ?></textarea><br />
            <span class="description"><?php _e('Video'); ?></span>
        </td>
</tr>
<?php
}


add_action ( 'edited_category', 'save_extra_category_fileds');
function save_extra_category_fileds( $term_id ) {
    if ( isset( $_POST['Cat_meta'] ) ) {
        $t_id = $term_id;
        $cat_meta = get_option( "category_$t_id");
        $cat_keys = array_keys($_POST['Cat_meta']);
            foreach ($cat_keys as $key){
            if (isset($_POST['Cat_meta'][$key])){
                $cat_meta[$key] = $_POST['Cat_meta'][$key];
            }
        }
        update_option( "category_$t_id", $cat_meta );
    }
}
?>

Template file

<center>
<?php 
if (isset($cat_data['extra4'])){
echo $cat_data['extra4'];
}
?>
</center>

I can also post the embed code for the video im trying to post if that helps its pretty long though

Any help is greatly appreciated.

Related posts

Leave a Reply

3 comments

  1. If I remember right WordPress emulates magic quotes in any case and disregards server setting for them. But this is trivia. 🙂

    Practical part is to try stripslashes() on your value if you are getting it from form.

  2. I don’t think WP handles magic quotes internally. I always use this code to check the magic quote:

    $value = get_magic_quotes_gpc() ? $value : stripslashes($value);