diff --git a/src/bp-activity/classes/class-bp-activity-follow.php b/src/bp-activity/classes/class-bp-activity-follow.php
index 4f5f37e9b5..379445736b 100644
--- a/src/bp-activity/classes/class-bp-activity-follow.php
+++ b/src/bp-activity/classes/class-bp-activity-follow.php
@@ -243,14 +243,83 @@ public static function get_counts( $user_id ) {
$followers = wp_cache_get( 'bp_total_follower_for_user_' . $user_id, 'bp' );
if ( false === $followers ) {
- $followers = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->activity->table_name_follow} WHERE leader_id = %d", $user_id ) );
+ /**
+ * Retrieves the count of users following a specific user.
+ *
+ * @since BuddyBoss [BBVERSION]
+ *
+ * @param int $user_id The user ID for whom the follower count is being retrieved.
+ *
+ * @return int The count of followers for the specified user.
+ */
+ $sql['select'] = "SELECT COUNT(u.id) FROM {$bp->activity->table_name_follow} u";
+ /**
+ * Filters the SELECT clause for retrieving the follower count.
+ *
+ * @since BuddyBoss [BBVERSION]
+ *
+ * @param string $select The SELECT clause of the SQL query.
+ * @param string $type The type of data being queried, e.g., 'follower_id'.
+ */
+ $sql['select'] = apply_filters( 'bp_user_query_join_sql', $sql['select'], 'follower_id' );
+
+ $sql['where'][] = $wpdb->prepare( "u.leader_id = %d", $user_id );
+ /**
+ * Filters the WHERE clause for retrieving the follower count.
+ *
+ * @since BuddyBoss [BBVERSION]
+ *
+ * @param array $where Array of WHERE clause conditions.
+ * @param string $type The type of data being queried, e.g., 'follower_id'.
+ */
+ $sql['where'] = apply_filters( 'bp_user_query_where_sql', $sql['where'], 'follower_id' );
+
+ $where_sql = 'WHERE ' . join( ' AND ', $sql['where'] );
+
+ $sql = "{$sql['select']} {$where_sql}";
+ $followers = $wpdb->get_var( $sql );
wp_cache_set( 'bp_total_follower_for_user_' . $user_id, $followers, 'bp' );
}
$following = wp_cache_get( 'bp_total_following_for_user_' . $user_id, 'bp' );
if ( false === $following ) {
- $following = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->activity->table_name_follow} WHERE follower_id = %d", $user_id ) );
+ $sql = array();
+ /**
+ * Retrieves the count of users being followed by a specific user.
+ *
+ * @since BuddyBoss [BBVERSION]
+ *
+ * @param int $user_id The user ID for whom the follow count is being retrieved.
+ *
+ * @return int The count of users the specified user is following.
+ */
+ $sql['select'] = "SELECT COUNT(u.id) FROM {$bp->activity->table_name_follow} u";
+ /**
+ * Filters the SELECT clause for retrieving the follow count.
+ *
+ * @since BuddyBoss [BBVERSION]
+ *
+ * @param string $select The SELECT clause of the SQL query.
+ * @param string $type The type of data being queried, e.g., 'leader_id'.
+ */
+ $sql['select'] = apply_filters( 'bp_user_query_join_sql', $sql['select'], 'leader_id' );
+
+ $sql['where'][] = $wpdb->prepare( "u.follower_id = %d", $user_id );
+ /**
+ * Filters the WHERE clause for retrieving the follow count.
+ *
+ * @since BuddyBoss [BBVERSION]
+ *
+ * @param array $where Array of WHERE clause conditions.
+ * @param string $type The type of data being queried, e.g., 'leader_id'.
+ */
+ $sql['where'] = apply_filters( 'bp_user_query_where_sql', $sql['where'], 'leader_id' );
+
+ $where_sql = 'WHERE ' . join( ' AND ', $sql['where'] );
+
+ $sql = "{$sql['select']} {$where_sql}";
+ $following = $wpdb->get_var( $sql );
wp_cache_set( 'bp_total_following_for_user_' . $user_id, $following, 'bp' );
}
diff --git a/src/bp-core/admin/bp-core-admin-tools.php b/src/bp-core/admin/bp-core-admin-tools.php
index f3efb639e4..6d6817482b 100644
--- a/src/bp-core/admin/bp-core-admin-tools.php
+++ b/src/bp-core/admin/bp-core-admin-tools.php
@@ -496,36 +496,41 @@ function bp_admin_repair_friend_count() {
$statement = __( 'Repairing total connections count for each member … %s', 'buddyboss' );
$result = __( 'Failed!', 'buddyboss' );
- $sql_delete = "DELETE FROM {$wpdb->usermeta} WHERE meta_key IN ( 'total_friend_count' );";
- if ( is_wp_error( $wpdb->query( $sql_delete ) ) ) {
- return array( 1, sprintf( $statement, $result ) );
+ $bp = buddypress();
+ $sql = "SELECT COUNT(u.ID) as c FROM {$wpdb->users} u";
+
+ // Check if moderation is enabled then exclude suspended users.
+ if ( bp_is_active( 'moderation' ) ) {
+ $sql .= " LEFT JOIN {$bp->moderation->table_name} s
+ ON u.ID = s.item_id
+ AND s.item_type = 'user'
+ AND ( s.user_suspended = 1 OR s.hide_sitewide = 1 )
+ WHERE s.item_id IS NULL";
}
- $bp = buddypress();
-
// Walk through all users on the site.
- $total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
+ $total_users = $wpdb->get_row( $sql )->c;
- $updated = array();
if ( $total_users > 0 ) {
- $per_query = 500;
+ $per_query = 50;
$offset = 0;
while ( $offset < $total_users ) {
- // Only bother updating counts for users who actually have friendships.
- $friendships = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id FROM {$bp->friends->table_name} WHERE is_confirmed = 1 AND ( ( initiator_user_id > %d AND initiator_user_id <= %d ) OR ( friend_user_id > %d AND friend_user_id <= %d ) )", $offset, $offset + $per_query, $offset, $offset + $per_query ) );
-
- // The previous query will turn up duplicates, so we
- // filter them here.
- foreach ( $friendships as $friendship ) {
- if ( ! isset( $updated[ $friendship->initiator_user_id ] ) ) {
- BP_Friends_Friendship::total_friend_count( $friendship->initiator_user_id );
- $updated[ $friendship->initiator_user_id ] = 1;
- }
+ $select = "SELECT DISTINCT u.ID FROM {$wpdb->users} u";
+ $join = '';
+ $where = 'WHERE u.ID IS NOT NULL';
+ $limit = $wpdb->prepare('LIMIT %d OFFSET %d', $per_query, $offset);
+
+ // Check if moderation is enabled then exclude suspended users.
+ if ( bp_is_active( 'moderation' ) ) {
+ $join .= " LEFT JOIN {$bp->moderation->table_name} s
+ ON ( u.ID = s.item_id AND s.item_type = 'user' )
+ AND (s.user_suspended = 1 OR s.hide_sitewide = 1)";
+ $where .= ' AND s.item_id IS NULL';
+ }
- if ( ! isset( $updated[ $friendship->friend_user_id ] ) ) {
- BP_Friends_Friendship::total_friend_count( $friendship->friend_user_id );
- $updated[ $friendship->friend_user_id ] = 1;
- }
+ $members = $wpdb->get_results( "{$select} {$join} {$where} {$limit}" );
+ foreach ( $members as $member ) {
+ BP_Friends_Friendship::total_friend_count( $member->ID );
}
$offset += $per_query;
diff --git a/src/bp-core/bp-core-filters.php b/src/bp-core/bp-core-filters.php
index 1323b2dd33..b4b2ee736b 100644
--- a/src/bp-core/bp-core-filters.php
+++ b/src/bp-core/bp-core-filters.php
@@ -2650,3 +2650,27 @@ function bb_redirection_allowed_third_party_domains( $hosts ) {
return $hosts;
}
+
+/**
+ * Handles moderation component is activated or deactivated.
+ * Runs a background update to recalculate member friends count if the moderation component status changes.
+ *
+ * @since BuddyBoss [BBVERSION]
+ *
+ * @param array $active_components Array of active components.
+ *
+ * @return void
+ */
+function bb_update_moderation_component_status( $active_components = array() ) {
+ $active_components = array_keys( $active_components );
+ $db_components = array_keys( bp_get_option( 'bp-active-components', array() ) );
+
+ $is_moderation_disabled = in_array( 'moderation', $db_components, true ) && ! in_array( 'moderation', $active_components, true );
+ $is_moderation_enabled = ! in_array( 'moderation', $db_components, true ) && in_array( 'moderation', $active_components, true );
+
+ if ( $is_moderation_disabled || $is_moderation_enabled ) {
+ bb_create_background_member_friends_count();
+ }
+}
+
+add_action( 'bp_core_install', 'bb_update_moderation_component_status', 10, 1 );
diff --git a/src/bp-core/bp-core-update.php b/src/bp-core/bp-core-update.php
index 894a7433bc..3c500dc3c0 100644
--- a/src/bp-core/bp-core-update.php
+++ b/src/bp-core/bp-core-update.php
@@ -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 ).
@@ -3809,3 +3813,23 @@ function bb_update_to_2_6_70() {
}
}
}
+
+/**
+ * Fixed count for my connection.
+ *
+ * @since BuddyBoss [BBVERSION]
+ */
+function bb_update_to_2_6_80() {
+ if ( ! bp_is_active( 'moderation' ) ) {
+ return;
+ }
+ $is_already_run = get_transient( 'bb_update_to_2_6_80' );
+ if ( $is_already_run ) {
+ return;
+ }
+
+ // Set a transient to avoid running the update multiple times within an hour.
+ set_transient( 'bb_update_to_2_6_80', 'yes', HOUR_IN_SECONDS );
+
+ bb_create_background_member_friends_count();
+}
diff --git a/src/bp-friends/classes/class-bp-friends-friendship.php b/src/bp-friends/classes/class-bp-friends-friendship.php
index e9a0caa5ea..6e504df128 100644
--- a/src/bp-friends/classes/class-bp-friends-friendship.php
+++ b/src/bp-friends/classes/class-bp-friends-friendship.php
@@ -380,7 +380,44 @@ public static function get_friendship_ids_for_user( $user_id ) {
$friendship_ids = wp_cache_get( $cache_key, 'bp_friends_friendships_for_user' );
if ( false === $friendship_ids ) {
- $friendship_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d OR friend_user_id = %d) ORDER BY date_created DESC", $user_id, $user_id ) );
+ // Initialize the SQL query components.
+ $sql['select'] = "SELECT f.id FROM {$bp->friends->table_name} as f";
+ $sql['join'] = '';
+
+ /**
+ * Filters the SELECT clause for retrieving friendship IDs.
+ *
+ * @since BuddyBoss [BBVERSION]
+ *
+ * @param string $select The SELECT clause of the SQL query.
+ * @param int $user_id The user ID for whom friendship IDs are being fetched.
+ */
+ $sql['select'] = apply_filters( 'bb_get_friendship_ids_for_user_select_sql', $sql['select'], $user_id );
+
+ /**
+ * Filters the JOIN clause for retrieving friendship IDs.
+ *
+ * @since BuddyBoss [BBVERSION]
+ *
+ * @param string $join The JOIN clause of the SQL query.
+ * @param int $user_id The user ID for whom friendship IDs are being fetched.
+ */
+ $sql['join'] = apply_filters( 'bb_get_friendship_ids_for_user_join_sql', $sql['join'], $user_id );
+
+ $sql['where'][] = $wpdb->prepare( "(f.initiator_user_id = %d OR f.friend_user_id = %d)", $user_id, $user_id );
+ /**
+ * Filters the WHERE clause for retrieving friendship IDs.
+ *
+ * @since BuddyBoss [BBVERSION]
+ *
+ * @param array $where Array of WHERE clause conditions.
+ * @param int $user_id The user ID for whom friendship IDs are being fetched.
+ */
+ $sql['where'] = apply_filters( 'bb_get_friendship_ids_for_user_where_sql', $sql['where'], $user_id );
+ $where_sql = 'WHERE ' . join( ' AND ', $sql['where'] );
+
+ $sql = "{$sql['select']} {$sql['join']} {$where_sql} ORDER BY f.date_created DESC";
+ $friendship_ids = $wpdb->get_col( $sql );
wp_cache_set( $cache_key, $friendship_ids, 'bp_friends_friendships_for_user' );
}
diff --git a/src/bp-moderation/bp-moderation-filters.php b/src/bp-moderation/bp-moderation-filters.php
index 4bd303d590..b40c902013 100644
--- a/src/bp-moderation/bp-moderation-filters.php
+++ b/src/bp-moderation/bp-moderation-filters.php
@@ -283,23 +283,6 @@ function bp_moderation_block_member() {
friends_remove_friend( bp_loggedin_user_id(), $item_id );
}
- if (
- function_exists( 'bp_is_following' ) &&
- bp_is_following(
- array(
- 'leader_id' => $item_id,
- 'follower_id' => bp_loggedin_user_id(),
- )
- )
- ) {
- bp_stop_following(
- array(
- 'leader_id' => $item_id,
- 'follower_id' => bp_loggedin_user_id(),
- )
- );
- }
-
$response['button'] = bp_moderation_get_report_button(
array(
'button_attr' => array(
@@ -1076,3 +1059,79 @@ function bb_moderation_async_request_batch_process( $batch ) {
}
add_action( 'bb_async_request_batch_process', 'bb_moderation_async_request_batch_process', 10, 1 );
+/**
+ * Filters the WHERE clause for friendship IDs to exclude suspended users.
+ *
+ * @since BuddyBoss [BBVERSION]
+ *
+ * @param array $where Array of WHERE clause conditions.
+ * @param int $user_id The user ID for whom friendship IDs are being fetched.
+ *
+ * @return array Modified array of WHERE clause conditions.
+ */
+function bb_moderation_get_friendship_ids_for_user_where_sql( $where, $user_id ) {
+ $where[] = '(s.user_suspended = 0 OR s.user_suspended IS NULL)';
+ $where[] = '(s.hide_sitewide = 0 OR s.hide_sitewide IS NULL)';
+
+ return $where;
+}
+
+add_filter( 'bb_get_friendship_ids_for_user_where_sql', 'bb_moderation_get_friendship_ids_for_user_where_sql', 10, 2 );
+
+/**
+ * Filters the JOIN clause for friendship IDs to exclude suspended users.
+ *
+ * @since BuddyBoss [BBVERSION]
+ *
+ * @param string $join The JOIN clause of the SQL query.
+ * @param int $user_id The user ID for whom friendship IDs are being fetched.
+ *
+ * @return string Modified JOIN clause of the SQL query.
+ */
+function bb_moderation_get_friendship_ids_for_user_join_sql( $join, $user_id ) {
+ $bp = buddypress();
+
+ // Join with the wp_bp_suspend table to filter out users based on suspension criteria.
+ $join .= ' LEFT JOIN ' . $bp->moderation->table_name . ' s ON (';
+ $join .= ' (f.initiator_user_id = s.item_id OR f.friend_user_id = s.item_id)';
+ $join .= ' AND s.item_type = "user"';
+ $join .= ' AND (s.hide_sitewide = 1 OR s.user_suspended = 1)';
+ $join .= ')';
+
+ // Join with the wp_bp_moderation table to apply moderation checks.
+ $join .= ' LEFT JOIN ' . $bp->moderation->table_name_reports . ' m ON (';
+ $join .= ' s.id = m.moderation_id';
+ $join .= ' AND (';
+ $join .= ' (m.user_id = ' . $user_id . ' AND m.user_report = 0)';
+ $join .= ' OR m.user_report != 1';
+ $join .= ')';
+ $join .= ')';
+
+ return $join;
+}
+
+add_filter( 'bb_get_friendship_ids_for_user_join_sql', 'bb_moderation_get_friendship_ids_for_user_join_sql', 10, 2 );
+
+
+function bb_test_moderation_get_friendship_ids_for_user_where_sql( $where, $user_id ) {
+ global $wpdb;
+ $moderated_user_ids = bb_moderation_moderated_user_ids();
+
+ // If user ID is also in fetched modarated user ids, remove it.
+ if ( in_array( $user_id, $moderated_user_ids, true ) ) {
+ $moderated_user_ids = array_diff( $moderated_user_ids, array( $user_id ) );
+ }
+
+ // If there are any suspended users, add conditions to exclude them.
+ if ( ! empty( $moderated_user_ids ) ) {
+ $placeholders = implode( ', ', array_fill( 0, count( $moderated_user_ids ), '%d' ) );
+ $where[] = $wpdb->prepare(
+ "(initiator_user_id NOT IN ( {$placeholders} ) AND friend_user_id NOT IN ( {$placeholders} ))",
+ ...$moderated_user_ids,
+ ...$moderated_user_ids
+ );
+ }
+ return $where;
+}
+
+//add_filter( 'bb_get_friendship_ids_for_user_where_sql', 'bb_test_moderation_get_friendship_ids_for_user_where_sql', 10, 2 );
diff --git a/src/bp-moderation/classes/suspend/class-bp-suspend-member.php b/src/bp-moderation/classes/suspend/class-bp-suspend-member.php
index 9916df8506..abaeb884b1 100644
--- a/src/bp-moderation/classes/suspend/class-bp-suspend-member.php
+++ b/src/bp-moderation/classes/suspend/class-bp-suspend-member.php
@@ -715,9 +715,16 @@ protected function get_related_contents( $member_id, $args = array() ) {
$action = ! empty( $args['action'] ) ? $args['action'] : '';
$page = ! empty( $args['page'] ) ? $args['page'] : - 1;
$related_contents = array();
+ $member_id = (int) $member_id;
// Update friend count.
- if ( bp_is_active( 'friends' ) && $page <= 1 ) {
+ if (
+ bp_is_active( 'friends' ) &&
+ $page <= 1 &&
+ ! empty( $args['action_suspend'] )
+ ) {
+
+ // Update friend count for the suspend users only not for the blocked users.
$friend_ids = friends_get_friend_user_ids( $member_id );
if ( ! empty( $friend_ids ) ) {
@@ -1182,13 +1189,6 @@ public function bb_update_member_friend_count( $user_id, $member_ids, $type ) {
if ( ! empty( $friend_ids ) ) {
$total_friend_count = count( $friend_ids );
-
- if ( 'hide' === $type && in_array( $user_id, $friend_ids, true ) ) {
- --$total_friend_count;
- } elseif ( 'unhide' === $type && ! in_array( $user_id, $friend_ids, true ) ) {
- ++$total_friend_count;
- }
-
bp_update_user_meta( $member_id, 'total_friend_count', (int) $total_friend_count );
}
diff --git a/src/bp-templates/bp-nouveau/js/buddypress-nouveau.js b/src/bp-templates/bp-nouveau/js/buddypress-nouveau.js
index d3591deb15..f32d9c9048 100644
--- a/src/bp-templates/bp-nouveau/js/buddypress-nouveau.js
+++ b/src/bp-templates/bp-nouveau/js/buddypress-nouveau.js
@@ -2263,6 +2263,23 @@ window.bp = window.bp || {};
item.find( '.followers-wrap' ).replaceWith( response.data.count );
}
+ // Update the following count.
+ if ( $( self.objectNavParent + ' [data-bp-scope="following"]' ).length ) {
+ var following_count = Number( $( self.objectNavParent + ' [data-bp-scope="following"] span' ).html() ) || 0;
+
+ if ( -1 !== $.inArray( action, [ 'unfollow' ] ) ) {
+ following_count -= 1;
+ } else if ( -1 !== $.inArray( action, [ 'follow' ] ) ) {
+ following_count += 1;
+ }
+
+ if ( following_count < 0 ) {
+ following_count = 0;
+ }
+
+ $( self.objectNavParent + ' [data-bp-scope="following"] span' ).html( following_count );
+ }
+
target.parent().replaceWith( response.data.contents );
}
}
diff --git a/src/bp-templates/bp-nouveau/js/buddypress-nouveau.min.js b/src/bp-templates/bp-nouveau/js/buddypress-nouveau.min.js
index 347b62a626..da697c7161 100644
--- a/src/bp-templates/bp-nouveau/js/buddypress-nouveau.min.js
+++ b/src/bp-templates/bp-nouveau/js/buddypress-nouveau.min.js
@@ -1 +1 @@
-window.wp=window.wp||{},window.bp=window.bp||{},function(f){"undefined"!=typeof BP_Nouveau&&(bp.Nouveau={start:function(){this.setupGlobals(),this.prepareDocument(),this.initObjects(),this.setHeartBeat(),this.addListeners(),this.switchGridList(),this.sendInvitesRevokeAccess(),this.sentInvitesFormValidate(),this.registerPopUp(),this.loginPopUp(),this.reportPopUp(),this.reportActions(),this.reportedPopup(),this.togglePassword(),this.enableSubmitOnLegalAgreement(),this.profileNotificationSetting(),this.xProfileBlock(),"undefined"!=typeof BB_Nouveau_Presence&&this.userPresenceStatus();var r=this;f(document).on("bb_trigger_toast_message",function(e,t,i,a,o,n,s){r.bbToastMessage(t,i,a,o,n,s)}),bp.Nouveau.lazyLoad(".lazy"),f(window).on("scroll resize",function(){bp.Nouveau.lazyLoad(".lazy")})},bbToastMessage:function(e,t,i,a,o,n){var s,r,d,l,c,p;function u(){f(r).removeClass("pull-animation").addClass("close-item").delay(500).remove()}t&&""!=t.trim()&&(s="unique-"+Math.floor(1e6*Math.random()),r="."+s,c=l=d="",n=n&&"number"==typeof n?1e3*n:5e3,i&&("success"===(l=i)?c="check":"warning"===i?c="exclamation-triangle":"delete"===i?(c="trash",l="error"):c="info"),null!==a&&(d="has-url"),i="",i+='
',i+='',e&&(i+=''+e+""),t&&(i+=''+t+""),i+="
",i+='',i+=a?'':"",f((f(".bb-toast-messages-enable").length||(f(".bb-onscreen-notification-enable ul.notification-list").length?(p=f(".bb-onscreen-notification").hasClass("bb-position-left")?"left":"right",p=f(''),f(".bb-onscreen-notification").show(),f(p).insertBefore(".bb-onscreen-notification-enable ul.notification-list")):(p=f(''),f("body").append(p))),".bb-toast-messages-enable .toast-messages-list")).append(' '+i+" "),o&&setInterval(function(){u()},n),f(r+" .actions .action-close").on("click",function(){u()}))},setupGlobals:function(){this.ajax_request=null,this.objects=f.map(BP_Nouveau.objects,function(e){return e}),this.objectNavParent=BP_Nouveau.object_nav_parent,this.heartbeat=wp.heartbeat||!1,this.querystring=this.getLinkParams(),this.bbServerTimeDiff=new Date(BP_Nouveau.wpTime).getTime()-(new Date).getTime()},prepareDocument:function(){var i;f("body").hasClass("no-js")&&f("body").removeClass("no-js").addClass("js"),BP_Nouveau.warnings&&"undefined"!=typeof console&&console.warn&&f.each(BP_Nouveau.warnings,function(e,t){console.warn(t)}),f(".buddypress_object_nav .widget-title").length&&(i=f(".buddypress_object_nav .widget-title").html(),f("body").find('*:contains("'+i+'")').each(function(e,t){f(t).hasClass("widget-title")||i!==f(t).html()||f(t).is("a")||f(t).remove()}))},getStorage:function(e,t){e=(e=sessionStorage.getItem(e))?JSON.parse(e):{};return void 0!==t?e[t]||!1:e},setStorage:function(e,t,i){var a=this.getStorage(e);return void 0===i&&void 0!==a[t]?delete a[t]:a[t]=i,sessionStorage.setItem(e,JSON.stringify(a)),null!==sessionStorage.getItem(e)},getLinkParams:function(e,t){e=e?-1!==e.indexOf("?")?"?"+e.split("?")[1]:"":document.location.search;if(!e)return null;e=e.replace(/(^\?)/,"").split("&").map(function(e){return this[(e=e.split("="))[0]]=e[1],this}.bind({}))[0];return t?e[t]:e},urlDecode:function(e,t){var i=t||{amp:"&",lt:"<",gt:">",quot:'"',"#039":"'"};return decodeURIComponent(e.replace(/\+/g," ")).replace(/&([^;]+);/g,function(e,t){return i[t]||""})},ajax:function(e,t,i){this.ajax_request&&void 0===i&&"scheduled"!==e.status&&this.ajax_request.abort();e=f.extend({},bp.Nouveau.getStorage("bp-"+t),{nonce:BP_Nouveau.nonces[t]},e);return void 0!==BP_Nouveau.customizer_settings&&(e.customized=BP_Nouveau.customizer_settings),void 0!==BP_Nouveau.modbypass&&(e.modbypass=BP_Nouveau.modbypass),this.ajax_request=f.post(BP_Nouveau.ajaxurl,e,"json"),this.ajax_request},inject:function(e,t,i){f(e).length&&t&&(("append"===(i=i||"reset")?f(e).append(t):"prepend"===i?f(e).prepend(t):"after"===i?f(e).after(t):f(e).html(t)).find("li.activity-item").each(this.hideSingleUrl),"undefined"==typeof bp_mentions&&void 0===bp.mentions||(f(".bp-suggestions").bp_mentions(bp.mentions.users),f("#whats-new").on("inserted.atwho",function(){var e;window.getSelection&&document.createRange?(e=window.getSelection&&window.getSelection())&&0 p").removeAttr("br").removeAttr("a").text(),t="",i="",a="",o=0;if(0<=e.indexOf("http://")?(a=e.indexOf("http://"),o=1):0<=e.indexOf("https://")?(a=e.indexOf("https://"),o=1):0<=e.indexOf("www.")&&(a=e.indexOf("www"),o=1),1===o){for(var n=a;n p:first").hide()}},objectRequest:function(a){var e,o,n=this;if((a=f.extend({object:"",scope:null,filter:null,target:"#buddypress [data-bp-list]",search_terms:"",page:1,extras:null,caller:null,template:null,method:"reset",ajaxload:!0},a)).object&&a.target)return"activity"==a.object&&"#buddypress [data-bp-list] ul.bp-list"==a.target&&(a.target="#buddypress [data-bp-list] ul.bp-list:not(#bb-media-model-container ul.bp-list)"),["members","activity","media","document"].includes(a.object)&&!f(this.objectNavParent+' [data-bp-scope="'+a.scope+'"]').length&&(a.scope="all"),a.search_terms&&(a.search_terms=a.search_terms.replace(//g,">")),null!==a.scope&&this.setStorage("bp-"+a.object,"scope",a.scope),null!==a.filter&&this.setStorage("bp-"+a.object,"filter",a.filter),null!==a.extras&&this.setStorage("bp-"+a.object,"extras",a.extras),!(!_.isUndefined(a.ajaxload)&&!1===a.ajaxload)&&(f(this.objectNavParent+" [data-bp-object]").each(function(){f(this).removeClass("selected loading")}),(f(this.objectNavParent+' [data-bp-scope="'+a.scope+'"]').length?f(this.objectNavParent+' [data-bp-scope="'+a.scope+'"], #object-nav li.current'):f(this.objectNavParent+" [data-bp-scope]:eq(0), #object-nav li.current")).addClass("selected loading"),0===f(this.objectNavParent+' [data-bp-scope="'+a.scope+'"]').length&&(e=["group_members"===a.object&&f("body").hasClass("group-members"),"activity"===a.object&&f("body.groups").hasClass("activity"),"document"===a.object&&f("body").hasClass("documents"),"manage_group_members"===a.object&&f("body").hasClass("manage-members"),"document"===a.object&&(f("body").hasClass("document")||f("body").hasClass("documents"))],o=[f(".groups .group-search.members-search"),f(".groups .group-search.activity-search"),f(".documents .bp-document-listing .bb-title"),f(".groups .group-search.search-wrapper"),f("#bp-media-single-folder .bb-title")],e.forEach(function(e,t){e&&o[t].addClass("loading")})),f('#buddypress [data-bp-filter="'+a.object+'"] option[value="'+a.filter+'"]').prop("selected",!0),"friends"===a.object||"group_members"===a.object||"manage_group_members"===a.object?(a.template=a.object,a.object="members"):"group_requests"===a.object?(a.object="groups",a.template="group_requests"):"group_subgroups"===a.object?(a.object="groups",a.template="group_subgroups"):"notifications"===a.object&&(a.object="members",a.template="member_notifications"),e=f.extend({action:a.object+"_filter"},a),this.ajax(e,a.object).done(function(e){if(!1!==e.success&&!_.isUndefined(e.data)){if("scheduled"===a.status&&(f(e.data.contents).hasClass("bp-feedback")?f(a.target).parent().addClass("has-no-content"):f(a.target).parent().addClass("has-content")),_.isUndefined(e.data.layout)||(f(".layout-view").removeClass("active"),f(".layout-"+e.data.layout+"-view").addClass("active")),!f("body.group-members.members.buddypress").length||_.isUndefined(e.data)||_.isUndefined(e.data.count)||f("body.group-members.members.buddypress ul li#members-groups-li").find("span").text(e.data.count),f(n.objectNavParent+' [data-bp-scope="'+a.scope+'"]').removeClass("loading"),f(n.objectNavParent+' [data-bp-scope="'+a.scope+'"]').find("span").text(""),0===f(n.objectNavParent+' [data-bp-scope="'+a.scope+'"]').length&&o.forEach(function(e){e.removeClass("loading")}),_.isUndefined(e.data)||_.isUndefined(e.data.count)||f(n.objectNavParent+' [data-bp-scope="'+a.scope+'"]').find("span").text(e.data.count),!_.isUndefined(e.data)&&!_.isUndefined(e.data.scopes))for(var t in e.data.scopes)f(n.objectNavParent+' [data-bp-scope="'+t+'"]').find("span").text(e.data.scopes[t]);var i;"reset"!==a.method?(n.inject(a.target,e.data.contents,a.method),f(a.target).trigger("bp_ajax_"+a.method,f.extend(a,{response:e.data}))):"pag-bottom"===a.caller?(i=null,i=f("#subnav").length?f("#subnav").parent():f(a.target),f("html,body").animate({scrollTop:i.offset().top},"slow",function(){f(a.target).fadeOut(100,function(){n.inject(this,e.data.contents,a.method),f(this).fadeIn(100),f(a.target).trigger("bp_ajax_request",f.extend(a,{response:e.data})),bp.Nouveau.lazyLoad&&setTimeout(function(){bp.Nouveau.lazyLoad(".lazy")},1e3)})})):f(a.target).fadeOut(100,function(){n.inject(this,e.data.contents,a.method),f(this).fadeIn(100),f(a.target).trigger("bp_ajax_request",f.extend(a,{response:e.data})),bp.Nouveau.lazyLoad&&setTimeout(function(){bp.Nouveau.lazyLoad(".lazy")},1e3)}),setTimeout(function(){n.reportPopUp(),n.reportedPopup(),f(".activity-item.bb-closed-comments").find(".edit-activity, .acomment-edit").parents(".generic-button").hide()},1e3)}}))},initObjects:function(){var a,o=this,n={},s="all",r="",d=null,l=null;f.each(this.objects,function(e,t){var i;f('#buddypress [data-bp-list="'+t+'"][data-ajax="false"]').length&&!_.isUndefined(BP_Nouveau.is_send_ajax_request)&&""!==BP_Nouveau.is_send_ajax_request||(a=o.getStorage("bp-"+t),void 0!==(i=window.location.hash.substr(1))&&"following"==i?s=i:void 0!==a.scope&&(s=a.scope),void 0!==a.extras&&"notifications"!==t&&(d=a.extras),f('#buddypress [data-bp-filter="'+t+'"]').length&&(void 0!==a.filter?(l=a.filter,f('#buddypress [data-bp-filter="'+t+'"] option[value="'+l+'"]').prop("selected",!0)):"-1"!==f('#buddypress [data-bp-filter="'+t+'"]').val()&&"0"!==f('#buddypress [data-bp-filter="'+t+'"]').val()&&(l=f('#buddypress [data-bp-filter="'+t+'"]').val())),f(this.objectNavParent+' [data-bp-object="'+t+'"]').length&&(f(this.objectNavParent+' [data-bp-object="'+t+'"]').each(function(){f(this).removeClass("selected")}),f(this.objectNavParent+' [data-bp-scope="'+t+'"], #object-nav li.current').addClass("selected")),null!==o.querystring&&(void 0!==o.querystring[t+"_search"]?r=decodeURI(o.querystring[t+"_search"]):void 0!==o.querystring.s&&(r=decodeURI(o.querystring.s)),r&&f('#buddypress [data-bp-search="'+t+'"] input[type=search]').val(r)),f('#buddypress [data-bp-list="'+t+'"]').length&&(n={object:t,scope:s,filter:l,search_terms:r,extras:d},f('#buddypress [data-bp-member-type-filter="'+t+'"]').length?n.member_type_id=f('#buddypress [data-bp-member-type-filter="'+t+'"]').val():f('#buddypress [data-bp-group-type-filter="'+t+'"]').length&&(n.group_type=f('#buddypress [data-bp-group-type-filter="'+t+'"]').val()),_.isUndefined(BP_Nouveau.is_send_ajax_request)||""!==BP_Nouveau.is_send_ajax_request||(n.ajaxload=!1),o.objectRequest(n)))})},setHeartBeat:function(){void 0!==BP_Nouveau.pulse&&this.heartbeat&&(this.heartbeat.interval(Number(BP_Nouveau.pulse)),f.fn.extend({"heartbeat-send":function(){return this.bind("heartbeat-send")}}),f.fn.extend({"heartbeat-tick":function(){return this.bind("heartbeat-tick")}}))},addListeners:function(){f("[data-bp-disable-input]").on("change",this.toggleDisabledInput),f(this.objectNavParent+" .bp-navs").on("click","a",this,this.scopeQuery),f(document).on("change","#buddypress [data-bp-filter]",this,this.filterQuery),f(document).on("change","#buddypress [data-bp-group-type-filter]",this,this.typeGroupFilterQuery),f(document).on("change","#buddypress [data-bp-member-type-filter]",this,this.typeMemberFilterQuery),f("#buddypress [data-bp-search]").on("submit","form",this,this.searchQuery),f("#buddypress [data-bp-search]").on("keyup","input[name=group_members_search]",this,_.throttle(this.searchQuery,900)),f("#buddypress [data-bp-search] form").on("search","input[type=search]",this.resetSearch),f("#buddypress [data-bp-list], #buddypress #item-header, #buddypress.bp-shortcode-wrap .dir-list, #buddypress .bp-messages-content").on("click","[data-bp-btn-action]",this,this.buttonAction),f("#buddypress [data-bp-list], #buddypress #item-header, #buddypress.bp-shortcode-wrap .dir-list, #buddypress .messages-screen").on("blur","[data-bp-btn-action]",this,this.buttonRevert),f("#buddypress [data-bp-list], #buddypress #item-header, #buddypress.bp-shortcode-wrap .dir-list, #buddypress .messages-screen").on("mouseover","[data-bp-btn-action]",this,this.buttonHover),f("#buddypress [data-bp-list], #buddypress #item-header, #buddypress.bp-shortcode-wrap .dir-list, #buddypress .messages-screen").on("mouseout","[data-bp-btn-action]",this,this.buttonHoverout),f("#buddypress [data-bp-list], #buddypress #item-header, #buddypress.bp-shortcode-wrap .dir-list, #buddypress .messages-screen").on("mouseover",".awaiting_response_friend",this,this.awaitingButtonHover),f("#buddypress [data-bp-list], #buddypress #item-header, #buddypress.bp-shortcode-wrap .dir-list, #buddypress .messages-screen").on("mouseout",".awaiting_response_friend",this,this.awaitingButtonHoverout),f(document).on("click","#buddypress .bb-leave-group-popup .bb-confirm-leave-group",this.leaveGroupAction),f(document).on("click","#buddypress .bb-leave-group-popup .bb-close-leave-group",this.leaveGroupClose),f(document).on("click","#buddypress .bb-remove-connection .bb-confirm-remove-connection",this.removeConnectionAction),f(document).on("click","#buddypress .bb-remove-connection .bb-close-remove-connection",this.removeConnectionClose),f(document).on("click","#buddypress table.invite-settings .field-actions .field-actions-remove, #buddypress table.invite-settings .field-actions-add",this,this.addRemoveInvite),f(document).on("click",".show-action-popup",this.showActionPopup),f(document).on("click","#message-threads .block-member",this.threadListBlockPopup),f(document).on("click","#message-threads .report-content",this.threadListReportPopup),f(document).on("click",".bb-close-action-popup, .action-popup-overlay",this.closeActionPopup),f(document).on("keyup",'.search-form-has-reset input[type="search"], .search-form-has-reset input#bbp_search',_.throttle(this.directorySearchInput,900)),f(document).on("click",".search-form-has-reset .search-form_reset",this.resetDirectorySearch),f(document).on("keyup",this,this.keyUp),f("[data-bp-close]").on("click",this,this.closeNotice),f("#buddypress [data-bp-list]").on("click","[data-bp-pagination] a",this,this.paginateAction),f(document).on("click",this.closePickersOnClick),document.addEventListener("keydown",this.closePickersOnEsc),f(document).on("click","#item-header a.position-change-cover-image, .header-cover-reposition-wrap a.cover-image-save, .header-cover-reposition-wrap a.cover-image-cancel",this.coverPhotoCropper),f(document).on("click","#cover-photo-alert .bb-model-close-button",this.coverPhotoCropperAlert),f(document).on("click",this.toggleMoreOption.bind(this)),f(document).on("heartbeat-send",this.bbHeartbeatSend.bind(this)),f(document).on("heartbeat-tick",this.bbHeartbeatTick.bind(this)),f(document).on("click",this.toggleActivityOption.bind(this)),bp.Nouveau.notificationRemovedAction(),bp.Nouveau.removeAllNotification(),bp.Nouveau.setTitle(),f(document).on("click",".more-following .count-more",this.bbWidgetMoreFollowing),f(".bb-accordion .bb-accordion_trigger").on("click",this.toggleAccordion),f(document).keydown(this.mediumFormAction.bind(this))},bbHeartbeatSend:function(e,t){t.onScreenNotifications=!0,f("#buddypress").trigger("bb_heartbeat_send",t)},bbHeartbeatTick:function(e,t){bp.Nouveau.bbInjectOnScreenNotifications(e,t)},bbInjectOnScreenNotifications:function(e,t){var i,a,o,n,s,r;"1"==f(".bb-onscreen-notification").data("enable")&&(void 0===t.on_screen_notifications&&""===t.on_screen_notifications||(i=f(".bb-onscreen-notification"),r=(a=i.find(".notification-list")).data("removed-items"),o=a.data("animated-items"),n=[],s=f(f.parseHTML(""+t.on_screen_notifications+"
")),f.each(r,function(e,t){t=s.find("[data-notification-id="+t+"]");t.length&&t.closest(".read-item").remove()}),(r=s.find(".read-item")).each(function(e,t){var i=f(t).find(".actions .action-close").data("notification-id");"-1"==f.inArray(i,o)?(f(t).addClass("pull-animation"),o.push(i),n.push(i)):f(t).removeClass("pull-animation")}),n.length&&r.each(function(e,t){var i=f(t).find(".actions .action-close").data("notification-id");"-1"==f.inArray(i,n)&&(f(t).removeClass("recent-item"),(t=a.data("border-items")).push(i),a.attr("data-border-items",JSON.stringify(t)))}),a.attr("data-animated-items",JSON.stringify(o)),r.length&&(i.removeClass("close-all-items"),r.eq(2).nextAll().addClass("bb-more-item"),3 li").each(function(){f(this).removeClass("pull-animation").addClass("close-item").delay(500).remove()}),f(".toast-messages-list > li").each(function(){f(this).removeClass("pull-animation").addClass("close-item").delay(500).remove()}),t.removeClass("bb-more-than-3")})},setTitle:function(){var e=f("html head").find("title").text();f(".bb-onscreen-notification").attr("data-title-tag",e)},visibilityOnScreenClearButton:function(){var e=f(".bb-onscreen-notification");1 tbody > tr").each(function(){f(this).find('input[type="text"]').removeAttr("style"),f(this).find('input[type="email"]').removeAttr("style")}),f("body.send-invites #send-invite-form #member-invites-table > tbody > tr").each(function(){e=f.trim(f(this).find('input[type="text"]').val()),i=f(this).find("input").attr("id"),t=f.trim(f(this).find('input[type="email"]').val()),""===e&&""===t?0:""!==e&&""===t?(i=f(this).find('input[type="email"]').attr("id"),a.push(i)):""===e&&""!==t?(i=f(this).find('input[type="text"]').attr("id"),a.push(i)):l.test(t)?o.push(1):(i=f(this).find('input[type="email"]').attr("id"),a.push(i))}),f(".span_error").remove(),0!==a.length)return a.forEach(function(e){f("#"+e).attr("style","border:1px solid #ef3e46"),-1!==e.indexOf("email_")?f("#"+e).after(''+p+""):f("#"+e).after(''+c+"")}),f("html, body").animate({scrollTop:f("#item-body").offset().top},2e3),alert(u),!1;if(f("#email_0_email_error").length&&f("#email_0_email_error").remove(),0===o.length){n=f("#invitee_0_title").val(),s=f("#email_0_email").val();return""===n&&""===s?(f("#invitee_0_title").attr("style","border:1px solid #ef3e46"),f("#invitee_0_title").focus(),f("#email_0_email").attr("style","border:1px solid #ef3e46"),!1):(""!==n&&""===s?(f("#email_0_email").attr("style","border:1px solid #ef3e46"),f("#email_0_email").focus()):(l.test(s)||(f("#email_0_email").attr("style","border:1px solid #ef3e46"),f("#email_0_email").focus(),f("#email_0_email_error").remove(),f("#email_0_email").after(''+p+"")),alert(u)),!1)}})},sendInvitesRevokeAccess:function(){f("body.sent-invites #member-invites-table").length&&f("body.sent-invites #member-invites-table tr td span a.revoked-access").click(function(e){e.preventDefault();var t=f(this).attr("data-name"),i=f(this).attr("id"),e=f(this).attr("data-revoke-access");if(!confirm(t))return!1;f.ajax({url:e,type:"post",data:{item_id:i},success:function(){window.location.reload(!0)}})})},toggleDisabledInput:function(){var e=f(this).attr("data-bp-disable-input");f(e).prop("disabled",!0)&&!f(this).hasClass("enabled")?(f(this).addClass("enabled").removeClass("disabled"),f(e).prop("disabled",!1)):f(e).prop("disabled",!1)&&f(this).hasClass("enabled")&&(f(this).removeClass("enabled").addClass("disabled"),f(e).attr("disabled","disabled"))},keyUp:function(e){var t=e.data;27===e.keyCode&&t.buttonRevertAll()},scopeQuery:function(e){var t,i,a=e.data,o=f(e.currentTarget).parent(),n="",s=null,r={};if(o.hasClass("no-ajax")||f(e.currentTarget).hasClass("no-ajax")||!o.attr("data-bp-scope"))return e;if(t=o.data("bp-scope"),i=o.data("bp-object"),!t||!i)return e;e.preventDefault();var e=a.getStorage("bp-"+i);void 0!==e.extras&&"notifications"!==i&&(s=e.extras),e=f("#buddypress").find('[data-bp-filter="'+i+'"]').first().val(),f('#buddypress [data-bp-search="'+i+'"] input[type=search]').length&&(n=f('#buddypress [data-bp-search="'+i+'"] input[type=search]').val()),o.hasClass("dynamic")&&o.find("a span").html(""),r={object:i,scope:t,filter:e,search_terms:n,page:1,extras:s},f('#buddypress [data-bp-member-type-filter="'+i+'"]').length?r.member_type_id=f('#buddypress [data-bp-member-type-filter="'+i+'"]').val():f('#buddypress [data-bp-group-type-filter="'+i+'"]').length&&(r.group_type=f('#buddypress [data-bp-group-type-filter="'+i+'"]').val()),a.objectRequest(r)},filterQuery:function(e){var t=e.data,i=f(e.target).data("bp-filter"),a="all",o=f(e.target).val(),n="",s=!1;if(!i)return e;f(t.objectNavParent+" [data-bp-object].selected").length&&(a=f(t.objectNavParent+" [data-bp-object].selected").data("bp-scope")),f('#buddypress [data-bp-search="'+i+'"] input[type=search]').length&&(n=f('#buddypress [data-bp-search="'+i+'"] input[type=search]').val());e=t.getStorage("bp-"+(i="friends"===i?"members":i));void 0!==e.extras&&"notifications"!==i&&(s=e.extras),"members"===i?t.objectRequest({object:i,scope:a,filter:o,search_terms:n,page:1,extras:s,template:null,member_type_id:f('#buddypress [data-bp-member-type-filter="'+i+'"]').val()}):"groups"===i?t.objectRequest({object:i,scope:a,filter:o,search_terms:n,page:1,extras:s,template:null,group_type:f('#buddypress [data-bp-group-type-filter="'+i+'"]').val()}):t.objectRequest({object:i,scope:a,filter:o,search_terms:n,page:1,extras:s,template:null})},typeGroupFilterQuery:function(e){var t=e.data,i=f(e.target).data("bp-group-type-filter"),a="all",o=null,n=null,s="";if(!i)return e;void 0!==(e=t.getStorage("bp-"+i)).extras&&"notifications"!==i&&(n=e.extras),f('#buddypress [data-bp-filter="'+i+'"]').length&&(void 0!==e.filter?(o=e.filter,f('#buddypress [data-bp-filter="'+i+'"] option[value="'+o+'"]').prop("selected",!0)):"-1"!==f('#buddypress [data-bp-filter="'+i+'"]').val()&&"0"!==f('#buddypress [data-bp-filter="'+i+'"]').val()&&(o=f('#buddypress [data-bp-filter="'+i+'"]').val())),f(t.objectNavParent+" [data-bp-object].selected").length&&(a=f(t.objectNavParent+" [data-bp-object].selected").data("bp-scope")),f('#buddypress [data-bp-search="'+i+'"] input[type=search]').length&&(s=f('#buddypress [data-bp-search="'+i+'"] input[type=search]').val()),t.objectRequest({object:i,scope:a,filter:o,search_terms:s,page:1,template:null,extras:n,group_type:f('#buddypress [data-bp-group-type-filter="'+i+'"]').val()})},typeMemberFilterQuery:function(e){var t=e.data,i=f(e.target).data("bp-member-type-filter"),a="all",o=null,n=null,s="";if(!i)return e;void 0!==(e=t.getStorage("bp-"+(i="friends"===i?"members":i))).extras&&"notifications"!==i&&(n=e.extras),f('#buddypress [data-bp-filter="'+i+'"]').length&&(void 0!==e.filter?(o=e.filter,f('#buddypress [data-bp-filter="'+i+'"] option[value="'+o+'"]').prop("selected",!0)):"-1"!==f('#buddypress [data-bp-filter="'+i+'"]').val()&&"0"!==f('#buddypress [data-bp-filter="'+i+'"]').val()&&(o=f('#buddypress [data-bp-filter="'+i+'"]').val())),f(t.objectNavParent+" [data-bp-object].selected").length&&(a=f(t.objectNavParent+" [data-bp-object].selected").data("bp-scope")),f('#buddypress [data-bp-search="'+i+'"] input[type=search]').length&&(s=f('#buddypress [data-bp-search="'+i+'"] input[type=search]').val()),t.objectRequest({object:i,scope:a,filter:o,search_terms:s,page:1,template:null,extras:n,member_type_id:f('#buddypress [data-bp-member-type-filter="'+i+'"]').val()})},searchQuery:function(e){var t,i,a,o=e.data,n="all",s=!1;if(f(e.delegateTarget).hasClass("no-ajax")||void 0===f(e.delegateTarget).data("bp-search"))return e;e.preventDefault(),t=f(e.delegateTarget).data("bp-search"),i=f("#buddypress").find('[data-bp-filter="'+t+'"]').first().val(),a=f(e.delegateTarget).find("input[type=search]").first().val(),f(o.objectNavParent+" [data-bp-object]").length&&(n=f(o.objectNavParent+' [data-bp-object="'+t+'"].selected').data("bp-scope"));e=o.getStorage("bp-"+t);void 0!==e.extras&&"notifications"!==t&&(s=e.extras),o.objectRequest({object:t,scope:n,filter:i,search_terms:a,page:1,extras:s,template:null})},showSearchSubmit:function(e){f(e.delegateTarget).find("[type=submit]").addClass("bp-show"),f("[type=submit]").hasClass("bp-hide")&&f("[type=submit]").removeClass("bp-hide")},resetSearch:function(e){f(e.target).val()?f(e.delegateTarget).find("[type=submit]").show():f(e.delegateTarget).submit()},buttonAction:function(e){var a=e.data,o=f(e.currentTarget),n=o.data("bp-btn-action"),t=o.data("bp-nonce"),s=o.closest("[data-bp-item-id]"),i=s.data("bp-item-id"),r=o.closest(".list-wrap"),d=s.data("bp-item-component"),l="",c=s.data("bp-used-to-component");if(!n||!i||!d)return e;if(e.preventDefault(),o.hasClass("bp-toggle-action-button"))return f(document.body).hasClass("buddyboss-theme")&&void 0!==o.data("balloon")?o.attr("data-balloon",o.data("title")):o.text(o.data("title")),o.removeClass("bp-toggle-action-button"),o.addClass("bp-toggle-action-button-clicked"),!1;if(void 0!==o.data("only-admin"))return void 0!==BP_Nouveau.only_admin_notice&&window.alert(BP_Nouveau.only_admin_notice),!1;if("is_friend"!==n&&(void 0!==BP_Nouveau[n+"_confirm"]&&!1===window.confirm(BP_Nouveau[n+"_confirm"])||o.hasClass("pending")))return!1;var p=f(".bb-leave-group-popup"),u=f(o).data("bb-group-name"),b=f(o).data("bb-group-link");if("leave_group"===n&&"true"!==f(o).attr("data-popup-shown")){if(p.length){var m=p.find(".bb-leave-group-content"),e=!!s.hasClass("has-child");return m.html(e?BP_Nouveau.parent_group_leave_confirm:BP_Nouveau.group_leave_confirm),e||m.find(".bb-group-name").html(''+u+""),f("body").find('[data-current-anchor="true"]').removeClass("bp-toggle-action-button bp-toggle-action-button-hover").addClass("bp-toggle-action-button-clicked"),p.show(),f(o).attr("data-current-anchor","true"),f(o).attr("data-popup-shown","true"),!1}}else f("body").find('[data-popup-shown="true"]').attr("data-popup-shown","false"),f("body").find('[data-current-anchor="true"]').attr("data-current-anchor","false"),p.find(".bb-leave-group-content .bb-group-name").html(""),p.hide();b={};f(o).closest("#item-header").length?b=f("#item-header .bb-remove-connection"):f(o).closest('.members[data-bp-list="members"]').length?b=f('.members[data-bp-list="members"] .bb-remove-connection'):f(o).closest('.group_members[data-bp-list="group_members"]').length&&(b=f('.group_members[data-bp-list="group_members"] .bb-remove-connection'));u=f(o).data("bb-user-name"),p=f(o).data("bb-user-link");if("is_friend"===n&&"opened"!==f(o).attr("data-popup-shown")){if(b.length)return b.find(".bb-remove-connection-content .bb-user-name").html(''+u+""),f("body").find('[data-current-anchor="true"]').removeClass("bp-toggle-action-button bp-toggle-action-button-hover").addClass("bp-toggle-action-button-clicked"),b.show(),f(o).attr("data-current-anchor","true"),f(o).attr("data-popup-shown","opened"),!1}else f("body").find('[data-popup-shown="opened"]').attr("data-popup-shown","closed"),f("body").find('[data-current-anchor="true"]').attr("data-current-anchor","false"),b.length&&(b.find(".bb-remove-connection-content .bb-user-name").html(""),b.hide());l=t?a.getLinkParams(t,"_wpnonce"):void 0===o.prop("href")?a.getLinkParams(o.attr("href"),"_wpnonce"):a.getLinkParams(o.prop("href"),"_wpnonce"),u={is_friend:"remove_friend",not_friends:"add_friend",pending:"withdraw_friendship",accept_friendship:"accept_friendship",reject_friendship:"reject_friendship"};"members"===d&&void 0!==u[n]&&(n=u[n],d="friends");b={not_following:"follow",following:"unfollow"};"members"===d&&void 0!==b[n]&&(n=b[n],d="follow"),o.addClass("pending loading");t="";f(document.body).hasClass("directory")&&f(document.body).hasClass("members")||f(document.body).hasClass("group-members")?t="directory":f(document.body).hasClass("bp-user")&&(t="single");u="primary",b="single"===t?o.closest(".header-dropdown"):o.closest(".footer-button-wrap");void 0!==b.length&&0"+e.data.feedback+"","info",null,!0])}var t,i;return(f("#friends-personal-li").length&&(i=f("#friends-personal-li a span"),t=f("#friends-personal-li a"),(void 0!==e.data.is_user&&e.data.is_user&&void 0!==e.data.friend_count||void 0!==e.data.friend_count)&&("0"!==e.data.friend_count?i.length?f(i).html(e.data.friend_count):f(t).append(''+e.data.friend_count+""):f(i).hide())),void 0!==e.data.is_user&&e.data.is_user)?(o.parent().html(e.data.feedback),void s.fadeOut(1500)):void 0!==e.data.is_user&&!e.data.is_user&&void 0!==e.data.group_url&&e.data.group_url?window.location=e.data.group_url:(f(a.objectNavParent+' [data-bp-scope="personal"]').length&&(i=Number(f(a.objectNavParent+' [data-bp-scope="personal"] span').html())||0,-1!==f.inArray(n,["leave_group","remove_friend"])?--i:-1!==f.inArray(n,["join_group"])&&(i+=1),i<0&&(i=0),f(a.objectNavParent+' [data-bp-scope="personal"] span').html(i)),"follow"===d&&0"+e.data.feedback+"","error",null,!0])}).fail(function(){var e,t;["unsubscribe","subscribe"].includes(n)&&(25<(e=f(o).data("bb-group-name")).length&&(e=e.substring(0,25)+"..."),t=""+BP_Nouveau.subscriptions.error+""+e+".
","subscribe"===n&&(t=""+BP_Nouveau.subscriptions.subscribe_error+""+e+"
"),jQuery(document).trigger("bb_trigger_toast_message",["",t,"error",null,!0])),o.removeClass("pending loading")})},buttonRevert:function(e){e=f(e.currentTarget);e.hasClass("bp-toggle-action-button-clicked")&&!e.hasClass("loading")&&(f(document.body).hasClass("buddyboss-theme")&&void 0!==e.data("balloon")?e.attr("data-balloon",e.data("title-displayed")):e.text(e.data("title-displayed")),e.removeClass("bp-toggle-action-button-clicked"),e.addClass("bp-toggle-action-button"))},buttonHover:function(e){var t=f(e.currentTarget),i=t.data("bp-btn-action"),a=t.closest("[data-bp-item-id]"),o=a.data("bp-item-id"),a=a.data("bp-item-component");return i&&o&&a?(e.preventDefault(),t.hasClass("bp-toggle-action-button")?(t.hasClass("group-subscription")&&void 0!==t.data("title")&&void 0!==t.data("title-displayed")&&0===t.data("title").replace(/<(.|\n)*?>/g,"").length&&0===t.data("title-displayed").replace(/<(.|\n)*?>/g,"").length||(f(document.body).hasClass("buddyboss-theme")&&void 0!==t.data("balloon")&&(t.hasClass("following")||t.attr("data-balloon",t.data("title").replace(/<(.|\n)*?>/g,"")),t.find("span").html(t.data("title"))),t.html(t.data("title"))),t.removeClass("bp-toggle-action-button"),t.addClass("bp-toggle-action-button-hover"),!1):void 0):e},buttonHoverout:function(e){e=f(e.currentTarget);if(e.hasClass("bp-toggle-action-button-hover")&&!e.hasClass("loading")){if(e.hasClass("group-subscription")&&void 0!==e.data("title")&&void 0!==e.data("title-displayed")&&0===e.data("title").replace(/<(.|\n)*?>/g,"").length&&0===e.data("title-displayed").replace(/<(.|\n)*?>/g,"").length)return e.removeClass("bp-toggle-action-button-hover"),e.addClass("bp-toggle-action-button"),!1;f(document.body).hasClass("buddyboss-theme")&&void 0!==e.data("balloon")&&(e.hasClass("following")||e.attr("data-balloon",e.data("title-displayed").replace(/<(.|\n)*?>/g,"")),e.find("span").html(e.data("title-displayed"))),e.html(e.data("title-displayed")),e.removeClass("bp-toggle-action-button-hover"),e.addClass("bp-toggle-action-button")}},awaitingButtonHover:function(e){var t=f(e.currentTarget);if(e.preventDefault(),t.hasClass("bp-toggle-action-button"))return f(document.body).hasClass("buddyboss-theme")&&void 0!==t.data("balloon")&&(t.hasClass("following")||t.attr("data-balloon",t.data("title").replace(/<(.|\n)*?>/g,"")),t.find("span").html(t.data("title"))),t.html(t.data("title")),t.removeClass("bp-toggle-action-button"),t.addClass("bp-toggle-action-button-hover"),!1},awaitingButtonHoverout:function(e){e=f(e.currentTarget);e.hasClass("bp-toggle-action-button-hover")&&!e.hasClass("loading")&&(f(document.body).hasClass("buddyboss-theme")&&void 0!==e.data("balloon")&&(e.hasClass("following")||e.attr("data-balloon",e.data("title-displayed").replace(/<(.|\n)*?>/g,"")),e.find("span").html(e.data("title-displayed"))),e.html(e.data("title-displayed")),e.removeClass("bp-toggle-action-button-hover"),e.addClass("bp-toggle-action-button"))},leaveGroupAction:function(e){e.preventDefault(),f("body").find('[data-current-anchor="true"]').removeClass("bp-toggle-action-button bp-toggle-action-button-hover").addClass("bp-toggle-action-button-clicked"),f("body").find('[data-current-anchor="true"]').trigger("click")},leaveGroupClose:function(e){e.preventDefault();e=f(e.currentTarget),e=f(e).closest(".bb-leave-group-popup");f("body").find('[data-current-anchor="true"]').attr("data-current-anchor","false"),f("body").find('[data-popup-shown="true"]').attr("data-popup-shown","false"),e.find(".bb-leave-group-content .bb-group-name").html(""),e.hide()},removeConnectionAction:function(e){e.preventDefault(),f("body").find('[data-current-anchor="true"]').removeClass("bp-toggle-action-button bp-toggle-action-button-hover").addClass("bp-toggle-action-button-clicked"),f("body").find('[data-current-anchor="true"]').trigger("click")},removeConnectionClose:function(e){e.preventDefault();e=f(e.currentTarget),e=f(e).closest(".bb-remove-connection");f("body").find('[data-current-anchor="true"]').attr("data-current-anchor","false"),f("body").find('[data-popup-shown="opened"]').attr("data-popup-shown","closed"),e.find(".bb-remove-connection-content .bb-user-name").html(""),e.hide()},buttonRevertAll:function(){f.each(f("#buddypress [data-bp-btn-action]"),function(){f(this).hasClass("bp-toggle-action-button-clicked")&&!f(this).hasClass("loading")&&(f(document.body).hasClass("buddyboss-theme")&&void 0!==f(this).data("balloon")?f(this).attr("data-balloon",f(this).data("title-displayed")):f(this).text(f(this).data("title-displayed")),f(this).removeClass("bp-toggle-action-button-clicked"),f(this).addClass("bp-toggle-action-button"),f(this).trigger("blur"))})},addRemoveInvite:function(e){var t=e.currentTarget,i=f(t).closest("tbody");if(f(t).hasClass("field-actions-remove")){if(!(1"+e+"").insertBefore(f(this).closest("tr")),20 input").attr("name","invitee["+e+"][]"),f(this).find(".field-name > input").attr("id","invitee_"+e+"_title"),f(this).find(".field-email > input").attr("name","email["+e+"][]"),f(this).find(".field-email > input").attr("id","email_"+e+"_email"),f(this).find(".field-member-type > select").attr("name","member-type["+e+"][]"),f(this).find(".field-member-type > select").attr("id","member_type_"+e+"_member_type")})},closeNotice:function(e){var t=f(e.currentTarget);e.preventDefault(),"clear"===t.data("bp-close")&&(void 0!==f.cookie("bp-message")&&f.removeCookie("bp-message"),void 0!==f.cookie("bp-message-type")&&f.removeCookie("bp-message-type")),t.closest(".bp-feedback").hasClass("bp-sitewide-notice")&&bp.Nouveau.ajax({action:"messages_dismiss_sitewide_notice"},"messages"),t.closest(".bp-feedback").remove()},paginateAction:function(e){var t,i=e.data,a=f(e.currentTarget),o=null,n=null,s=null,r=null,d=a.closest("[data-bp-pagination]").data("bp-pagination")||null;if(null===d)return e;e.preventDefault(),null!==(e=f(e.delegateTarget).data("bp-list")||null)&&(void 0!==(t=i.getStorage("bp-"+e)).scope&&(o=t.scope),void 0!==t.filter&&(n=t.filter),void 0!==t.extras&&(r=t.extras)),null!==e&&(void 0!==(t=i.getStorage("bp-"+e)).scope&&(o=t.scope),void 0!==t.filter&&(n=t.filter),void 0!==t.extras&&(r=t.extras));d={object:e,scope:o,filter:n,search_terms:s=f('#buddypress [data-bp-search="'+e+'"] input[type=search]').length?f('#buddypress [data-bp-search="'+e+'"] input[type=search]').val():s,extras:r,caller:a.closest("[data-bp-pagination]").hasClass("bottom")?"pag-bottom":"",page:i.getLinkParams(a.prop("href"),d)||1};f("#buddypress [data-bp-group-type-filter]").length&&(d.group_type=f("#buddypress [data-bp-group-type-filter]").val()),f("#buddypress [data-bp-member-type-filter]").length&&(d.member_type_id=f("#buddypress [data-bp-member-type-filter]").val()),i.objectRequest(d)},enableSubmitOnLegalAgreement:function(){f("body #buddypress #register-page #signup-form #legal_agreement").length&&(f("body #buddypress #register-page #signup-form .submit #signup_submit").prop("disabled",!0),f(document).on("change","body #buddypress #register-page #signup-form #legal_agreement",function(){f(this).prop("checked")?f("body #buddypress #register-page #signup-form .submit #signup_submit").prop("disabled",!1):f("body #buddypress #register-page #signup-form .submit #signup_submit").prop("disabled",!0)}))},registerPopUp:function(){f(".popup-modal-register").length&&f(".popup-modal-register").magnificPopup({type:"inline",preloader:!1,fixedBgPos:!0,fixedContentPos:!0}),f(".popup-modal-dismiss").length&&f(".popup-modal-dismiss").click(function(e){e.preventDefault(),f.magnificPopup.close()})},loginPopUp:function(){f(".popup-modal-login").length&&f(".popup-modal-login").magnificPopup({type:"inline",preloader:!1,fixedBgPos:!0,fixedContentPos:!0}),f(".popup-modal-dismiss").length&&f(".popup-modal-dismiss").click(function(e){e.preventDefault(),f.magnificPopup.close()})},threadListBlockPopup:function(e){e.preventDefault();var t=f(this).data("bp-content-id"),i=f(this).data("bp-content-type"),a=f(this).data("bp-nonce"),o=f(this).attr("href");void 0!==t&&void 0!==i&&void 0!==a&&(f(document).find(".bp-report-form-err").empty(),(e=f(o)).find(".bp-content-id").val(t),e.find(".bp-content-type").val(i),e.find(".bp-nonce").val(a)),0