Skip to content

Instantly share code, notes, and snippets.

@raftaar1191
Last active May 13, 2017 04:57
Show Gist options
  • Save raftaar1191/f98227016534ecc49158879c0fdba710 to your computer and use it in GitHub Desktop.
Save raftaar1191/f98227016534ecc49158879c0fdba710 to your computer and use it in GitHub Desktop.
Disallow some tag for BuddyPress activity content
<?php
// check if function does not exists
if ( ! function_exists( 'rtmedia_bp_activity_allowed_tags_callback' ) ) {
function rtmedia_bp_activity_allowed_tags_callback( $activity_allowedtags ) {
global $activities_template;
$rtmedia_type = array( 'rtmedia_update', 'rtmedia_like_activity', 'rtmedia_comment_activity' );
// $activities_template exists and type not like $rtmedia_type.
if ( is_object( $activities_template ) && isset( $activities_template->activity ) && is_object( $activities_template->activity ) && isset( $activities_template->activity->type ) && ! in_array( $activities_template->activity->type, $rtmedia_type ) ) {
// check if ul exists.
if ( isset( $activity_allowedtags['ul'] ) ) {
unset( $activity_allowedtags['ul'] );
}
// check if ul class exists.
if ( isset( $activity_allowedtags['ul']['class'] ) ) {
unset( $activity_allowedtags['ul']['class'] );
}
// check if li exists.
if ( isset( $activity_allowedtags['li'] ) ) {
unset( $activity_allowedtags['li'] );
}
// check if li class exists.
if ( isset( $activity_allowedtags['li']['class'] ) ) {
unset( $activity_allowedtags['li']['class'] );
}
}
return $activity_allowedtags;
}
}
add_filter( 'bp_activity_allowed_tags', 'rtmedia_bp_activity_allowed_tags_callback', 1000, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment