• Hello,

    I’m in the process of creating my theme. I am having trouble with the option input and textarea fields. Here is my code:

    <?php
    
    if(get_option($value['id']) != '')
    {
        echo stripslashes(get_option($value['id']));
    }
    else
    {
         echo (stripslashes($value['std']));
    }
    
    ?>

    Unfortunatley, this is not stripping the slashes! The slashes are still appearing. So if the user typed in <div id="foo">bar</div> it would add escape slashes before the quote marks.

    Any reason why my stripslashes() function is being ignored?

    Thank you.

Viewing 1 replies (of 1 total)
  • Try htmlspecialcharacters I have seen this used for pagemeta.

    I am still finding my way around but I have used it like this:
    $scheme['menuBg'] = '#' .htmlspecialchars( get_post_meta( $postid, $prefix .'menu_bg_color', true ));

    B.T.W.
    You do not need the !=””, the if is false if null, empty or 0 is returned.

    <?php
    if(get_option($value['id']))
    {
        echo htmlspecialchars(get_option($value['id']));
    }
    else
    {
        echo htmlspecialchars($value['std']);
    }
    ?>

    As you are outputting html then I am asuming that it is a template part, I notice that the structure is normally different and braces are rarely used in favor of :, I do not know why maybe someone else can explain, but the output would be like.

    <?php if(get_option($value['id'])) : ?>
     <?php echo htmlspecialchars(get_option($value['id'])); ?>
    <?php else: ?>
      <?php echo htmlspecialchars($value['std']); ?>
    <?php endif; ?>

    HTH

    David

Viewing 1 replies (of 1 total)
  • The topic ‘Need help with stripslashes()’ is closed to new replies.