ajax_querystring = 'type=' . $filter . '&page=' . $page; if ( !empty( $search_terms ) ) $bp->ajax_querystring .= '&search_terms=' . $search_terms; if ( $scope == 'personal' || $bp->displayed_user->id ) { $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id; $bp->ajax_querystring .= '&user_id=' . $user_id; } $bp->ajax_querystring = apply_filters( 'bp_dtheme_ajax_querystring_content_filter', $bp->ajax_querystring, $extras ); locate_template( array( "$object/$object-loop.php" ), true ); } add_action( 'wp_ajax_members_filter', 'bp_dtheme_object_filter' ); add_action( 'wp_ajax_groups_filter', 'bp_dtheme_object_filter' ); add_action( 'wp_ajax_blogs_filter', 'bp_dtheme_object_filter' ); add_action( 'wp_ajax_forums_filter', 'bp_dtheme_object_filter' ); function bp_dtheme_post_update() { global $bp; /* Check the nonce */ check_admin_referer( 'post_update', '_wpnonce_post_update' ); if ( !is_user_logged_in() ) { echo '-1'; return false; } if ( empty( $_POST['content'] ) ) { echo '-1
' . __( 'Please enter some content to post.', 'buddypress' ) . '
' . __( 'There was a problem posting your update, please try again.', 'buddypress' ) . '
' . __( 'Please do not leave the comment area blank.', 'buddypress' ) . '
'; return false; } if ( empty( $_POST['form_id'] ) || empty( $_POST['comment_id'] ) || !is_numeric( $_POST['form_id'] ) || !is_numeric( $_POST['comment_id'] ) ) { echo '-1' . __( 'There was an error posting that reply, please try again.', 'buddypress' ) . '
' . __( 'There was an error posting that reply, please try again.', 'buddypress' ) . '
' . __( 'There was a problem when deleting. Please try again.', 'buddypress' ) . '
'; return false; } return true; } add_action( 'wp_ajax_delete_activity_comment', 'bp_dtheme_delete_activity' ); add_action( 'wp_ajax_delete_activity', 'bp_dtheme_delete_activity' ); function bp_dtheme_activity_loop( $scope = 'all', $filter = false, $query_string = false, $per_page = 20, $page = 1 ) { global $bp; if ( !$query_string ) { /* If we are on a profile page we only want to show that users activity */ if ( $bp->displayed_user->id ) { $query_string = 'user_id=' . $bp->displayed_user->id; } else { /* Make sure a scope is set. */ if ( empty($scope) ) $type = 'all'; $feed_url = site_url( BP_ACTIVITY_SLUG . '/feed/' ); switch ( $scope ) { case 'friends': $friend_ids = implode( ',', friends_get_friend_user_ids( $bp->loggedin_user->id ) ); $query_string = 'user_id=' . $friend_ids; $feed_url = $bp->loggedin_user->domain . BP_ACTIVITY_SLUG . '/my-friends/feed/'; break; case 'groups': $groups = groups_get_user_groups( $bp->loggedin_user->id ); $group_ids = implode( ',', $groups['groups'] ); $query_string = 'object=groups&primary_id=' . $group_ids . '&show_hidden=1'; $feed_url = $bp->loggedin_user->domain . BP_ACTIVITY_SLUG . '/my-groups/feed/'; break; case 'favorites': $favs = bp_activity_get_user_favorites( $bp->loggedin_user->id ); if ( empty( $favs ) ) $favorite_ids = false; $favorite_ids = implode( ',', (array)$favs ); $query_string = 'include=' . $favorite_ids; $feed_url = $bp->loggedin_user->domain . BP_ACTIVITY_SLUG . '/favorites/feed/'; break; case 'atme': $query_string = 'search_terms=@' . bp_core_get_username( $bp->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login ); $feed_url = $bp->loggedin_user->domain . BP_ACTIVITY_SLUG . '/mentions/feed/'; /* Reset the number of new @ mentions for the user */ delete_usermeta( $bp->loggedin_user->id, 'bp_new_mention_count' ); break; } } /* Build the filter */ if ( $filter && $filter != '-1' ) $query_string .= '&action=' . $filter; /* If we are viewing a group then filter the activity just for this group */ if ( $bp->groups->current_group ) { $query_string .= '&object=' . $bp->groups->id . '&primary_id=' . $bp->groups->current_group->id; /* If we're viewing a non-private group and the user is a member, show the hidden activity for the group */ if ( 'public' != $bp->groups->current_group->status && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) $query_string .= '&show_hidden=1'; } /* Add the per_page param */ $query_string .= '&per_page=' . $per_page; /* Add the comments param */ if ( $bp->displayed_user->id || 'atme' == $scope ) $query_string .= '&display_comments=stream'; else $query_string .= '&display_comments=threaded'; } /* Add the new page param */ $args = explode( '&', trim( $query_string ) ); foreach( $args as $arg ) { if ( false === strpos( $arg, 'page' ) ) $new_args[] = $arg; } $query_string = implode( '&', $new_args ) . '&page=' . $page; $bp->ajax_querystring = apply_filters( 'bp_dtheme_ajax_querystring_activity_filter', $query_string, $scope ); $result['query_string'] = $bp->ajax_querystring; $result['feed_url'] = apply_filters( 'bp_dtheme_ajax_feed_url', $feed_url ); /* Buffer the loop in the template to a var for JS to spit out. */ ob_start(); locate_template( array( 'activity/activity-loop.php' ), true ); $result['contents'] = ob_get_contents(); ob_end_clean(); echo json_encode( $result ); } function bp_dtheme_ajax_widget_filter() { bp_dtheme_activity_loop( $_POST['scope'], $_POST['filter'] ); } add_action( 'wp_ajax_activity_widget_filter', 'bp_dtheme_ajax_widget_filter' ); function bp_dtheme_ajax_load_older_updates() { bp_dtheme_activity_loop( false, false, $_POST['query_string'], 20, $_POST['page'] ); } add_action( 'wp_ajax_activity_get_older_updates', 'bp_dtheme_ajax_load_older_updates' ); function bp_dtheme_mark_activity_favorite() { global $bp; bp_activity_add_user_favorite( $_POST['id'] ); _e( 'Remove Favorite', 'buddypress' ); } add_action( 'wp_ajax_activity_mark_fav', 'bp_dtheme_mark_activity_favorite' ); function bp_dtheme_unmark_activity_favorite() { global $bp; bp_activity_remove_user_favorite( $_POST['id'] ); _e( 'Favorite', 'buddypress' ); } add_action( 'wp_ajax_activity_mark_unfav', 'bp_dtheme_unmark_activity_favorite' ); function bp_dtheme_ajax_invite_user() { global $bp; check_ajax_referer( 'groups_invite_uninvite_user' ); if ( !$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id'] ) return false; if ( !groups_is_user_admin( $bp->loggedin_user->id, $_POST['group_id'] ) ) return false; if ( !friends_check_friendship( $bp->loggedin_user->id, $_POST['friend_id'] ) ) return false; if ( 'invite' == $_POST['friend_action'] ) { if ( !groups_invite_user( array( 'user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id'] ) ) ) return false; $user = new BP_Core_User( $_POST['friend_id'] ); echo '" . __( 'There was a problem accepting that request. Please try again.', 'buddypress' ) . '
" . __( 'There was a problem rejecting that request. Please try again.', 'buddypress' ) . '
" . __('There was a problem closing the notice.', 'buddypress') . '
" . __( 'There was a problem sending that reply. Please try again.', 'buddypress' ) . '
'; } } add_action( 'wp_ajax_messages_send_reply', 'bp_dtheme_ajax_messages_send_reply' ); function bp_dtheme_ajax_message_markunread() { global $bp; if ( !isset($_POST['thread_ids']) ) { echo "-1" . __('There was a problem marking messages as unread.', 'buddypress' ) . '
" . __('There was a problem marking messages as read.', 'buddypress' ) . '