Advertisement
vapvarun

Add and remove filters to allow more tags in group description.

Jun 5th, 2024 (edited)
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. /**
  2.  * Add and remove filters to allow more tags in group description.
  3.  */
  4. function wbcom_add_remove_group_desc_filters() {
  5.     remove_filter( 'groups_group_description_before_save', 'wp_filter_kses', 1 );
  6.     add_filter( 'groups_group_description_before_save', 'bp_groups_filter_kses', 1 );
  7. }
  8.  
  9. add_action( 'bp_loaded', 'wbcom_add_remove_group_desc_filters');
  10.  
  11. /**
  12.  * Allow additional tags in group description.
  13.  *
  14.  * @param array $tags The current array of allowed tags.
  15.  * @return array The modified array of allowed tags.
  16.  */
  17. function wbcom_allow_extra_group_desc_tags( $tags ) {
  18.     $tags['ul'] = array();
  19.     $tags['ol'] = array();
  20.     $tags['li'] = array();
  21.     $tags['strong'] = array();
  22.     $tags['b'] = array();
  23.     return $tags;
  24. }
  25. add_filter( 'bp_groups_filter_kses', 'wbcom_allow_extra_group_desc_tags' );
  26.  
  27. function display_custom_group_description() {
  28.     if ( bp_is_single_item() && bp_is_groups_component() ) {
  29.         $group = groups_get_current_group();
  30.         echo wpautop( wp_kses_post( $group->description ) );
  31.     }
  32. }
  33. add_action('bp_group_header_meta', 'display_custom_group_description');
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement