xprofile_filter_kses( string $content, BP_XProfile_ProfileData|null $data_obj = null, int|null $field_id = null )
Run profile field values through kses with filterable allowed tags.
Description Description
Parameters 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 Return
(string) $content
Source Source
File: bp-xprofile/bp-xprofile-filters.php
function xprofile_filter_kses( $content, $data_obj = null, $field_id = null ) {
global $allowedtags;
$xprofile_allowedtags = $allowedtags;
$xprofile_allowedtags['a']['rel'] = array();
if ( null === $field_id && $data_obj instanceof BP_XProfile_ProfileData ) {
$field_id = $data_obj->field_id;
}
// If the field supports rich text, we must allow tags that appear in wp_editor().
if ( $field_id && bp_xprofile_is_richtext_enabled_for_field( $field_id ) ) {
$richtext_tags = array(
'img' => array( 'src' => 1, 'alt' => 1, 'width' => 1, 'height' => 1 ),
'ul' => array(),
'ol' => array(),
'li' => array(),
'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 1.5.0
* @since 2.1.0 Added `$data_obj` parameter.
* @since 5.0.0 Added `$field_id` parameter.
*
* @param array $xprofile_allowedtags Array of allowed tags for profile field values.
* @param BP_XProfile_ProfileData|null $data_obj The BP_XProfile_ProfileData object.
* @param int|null $field_id The ID of the profile field.
*/
$xprofile_allowedtags = apply_filters( 'xprofile_allowed_tags', $xprofile_allowedtags, $data_obj, $field_id );
return wp_kses( $content, $xprofile_allowedtags );
}
Changelog Changelog
| Version | Description |
|---|---|
| 5.0.0 | Added $field_id parameter. |
| 2.1.0 | Added $data_obj parameter. |
| 1.5.0 | Introduced. |