Changeset 8458
- Timestamp:
- 05/28/2014 05:23:47 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-filters.php
r7790 r8458 34 34 add_filter( 'bp_get_group_description_excerpt', 'make_clickable', 9 ); 35 35 36 add_filter( 'bp_get_group_name', 'wp_filter_kses', 1 );37 add_filter( 'bp_get_group_permalink', 'wp_filter_kses', 1 );36 add_filter( 'bp_get_group_name', 'wp_filter_kses', 1 ); 37 add_filter( 'bp_get_group_permalink', 'wp_filter_kses', 1 ); 38 38 add_filter( 'bp_get_group_description', 'bp_groups_filter_kses', 1 ); 39 add_filter( 'bp_get_group_description_excerpt', 'wp_filter_kses', 1 );40 add_filter( 'groups_group_name_before_save', 'wp_filter_kses', 1 );41 add_filter( 'groups_group_description_before_save', 'wp_filter_kses', 1 );39 add_filter( 'bp_get_group_description_excerpt', 'wp_filter_kses', 1 ); 40 add_filter( 'groups_group_name_before_save', 'wp_filter_kses', 1 ); 41 add_filter( 'groups_group_description_before_save', 'wp_filter_kses', 1 ); 42 42 43 43 add_filter( 'bp_get_group_description', 'stripslashes' ); … … 66 66 add_filter( 'bp_get_group_total_members', 'bp_core_number_format' ); 67 67 68 function bp_groups_filter_kses( $content ) { 69 global $allowedtags; 70 71 $groups_allowedtags = $allowedtags; 72 $groups_allowedtags['a']['class'] = array(); 73 $groups_allowedtags['img'] = array(); 74 $groups_allowedtags['img']['src'] = array(); 75 $groups_allowedtags['img']['alt'] = array(); 76 $groups_allowedtags['img']['class'] = array(); 77 $groups_allowedtags['img']['width'] = array(); 78 $groups_allowedtags['img']['height'] = array(); 79 $groups_allowedtags['img']['class'] = array(); 80 $groups_allowedtags['img']['id'] = array(); 81 $groups_allowedtags['code'] = array(); 82 $groups_allowedtags = apply_filters( 'bp_groups_filter_kses', $groups_allowedtags ); 83 84 return wp_kses( $content, $groups_allowedtags ); 68 /** 69 * Filter output of Group Description through WordPress's KSES API. 70 * 71 * @since BuddyPress (1.1.0) 72 * 73 * @param string $content 74 * @return string 75 */ 76 function bp_groups_filter_kses( $content = '' ) { 77 78 /** 79 * Note that we don't immediately bail if $content is empty. This is because 80 * WordPress's KSES API calls several other filters that might be relevant 81 * to someone's workflow (like `pre_kses`) 82 */ 83 84 // Get allowed tags using core WordPress API allowing third party plugins 85 // to target the specific `buddypress-groups` context. 86 $allowed_tags = wp_kses_allowed_html( 'buddypress-groups' ); 87 88 // Add our own tags allowed in group descriptions 89 $allowed_tags['a']['class'] = array(); 90 $allowed_tags['img'] = array(); 91 $allowed_tags['img']['src'] = array(); 92 $allowed_tags['img']['alt'] = array(); 93 $allowed_tags['img']['class'] = array(); 94 $allowed_tags['img']['width'] = array(); 95 $allowed_tags['img']['height'] = array(); 96 $allowed_tags['img']['class'] = array(); 97 $allowed_tags['img']['id'] = array(); 98 $allowed_tags['code'] = array(); 99 100 /** 101 * Filter HTML elements allowed for a given context. 102 * 103 * @since BuddyPress (1.1.0) 104 * 105 * @param string $allowed_tags Allowed tags, attributes, and/or entities. 106 */ 107 $tags = apply_filters( 'bp_groups_filter_kses', $allowed_tags ); 108 109 // Return KSES'ed content, allowing the above tags 110 return wp_kses( $content, $tags ); 85 111 } 86 112
Note: See TracChangeset
for help on using the changeset viewer.