weblog-content /wp-content/plugins/buddypress/bp-activity/bp-activity-filters.php

Language PHP Lines 141
MD5 Hash a783e723b0221e47f600b52b32c24c52 Estimated Cost $2,712 (why?)
Repository https://bitbucket.org/openfarmtech/weblog-content View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php

/* Apply WordPress defined filters */
add_filter( 'bp_get_activity_action', 'bp_activity_filter_kses', 1 );
add_filter( 'bp_get_activity_content_body', 'bp_activity_filter_kses', 1 );
add_filter( 'bp_get_activity_content', 'bp_activity_filter_kses', 1 );
add_filter( 'bp_get_activity_parent_content', 'bp_activity_filter_kses', 1 );
add_filter( 'bp_get_activity_latest_update', 'bp_activity_filter_kses', 1 );
add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_filter_kses', 1 );
add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_filter_kses', 1 );
add_filter( 'bp_activity_content_before_save', 'bp_activity_filter_kses', 1 );
add_filter( 'bp_activity_action_before_save', 'bp_activity_filter_kses', 1 );

add_filter( 'bp_get_activity_action', 'force_balance_tags' );
add_filter( 'bp_get_activity_content_body', 'force_balance_tags' );
add_filter( 'bp_get_activity_content', 'force_balance_tags' );
add_filter( 'bp_get_activity_latest_update', 'force_balance_tags' );
add_filter( 'bp_get_activity_latest_update_excerpt', 'force_balance_tags' );
add_filter( 'bp_get_activity_feed_item_description', 'force_balance_tags' );

add_filter( 'bp_get_activity_action', 'wptexturize' );
add_filter( 'bp_get_activity_content_body', 'wptexturize' );
add_filter( 'bp_get_activity_content', 'wptexturize' );
add_filter( 'bp_get_activity_parent_content', 'wptexturize' );
add_filter( 'bp_get_activity_latest_update', 'wptexturize' );
add_filter( 'bp_get_activity_latest_update_excerpt', 'wptexturize' );

add_filter( 'bp_get_activity_action', 'convert_smilies' );
add_filter( 'bp_get_activity_content_body', 'convert_smilies' );
add_filter( 'bp_get_activity_content', 'convert_smilies' );
add_filter( 'bp_get_activity_parent_content', 'convert_smilies' );
add_filter( 'bp_get_activity_latest_update', 'convert_smilies' );
add_filter( 'bp_get_activity_latest_update_excerpt', 'convert_smilies' );

add_filter( 'bp_get_activity_action', 'convert_chars' );
add_filter( 'bp_get_activity_content_body', 'convert_chars' );
add_filter( 'bp_get_activity_content', 'convert_chars' );
add_filter( 'bp_get_activity_parent_content', 'convert_chars' );
add_filter( 'bp_get_activity_latest_update', 'convert_chars' );
add_filter( 'bp_get_activity_latest_update_excerpt', 'convert_chars' );

add_filter( 'bp_get_activity_action', 'wpautop' );
add_filter( 'bp_get_activity_content_body', 'wpautop' );
add_filter( 'bp_get_activity_content', 'wpautop' );
add_filter( 'bp_get_activity_feed_item_description', 'wpautop' );

add_filter( 'bp_get_activity_action', 'make_clickable' );
add_filter( 'bp_get_activity_content_body', 'make_clickable' );
add_filter( 'bp_get_activity_content', 'make_clickable' );
add_filter( 'bp_get_activity_parent_content', 'make_clickable' );
add_filter( 'bp_get_activity_latest_update', 'make_clickable' );
add_filter( 'bp_get_activity_latest_update_excerpt', 'make_clickable' );
add_filter( 'bp_get_activity_feed_item_description', 'make_clickable' );

