0

How should I escape echo for this function...

function pen_post_sidebar_twitter() {
    $twitter = esc_attr( get_option( 'twitter_handler' ));
    echo ( '<input type="text" name="twitter_handler" value="'.$twitter.'" placeholder="Twitter handler" /> <p class="description">Enter twitter handler without the @ sign.</p>' );
}
0

Try this

function pen_post_sidebar_twitter() {
    printf( '<input type="text" name="twitter_handler" value="%s" placeholder="Twitter handler" /> <p class="description">Enter twitter handler without the @ sign.</p>', esc_attr( get_option( 'twitter_handler' ) ) );
}

Thanks

1
  • This is correct, but you should explain what you did and why you did it. – Jacob Peattie Jan 9 '20 at 0:43

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.