wp_filter_post_kses

Sanitize content for allowed HTML tags for post content.

Description

(string) wp_filter_post_kses( (string) $data ); 

Post content refers to the page contents of the post type and not $_POST data from forms.

Returns (string)

Filtered post content with allowed HTML tags and attributes intact.

Parameters (1)

0. $data (string)
Post content to filter, expected to be escaped with slashes

Usage

  1. if ( !function_exists( 'wp_filter_post_kses' ) ) { 
  2. require_once ABSPATH . WPINC . '/kses.php'; 
  3.  
  4. // Post content to filter, expected to be escaped with slashes 
  5. $data = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_filter_post_kses($data); 
  9.  

Defined (1)

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

/wp-includes/kses.php  
  1. function wp_filter_post_kses( $data ) { 
  2. return addslashes( wp_kses( stripslashes( $data ), 'post' ) );