add_filter( 'bp_acomment_name', 'stripslashes_deep' );
add_filter( 'bp_get_activity_action', 'stripslashes_deep' );
add_filter( 'bp_get_activity_content', 'stripslashes_deep' );
add_filter( 'bp_get_activity_content_body', 'stripslashes_deep' );
add_filter( 'bp_get_activity_parent_content', 'stripslashes_deep' );
add_filter( 'bp_get_activity_latest_update', 'stripslashes_deep' );
add_filter( 'bp_get_activity_latest_update_excerpt', 'stripslashes_deep' );
add_filter( 'bp_get_activity_feed_item_description', 'stripslashes_deep' );

add_filter( 'bp_get_activity_content', 'bp_activity_make_nofollow_filter' );
add_filter( 'bp_get_activity_content_body', 'bp_activity_make_nofollow_filter' );
add_filter( 'bp_get_activity_parent_content', 'bp_activity_make_nofollow_filter' );
add_filter( 'bp_get_activity_latest_update', 'bp_activity_make_nofollow_filter' );
add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_make_nofollow_filter' );
add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_make_nofollow_filter' );

add_filter( 'bp_get_activity_parent_content', 'bp_create_excerpt' );

/* Allow shortcodes in activity posts */
add_filter( 'bp_get_activity_content', 'do_shortcode' );
add_filter( 'bp_get_activity_content_body', 'do_shortcode' );

function bp_activity_filter_kses( $content ) {
	global $allowedtags;

	$activity_allowedtags = $allowedtags;
	$activity_allowedtags['span'] = array();
	$activity_allowedtags['span']['class'] = array();
	$activity_allowedtags['div'] = array();
	$activity_allowedtags['div']['class'] = array();
	$activity_allowedtags['div']['id'] = array();
	$activity_allowedtags['a']['class'] = array();
	$activity_allowedtags['img'] = array();
	$activity_allowedtags['img']['src'] = array();
	$activity_allowedtags['img']['alt'] = array();
	$activity_allowedtags['img']['class'] = array();
	$activity_allowedtags['img']['width'] = array();
	$activity_allowedtags['img']['height'] = array();
	$activity_allowedtags['img']['class'] = array();
	$activity_allowedtags['img']['id'] = array();
	$activity_allowedtags['img']['title'] = array();
	$activity_allowedtags['code'] = array();

	$activity_allowedtags = apply_filters( 'bp_activity_allowed_tags', $activity_allowedtags );
	return wp_kses( $content, $activity_allowedtags );
}

function bp_activity_at_name_filter( $content ) {
	include_once( ABSPATH . WPINC . '/registration.php' );

	$pattern = '/[@]+([A-Za-z0-9-_]+)/';
	preg_match_all( $pattern, $content, $usernames );

	/* Make sure there's only one instance of each username */
	if ( !$usernames = array_unique( $usernames[1] ) )
		return $content;

	foreach( (array)$usernames as $username ) {
		if ( !$user_id = username_exists( $username ) )
			continue;

		/* Increase the number of new @ mentions for the user */
		$new_mention_count = (int)get_usermeta( $user_id, 'bp_new_mention_count' );
		update_usermeta( $user_id, 'bp_new_mention_count', $new_mention_count + 1 );

		$content = str_replace( "@$username", "<a href='" . bp_core_get_user_domain( bp_core_get_userid( $username ) ) . "' rel='nofollow'>@$username</a>", $content );
	}

	return $content;
}
add_filter( 'bp_activity_new_update_content', 'bp_activity_at_name_filter' );
add_filter( 'groups_activity_new_update_content', 'bp_activity_at_name_filter' );
add_filter( 'pre_comment_content', 'bp_activity_at_name_filter' );
add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' );
add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' );
add_filter( 'bp_activity_comment_content', 'bp_activity_at_name_filter' );

function bp_activity_make_nofollow_filter( $text ) {
	return preg_replace_callback( '|<a (.+?)>|i', 'bp_activity_make_nofollow_filter_callback', $text );
}
	function bp_activity_make_nofollow_filter_callback( $matches ) {
		$text = $matches[1];
		$text = str_replace( array( ' rel="nofollow"', " rel='nofollow'"), '', $text );
		return "<a $text rel=\"nofollow\">";
	}

?>
Back to Top