[resolved] problems returning options value (2 posts)

  1. cybershot
    Posted 4 years ago #

    I made a meta box for post and pages that has one text input option for a description. The database updates fine, I can see the option and value in the database. I can get the option and return it to the page just fine doing this

    $options = get_option('description');
    echo $options

    My problem is that I am trying to populate the form in the admin the same way but I get nothing.

    $options = get_option('description');
       echo '<label for="page_post_description">' . __("Description Text: ",'page_description_textdomain') . '</label><br /><br />';
       echo '<input type="text" class="widefat" id="page_post_description" name="description" value="' .  $options . '" />';

    What am I missing?

  2. Andrew Nacin
    Lead Developer
    Posted 4 years ago #

    Not sure, but one thing you're missing is an esc_attr() around $options, in order to properly escape the attribute value.

    This has two purposes. One, it closes a potential XSS vulnerability vector. Two, if you have single or double quotes, ampersands, or angle brackets in your description, this properly encodes them, rather than breaking your HTML.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.