Skip to content

Commit

Permalink
Ensure that invisible post and comments don't appear in What's Happen…
Browse files Browse the repository at this point in the history
  • Loading branch information
boonebgorges committed Jul 17, 2024
1 parent 17fdfdf commit 8fd40e6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/media-funcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,36 @@ function openlab_whats_happening_activity_items() {

$a = bp_activity_get( $activity_args );
$cached = $a['activities'];

// Post-query filter to ensure that no "invisible" post items are included.
$cached = array_filter(
$cached,
function( $activity ) {

Check failure on line 146 in lib/media-funcs.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Expected 1 space after FUNCTION keyword; 0 found
if ( 'groups' !== $activity->component ) {
return true;
}

if ( 'new_blog_post' !== $activity->type && 'new_blog_comment' !== $activity->type ) {
return true;
}

$site_id = openlab_get_site_id_by_group_id( $activity->item_id );

$invisible_post_ids = openlab_get_invisible_post_ids( $site_id );

if ( 'new_blog_post' === $activity->type ) {
$post_id = $activity->secondary_item_id;
} else {
switch_to_blog( $site_id );
$comment = get_comment( $activity->secondary_item_id );
$post_id = (int) $comment->comment_post_ID;
restore_current_blog();
}

return ! in_array( $post_id, $invisible_post_ids, true );
}
);

wp_cache_set( 'whats_happening_items', $cached, 'openlab' );
}

Expand Down

0 comments on commit 8fd40e6

Please sign in to comment.