0
0
Wordpressframework~10 mins

Data escaping (output) in Wordpress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to safely display a variable in WordPress output.

Wordpress
echo [1]($user_input);
Drag options to blanks, or click blank then click option'
Aesc_html
Bprint_r
Cvar_dump
Dsanitize_text_field
Attempts:
3 left
💡 Hint
Common Mistakes
Using sanitize_text_field() for output instead of input sanitization.
Using debugging functions like var_dump() or print_r() for output.
2fill in blank
medium

Complete the code to escape a URL before outputting it in WordPress.

Wordpress
echo '<a href="' . [1]($url) . '">Link</a>';
Drag options to blanks, or click blank then click option'
Aesc_url
Bsanitize_text_field
Cesc_html
Desc_attr
Attempts:
3 left
💡 Hint
Common Mistakes
Using esc_html() which is for HTML content, not URLs.
Using sanitize_text_field() which is for input sanitization.
3fill in blank
hard

Fix the error in escaping an attribute value in WordPress output.

Wordpress
echo '<input type="text" value="' . [1]($value) . '">';
Drag options to blanks, or click blank then click option'
Asanitize_text_field
Besc_html
Cesc_attr
Desc_url
Attempts:
3 left
💡 Hint
Common Mistakes
Using esc_html() which is for HTML content, not attributes.
Using esc_url() which is for URLs only.
4fill in blank
hard

Fill both blanks to escape a textarea content and its label in WordPress output.

Wordpress
<label for="comment">[1]( 'Your Comment' )</label>
<textarea id="comment">[2]($comment_text)</textarea>
Drag options to blanks, or click blank then click option'
Aesc_html_e
Besc_attr
Cesc_textarea
Desc_html
Attempts:
3 left
💡 Hint
Common Mistakes
Using esc_attr() for textarea content which is incorrect.
Not escaping the label text properly.
5fill in blank
hard

Fill all three blanks to safely output a link with title and URL in WordPress.

Wordpress
<a href="[1]" title="[2]">[3]</a>
Drag options to blanks, or click blank then click option'
Aesc_url($link_url)
Besc_attr($link_title)
Cesc_html($link_text)
Dsanitize_text_field($link_text)
Attempts:
3 left
💡 Hint
Common Mistakes
Using sanitize_text_field() for output escaping instead of input sanitization.
Mixing up escaping functions for different contexts.