WordPress.org

Ready to get started?Download WordPress

Forums

Stripslashes in textarea vs. text (3 posts)

  1. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    OK, I've pretty much wrapped up my theme options menu. Its all working pretty sweet except for one thing I just can't figure out. Stripslashes works in textarea, but not text. I'll post the relevant (I think) sections of code..... am I missing some understanding? Right now, anywhere I want users to be able to add code, I use a textarea, but really I don't need a giant textarea for users to add one line of code (like for google webmaster verification). As a note, I do use stripslashes in the theme call too.....

    <?php break;   
    
    case 'text':
    ?>   
    
    <div class="rm_input rm_text">
        <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
        <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'])  ); } else { echo $value['std']; } ?>" />
     <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>   
    
     </div>
    <?php
    break;   
    
    case 'textarea':
    ?>   
    
    <div class="rm_input rm_textarea">
        <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
        <textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?></textarea>
     <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>   
    
     </div>

    It's a problem mainly, that when users enter the code into the 'text' box and hit save on the options menu, everything gets all messed up immediately in the admin options menu

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Have a look at Data_Validation. It's a very useful page generally for this sort of thing.

  3. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    Thanks for the resource! I never woulda stumbled on that page on my own

Topic Closed

This topic has been closed to new replies.

About this Topic