Created
April 20, 2022 06:14
-
-
Save wbcomdev/b362a9061035aa4f2a026b379bbf3d5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Filters the MySQL WHERE conditions for the Activity items get method. | |
| * | |
| * @since BuddyPress 1.9.0 | |
| * | |
| * @param array $where_conditions Current conditions for MySQL WHERE statement. | |
| * @param array $r Parsed arguments passed into method. | |
| * @param string $select_sql Current SELECT MySQL statement at point of execution. | |
| * @param string $from_sql Current FROM MySQL statement at point of execution. | |
| * @param string $join_sql Current INNER JOIN MySQL statement at point of execution. | |
| */ | |
| function wbcom_hide_sticky_post_from_tabs( $where_conditions, $r, $select_sql, $from_sql, $join_sql ) { | |
| $plugins = get_option( 'active_plugins' ); | |
| if ( in_array( 'buddypress-sticky-post/buddypress-sticky-post.php', $plugins, true ) ) { | |
| $sticky_ids = bpsp_get_sticky_posts_ids(); | |
| if ( ! empty( $sticky_ids ) ) { | |
| if ( 'friends' === $_REQUEST['scope'] ) { // change scope here. | |
| $where_conditions['not_in'] = 'a.id NOT IN (' . $sticky_ids . ')'; | |
| } | |
| } else { | |
| return $where_conditions; | |
| } | |
| } | |
| return $where_conditions; | |
| } | |
| add_filter( 'bp_activity_get_where_conditions', 'wbcom_hide_sticky_post_from_tabs', 10, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment