Changeset 5277
- Timestamp:
- 11/05/2011 08:53:31 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-filters.php
r5259 r5277 10 10 // Exit if accessed directly 11 11 if ( !defined( 'ABSPATH' ) ) exit; 12 13 /** Filters *******************************************************************/ 12 14 13 15 // Apply WordPress defined filters … … 87 89 88 90 add_filter( 'bp_get_activity_parent_content', 'bp_create_excerpt' ); 91 92 add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 ); 93 add_filter( 'bp_get_activity_content', 'bp_activity_truncate_entry', 5 ); 94 95 /** Actions *******************************************************************/ 96 97 // At-name filter 98 add_action( 'bp_activity_after_save', 'bp_activity_at_name_filter_updates' ); 99 100 // Activity stream moderation 101 add_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2, 1 ); 102 add_action( 'bp_activity_before_save', 'bp_activity_check_blacklist_keys', 2, 1 ); 103 104 /** Functions *****************************************************************/ 105 106 /** 107 * Types of activity stream items to check against 108 * 109 * @since BuddyPress (1.6) 110 */ 111 function bp_activity_get_moderated_activity_types() { 112 $types = array( 113 'activity_comment', 114 'activity_update' 115 ); 116 return apply_filters( 'bp_activity_check_activity_types', $types ); 117 } 118 119 /** 120 * Check activity stream for moderation keys 121 * 122 * @since BuddyPress (1.6) 123 * @param BP_Activity_Activity $activity 124 * @return If activity type is not an update or comment 125 */ 126 function bp_activity_check_moderation_keys( $activity ) { 127 128 // Only check specific types of activity updates 129 if ( !in_array( $activity->type, bp_activity_get_moderated_activity_types() ) ) 130 return; 131 132 // Unset the activity component so activity stream update fails 133 // @todo This is temporary until some kind of moderation is built 134 if ( !bp_core_check_for_moderation( $activity->user_id, '', $activity->content ) ) 135 $activity->component = false; 136 } 137 138 /** 139 * Check activity stream for blacklisted keys 140 * 141 * @since BuddyPress (1.6) 142 * @param BP_Activity_Activity $activity 143 * @return If activity type is not an update or comment 144 */ 145 function bp_activity_check_blacklist_keys( $activity ) { 146 147 // Only check specific types of activity updates 148 if ( !in_array( $activity->type, bp_activity_get_moderated_activity_types() ) ) 149 return; 150 151 // Unset the activity component so activity stream update fails 152 if ( !bp_core_check_for_blacklist( $activity->user_id, '', $activity->content ) ) 153 $activity->component = false; 154 } 89 155 90 156 /** … … 199 265 $activity->save(); 200 266 } 201 add_filter( 'bp_activity_after_save', 'bp_activity_at_name_filter_updates' );202 267 203 268 /** … … 270 335 return apply_filters( 'bp_activity_truncate_entry', $excerpt, $text, $append_text ); 271 336 } 272 add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );273 add_filter( 'bp_get_activity_content', 'bp_activity_truncate_entry', 5 );274 337 275 338 ?>
Note: See TracChangeset
for help on using the changeset viewer.