From 92fcc8b17df02308f15a30caebb82deba02ed5b1 Mon Sep 17 00:00:00 2001 From: Yudhisthir Nahar Date: Wed, 8 Jan 2025 12:11:01 +0530 Subject: [PATCH] PROD-8099 Code reformatting --- .../classes/class-bp-friends-component.php | 8 +-- src/bp-media/bp-media-functions.php | 10 +-- .../bp-nouveau/buddypress-functions.php | 12 ++-- .../buddypress/groups/single/members.php | 12 +++- .../buddypress/groups/single/videos.php | 10 ++- .../members/single/courses/courses.php | 10 ++- .../buddypress/members/single/groups.php | 64 +++++++++---------- .../buddypress/members/single/media.php | 63 +++++++++--------- .../buddypress/members/single/video.php | 47 +++++++------- .../bp-nouveau/includes/groups/functions.php | 4 +- .../bp-nouveau/includes/media/functions.php | 12 ++-- .../bp-nouveau/includes/members/functions.php | 3 +- .../bp-nouveau/js/buddypress-media.js | 2 +- .../bp-nouveau/js/buddypress-video.js | 2 +- 14 files changed, 138 insertions(+), 121 deletions(-) diff --git a/src/bp-friends/classes/class-bp-friends-component.php b/src/bp-friends/classes/class-bp-friends-component.php index 25a5148638..9d460fe075 100644 --- a/src/bp-friends/classes/class-bp-friends-component.php +++ b/src/bp-friends/classes/class-bp-friends-component.php @@ -166,11 +166,9 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) { return; } - $access = bp_core_can_edit_settings(); - $slug = bp_get_friends_slug(); - $friends_link = trailingslashit( $user_domain . $slug ); - $enable_count = bb_member_directory_count_enable(); - + $access = bp_core_can_edit_settings(); + $slug = bp_get_friends_slug(); + $friends_link = trailingslashit( $user_domain . $slug ); $main_nav_name = __( 'Connections', 'buddyboss' ); $main_nav = array( diff --git a/src/bp-media/bp-media-functions.php b/src/bp-media/bp-media-functions.php index 7a21625eaf..ff3a079f51 100644 --- a/src/bp-media/bp-media-functions.php +++ b/src/bp-media/bp-media-functions.php @@ -849,7 +849,7 @@ function bp_media_get_total_media_count() { * * @return int album count of the user. */ -function bp_media_get_total_album_count() { +function bb_media_get_total_album_count() { add_filter( 'bp_ajax_querystring', 'bp_media_object_template_results_media_personal_scope', 20 ); bp_has_albums( bp_ajax_querystring( 'albums' ) ); @@ -858,13 +858,13 @@ function bp_media_get_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. + * Filters the total media album count for a given user. * - * @param int $count Total media count for a given user. + * @since BuddyBoss [BBVERSION] * - * @since BuddyBoss 1.0.0 + * @param int $count Total media album count for a given user. */ - return apply_filters( 'bp_media_get_total_album_count', (int) $count ); + return apply_filters( 'bb_media_get_total_album_count', (int) $count ); } /** diff --git a/src/bp-templates/bp-nouveau/buddypress-functions.php b/src/bp-templates/bp-nouveau/buddypress-functions.php index c674819871..6574f530b0 100644 --- a/src/bp-templates/bp-nouveau/buddypress-functions.php +++ b/src/bp-templates/bp-nouveau/buddypress-functions.php @@ -663,20 +663,20 @@ public function localize_scripts() { 'wpTimezone' => bp_get_option( 'timezone_string' ), 'dir_labels' => array( 'members' => array( - 'singular' => esc_html( 'Member', 'buddyboss' ), - 'plural' => esc_html( 'Members', 'buddyboss' ), + 'singular' => esc_html__( 'Member', 'buddyboss' ), + 'plural' => esc_html__( 'Members', 'buddyboss' ), ), 'followers' => array( - 'singular' => esc_html( 'Follower', 'buddyboss' ), - 'plural' => esc_html( 'Followers', 'buddyboss' ), + 'singular' => esc_html__( 'Follower', 'buddyboss' ), + 'plural' => esc_html__( 'Followers', 'buddyboss' ), ), ), ); if ( bp_is_active( 'friends' ) ) { $params['dir_labels']['connections'] = array( - 'singular' => esc_html( 'Connection', 'buddyboss' ), - 'plural' => esc_html( 'Connections', 'buddyboss' ), + 'singular' => esc_html__( 'Connection', 'buddyboss' ), + 'plural' => esc_html__( 'Connections', 'buddyboss' ), ); } diff --git a/src/bp-templates/bp-nouveau/buddypress/groups/single/members.php b/src/bp-templates/bp-nouveau/buddypress/groups/single/members.php index 991402aad6..e317fd7dfe 100644 --- a/src/bp-templates/bp-nouveau/buddypress/groups/single/members.php +++ b/src/bp-templates/bp-nouveau/buddypress/groups/single/members.php @@ -10,7 +10,7 @@ $is_send_ajax_request = bb_is_send_ajax_request(); bp_get_template_part( 'groups/single/parts/members-subnav' ); $enable_count = bb_member_directory_count_enable(); -$count = $enable_count ? groups_get_total_member_count( bp_get_current_group_id () ) : false; +$count = $enable_count ? groups_get_total_member_count( bp_get_current_group_id() ) : false; if ( false !== $count ) { bp_nouveau_search_form(); ?> @@ -20,7 +20,15 @@ /* translators: %d is the members count */ printf( - wp_kses( _n( '%d Member', '%d Members', $count, 'buddyboss' ), array( 'span' => array( 'class' => true ) ) ), + wp_kses( + _n( + '%d Member', + '%d Members', + $count, + 'buddyboss' + ), + array( 'span' => array( 'class' => true ) ) + ), $count ); } diff --git a/src/bp-templates/bp-nouveau/buddypress/groups/single/videos.php b/src/bp-templates/bp-nouveau/buddypress/groups/single/videos.php index 49e4c0ddae..7331766d9b 100644 --- a/src/bp-templates/bp-nouveau/buddypress/groups/single/videos.php +++ b/src/bp-templates/bp-nouveau/buddypress/groups/single/videos.php @@ -18,7 +18,15 @@ /* translators: %d is the video count */ printf( - wp_kses( _n( '%d Video', '%d Videos', $count, 'buddyboss' ), array( 'span' => array( 'class' => true ) ) ), + wp_kses( + _n( + '%d Video', + '%d Videos', + $count, + 'buddyboss' + ), + array( 'span' => array( 'class' => true ) ) + ), $count ); } diff --git a/src/bp-templates/bp-nouveau/buddypress/members/single/courses/courses.php b/src/bp-templates/bp-nouveau/buddypress/members/single/courses/courses.php index 3cc395c022..f102942b59 100644 --- a/src/bp-templates/bp-nouveau/buddypress/members/single/courses/courses.php +++ b/src/bp-templates/bp-nouveau/buddypress/members/single/courses/courses.php @@ -62,7 +62,15 @@ /* translators: %d is the courses count */ printf( - wp_kses( _n( '%d Course', '%d Courses', $count, 'buddyboss' ), array( 'span' => array( 'class' => true ) ) ), + wp_kses( + _n( + '%d Course', + '%d Courses', + $count, + 'buddyboss' + ), + array( 'span' => array( 'class' => true ) ) + ), $count ); ?> diff --git a/src/bp-templates/bp-nouveau/buddypress/members/single/groups.php b/src/bp-templates/bp-nouveau/buddypress/members/single/groups.php index 0c01f6b8e0..da9f0ec256 100644 --- a/src/bp-templates/bp-nouveau/buddypress/members/single/groups.php +++ b/src/bp-templates/bp-nouveau/buddypress/members/single/groups.php @@ -14,48 +14,44 @@ bp_get_template_part( 'members/single/parts/item-subnav' ); } -switch ( bp_current_action() ) : - case 'my-groups': - $count = bp_get_total_group_count_for_user( bp_displayed_user_id() ); - ?> -
- %d Group', '%d Groups', $count, 'buddyboss' ), array( 'span' => array( 'class' => true ) ) ), - $count - ); - } - ?> -
- -
- %d Invite', '%d Invites', $count, 'buddyboss' ), array( 'span' => array( 'class' => true ) ) ), - $count - ); - } - ?> -
+if ( false !== $count ) { + ?> +
%d ' . ( 'invites' === $bp_current_action ? 'Invite' : 'Group' ), + '%d ' . ( 'invites' === $bp_current_action ? 'Invites' : 'Groups' ), + $count, + 'buddyboss' + ), + array( 'span' => array( 'class' => true ) ) + ), + $count + ); + } + ?> +
+ -
- %d Photo', '%d Photos', $count, 'buddyboss' ), array( 'span' => array( 'class' => true ) ) ), - $count - ); - } - ?> -
+ if ( 'my-media' === $bp_current_action ) { + $count = $count = bp_media_get_total_media_count(); + } elseif ( 'albums' === $bp_current_action && ! bp_is_single_album() ) { + $count = bb_media_get_total_album_count(); + } + + if ( false !== $count ) { + ?> +
-
- %d Album', '%d Albums', $count, 'buddyboss' ), array( 'span' => array( 'class' => true ) ) ), - $count - ); - ?> -
- %d ' . ( 'albums' === $bp_current_action ? 'Album' : 'Photo' ), + '%d ' . ( 'albums' === $bp_current_action ? 'Albums' : 'Photos' ), + $count, + 'buddyboss' + ), + array( 'span' => array( 'class' => true ) ) + ), + $count + ); } - break; - endswitch; + ?> +
+
@@ -57,7 +54,7 @@ } bp_get_template_part( 'document/theatre' ); - switch ( bp_current_action() ) : + switch ( $bp_current_action ) : // Home/Media. case 'my-media': diff --git a/src/bp-templates/bp-nouveau/buddypress/members/single/video.php b/src/bp-templates/bp-nouveau/buddypress/members/single/video.php index 630e2335db..fd916cb7ff 100644 --- a/src/bp-templates/bp-nouveau/buddypress/members/single/video.php +++ b/src/bp-templates/bp-nouveau/buddypress/members/single/video.php @@ -9,30 +9,33 @@ */ $is_send_ajax_request = bb_is_send_ajax_request(); - +$bp_current_action = bp_current_action(); if ( bp_is_user() ) { - switch ( bp_current_action() ) : - case 'my-video': - $count = bp_video_get_total_video_count( bp_displayed_user_id() ); - ?> -
- %d Video', '%d Videos', $count, 'buddyboss' ), array( 'span' => array( 'class' => true ) ) ), - $count - ); - } - ?> -
+ if ( 'my-video' === $bp_current_action ) { + $count = bp_video_get_total_video_count(); + ?> +
%d Video', + '%d Videos', + $count, + 'buddyboss' + ), + array( 'span' => array( 'class' => true ) ) + ), + $count + ); + } + ?> +
+
@@ -42,7 +45,7 @@ bp_get_template_part( 'media/theatre' ); bp_get_template_part( 'document/theatre' ); - switch ( bp_current_action() ) : + switch ( $bp_current_action ) : // Home/Video. case 'my-video': diff --git a/src/bp-templates/bp-nouveau/includes/groups/functions.php b/src/bp-templates/bp-nouveau/includes/groups/functions.php index 3cf2c5f699..cacc487fba 100644 --- a/src/bp-templates/bp-nouveau/includes/groups/functions.php +++ b/src/bp-templates/bp-nouveau/includes/groups/functions.php @@ -119,8 +119,8 @@ function bp_nouveau_groups_disallow_all_members_invites( $default = false ) { function bp_nouveau_groups_localize_scripts( $params = array() ) { $params['dir_labels']['groups'] = array( - 'singular' => esc_html( 'Group', 'buddyboss' ), - 'plural' => esc_html( 'Groups', 'buddyboss' ), + 'singular' => esc_html__( 'Group', 'buddyboss' ), + 'plural' => esc_html__( 'Groups', 'buddyboss' ), ); if ( ! bp_is_group_invites() && ! ( bp_is_group_create() && bp_is_group_creation_step( 'group-invites' ) ) ) { diff --git a/src/bp-templates/bp-nouveau/includes/media/functions.php b/src/bp-templates/bp-nouveau/includes/media/functions.php index 9f158448cf..1bad2feead 100644 --- a/src/bp-templates/bp-nouveau/includes/media/functions.php +++ b/src/bp-templates/bp-nouveau/includes/media/functions.php @@ -199,16 +199,16 @@ function bp_nouveau_media_localize_scripts( $params = array() ) { $params['dir_labels'], array( 'video' => array( - 'singular' => esc_html( 'Video', 'buddyboss' ), - 'plural' => esc_html( 'Videos', 'buddyboss' ), + 'singular' => esc_html__( 'Video', 'buddyboss' ), + 'plural' => esc_html__( 'Videos', 'buddyboss' ), ), 'album' => array( - 'singular' => esc_html( 'Album', 'buddyboss' ), - 'plural' => esc_html( 'Albums', 'buddyboss' ), + 'singular' => esc_html__( 'Album', 'buddyboss' ), + 'plural' => esc_html__( 'Albums', 'buddyboss' ), ), 'media' => array( - 'singular' => esc_html( 'Photo', 'buddyboss' ), - 'plural' => esc_html( 'Photos', 'buddyboss' ), + 'singular' => esc_html__( 'Photo', 'buddyboss' ), + 'plural' => esc_html__( 'Photos', 'buddyboss' ), ), ) ); diff --git a/src/bp-templates/bp-nouveau/includes/members/functions.php b/src/bp-templates/bp-nouveau/includes/members/functions.php index 135506a860..e60b1a6a62 100644 --- a/src/bp-templates/bp-nouveau/includes/members/functions.php +++ b/src/bp-templates/bp-nouveau/includes/members/functions.php @@ -17,8 +17,7 @@ * @return array An associative array of nav items. */ function bp_nouveau_get_members_directory_nav_items() { - $enable_count = bb_member_directory_count_enable(); - $nav_items = array(); + $nav_items = array(); $nav_items['all'] = array( 'component' => 'members', diff --git a/src/bp-templates/bp-nouveau/js/buddypress-media.js b/src/bp-templates/bp-nouveau/js/buddypress-media.js index a1d1a69c6d..f84419264e 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-media.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-media.js @@ -5290,7 +5290,7 @@ window.bp = window.bp || {}; dir_count = response.data.media_all_count; } else if ( 'personal' === dir_scope ) { dir_count = response.data.media_personal_count; - } else if( 'groups' === dir_scope ) { + } else if ( 'groups' === dir_scope ) { dir_count = response.data.media_group_count; } diff --git a/src/bp-templates/bp-nouveau/js/buddypress-video.js b/src/bp-templates/bp-nouveau/js/buddypress-video.js index caa9274129..e63421fe50 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-video.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-video.js @@ -474,7 +474,7 @@ window.bp = window.bp || {}; dir_count = response.data.video_all_count; } else if ( 'personal' === dir_scope ) { dir_count = response.data.video_personal_count; - } else if( 'groups' === dir_scope ) { + } else if ( 'groups' === dir_scope ) { dir_count = response.data.video_group_count; }