wp_kses_allowed_html

Return a list of allowed tags and attributes for a given context.

Description

(array) wp_kses_allowed_html( (string) $context = '' ); 

Returns (array)

List of allowed tags and their allowed attributes.

Parameters (1)

0. $context — Optional. (string) => ''
The context for which to retrieve tags. Allowed values are post, strip, data,entities, or the name of a field filter such as pre_user_description.

Usage

  1. if ( !function_exists( 'wp_kses_allowed_html' ) ) { 
  2. require_once ABSPATH . WPINC . '/kses.php'; 
  3. $context = ''; 
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_kses_allowed_html($context); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/kses.php  
  1. function wp_kses_allowed_html( $context = '' ) { 
  2. global $allowedposttags, $allowedtags, $allowedentitynames; 
  3.  
  4. if ( is_array( $context ) ) { 
  5. /** 
  6. * Filters HTML elements allowed for a given context. 
  7. * @since 3.5.0 
  8. * @param string $tags Allowed tags, attributes, and/or entities. 
  9. * @param string $context Context to judge allowed tags by. Allowed values are 'post',  
  10. * 'data', 'strip', 'entities', 'explicit', or the name of a filter. 
  11. */ 
  12. return apply_filters( 'wp_kses_allowed_html', $context, 'explicit' ); 
  13.  
  14. switch ( $context ) { 
  15. case 'post': 
  16. /** This filter is documented in wp-includes/kses.php */ 
  17. return apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context ); 
  18.  
  19. case 'user_description': 
  20. case 'pre_user_description': 
  21. $tags = $allowedtags; 
  22. $tags['a']['rel'] = true; 
  23. /** This filter is documented in wp-includes/kses.php */ 
  24. return apply_filters( 'wp_kses_allowed_html', $tags, $context ); 
  25.  
  26. case 'strip': 
  27. /** This filter is documented in wp-includes/kses.php */ 
  28. return apply_filters( 'wp_kses_allowed_html', array(), $context ); 
  29.  
  30. case 'entities': 
  31. /** This filter is documented in wp-includes/kses.php */ 
  32. return apply_filters( 'wp_kses_allowed_html', $allowedentitynames, $context); 
  33.  
  34. case 'data': 
  35. default: 
  36. /** This filter is documented in wp-includes/kses.php */ 
  37. return apply_filters( 'wp_kses_allowed_html', $allowedtags, $context );