slimline_wp_filter_kses() - slimline/tinymce GitHub Wiki

Applies post allowed HTML to terms and/or users.

Source

/**
 * Replacement for wp_filter_kses that accepts the same HTML tags as are allowed for posts
 *
 * @param  string $data HTML markup to filter for user content (slashed -- must
 *                      stripslashes to edit then re-add slashes before returning)
 * @return string       HTML markup filtered through wp_kses()
 * @link   https://github.com/slimline/tinymce/wiki/slimline_wp_filter_kses()
 * @since  0.1.2
 */
function slimline_wp_filter_kses( $data ) {

	/**
	 * wp_kses call
	 *
	 * @param string Content to filter through wp_kses (the un-slashed description
	 *               content)
	 * @param array  Allowed HTML elements. Here we are retrieving the HTML elements
	 *               allowed for posts. Users can filter this array using the
	 *               `wp_kses_allowed_html` filter.
	 * @link  https://developer.wordpress.org/reference/functions/wp_kses/
	 *        Documentation of `wp_kses` function
	 * @link  https://developer.wordpress.org/reference/functions/wp_kses_allowed_html/
	 *        Documentation of `wp_kses` function
	 */
	return addslashes( wp_kses( stripslashes( $data ), wp_kses_allowed_html( 'post' ) ) );
}

Hook

Applied to pre_term_description at priority 10 (for terms) and pre_user_description at priority 10 (for user bios).

Changelog

  • Since 0.1.2