Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROD-8099 #4530

Open
wants to merge 60 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
86fb532
PROD-8099 - Added admin setting for member count in the member directory
jitendrabanjara1991 Oct 10, 2024
a9b64bf
PROD-8099 - Added admin setting for group count in the group directory
jitendrabanjara1991 Oct 10, 2024
53f4676
PROD-8099 - Fetch value for member count/group count enable/disable
jitendrabanjara1991 Oct 10, 2024
e073f94
PROD-8099 - Update option name
jitendrabanjara1991 Oct 10, 2024
e7aa449
PROD-8099 - Update input name according to option name
jitendrabanjara1991 Oct 10, 2024
28029a7
PROD-8099: Display member count only when user count setting is enabled
jitendrabanjara1991 Oct 10, 2024
58753c3
PROD-8099 - Display group count only when user count setting is enabled
jitendrabanjara1991 Oct 10, 2024
99ca657
PROD-8099 - Update position for Group Count settings and remove callb…
jitendrabanjara1991 Oct 10, 2024
ecc6052
PROD-8099 - Added migration code to Enable the member and group direc…
jitendrabanjara1991 Oct 10, 2024
20e9464
PROD-8099 - Update db version
jitendrabanjara1991 Oct 10, 2024
be1ef6d
PROD-8099 - Hide count for personal users connection and groups as th…
jitendrabanjara1991 Oct 11, 2024
28efed7
PROD-8099 - Hide count for group members when 'User Count' is disable
jitendrabanjara1991 Oct 11, 2024
6580fc4
PROD-8099 - Hide count for group members when 'User Count' is disable…
jitendrabanjara1991 Oct 11, 2024
432a84b
PROD-8099 - Default off for new installation
jitendrabanjara1991 Oct 14, 2024
b8a42bc
PROD-8099 Initial implementation count migration
bb-yudhisthir Nov 15, 2024
d0f70c7
PROD-8099 Updates for count relocation
bb-yudhisthir Nov 19, 2024
ff0c6b6
PROD-8099 Update logic
bb-yudhisthir Nov 20, 2024
62c4cce
Merge branch 'release' into PROD-8099
bb-yudhisthir Nov 20, 2024
0ad2221
[PROD-8099] PROD-8090 Learndash count migration
bb-yudhisthir Nov 20, 2024
ddd5f24
PROD-8099 relocate notification count
bb-yudhisthir Nov 21, 2024
9a713a0
PROD-8099 Learndash relocate course count
bb-yudhisthir Nov 21, 2024
99162c4
[PROD-8099] Style Directory count
amincdev Nov 21, 2024
8da9b73
PROD-8099 revert notification related changes for default theme
bb-yudhisthir Nov 21, 2024
ec7b53a
[PROD-8099] Make styling general
amincdev Nov 21, 2024
250f4e1
[PROD-8099] Add spacing for count
amincdev Nov 21, 2024
d3064aa
[PROD-8099] Align Directory count with filters
amincdev Nov 21, 2024
17ed8a2
[PROD-8099] Place Group -> Members directory count in correctly
amincdev Nov 21, 2024
1b67a2b
[PROD-8099] Groups Photo tab Directory count placement corrections
amincdev Nov 21, 2024
437dd95
PROD-8099 Code logic update
bb-yudhisthir Nov 25, 2024
1bca0cf
Merge branch 'release' into PROD-8099
bb-yudhisthir Nov 26, 2024
de49d71
PROD-8099 minify js
bb-yudhisthir Nov 26, 2024
9b166d2
PROD-8099 Js update for the videos and photos count
bb-yudhisthir Dec 16, 2024
01fe781
PROD-8099 Update photos and videos count relocate logic and support f…
bb-yudhisthir Dec 16, 2024
a37701a
PROD-8099 fixed the issue with my groups tabs in directory after new …
bb-yudhisthir Dec 16, 2024
616970b
PROD-8099 Logic update for count relocation for directory
bb-yudhisthir Dec 18, 2024
90b8402
PROD-8099 Remove commented code
bb-yudhisthir Dec 18, 2024
a669982
Merge branch 'release' into PROD-8099
bb-yudhisthir Dec 19, 2024
efe772e
PROD-8099 update function
bb-yudhisthir Dec 30, 2024
e03a487
PROD-8099 Add settings telemetry
bb-yudhisthir Jan 1, 2025
92fcc8b
PROD-8099 Code reformatting
bb-yudhisthir Jan 8, 2025
89a3791
PROD-8099 Code reformatting
bb-yudhisthir Jan 8, 2025
40ea22e
PROD-8099 Code refactor
bb-yudhisthir Jan 8, 2025
65ed679
PROD-8099 fix jshint warnings
bb-yudhisthir Jan 10, 2025
e2343f0
PROD-8099 Updates with the single global count setting
bb-yudhisthir Jan 16, 2025
bbd1aa9
PROD-8099 Update telemetry
bb-yudhisthir Jan 16, 2025
8e46816
PROD-8099 Update migration
bb-yudhisthir Jan 16, 2025
3bdaef0
Merge branch 'release' into PROD-8099
bb-yudhisthir Jan 17, 2025
0ef1546
PROD-8099 Update Typo condition
bb-yudhisthir Jan 17, 2025
f3a6e7d
[PROD-8099] Group members item count position
amincdev Jan 17, 2025
2e75c82
PROD-8099 show media count based on setting
bb-yudhisthir Jan 17, 2025
19fd028
PROD-8099 show count based on setting
bb-yudhisthir Jan 20, 2025
8acc71e
PROD-8099 Code refactor
bb-yudhisthir Jan 20, 2025
3a77c84
[PROD-8099] Directory page item count spacing
amincdev Jan 20, 2025
bdd6510
PROD-8099 Fix the fatal error with default theme
bb-yudhisthir Jan 20, 2025
3435352
[PROD-8099] Fix spacing issue of item count
amincdev Jan 20, 2025
f6587fc
PROD-8099 Update function for the count based on the setting
bb-yudhisthir Jan 20, 2025
003b0ae
PROD-8099 enabled as default
bb-yudhisthir Jan 21, 2025
92e0b0a
PROD-8099 default count enabled
bb-yudhisthir Jan 21, 2025
3f5b89b
PROD-8099 update document
bb-yudhisthir Jan 21, 2025
c8409a3
PROD-8099 revert doc block and default value
bb-yudhisthir Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/bp-core/admin/settings/bp-admin-setting-groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ public function register_fields() {
$args['class'] = 'group-gride-style group-layout-options ' . esc_attr( $pro_class );
$this->add_field( 'bb-group-directory-layout-grid-style', esc_html__( 'Grid Style', 'buddyboss' ) . bb_get_pro_label_notice(), 'bb_admin_setting_group_grid_style', 'radio', $args );

$this->add_field( 'bb-group-directory-count', esc_html__( 'Group Count', 'buddyboss' ), array( $this, 'bb_admin_setting_group_directory_count' ), 'checkbox' );

// Admin Settings for Settings > Groups > Group Directories > Elements.
$args = array(
'class' => 'group-elements ' . esc_attr( $pro_class ),
Expand Down Expand Up @@ -360,6 +362,22 @@ public function bb_group_default_custom_group_avatar_upload_dir( $upload_dir = a
$upload_dir
);
}

/**
* Displays the setting field for enabling or disabling group counts in the admin area.
*
* @since BuddyBoss [BBVERSION]
*
* @return void
*/
public function bb_admin_setting_group_directory_count() {
?>
<input id="bb-group-directory-count" name="bb-group-directory-count" type="checkbox" value="1" <?php checked( bb_group_directory_count_enable() ); ?> />
<label for="bb-group-directory-count">
<?php esc_html_e( 'Show group counts at the top of the page for All Groups & My Groups.', 'buddyboss' ); ?>
</label>
<?php
}
}

