xprofile_filter_kses( string $content, object|null $data_obj = null, int|null $field_id = null )
Run profile field values through kses with filterable allowed tags.
Description
Parameters
- $content
-
(Required) Content to filter.
- $data_obj
-
(Optional) The BP_XProfile_ProfileData object.
Default value: null
- $field_id
-
(Optional) The ID of the profile field.
Default value: null
Return
(string) $content
Source
File: bp-xprofile/bp-xprofile-filters.php
function xprofile_filter_kses( $content, $data_obj = null ) { global $allowedtags; $xprofile_allowedtags = $allowedtags; $xprofile_allowedtags['a']['rel'] = array(); // If the field supports rich text, we must allow tags that appear in wp_editor(). if ( $data_obj instanceof BP_XProfile_ProfileData && bp_xprofile_is_richtext_enabled_for_field( $data_obj->field_id ) ) { $richtext_tags = array( 'img' => array( 'id' => 1, 'class' => 1, 'src' => 1, 'alt' => 1, 'width' => 1, 'height' => 1 ), 'ul' => array( 'id' => 1, 'class' => 1 ), 'ol' => array( 'id' => 1, 'class' => 1 ), 'li' => array( 'id' => 1, 'class' => 1 ), 'span' => array( 'style' => 1 ), 'p' => array( 'style' => 1 ), ); $xprofile_allowedtags = array_merge( $allowedtags, $richtext_tags ); } /** * Filters the allowed tags for use within xprofile_filter_kses(). * * @since BuddyPress 1.5.0 * * @param array $xprofile_allowedtags Array of allowed tags for profile field values. * @param BP_XProfile_ProfileData $data_obj The BP_XProfile_ProfileData object. */ $xprofile_allowedtags = apply_filters( 'xprofile_allowed_tags', $xprofile_allowedtags, $data_obj ); return wp_kses( $content, $xprofile_allowedtags ); }
Changelog
Version | Description |
---|---|
BuddyPress 1.5.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.