For the first example, a lot of people will use wp_kses_post to handle basic HTML output from wrapper functions. It’s a shortcut for some basic attributes and tags using wp_kses. You could use this function where you specify allowed tags and attributes that can pass through for the second example.
Related Posts:
- Sanitization html output itself
- Should I sanitize an email address before passing it to the is_email() function?
- Escaping and sanitizing SVGs in metabox textarea
- What is the difference between wp_strip_all_tags and wp_filter_nohtml_kses?
- Reason for Lowercase usernames
- What is the best way to sanitize data?
- Should nonce be sanitized?
- esc_url removes white space. Can I change that to using ‘-‘?
- Sanitatizing when using the posts_where hook
- Escape hexadecimals/rgba values
- Correct processing of `$_POST`, following WordPress Coding Standards
- Must I serialize/sanitize/escape array data before using set_transient?
- Echo JavaScript Safely
- wp_kses ignore allowed and allow everything
- Sanitize array callback for the WordPress Settings API
- Why the WP Core team does not allow filter_* functions? [closed]
- How to escape $_GET and check if isset?
- What’s a safe / good way to output HTML safely within WordPress templates?
- Do Not Understand → Rule No. 4: Making Data Safe Is About Context [closed]
- Sanitizing output that contains quotes?
- WP_Customize_Manager: How to get control ID
- How to use wp_filter_oembed_result?
- Post text sanitization after publishing/editing – changes are not saved
- wp_set_object_terms() without accents
- Escaping data from database (users table) is necessary?
- Properly sanitize an input field “Name “
- What is the proper way to sanitize $_POST and $_GET vars?
- Why is sanitize_text_field() selectively trimming data?
- Data sanitization: Best Practices with code examples
- How to safely sanitize a textarea which takes full HTML input
- Custom page with variables in url. Nice url with add_rewrite_rule
- Sandwich Coding Standards
- When to use Exceptions vs Error Objects vs just plain false/null
- Actions, functions and conditionals
- WordPress and event-driven programming – what is it about?
- is_email() VS sanitize_email()
- What is the difference between esc_html and wp_filter_nohtml_kses?
- Sanitation needed for WP_Query or get_posts calls?
- Escaping WP_Query tax_query when term has special character(s)
- How to allow HTML tags into WP Bakery (formerly Visual Composer) `textfield` parameter
- Can I create customizer setting that can handle plugin shortcode?
- Make shortcode work with nested double quotes
- Nonce in settings API with tabbed navigation
- Default WordPress settings API data sanitization
- How do I sanitize a javascript text?
- What is the difference between strip_tags and wp_filter_nohtml_kses?
- Should I sanitize custom post meta if it is going to be escaped later?
- How to display data from custom table in wordpress database?
- Remove tinyMCE from admin and replace with textarea
- wp_sanitize_redirect strips out @ signs (even from parameters) — why?
- array_map() for sanitizing $_POST
- why is esc_html() returning nothing given a string containing a high-bit character?
- Are we allowed to use the Allman (BSD) indent style when coding WordPress plugins and themes?
- How Could I sanitize the receive data from this code
- Assignments must be the first block of code on a line Validation Error on Travis
- Settings API – sanitize_callback is not called and it leads to an incorrect behavior
- Best Practice for Validating and Sanitizing Data
- Storing HTML in wp_options
- What is the proper way to validate and sanitize JSON response from REST API?
- MITM risk of not sanitizing?
- Which escape function to use when escaping an email or plain text?
- Modify automatically generation of slug when term is created
- Can i use the same sanitize function on multiple theme mod textboxes?
- What function removes apostrophes when making a slug?
- How to sanitize uploaded file filename from a plugin?
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- Should I check for privileges before hooking into `wp_ajax_$handle` or after?
- Is wp_kses the right approach in sanitizing this string?
- Add comments for template variables
- Customizer: Category Select Sanitize
- Prevent invalid or empty values from being saved to the database and retain the form field values upon error
- Theme Customizier sanitize_callback not working
- Change wp_sanitize function?
- Do define() statements need phpDocumentor-style docblocks?
- Understanding how the class family `inner-container` works
- How to escape html generate by a loop
- confused about sanitize_email after is_email [duplicate]
- Trouble creating custom sanitization function for user list dropdown
- Output Sanitation
- Invalidate username if it contains @ symbol
- Contact Form Security
- How to allow certain PHP functions when using sanitize_callback in the word press customizer
- Exit or die in main plugin file breaking php standards recommendation
- Display the line breaks in user bio without using html
- Sanitize $_GET variable when comparing
- How can I apply custom sanitization to new usernames?
- How do I sanitize the str_replace function in javascript variables
- Class or function wrapper for plugin code
- Sanitizing textarea for wp_insert_post with TinyMCE enabled or disabled
- Safely store code(html/js..) into database
- Sanitaizing Select Optin For Custom Post Type Metabox in WP
- settings api and the data passed in the parameter
- HTML Img with data:image src gets sanitized in admin?
- Check if almost 10 year old – working code is up to date
- Where is the HTML-handler part in the wpdb class?
- WP nonce verification
- Can we validate data from jquery
- Custom-Metaboxes-and-Fields text_url field prepending http://
- Data validation for inline javascript
- Extend file format support for post thumbnails