1

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

<?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.

1
  • TIP: Drop the center tag, it's been deprecated for a long time now, use <div style="margin: 0 auto"></div> or <div style="text-align:center"></div>..or a CSS controlled equivalent.. (which you use depends on what you're trying to center)..
    – t31os
    Apr 3, 2011 at 22:27

3 Answers 3

5

WordPress emulates magic_quotes_gpc and won't be deprecating this for some time due to concerns over plugin security and backward compatibility.

To work around this, you need to use stripslashes() or, if you need to strip slashes when data arrives via $_POST, $_GET, $_COOKIE, and $_REQUEST arrays, you can use the WordPress stripslashes_deep() function: http://codex.wordpress.org/Function_Reference/stripslashes_deep

2

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);
1
  • 1
    As per other answers WordPress disregards server setting for this and always adds quotes, so it checking for server setting is useless.
    – Rarst
    Jul 2, 2011 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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