return new BP_Admin_Setting_Groups();
18 changes: 18 additions & 0 deletions src/bp-core/admin/settings/bp-admin-setting-xprofile.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ public function register_fields() {
$args['class'] = 'profile-default-layout profile-layout-options';
$this->add_field( 'bp-profile-layout-default-format', esc_html__( 'Default View', 'buddyboss' ), array( $this, 'bp_admin_setting_profile_layout_default_option' ), 'radio', $args );

$this->add_field( 'bb-member-directory-count', esc_html__( 'User Count', 'buddyboss' ), array( $this, 'bb_admin_setting_member_directory_count' ), 'checkbox' );

// Member directory elements.
$args = array();
$args['class'] = 'member-directory-elements ' . esc_attr( $pro_class );
Expand Down Expand Up @@ -832,6 +834,22 @@ public function bb_profile_slug_format_callback() {
esc_html__( 'Select the format of your member’s profile links (i.e. /members/username). Both formats will open the member’s profile, so you can safely change without breaking previously shared links.', 'buddyboss' )
);
}

/**
* Displays the setting field for enabling or disabling member counts in the admin area.
*
* @since BuddyBoss [BBVERSION]
*
* @return void
*/
public function bb_admin_setting_member_directory_count() {
?>
<input id="bb-member-directory-count" name="bb-member-directory-count" type="checkbox" value="1" <?php checked( bb_member_directory_count_enable() ); ?> />
<label for="bb-member-directory-count">
<?php esc_html_e( 'Show user counts at the top of the page for All Members, My Connections & Followers.', 'buddyboss' ); ?>
</label>
<?php
}
}

