Security
On the way out
- Everything printed is escaped for where it goes.
ugly_show()picks the right way for each type of field, so you cannot forget it. ugly_get()is raw on purpose. It gives you the value to decide things with. You escape where it matters, withesc_html(),esc_url()oresc_attr().- The templates written from a group never carry text from a title, a label or a name as code.
- A
<in a text field stays a<in Block Bindings.
The rule that keeps a site safe
| You do | Safe? |
|---|---|
ugly_show( 'name' ) |
Yes. Escaped for its type |
echo esc_html( ugly_get( 'name' ) ) |
Yes |
echo esc_url( ugly_get( 'link' )['url'] ) |
Yes |
echo ugly_get( 'name' ); |
No, unless the field is rich text, which is ready HTML. For any other type, escape |
Putting ugly_get() inside a <script> or a style="" without wp_json_encode() or esc_attr() |
No |
Did this article answer your question?
Thank you. It helps us make the documentation better. Need more help?