WordPress.org

Support

Support » How-To and Troubleshooting » can't get esc_attr to work but esc_textarea does

can't get esc_attr to work but esc_textarea does

  • Here’s an example line of code for a textbox input:

    '<input class="custom-fields custom-fields-textbox" type="text" name="', $field['id'], '" id="a_', $field['id'], '" value="', esc_attr ($meta ? $meta : $field['default_textbox']), '" /><br />',

    That doesn’t work, but replace esc_attr with esc_textarea and it does work. Meaning the relevant characters are encoded.

    Ditto with this:

    $allowed_html = array('strong' => array());
    		$meta = wp_kses($meta, $allowed_html);
    		$meta = esc_attr( $meta)

    Again, esc_attr doesn’t work but esc_textarea does.

    I’m stuck.

  • The topic ‘can't get esc_attr to work but esc_textarea does’ is closed to new replies.