return new BP_Admin_Setting_Xprofile();
46 changes: 46 additions & 0 deletions src/bp-core/bp-core-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ function bp_get_default_options() {
'bb_load_activity_per_request' => 10,
'bb_activity_load_type' => 'infinite',

'bb-member-directory-count' => false,
'bb-group-directory-count' => false,
'bb-enable-sso' => false,
);

Expand Down Expand Up @@ -2757,3 +2759,47 @@ function bb_get_load_activity_per_request( $default = 10 ) {
function bb_is_send_ajax_request() {
return (bool) ( 2 === bb_get_ajax_request_page_load() );
}

/**
* Determines whether to show group counts at the top of the page for All Groups & My Groups.
*
* @since BuddyBoss [BBVERSION]
*
* @param bool $default Optional. Default value to use if the option is not set. Default false.
*
* @return bool True if group counts should be displayed, false otherwise.
*/
function bb_group_directory_count_enable( $default = false ) {

/**
* Filter to modify the behavior of the group counts feature.
*
* @since BuddyBoss [BBVERSION]
*
* @param bool $show_counts Whether to show group counts. Default is the value retrieved from the settings.
* @param bool $default The default value if the setting is not configured. Default false.
*/
return (bool) apply_filters( 'bb_group_directory_count_enable', (bool) bp_get_option( 'bb-group-directory-count', $default ) );
}

/**
* Determines whether to show member counts at the top of the page for All Members, My Connections & Followers.
*
* @since BuddyBoss [BBVERSION]
*
* @param bool $default Optional. Default value to use if the option is not set. Default false.
*
* @return bool True if group counts should be displayed, false otherwise.
*/
function bb_member_directory_count_enable( $default = false ) {

/**
* Filter to modify the behavior of the member counts feature.
*
* @since BuddyBoss [BBVERSION]
*
* @param bool $show_counts Whether to show member counts. Default is the value retrieved from the settings.
* @param bool $default The default value if the setting is not configured. Default false.
*/
return (bool) apply_filters( 'bb_member_directory_count_enable', (bool) bp_get_option( 'bb-member-directory-count', $default ) );
}
16 changes: 16 additions & 0 deletions src/bp-core/bp-core-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,10 @@ function bp_version_updater() {
bb_update_to_2_6_70();
}

if ( $raw_db_version < 21311 ) {
bb_update_to_2_6_80();
}

if ( $raw_db_version !== $current_db ) {
// @todo - Write only data manipulate migration here. ( This is not for DB structure change ).

Expand Down Expand Up @@ -3809,3 +3813,15 @@ function bb_update_to_2_6_70() {
}
}
}

/**
* Enable the member and group directory count option for existing installations.
*
* @since BuddyBoss [BBVERSION]
*
* @return void
*/
function bb_update_to_2_6_80() {
bp_update_option( 'bb-member-directory-count', 1 );
bp_update_option( 'bb-group-directory-count', 1 );
}
2 changes: 2 additions & 0 deletions src/bp-core/classes/class-bb-telemetry.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ public function bb_telemetry_platform_data( $bb_telemetry_data ) {
'bp_document_allowed_size',
'bp_media_allowed_size',
'_bb_enable_activity_post_polls',
'bb-member-directory-count',
'bb-group-directory-count',
)
);

Expand Down
11 changes: 2 additions & 9 deletions src/bp-friends/classes/class-bp-friends-component.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,9 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
$access = bp_core_can_edit_settings();
$slug = bp_get_friends_slug();
$friends_link = trailingslashit( $user_domain . $slug );

// Add 'Connections' to the main navigation.
$count = friends_get_total_friend_count();
$class = ( 0 === $count ) ? 'no-count' : 'count';
$enable_count = bb_member_directory_count_enable();
bb-yudhisthir marked this conversation as resolved.
Show resolved Hide resolved

$main_nav_name = __( 'Connections', 'buddyboss' );
$main_nav_name .= sprintf(
' <span class="%s">%s</span>',
esc_attr( $class ),
$count
);

$main_nav = array(
'name' => $main_nav_name,
Expand Down
16 changes: 2 additions & 14 deletions src/bp-groups/classes/class-bp-groups-component.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,18 +566,7 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
$user_domain = false;
}

// Only grab count if we're on a user page.
if ( bp_is_user() ) {
$class = ( 0 === groups_total_groups_for_user( bp_displayed_user_id() ) ) ? 'no-count' : 'count';
$nav_name = __( 'Groups', 'buddyboss' );
$nav_name .= sprintf(
' <span class="%s">%s</span>',
esc_attr( $class ),
bp_get_total_group_count_for_user()
);
} else {
$nav_name = __( 'Groups', 'buddyboss' );
}
$nav_name = __( 'Groups', 'buddyboss' );

$slug = bp_get_groups_slug();

