From 755310bfecfbc324c968b7197a62519f08da45a1 Mon Sep 17 00:00:00 2001 From: Yudhisthir Nahar Date: Wed, 8 Jan 2025 17:50:05 +0530 Subject: [PATCH] PROD-8364 Timeline filters settings --- src/bp-core/admin/bp-core-admin-settings.php | 69 +++++++++++++++++++ .../settings/bp-admin-setting-activity.php | 3 + src/bp-core/bp-core-options.php | 48 +++++++++++-- src/bp-core/bp-core-update.php | 1 + .../common/search-and-filters-bar.php | 19 +++-- 5 files changed, 131 insertions(+), 9 deletions(-) diff --git a/src/bp-core/admin/bp-core-admin-settings.php b/src/bp-core/admin/bp-core-admin-settings.php index a55a1d14ec..60dd7f50ed 100644 --- a/src/bp-core/admin/bp-core-admin-settings.php +++ b/src/bp-core/admin/bp-core-admin-settings.php @@ -3821,6 +3821,75 @@ function bb_admin_setting_callback_activity_filters() { + +

+
+ $value ) { + if ( isset( $filter_labels[ $key ] ) ) { + $sorted_filter_labels[ $key ] = $filter_labels[ $key ]; + } + } + + // Add the remaining labels that were not part of $activity_filters. + if ( count( $filter_labels ) > count( $sorted_filter_labels ) ) { + foreach ( $filter_labels as $key => $label ) { + if ( ! isset( $sorted_filter_labels[ $key ] ) ) { + $sorted_filter_labels[ $key ] = $label; + } + } + } + } else { + $sorted_filter_labels = $filter_labels; + } + + foreach ( $sorted_filter_labels as $key => $label ) : + $readonly = ''; + if ( 'just-me' === $key ) { + $readonly = 'disabled'; + } + ?> +
+ + /> + + id="bb_activity_filter_" + name="bb_activity_timeline_filter_options[]" + type="checkbox" + value="1" + + /> + +
+ +
+ add_field( 'bb_activity_filter_options', __( 'Activity filters', 'buddyboss' ), 'bb_admin_setting_callback_activity_filters' ); + // Timeline filters. + $this->add_field( 'bb_activity_timeline_filter_options', __( 'Profile Timeline filters', 'buddyboss' ), 'bb_admin_setting_callback_activity_timeline_filters' ); + // Activity sorting. $this->add_field( 'bb_activity_sorting_options', __( 'Activity sorting', 'buddyboss' ), 'bb_admin_setting_callback_activity_sorting' ); diff --git a/src/bp-core/bp-core-options.php b/src/bp-core/bp-core-options.php index 243d523d16..f9681bd28e 100644 --- a/src/bp-core/bp-core-options.php +++ b/src/bp-core/bp-core-options.php @@ -2768,12 +2768,12 @@ function bb_is_send_ajax_request() { function bb_get_activity_filter_options_labels() { $filters = array( 'all' => __( 'All updates', 'buddyboss' ), + 'just-me' => __( 'Created by me', 'buddyboss' ), 'favorites' => __( "I've reacted to", 'buddyboss' ), - 'friends' => __( 'From my connections', 'buddyboss' ), 'groups' => __( 'From my groups', 'buddyboss' ), + 'friends' => __( 'From my connections', 'buddyboss' ), 'mentions' => __( "I'm mentioned in", 'buddyboss' ), 'following' => __( "I'm following", 'buddyboss' ), - 'just-me' => __( 'Created by me', 'buddyboss' ), ); return (array) apply_filters( 'bb_get_activity_filter_options_labels', $filters ); } @@ -2789,16 +2789,56 @@ function bb_get_activity_filter_options_labels() { */ function bb_get_enabled_activity_filter_options( $default = array( 'all' => 1, + 'just-me' => 1, 'favorites' => 1, - 'friends' => 1, 'groups' => 1, + 'friends' => 1, 'mentions' => 1, 'following' => 1, - 'just-me' => 1, ) ) { return (array) apply_filters( 'bb_get_enabled_activity_filter_options', bp_get_option( 'bb_activity_filter_options', $default ) ); } +/** + * Get all activity timeline filters option labels. + * + * @since BuddyBoss [BBVERSION} + * + * @return array Array of all activity timeline filters option labels. + */ +function bb_get_activity_timeline_filter_options_labels() { + $filters = array( + 'just-me' => __( 'Personal posts', 'buddyboss' ), + 'favorites' => __( 'Reacted to', 'buddyboss' ), + 'groups' => __( 'From groups', 'buddyboss' ), + 'friends' => __( 'From connections', 'buddyboss' ), + 'mentions' => __( 'Mentioned in', 'buddyboss' ), + 'following' => __( 'Following', 'buddyboss' ), + + ); + return (array) apply_filters( 'bb_get_activity_timeline_filter_options_labels', $filters ); +} + +/** + * Get enabled activity timeline filters options. + * + * @since BuddyBoss [BBVERSION} + * + * @param array $default Array of default activity timeline filter options. + * + * @return array Array of enabled activity timeline filters options. + */ +function bb_get_enabled_activity_timeline_filter_options( $default = array( + 'just-me' => 1, + 'favorites' => 1, + 'groups' => 1, + 'friends' => 1, + 'mentions' => 1, + 'following' => 1, +) ) { + return (array) apply_filters( 'bb_get_enabled_activity_timeline_filter_options', bp_get_option( 'bb_activity_timeline_filter_options', $default ) ); +} + /** * Get all activity sorting options labels. * diff --git a/src/bp-core/bp-core-update.php b/src/bp-core/bp-core-update.php index 007b57d5ff..d4873052cc 100644 --- a/src/bp-core/bp-core-update.php +++ b/src/bp-core/bp-core-update.php @@ -3892,6 +3892,7 @@ function bb_update_to_2_6_80() { // Migrate activity tabs settings to filters. if ( ! bp_is_activity_tabs_active() ) { bp_update_option( 'bb_activity_filter_options', array( 'all' => 1 ) ); + bp_update_option( 'bb_activity_timeline_filter_options', array( 'just-me' => 1 ) ); } set_transient( 'bb_update_to_2_6_80', 'yes', HOUR_IN_SECONDS ); diff --git a/src/bp-templates/bp-nouveau/buddypress/common/search-and-filters-bar.php b/src/bp-templates/bp-nouveau/buddypress/common/search-and-filters-bar.php index 5dfe184a95..93b6a7cb52 100644 --- a/src/bp-templates/bp-nouveau/buddypress/common/search-and-filters-bar.php +++ b/src/bp-templates/bp-nouveau/buddypress/common/search-and-filters-bar.php @@ -78,9 +78,18 @@ ?> - @@ -111,10 +120,10 @@ continue; } - if ( 'all' !== $key && ! is_user_logged_in() ) { + if ( bp_is_activity_directory() && 'all' !== $key && ! is_user_logged_in() ) { continue; } - + if ( isset( $skip_conditions[ $key ] ) && $skip_conditions[ $key ] ) { continue; }