Expand Down Expand Up @@ -643,9 +632,8 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) {

$group_link = bp_get_group_permalink( $this->current_group );

// Add the "Members" subnav item, as this will always be present.
$sub_nav[] = array(
'name' => sprintf( apply_filters( 'group_single_members_label', __( 'Members', 'buddyboss' ) ) . __( ' %s', 'buddyboss' ), '<span>' . number_format( $this->current_group->total_member_count ) . '</span>' ),
'name' => apply_filters( 'group_single_members_label', __( 'Members', 'buddyboss' ) ),
'slug' => 'members',
'parent_url' => $group_link,
'parent_slug' => $this->current_group->slug,
Expand Down
20 changes: 1 addition & 19 deletions src/bp-integrations/learndash/core/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,7 @@ public function setup_nav() {
$atts = apply_filters( 'bp_learndash_user_courses_atts', array() );
$user_courses = apply_filters( 'bp_learndash_user_courses', ld_get_mycourses( $this->bp_displayed_user_id, $atts ) );
bb-yudhisthir marked this conversation as resolved.
Show resolved Hide resolved

$user_courses_count = is_array( $user_courses ) ? count( $user_courses ) : 0;

// Only grab count if we're on a user page.
if ( bp_is_user() ) {
$class = ( 0 === $user_courses_count ) ? 'no-count' : 'count';

$nav_name = sprintf(
/* translators: %s: Group count for the current user */
__( '%1$s %2$s', 'buddyboss' ),
$this->course_name,
sprintf(
'<span class="%s">%s</span>',
esc_attr( $class ),
$user_courses_count
)
);
} else {
$nav_name = $this->course_name;
}
$nav_name = $this->course_name;

bp_core_new_nav_item(
array(
Expand Down
25 changes: 25 additions & 0 deletions src/bp-media/bp-media-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,31 @@ function bp_media_get_total_media_count() {
return apply_filters( 'bp_media_get_total_media_count', (int) $count );
}

/**
* Get the album count of a user.
*
* @since BuddyBoss [BBVERSION]
*
* @return int album count of the user.
*/
function bp_media_get_total_album_count() {
bb-yudhisthir marked this conversation as resolved.
Show resolved Hide resolved

add_filter( 'bp_ajax_querystring', 'bp_media_object_template_results_media_personal_scope', 20 );
bp_has_albums( bp_ajax_querystring( 'albums' ) );
global $media_album_template;
$count = $media_album_template->total_album_count;
remove_filter( 'bp_ajax_querystring', 'bp_media_object_template_results_media_personal_scope', 20 );

/**
* Filters the total media count for a given user.
*
* @param int $count Total media count for a given user.
*
* @since BuddyBoss 1.0.0
*/
return apply_filters( 'bp_media_get_total_album_count', (int) $count );
bb-yudhisthir marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Get the groups media count of a given user.
*
Expand Down
15 changes: 1 addition & 14 deletions src/bp-media/classes/class-bp-media-component.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,20 +261,7 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) {

$slug = bp_get_media_slug();
$media_link = trailingslashit( $user_domain . $slug );

// Only grab count if we're on a user page and current user has access.
if ( bp_is_user() ) {
$count = bp_media_get_total_media_count( bp_displayed_user_id() );
$class = ( 0 === $count ) ? 'no-count' : 'count';
$nav_name = __( 'Photos', 'buddyboss' );
$nav_name .= sprintf(
' <span class="%s">%s</span>',
esc_attr( $class ),
$count
);
} else {
$nav_name = __( 'Photos', 'buddyboss' );
}
$nav_name = __( 'Photos', 'buddyboss' );

// Add 'Photos' to the main navigation.
$main_nav = array(
Expand Down
19 changes: 2 additions & 17 deletions src/bp-notifications/classes/class-bp-notifications-component.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,23 +223,8 @@ public function setup_admin_bar( $wp_admin_nav = array() ) {
// Setup the logged in user variables.
$notifications_link = trailingslashit( bp_loggedin_user_domain() . bp_get_notifications_slug() );

// Pending notification requests.
$count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
if ( ! empty( $count ) ) {
$title = sprintf(
/* translators: %s: Unread notification count for the current user */
__( 'Notifications %s', 'buddyboss' ),
'<span class="count">' . bp_core_number_format( $count ) . '</span>'
);
$unread = sprintf(
/* translators: %s: Unread notification count for the current user */
__( 'Unread %s', 'buddyboss' ),
'<span class="count">' . bp_core_number_format( $count ) . '</span>'
);
} else {
$title = __( 'Notifications', 'buddyboss' );
$unread = __( 'Unread', 'buddyboss' );
}
$title = __( 'Notifications', 'buddyboss' );
$unread = __( 'Unread', 'buddyboss' );

// Add the "My Account" sub menus.
$wp_admin_nav[] = array(
Expand Down
Loading
Loading