Skip to content
Snippets Groups Projects
Commit 0839b6c3 authored by root's avatar root Committed by lechuck
Browse files

updated buddypress to 1.5.3.1

parent 976299de
No related branches found
No related tags found
No related merge requests found
Showing
with 6091 additions and 366 deletions
<?php
/**
* Action functions are exactly the same as screen functions, however they do
* not have a template screen associated with them. Usually they will send the
* user back to the default screen after execution.
*
* @package BuddyPress
* @subpackage ActivityActions
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Allow core components and dependent plugins to register activity actions
*
* @since 1.2.0
*
* @uses do_action() To call 'bp_register_activity_actions' hook.
*/
function bp_register_activity_actions() {
do_action( 'bp_register_activity_actions' );
}
add_action( 'bp_init', 'bp_register_activity_actions', 8 );
/**
* Allow core components and dependent plugins to register activity actions
*
* @since 1.2.0
*
* @global object $bp BuddyPress global settings
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
* @uses bp_action_variable()
* @uses bp_activity_get_specific()
* @uses bp_is_active()
* @uses bp_core_get_user_domain()
* @uses groups_get_group()
* @uses bp_get_group_permalink()
* @uses apply_filters_ref_array() To call the 'bp_activity_permalink_redirect_url' hook
* @uses bp_core_redirect()
* @uses bp_get_root_domain()
*
* @return bool False on failure
*/
function bp_activity_action_permalink_router() {
global $bp;
// Not viewing activity
if ( !bp_is_activity_component() || !bp_is_current_action( 'p' ) )
return false;
// No activity to display
if ( !bp_action_variable( 0 ) || !is_numeric( bp_action_variable( 0 ) ) )
return false;
// Get the activity details
$activity = bp_activity_get_specific( array( 'activity_ids' => bp_action_variable( 0 ), 'show_hidden' => true ) );
// 404 if activity does not exist
if ( empty( $activity['activities'][0] ) ) {
bp_do_404();
return;
} else {
$activity = $activity['activities'][0];
}
// Do not redirect at default
$redirect = false;
// Redirect based on the type of activity
if ( bp_is_active( 'groups' ) && $activity->component == $bp->groups->id ) {
// Activity is a user update
if ( !empty( $activity->user_id ) ) {
$redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
// Activity is something else
} else {
// Set redirect to group activity stream
if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
$redirect = bp_get_group_permalink( $group ) . bp_get_activity_slug() . '/' . $activity->id . '/';
}
}
// Set redirect to users' activity stream
} else {
$redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id;
}
// Allow redirect to be filtered
if ( !$redirect = apply_filters_ref_array( 'bp_activity_permalink_redirect_url', array( $redirect, &$activity ) ) )
bp_core_redirect( bp_get_root_domain() );
// Redirect to the actual activity permalink page
bp_core_redirect( $redirect );
}
add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
/**
* Delete specific activity item and redirect to previous page.
*
* @since 1.1.0
*
* @param int $activity_id Activity id to be deleted. Defaults to 0.
*
* @global object $bp BuddyPress global settings
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
* @uses bp_action_variable()
* @uses check_admin_referer()
* @uses bp_activity_user_can_delete()
* @uses do_action() Calls 'bp_activity_before_action_delete_activity' hook to allow actions to be taken before the activity is deleted.
* @uses bp_activity_delete()
* @uses bp_core_add_message()
* @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow actions to be taken after the activity is deleted.
* @uses bp_core_redirect()
*
* @return bool False on failure
*/
function bp_activity_action_delete_activity( $activity_id = 0 ) {
global $bp;
// Not viewing activity or action is not delete
if ( !bp_is_activity_component() || !bp_is_current_action( 'delete' ) )
return false;
if ( empty( $activity_id ) && bp_action_variable( 0 ) )
$activity_id = (int) bp_action_variable( 0 );
// Not viewing a specific activity item
if ( empty( $activity_id ) )
return false;
// Check the nonce
check_admin_referer( 'bp_activity_delete_link' );
// Load up the activity item
$activity = new BP_Activity_Activity( $activity_id );
// Check access
if ( empty( $activity->user_id ) || !bp_activity_user_can_delete( $activity ) )
return false;
// Call the action before the delete so plugins can still fetch information about it
do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id );
// Delete the activity item and provide user feedback
if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) )
bp_core_add_message( __( 'Activity deleted successfully', 'buddypress' ) );
else
bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
// Check for the redirect query arg, otherwise let WP handle things
if ( !empty( $_GET['redirect_to'] ) )
bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
else
bp_core_redirect( wp_get_referer() );
}
add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
/**
* Post user/group activity update.
*
* @since 1.2.0
*
* @global object $bp BuddyPress global settings
* @uses is_user_logged_in()
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
* @uses check_admin_referer()
* @uses apply_filters() To call 'bp_activity_post_update_content' hook.
* @uses apply_filters() To call 'bp_activity_post_update_object' hook.
* @uses apply_filters() To call 'bp_activity_post_update_item_id' hook.
* @uses bp_core_add_message()
* @uses bp_core_redirect()
* @uses bp_activity_post_update()
* @uses groups_post_update()
* @uses bp_core_redirect()
* @uses apply_filters() To call 'bp_activity_custom_update' hook.
*
* @return bool False on failure
*/
function bp_activity_action_post_update() {
global $bp;
// Do not proceed if user is not logged in, not viewing activity, or not posting
if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) )
return false;
// Check the nonce
check_admin_referer( 'post_update', '_wpnonce_post_update' );
// Get activity info
$content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
$object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
$item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
// No activity content so provide feedback and redirect
if ( empty( $content ) ) {
bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' );
bp_core_redirect( wp_get_referer() );
}
// No existing item_id
if ( empty( $item_id ) ) {
$activity_id = bp_activity_post_update( array( 'content' => $content ) );
// Post to groups object
} else if ( 'groups' == $object && bp_is_active( 'groups' ) ) {
if ( (int)$item_id ) {
$activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
}
// Special circumstance so let filters handle it
} else {
$activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );
}
// Provide user feedback
if ( !empty( $activity_id ) )
bp_core_add_message( __( 'Update Posted!', 'buddypress' ) );
else
bp_core_add_message( __( 'There was an error when posting your update, please try again.', 'buddypress' ), 'error' );
// Redirect
bp_core_redirect( wp_get_referer() );
}
add_action( 'bp_actions', 'bp_activity_action_post_update' );
/**
* Post new activity comment.
*
* @since 1.2.0
*
* @global object $bp BuddyPress global settings
* @uses is_user_logged_in()
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
* @uses check_admin_referer()
* @uses apply_filters() To call 'bp_activity_post_comment_activity_id' hook.
* @uses apply_filters() To call 'bp_activity_post_comment_content' hook.
* @uses bp_core_add_message()
* @uses bp_core_redirect()
* @uses bp_activity_new_comment()
* @uses wp_get_referer()
*
* @return bool False on failure
*/
function bp_activity_action_post_comment() {
global $bp;
if ( !is_user_logged_in() || ( bp_is_activity_component() ) || !bp_is_current_action( 'reply' ) )
return false;
// Check the nonce
check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
$activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] );
$content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] );
if ( empty( $content ) ) {
bp_core_add_message( __( 'Please do not leave the comment area blank.', 'buddypress' ), 'error' );
bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
}
$comment_id = bp_activity_new_comment( array(
'content' => $content,
'activity_id' => $activity_id,
'parent_id' => $parent_id
));
if ( !empty( $comment_id ) )
bp_core_add_message( __( 'Reply Posted!', 'buddypress' ) );
else
bp_core_add_message( __( 'There was an error posting that reply, please try again.', 'buddypress' ), 'error' );
bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
}
add_action( 'bp_actions', 'bp_activity_action_post_comment' );
/**
* Mark activity as favorite.
*
* @since 1.2.0
*
* @global object $bp BuddyPress global settings
* @uses is_user_logged_in()
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
* @uses check_admin_referer()
* @uses bp_activity_add_user_favorite()
* @uses bp_action_variable()
* @uses bp_core_add_message()
* @uses bp_core_redirect()
* @uses wp_get_referer()
*
* @return bool False on failure
*/
function bp_activity_action_mark_favorite() {
global $bp;
if ( !is_user_logged_in() || ( bp_is_activity_component() ) || !bp_is_current_action( 'favorite' ) )
return false;
// Check the nonce
check_admin_referer( 'mark_favorite' );
if ( bp_activity_add_user_favorite( bp_action_variable( 0 ) ) )
bp_core_add_message( __( 'Activity marked as favorite.', 'buddypress' ) );
else
bp_core_add_message( __( 'There was an error marking that activity as a favorite, please try again.', 'buddypress' ), 'error' );
bp_core_redirect( wp_get_referer() . '#activity-' . bp_action_variable( 0 ) );
}
add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
/**
* Remove activity from favorites.
*
* @since 1.2.0
*
* @global object $bp BuddyPress global settings
* @uses is_user_logged_in()
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
* @uses check_admin_referer()
* @uses bp_activity_remove_user_favorite()
* @uses bp_action_variable()
* @uses bp_core_add_message()
* @uses bp_core_redirect()
* @uses wp_get_referer()
*
* @return bool False on failure
*/
function bp_activity_action_remove_favorite() {
global $bp;
if ( !is_user_logged_in() || ( bp_is_activity_component() ) || !bp_is_current_action( 'unfavorite' ) )
return false;
// Check the nonce
check_admin_referer( 'unmark_favorite' );
if ( bp_activity_remove_user_favorite( bp_action_variable( 0 ) ) )
bp_core_add_message( __( 'Activity removed as favorite.', 'buddypress' ) );
else
bp_core_add_message( __( 'There was an error removing that activity as a favorite, please try again.', 'buddypress' ), 'error' );
bp_core_redirect( wp_get_referer() . '#activity-' . bp_action_variable( 0 ) );
}
add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
/**
* Load the sitewide feed.
*
* @since 1.0.0
*
* @global object $bp BuddyPress global settings
* @global object $wp_query
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
* @uses bp_is_user()
* @uses status_header()
*
* @return bool False on failure
*/
function bp_activity_action_sitewide_feed() {
global $bp, $wp_query;
if ( !bp_is_activity_component() || !bp_is_current_action( 'feed' ) || bp_is_user() || !empty( $bp->groups->current_group ) )
return false;
$wp_query->is_404 = false;
status_header( 200 );
include_once( 'feeds/bp-activity-sitewide-feed.php' );
die;
}
add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
/**
* Load a user's personal feed.
*
* @since 1.0.0
*
* @global object $bp BuddyPress global settings
* @global object $wp_query
* @uses bp_is_user_activity()
* @uses bp_is_current_action()
* @uses status_header()
*
* @return bool False on failure
*/
function bp_activity_action_personal_feed() {
global $bp, $wp_query;
if ( !bp_is_user_activity() || !bp_is_current_action( 'feed' ) )
return false;
$wp_query->is_404 = false;
status_header( 200 );
include_once( 'feeds/bp-activity-personal-feed.php' );
die;
}
add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
/**
* Load a user's friends feed.
*
* @since 1.0.0
*
* @global object $bp BuddyPress global settings
* @global object $wp_query
* @uses bp_is_active()
* @uses bp_is_user_activity()
* @uses bp_is_current_action()
* @uses bp_get_friends_slug()
* @uses bp_is_action_variable()
* @uses status_header()
*
* @return bool False on failure
*/
function bp_activity_action_friends_feed() {
global $bp, $wp_query;
if ( !bp_is_active( 'friends' ) || !bp_is_user_activity() || !bp_is_current_action( bp_get_friends_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
return false;
$wp_query->is_404 = false;
status_header( 200 );
include_once( 'feeds/bp-activity-friends-feed.php' );
die;
}
add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
/**
* Load a user's my groups feed.
*
* @since 1.2.0
*
* @global object $bp BuddyPress global settings
* @global object $wp_query
* @uses bp_is_active()
* @uses bp_is_user_activity()
* @uses bp_is_current_action()
* @uses bp_get_groups_slug()
* @uses bp_is_action_variable()
* @uses status_header()
*
* @return bool False on failure
*/
function bp_activity_action_my_groups_feed() {
global $bp, $wp_query;
if ( !bp_is_active( 'groups' ) || !bp_is_user_activity() || !bp_is_current_action( bp_get_groups_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
return false;
$wp_query->is_404 = false;
status_header( 200 );
include_once( 'feeds/bp-activity-mygroups-feed.php' );
die;
}
add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
/**
* Load a user's @mentions feed.
*
* @since 1.2.0
*
* @global object $bp BuddyPress global settings
* @global object $wp_query
* @uses bp_is_user_activity()
* @uses bp_is_current_action()
* @uses bp_is_action_variable()
* @uses status_header()
*
* @return bool False on failure
*/
function bp_activity_action_mentions_feed() {
global $bp, $wp_query;
if ( !bp_is_user_activity() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) )
return false;
$wp_query->is_404 = false;
status_header( 200 );
include_once( 'feeds/bp-activity-mentions-feed.php' );
die;
}
add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
/**
* Load a user's favorites feed.
*
* @since 1.2.0
*
* @global object $bp BuddyPress global settings
* @global object $wp_query
* @uses bp_is_user_activity()
* @uses bp_is_current_action()
* @uses bp_is_action_variable()
* @uses status_header()
*
* @return bool False on failure
*/
function bp_activity_action_favorites_feed() {
global $bp, $wp_query;
if ( !bp_is_user_activity() || !bp_is_current_action( 'favorites' ) || !bp_is_action_variable( 'feed', 0 ) )
return false;
$wp_query->is_404 = false;
status_header( 200 );
include_once( 'feeds/bp-activity-favorites-feed.php' );
die;
}
add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
?>
<?php
/* Apply WordPress defined filters */
/**
* The Activity filters
*
* @package BuddyPress
* @subpackage ActivityFilters
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
// Apply WordPress defined filters
add_filter( 'bp_get_activity_action', 'bp_activity_filter_kses', 1 );
add_filter( 'bp_get_activity_content_body', 'bp_activity_filter_kses', 1 );
add_filter( 'bp_get_activity_content', 'bp_activity_filter_kses', 1 );
......@@ -46,13 +56,13 @@ add_filter( 'bp_get_activity_content_body', 'wpautop' );
add_filter( 'bp_get_activity_content', 'wpautop' );
add_filter( 'bp_get_activity_feed_item_description', 'wpautop' );
add_filter( 'bp_get_activity_action', 'make_clickable' );
add_filter( 'bp_get_activity_content_body', 'make_clickable' );
add_filter( 'bp_get_activity_content', 'make_clickable' );
add_filter( 'bp_get_activity_parent_content', 'make_clickable' );
add_filter( 'bp_get_activity_latest_update', 'make_clickable' );
add_filter( 'bp_get_activity_latest_update_excerpt', 'make_clickable' );
add_filter( 'bp_get_activity_feed_item_description', 'make_clickable' );
add_filter( 'bp_get_activity_action', 'make_clickable', 9 );
add_filter( 'bp_get_activity_content_body', 'make_clickable', 9 );
add_filter( 'bp_get_activity_content', 'make_clickable', 9 );
add_filter( 'bp_get_activity_parent_content', 'make_clickable', 9 );
add_filter( 'bp_get_activity_latest_update', 'make_clickable', 9 );
add_filter( 'bp_get_activity_latest_update_excerpt', 'make_clickable', 9 );
add_filter( 'bp_get_activity_feed_item_description', 'make_clickable', 9 );
add_filter( 'bp_acomment_name', 'stripslashes_deep' );
add_filter( 'bp_get_activity_action', 'stripslashes_deep' );
......@@ -63,7 +73,7 @@ add_filter( 'bp_get_activity_latest_update', 'stripslashes_deep' );
add_filter( 'bp_get_activity_latest_update_excerpt', 'stripslashes_deep' );
add_filter( 'bp_get_activity_feed_item_description', 'stripslashes_deep' );
/* Apply BuddyPress defined filters */
// Apply BuddyPress defined filters
add_filter( 'bp_get_activity_content', 'bp_activity_make_nofollow_filter' );
add_filter( 'bp_get_activity_content_body', 'bp_activity_make_nofollow_filter' );
add_filter( 'bp_get_activity_parent_content', 'bp_activity_make_nofollow_filter' );
......@@ -71,12 +81,24 @@ add_filter( 'bp_get_activity_latest_update', 'bp_activity_make_nofollow_
add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_make_nofollow_filter' );
add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_make_nofollow_filter' );
add_filter( 'bp_get_activity_parent_content', 'bp_create_excerpt' );
add_filter( 'pre_comment_content', 'bp_activity_at_name_filter' );
add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' );
add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' );
/* Allow shortcodes in activity posts */
add_filter( 'bp_get_activity_content', 'do_shortcode' );
add_filter( 'bp_get_activity_content_body', 'do_shortcode' );
add_filter( 'bp_get_activity_parent_content', 'bp_create_excerpt' );
/**
* Custom kses filtering for activity content
*
* @since 1.1.0
*
* @param string $content The activity content
*
* @uses apply_filters() To call the 'bp_activity_allowed_tags' hook.
* @uses wp_kses()
*
* @return string $content Filtered activity content
*/
function bp_activity_filter_kses( $content ) {
global $allowedtags;
......@@ -87,6 +109,8 @@ function bp_activity_filter_kses( $content ) {
$activity_allowedtags['div']['class'] = array();
$activity_allowedtags['div']['id'] = array();
$activity_allowedtags['a']['class'] = array();
$activity_allowedtags['a']['id'] = array();
$activity_allowedtags['a']['rel'] = array();
$activity_allowedtags['img'] = array();
$activity_allowedtags['img']['src'] = array();
$activity_allowedtags['img']['alt'] = array();
......@@ -102,43 +126,143 @@ function bp_activity_filter_kses( $content ) {
return wp_kses( $content, $activity_allowedtags );
}
function bp_activity_at_name_filter( $content ) {
include_once( ABSPATH . WPINC . '/registration.php' );
$pattern = '/[@]+([A-Za-z0-9-_\.]+)/';
preg_match_all( $pattern, $content, $usernames );
// Make sure there's only one instance of each username
if ( !$usernames = array_unique( $usernames[1] ) )
return $content;
/**
* Finds and links @-mentioned users in the contents of activity items
*
* @since 1.2.0
*
* @param string $content The activity content
* @param int $activity_id The activity id
*
* @uses bp_activity_find_mentions()
* @uses bp_is_username_compatibility_mode()
* @uses bp_core_get_userid_from_nicename()
* @uses bp_activity_at_message_notification()
* @uses bp_core_get_user_domain()
* @uses bp_activity_adjust_mention_count()
*
* @return string $content Content filtered for mentions
*/
function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
$usernames = bp_activity_find_mentions( $content );
foreach( (array)$usernames as $username ) {
if ( !$user_id = username_exists( $username ) )
if ( bp_is_username_compatibility_mode() )
$user_id = username_exists( $username );
else
$user_id = bp_core_get_userid_from_nicename( $username );
if ( empty( $user_id ) )
continue;
// Increase the number of new @ mentions for the user
$new_mention_count = (int)get_user_meta( $user_id, 'bp_new_mention_count', true );
update_user_meta( $user_id, 'bp_new_mention_count', $new_mention_count + 1 );
// If an activity_id is provided, we can send email and BP notifications
if ( $activity_id ) {
bp_activity_at_message_notification( $activity_id, $user_id );
}
$content = str_replace( "@$username", "<a href='" . bp_core_get_user_domain( bp_core_get_userid( $username ) ) . "' rel='nofollow'>@$username</a>", $content );
$content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $content );
}
// Adjust the activity count for this item
if ( $activity_id )
bp_activity_adjust_mention_count( $activity_id, 'add' );
return $content;
}
add_filter( 'bp_activity_new_update_content', 'bp_activity_at_name_filter' );
add_filter( 'groups_activity_new_update_content', 'bp_activity_at_name_filter' );
add_filter( 'pre_comment_content', 'bp_activity_at_name_filter' );
add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' );
add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' );
add_filter( 'bp_activity_comment_content', 'bp_activity_at_name_filter' );
/**
* Catch mentions in saved activity items
*
* @since 1.5.0
*
* @param obj $activity
*
* @uses remove_filter() To remove the 'bp_activity_at_name_filter_updates' hook.
* @uses bp_activity_at_name_filter()
* @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
*/
function bp_activity_at_name_filter_updates( $activity ) {
// Only run this function once for a given activity item
remove_filter( 'bp_activity_after_save', 'bp_activity_at_name_filter_updates' );
// Run the content through the linking filter, making sure to increment mention count
$activity->content = bp_activity_at_name_filter( $activity->content, $activity->id );
// Resave the activity with the new content
$activity->save();
}
add_filter( 'bp_activity_after_save', 'bp_activity_at_name_filter_updates' );
/**
* Catches links in activity text so rel=nofollow can be added
*
* @since 1.2.0
*
* @param string $text Activity text
*
* @return string $text Text with rel=nofollow added to any links
*/
function bp_activity_make_nofollow_filter( $text ) {
return preg_replace_callback( '|<a (.+?)>|i', 'bp_activity_make_nofollow_filter_callback', $text );
}
/**
* Adds rel=nofollow to a link
*
* @since 1.2.0
*
* @param array $matches
*
* @return string $text Link with rel=nofollow added
*/
function bp_activity_make_nofollow_filter_callback( $matches ) {
$text = $matches[1];
$text = str_replace( array( ' rel="nofollow"', " rel='nofollow'"), '', $text );
return "<a $text rel=\"nofollow\">";
}
?>
/**
* Truncates long activity entries when viewed in activity streams
*
* @since 1.5.0
*
* @param $text The original activity entry text
*
* @uses bp_is_single_activity()
* @uses apply_filters() To call the 'bp_activity_excerpt_append_text' hook
* @uses apply_filters() To call the 'bp_activity_excerpt_length' hook
* @uses bp_create_excerpt()
* @uses bp_get_activity_id()
* @uses bp_get_activity_thread_permalink()
* @uses apply_filters() To call the 'bp_activity_truncate_entry' hook
*
* @return string $excerpt The truncated text
*/
function bp_activity_truncate_entry( $text ) {
global $activities_template;
// The full text of the activity update should always show on the single activity screen
if ( bp_is_single_activity() )
return $text;
$append_text = apply_filters( 'bp_activity_excerpt_append_text', __( '[Read more]', 'buddypress' ) );
$excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );
// Run the text through the excerpt function. If it's too short, the original text will be
// returned.
$excerpt = bp_create_excerpt( $text, $excerpt_length, array( 'ending' => __( '&hellip;', 'buddypress' ) ) );
// If the text returned by bp_create_excerpt() is different from the original text (ie it's
// been truncated), add the "Read More" link.
if ( $excerpt != $text ) {
$id = !empty( $activities_template->activity->current_comment->id ) ? 'acomment-read-more-' . $activities_template->activity->current_comment->id : 'activity-read-more-' . bp_get_activity_id();
$excerpt = sprintf( '%1$s<span class="activity-read-more" id="%2$s"><a href="%3$s" rel="nofollow">%4$s</a></span>', $excerpt, $id, bp_get_activity_thread_permalink(), $append_text );
}
return apply_filters( 'bp_activity_truncate_entry', $excerpt, $text, $append_text );
}
add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
add_filter( 'bp_get_activity_content', 'bp_activity_truncate_entry', 5 );
?>
\ No newline at end of file
This diff is collapsed.
<?php
/**
* BuddyPress Activity Streams Loader
*
* An activity stream component, for users, groups, and blog tracking.
*
* @package BuddyPress
* @subpackage ActivityCore
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Main Activity Class
*
* @since 1.5.0
*/
class BP_Activity_Component extends BP_Component {
/**
* Start the activity component creation process
*
* @since 1.5.0
*/
function BP_Activity_Component() {
$this->__construct();
}
function __construct() {
parent::start(
'activity',
__( 'Activity Streams', 'buddypress' ),
BP_PLUGIN_DIR
);
}
/**
* Include files
*
* @since 1.5.0
*/
function includes() {
// Files to include
$includes = array(
'actions',
'screens',
'filters',
'classes',
'template',
'functions',
'notifications',
);
parent::includes( $includes );
}
/**
* Setup globals
*
* The BP_ACTIVITY_SLUG constant is deprecated, and only used here for
* backwards compatibility.
*
* @since 1.5.0
*
* @global object $bp BuddyPress global settings
*/
function setup_globals() {
global $bp;
// Define a slug, if necessary
if ( !defined( 'BP_ACTIVITY_SLUG' ) )
define( 'BP_ACTIVITY_SLUG', $this->id );
// Global tables for activity component
$global_tables = array(
'table_name' => $bp->table_prefix . 'bp_activity',
'table_name_meta' => $bp->table_prefix . 'bp_activity_meta',
);
// All globals for activity component.
// Note that global_tables is included in this array.
$globals = array(
'path' => BP_PLUGIN_DIR,
'slug' => BP_ACTIVITY_SLUG,
'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,
'has_directory' => true,
'search_string' => __( 'Search Activity...', 'buddypress' ),
'global_tables' => $global_tables,
'notification_callback' => 'bp_activity_format_notifications',
);
parent::setup_globals( $globals );
}
/**
* Setup BuddyBar navigation
*
* @since 1.5.0
*
* @global object $bp BuddyPress global settings
* @uses bp_is_active()
* @uses is_user_logged_in()
* @uses bp_get_friends_slug()
* @uses bp_get_groups_slug()
*/
function setup_nav() {
global $bp;
// Add 'Activity' to the main navigation
$main_nav = array(
'name' => __( 'Activity', 'buddypress' ),
'slug' => $this->slug,
'position' => 10,
'screen_function' => 'bp_activity_screen_my_activity',
'default_subnav_slug' => 'just-me',
'item_css_id' => $this->id
);
// Stop if there is no user displayed or logged in
if ( !is_user_logged_in() && !isset( $bp->displayed_user->id ) )
return;
// Determine user to use
if ( isset( $bp->displayed_user->domain ) )
$user_domain = $bp->displayed_user->domain;
elseif ( isset( $bp->loggedin_user->domain ) )
$user_domain = $bp->loggedin_user->domain;
else
return;
// User link
$activity_link = trailingslashit( $user_domain . $this->slug );
// Add the subnav items to the activity nav item if we are using a theme that supports this
$sub_nav[] = array(
'name' => __( 'Personal', 'buddypress' ),
'slug' => 'just-me',
'parent_url' => $activity_link,
'parent_slug' => $this->slug,
'screen_function' => 'bp_activity_screen_my_activity',
'position' => 10
);
// @ mentions
$sub_nav[] = array(
'name' => __( 'Mentions', 'buddypress' ),
'slug' => 'mentions',
'parent_url' => $activity_link,
'parent_slug' => $this->slug,
'screen_function' => 'bp_activity_screen_mentions',
'position' => 20,
'item_css_id' => 'activity-mentions'
);
// Favorite activity items
$sub_nav[] = array(
'name' => __( 'Favorites', 'buddypress' ),
'slug' => 'favorites',
'parent_url' => $activity_link,
'parent_slug' => $this->slug,
'screen_function' => 'bp_activity_screen_favorites',
'position' => 30,
'item_css_id' => 'activity-favs'
);
// Additional menu if friends is active
if ( bp_is_active( 'friends' ) ) {
$sub_nav[] = array(
'name' => __( 'Friends', 'buddypress' ),
'slug' => bp_get_friends_slug(),
'parent_url' => $activity_link,
'parent_slug' => $this->slug,
'screen_function' => 'bp_activity_screen_friends',
'position' => 40,
'item_css_id' => 'activity-friends'
) ;
}
// Additional menu if groups is active
if ( bp_is_active( 'groups' ) ) {
$sub_nav[] = array(
'name' => __( 'Groups', 'buddypress' ),
'slug' => bp_get_groups_slug(),
'parent_url' => $activity_link,
'parent_slug' => $this->slug,
'screen_function' => 'bp_activity_screen_groups',
'position' => 50,
'item_css_id' => 'activity-groups'
);
}
parent::setup_nav( $main_nav, $sub_nav );
}
/**
* Set up the admin bar
*
* @since 1.5.0
*
* @global object $bp BuddyPress global settings
* @uses is_user_logged_in()
* @uses trailingslashit()
* @uses bp_get_total_mention_count_for_user()
* @uses bp_loggedin_user_id()
* @uses bp_is_active()
* @uses bp_get_friends_slug()
* @uses bp_get_groups_slug()
*/
function setup_admin_bar() {
global $bp;
// Prevent debug notices
$wp_admin_nav = array();
// Menus for logged in user
if ( is_user_logged_in() ) {
// Setup the logged in user variables
$user_domain = $bp->loggedin_user->domain;
$activity_link = trailingslashit( $user_domain . $this->slug );
// Unread message count
if ( $count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) {
$title = sprintf( __( 'Mentions <span class="count">%s</span>', 'buddypress' ), $count );
} else {
$title = __( 'Mentions', 'buddypress' );
}
// Add the "Activity" sub menu
$wp_admin_nav[] = array(
'parent' => $bp->my_account_menu_id,
'id' => 'my-account-' . $this->id,
'title' => __( 'Activity', 'buddypress' ),
'href' => trailingslashit( $activity_link )
);
// Mentions
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->id,
'id' => 'my-account-' . $this->id . '-mentions',
'title' => $title,
'href' => trailingslashit( $activity_link . 'mentions' )
);
// Personal
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->id,
'id' => 'my-account-' . $this->id . '-personal',
'title' => __( 'Personal', 'buddypress' ),
'href' => trailingslashit( $activity_link )
);
// Favorites
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->id,
'id' => 'my-account-' . $this->id . '-favorites',
'title' => __( 'Favorites', 'buddypress' ),
'href' => trailingslashit( $activity_link . 'favorites' )
);
// Friends?
if ( bp_is_active( 'friends' ) ) {
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->id,
'id' => 'my-account-' . $this->id . '-friends',
'title' => __( 'Friends', 'buddypress' ),
'href' => trailingslashit( $activity_link . bp_get_friends_slug() )
);
}
// Groups?
if ( bp_is_active( 'groups' ) ) {
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->id,
'id' => 'my-account-' . $this->id . '-groups',
'title' => __( 'Groups', 'buddypress' ),
'href' => trailingslashit( $activity_link . bp_get_groups_slug() )
);
}
}
parent::setup_admin_bar( $wp_admin_nav );
}
/**
* Sets up the title for pages and <title>
*
* @since 1.5.0
*
* @global object $bp BuddyPress global settings
* @uses bp_is_activity_component()
* @uses bp_is_my_profile()
* @uses bp_core_fetch_avatar()
*/
function setup_title() {
global $bp;
// Adjust title based on view
if ( bp_is_activity_component() ) {
if ( bp_is_my_profile() ) {
$bp->bp_options_title = __( 'My Activity', 'buddypress' );
} else {
$bp->bp_options_avatar = bp_core_fetch_avatar( array(
'item_id' => $bp->displayed_user->id,
'type' => 'thumb'
) );
$bp->bp_options_title = $bp->displayed_user->fullname;
}
}
parent::setup_title();
}
}
// Create the activity component
$bp->activity = new BP_Activity_Component();
?>
\ No newline at end of file
<?php
function bp_activity_at_message_notification( $content, $poster_user_id, $activity_id ) {
/**
* BuddyPress Activity Notifications
*
* @package BuddyPress
* @subpackage ActivityNotifications
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Sends an email notification and a BP notification when someone mentions you in an update
*
* @since 1.2.0
*
* @param int $activity_id The id of the activity update
* @param int $receiver_user_id The unique user_id of the user who is receiving the update
*
* @global object $bp BuddyPress global settings
* @uses bp_core_add_notification()
* @uses bp_get_user_meta()
* @uses bp_core_get_user_displayname()
* @uses bp_activity_get_permalink()
* @uses bp_core_get_user_domain()
* @uses bp_get_settings_slug()
* @uses bp_activity_filter_kses()
* @uses bp_core_get_core_userdata()
* @uses wp_specialchars_decode()
* @uses get_blog_option()
* @uses bp_is_active()
* @uses bp_is_group()
* @uses bp_get_current_group_name()
* @uses apply_filters() To call the 'bp_activity_at_message_notification_to' hook
* @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook
* @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook
* @uses wp_mail()
* @uses do_action() To call the 'bp_activity_sent_mention_email' hook
*/
function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
global $bp;
/* Scan for @username strings in an activity update. Notify each user. */
$pattern = '/[@]+([A-Za-z0-9-_\.]+)/';
preg_match_all( $pattern, $content, $usernames );
$activity = new BP_Activity_Activity( $activity_id );
/* Make sure there's only one instance of each username */
if ( !$usernames = array_unique( $usernames[1] ) )
return false;
$subject = '';
$message = '';
foreach( (array)$usernames as $username ) {
if ( !$receiver_user_id = bp_core_get_userid( $username ) )
continue;
// Add the BP notification
bp_core_add_notification( $activity_id, $receiver_user_id, 'activity', 'new_at_mention', $activity->user_id );
// Now email the user with the contents of the message (if they have enabled email notifications)
if ( 'no' != get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
$poster_name = bp_core_get_user_displayname( $poster_user_id );
// Now email the user with the contents of the message (if they have enabled email notifications)
if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
$poster_name = bp_core_get_user_displayname( $activity->user_id );
$message_link = bp_activity_get_permalink( $activity_id );
$settings_link = bp_core_get_user_domain( $receiver_user_id ) . BP_SETTINGS_SLUG . '/notifications/';
$message_link = bp_activity_get_permalink( $activity_id );
$settings_link = bp_core_get_user_domain( $receiver_user_id ) . bp_get_settings_slug() . '/notifications/';
$poster_name = stripslashes( $poster_name );
$content = bp_activity_filter_kses( stripslashes($content) );
$poster_name = stripslashes( $poster_name );
$content = bp_activity_filter_kses( strip_tags( stripslashes( $activity->content ) ) );
// Set up and send the message
$ud = bp_core_get_core_userdata( $receiver_user_id );
$to = $ud->user_email;
$sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
$subject = '[' . $sitename . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name );
// Set up and send the message
$ud = bp_core_get_core_userdata( $receiver_user_id );
$to = $ud->user_email;
$sitename = wp_specialchars_decode( get_blog_option( bp_get_root_blog_id(), 'blogname' ), ENT_QUOTES );
$subject = '[' . $sitename . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name );
$message = sprintf( __(
'%s mentioned you in an update:
if ( bp_is_active( 'groups' ) && bp_is_group() ) {
$message = sprintf( __(
'%1$s mentioned you in the group "%2$s":
"%s"
"%3$s"
To view and respond to the message, log in and visit: %s
To view and respond to the message, log in and visit: %4$s
---------------------
', 'buddypress' ), $poster_name, $content, $message_link );
', 'buddypress' ), $poster_name, bp_get_current_group_name(), $content, $message_link );
} else {
$message = sprintf( __(
'%1$s mentioned you in an update:
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
"%2$s"
/* Send the message */
$to = apply_filters( 'bp_activity_at_message_notification_to', $to );
$subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
$message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link );
To view and respond to the message, log in and visit: %3$s
wp_mail( $to, $subject, $message );
---------------------
', 'buddypress' ), $poster_name, $content, $message_link );
}
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
/* Send the message */
$to = apply_filters( 'bp_activity_at_message_notification_to', $to );
$subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
$message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link );
wp_mail( $to, $subject, $message );
}
do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content );
}
add_action( 'bp_activity_posted_update', 'bp_activity_at_message_notification', 10, 3 );
/**
* Sends an email notification and a BP notification when someone mentions you in an update
*
* @since 1.2.0
*
* @param int $comment_id The comment id
* @param int $commenter_id The unique user_id of the user who posted the comment
* @param array $params {@link bp_activity_new_comment()}
*
* @global object $bp BuddyPress global settings
* @uses bp_get_user_meta()
* @uses bp_core_get_user_displayname()
* @uses bp_activity_get_permalink()
* @uses bp_core_get_user_domain()
* @uses bp_get_settings_slug()
* @uses bp_activity_filter_kses()
* @uses bp_core_get_core_userdata()
* @uses wp_specialchars_decode()
* @uses get_blog_option()
* @uses bp_get_root_blog_id()
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook
* @uses wp_mail()
* @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook
* @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook
*/
function bp_activity_new_comment_notification( $comment_id, $commenter_id, $params ) {
global $bp;
......@@ -61,10 +137,10 @@ function bp_activity_new_comment_notification( $comment_id, $commenter_id, $para
$original_activity = new BP_Activity_Activity( $activity_id );
if ( $original_activity->user_id != $commenter_id && 'no' != get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) {
if ( $original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) {
$poster_name = bp_core_get_user_displayname( $commenter_id );
$thread_link = bp_activity_get_permalink( $activity_id );
$settings_link = bp_core_get_user_domain( $original_activity->user_id ) . BP_SETTINGS_SLUG . '/notifications/';
$settings_link = bp_core_get_user_domain( $original_activity->user_id ) . bp_get_settings_slug() . '/notifications/';
$poster_name = stripslashes( $poster_name );
$content = bp_activity_filter_kses( stripslashes($content) );
......@@ -72,15 +148,15 @@ function bp_activity_new_comment_notification( $comment_id, $commenter_id, $para
// Set up and send the message
$ud = bp_core_get_core_userdata( $original_activity->user_id );
$to = $ud->user_email;
$sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
$sitename = wp_specialchars_decode( get_blog_option( bp_get_root_blog_id(), 'blogname' ), ENT_QUOTES );
$subject = '[' . $sitename . '] ' . sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name );
$message = sprintf( __(
'%s replied to one of your updates:
'%1$s replied to one of your updates:
"%s"
"%2$s"
To view your original update and all comments, log in and visit: %s
To view your original update and all comments, log in and visit: %3$s
---------------------
', 'buddypress' ), $poster_name, $content, $thread_link );
......@@ -90,9 +166,11 @@ To view your original update and all comments, log in and visit: %s
/* Send the message */
$to = apply_filters( 'bp_activity_new_comment_notification_to', $to );
$subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name );
$message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link );
$message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link );
wp_mail( $to, $subject, $message );
do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
}
/***
......@@ -104,26 +182,26 @@ To view your original update and all comments, log in and visit: %s
$parent_comment = new BP_Activity_Activity( $parent_id );
if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) {
if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != bp_get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) {
$poster_name = bp_core_get_user_displayname( $commenter_id );
$thread_link = bp_activity_get_permalink( $activity_id );
$settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . BP_SETTINGS_SLUG . '/notifications/';
$settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . bp_get_settings_slug() . '/notifications/';
// Set up and send the message
$ud = bp_core_get_core_userdata( $parent_comment->user_id );
$to = $ud->user_email;
$sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
$sitename = wp_specialchars_decode( get_blog_option( bp_get_root_blog_id(), 'blogname' ), ENT_QUOTES );
$subject = '[' . $sitename . '] ' . sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name );
$poster_name = stripslashes( $poster_name );
$content = bp_activity_filter_kses( stripslashes( $content ) );
$message = sprintf( __(
'%s replied to one of your comments:
'%1$s replied to one of your comments:
"%s"
"%2$s"
To view the original activity, your comment and all replies, log in and visit: %s
To view the original activity, your comment and all replies, log in and visit: %3$s
---------------------
', 'buddypress' ), $poster_name, $content, $thread_link );
......@@ -133,10 +211,12 @@ To view the original activity, your comment and all replies, log in and visit: %
/* Send the message */
$to = apply_filters( 'bp_activity_new_comment_notification_comment_author_to', $to );
$subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name );
$message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content );
$message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link );
wp_mail( $to, $subject, $message );
do_action( 'bp_activity_sent_reply_to_reply_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
}
}
?>
?>
\ No newline at end of file
<?php
/**
* BuddyPress Activity Screens
*
* @package BuddyPress
* @subpackage ActivityScreens
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Activity screen index
*
* @since 1.5.0
*
* @uses bp_displayed_user_id()
* @uses bp_is_activity_component()
* @uses bp_current_action()
* @uses bp_update_is_directory()
* @uses do_action() To call the 'bp_activity_screen_index' hook
* @uses bp_core_load_template()
* @uses apply_filters() To call the 'bp_activity_screen_index' hook
*/
function bp_activity_screen_index() {
if ( !bp_displayed_user_id() && bp_is_activity_component() && !bp_current_action() ) {
bp_update_is_directory( true, 'activity' );
do_action( 'bp_activity_screen_index' );
bp_core_load_template( apply_filters( 'bp_activity_screen_index', 'activity/index' ) );
}
}
add_action( 'bp_screens', 'bp_activity_screen_index' );
/**
* Activity screen 'my activity' index
*
* @since 1.0.0
*
* @uses do_action() To call the 'bp_activity_screen_my_activity' hook
* @uses bp_core_load_template()
* @uses apply_filters() To call the 'bp_activity_template_my_activity' hook
*/
function bp_activity_screen_my_activity() {
do_action( 'bp_activity_screen_my_activity' );
bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'members/single/home' ) );
}
/**
* Activity screen 'friends' index
*
* @since 1.0.0
*
* @uses bp_is_active()
* @uses bp_update_is_item_admin()
* @uses is_super_admin()
* @uses do_action() To call the 'bp_activity_screen_friends' hook
* @uses bp_core_load_template()
* @uses apply_filters() To call the 'bp_activity_template_friends_activity' hook
*/
function bp_activity_screen_friends() {
if ( !bp_is_active( 'friends' ) )
return false;
bp_update_is_item_admin( is_super_admin(), 'activity' );
do_action( 'bp_activity_screen_friends' );
bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'members/single/home' ) );
}
/**
* Activity screen 'groups' index
*
* @since 1.2.0
*
* @uses bp_is_active()
* @uses bp_update_is_item_admin()
* @uses is_super_admin()
* @uses do_action() To call the 'bp_activity_screen_groups' hook
* @uses bp_core_load_template()
* @uses apply_filters() To call the 'bp_activity_template_groups_activity' hook
*/
function bp_activity_screen_groups() {
if ( !bp_is_active( 'groups' ) )
return false;
bp_update_is_item_admin( is_super_admin(), 'activity' );
do_action( 'bp_activity_screen_groups' );
bp_core_load_template( apply_filters( 'bp_activity_template_groups_activity', 'members/single/home' ) );
}
/**
* Activity screen 'favorites' index
*
* @since 1.2.0
*
* @uses bp_update_is_item_admin()
* @uses is_super_admin()
* @uses do_action() To call the 'bp_activity_screen_favorites' hook
* @uses bp_core_load_template()
* @uses apply_filters() To call the 'bp_activity_template_favorite_activity' hook
*/
function bp_activity_screen_favorites() {
bp_update_is_item_admin( is_super_admin(), 'activity' );
do_action( 'bp_activity_screen_favorites' );
bp_core_load_template( apply_filters( 'bp_activity_template_favorite_activity', 'members/single/home' ) );
}
/**
* Activity screen 'mentions' index
*
* @since 1.2.0
*
* @uses bp_update_is_item_admin()
* @uses is_super_admin()
* @uses do_action() To call the 'bp_activity_screen_mentions' hook
* @uses bp_core_load_template()
* @uses apply_filters() To call the 'bp_activity_template_mention_activity' hook
*/
function bp_activity_screen_mentions() {
bp_update_is_item_admin( is_super_admin(), 'activity' );
do_action( 'bp_activity_screen_mentions' );
bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) );
}
/**
* Removes activity notifications from the notification menu when a user clicks on them and
* is taken to a specific screen.
*
* @since 1.5.0
*
* @global object $bp BuddyPress global settings
* @uses bp_core_delete_notifications_by_type()
*/
function bp_activity_remove_screen_notifications() {
global $bp;
bp_core_delete_notifications_by_type( $bp->loggedin_user->id, $bp->activity->id, 'new_at_mention' );
}
add_action( 'bp_activity_screen_my_activity', 'bp_activity_remove_screen_notifications' );
add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications' );
add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' );
/**
* Reset the logged-in user's new mentions data when he visits his mentions screen
*
* @since 1.5.0
*
* @uses bp_is_my_profile()
* @uses bp_activity_clear_new_mentions()
* @uses bp_loggedin_user_id()
*/
function bp_activity_reset_my_new_mentions() {
if ( bp_is_my_profile() )
bp_activity_clear_new_mentions( bp_loggedin_user_id() );
}
add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' );
/**
* Reset the logged-in user's new mentions data when he visits his mentions screen
*
* @since 1.2.0
*
* @global object $bp BuddyPress global settings
* @uses bp_is_activity_component()
* @uses bp_activity_get_specific()
* @uses bp_current_action()
* @uses bp_action_variables()
* @uses bp_do_404()
* @uses bp_is_active()
* @uses groups_get_group()
* @uses groups_is_user_member()
* @uses apply_filters_ref_array() To call the 'bp_activity_permalink_access' hook
* @uses do_action() To call the 'bp_activity_screen_single_activity_permalink' hook
* @uses bp_core_add_message()
* @uses is_user_logged_in()
* @uses bp_core_redirect()
* @uses site_url()
* @uses esc_url()
* @uses bp_get_root_domain()
* @uses bp_get_activity_root_slug()
* @uses bp_core_load_template()
* @uses apply_filters() To call the 'bp_activity_template_profile_activity_permalink' hook
*/
function bp_activity_screen_single_activity_permalink() {
global $bp;
// No displayed user or not viewing activity component
if ( !bp_is_activity_component() )
return false;
if ( empty( $bp->current_action ) || !is_numeric( $bp->current_action ) )
return false;
// Get the activity details
$activity = bp_activity_get_specific( array( 'activity_ids' => bp_current_action(), 'show_hidden' => true ) );
// 404 if activity does not exist
if ( empty( $activity['activities'][0] ) || bp_action_variables() ) {
bp_do_404();
return;
} else {
$activity = $activity['activities'][0];
}
// Default access is true
$has_access = true;
// If activity is from a group, do an extra cap check
if ( isset( $bp->groups->id ) && $activity->component == $bp->groups->id ) {
// Activity is from a group, but groups is currently disabled
if ( !bp_is_active( 'groups') ) {
bp_do_404();
return;
}
// Check to see if the group is not public, if so, check the
// user has access to see this activity
if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
// Group is not public
if ( 'public' != $group->status ) {
// User is not a member of group
if ( !groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) {
$has_access = false;
}
}
}
}
// Allow access to be filtered
$has_access = apply_filters_ref_array( 'bp_activity_permalink_access', array( $has_access, &$activity ) );
// Allow additional code execution
do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
// Access is specifically disallowed
if ( false === $has_access ) {
// User feedback
bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
// Redirect based on logged in status
is_user_logged_in() ?
bp_core_redirect( $bp->loggedin_user->domain ) :
bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . esc_url( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $bp->current_action ) ) );
}
bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) );
}
add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' );
/**
* Add activity notifications settings to the notifications settings page
*
* @since 1.2.0
*
* @global object $bp BuddyPress global settings
* @uses bp_get_user_meta()
* @uses bp_core_get_username()
* @uses do_action() To call the 'bp_activity_screen_notification_settings' hook
*/
function bp_activity_screen_notification_settings() {
global $bp;
if ( !$mention = bp_get_user_meta( $bp->displayed_user->id, 'notification_activity_new_mention', true ) )
$mention = 'yes';
if ( !$reply = bp_get_user_meta( $bp->displayed_user->id, 'notification_activity_new_reply', true ) )
$reply = 'yes'; ?>
<table class="notification-settings" id="activity-notification-settings">
<thead>
<tr>
<th class="icon">&nbsp;</th>
<th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th>
<th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
<th class="no"><?php _e( 'No', 'buddypress' )?></th>
</tr>
</thead>
<tbody>
<tr id="activity-notification-settings-mentions">
<td>&nbsp;</td>
<td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) ?></td>
<td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php checked( $mention, 'yes', true ) ?>/></td>
<td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php checked( $mention, 'no', true ) ?>/></td>
</tr>
<tr id="activity-notification-settings-replies">
<td>&nbsp;</td>
<td><?php _e( "A member replies to an update or comment you've posted", 'buddypress' ) ?></td>
<td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php checked( $reply, 'yes', true ) ?>/></td>
<td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php checked( $reply, 'no', true ) ?>/></td>
</tr>
<?php do_action( 'bp_activity_screen_notification_settings' ) ?>
</tbody>
</table>
<?php
}
add_action( 'bp_notification_settings', 'bp_activity_screen_notification_settings', 1 );
?>
\ No newline at end of file
This diff is collapsed.
<?php
/**
* RSS2 Feed Template for displaying a member's favorite activity
*
* @package BuddyPress
* @subpackage ActivityFeeds
*/
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
header('Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
header('Status: 200 OK');
?>
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<?php echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?'.'>'; ?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
......@@ -18,13 +24,14 @@ header('Status: 200 OK');
>
<channel>
<title><?php echo bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Favorite Activity', 'buddypress' ) ?></title>
<title><?php bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Favorite Activity', 'buddypress' ) ?></title>
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
<link><?php echo site_url( BP_ACTIVITY_SLUG . '/#my-favorites/' ) ?></link>
<link><?php echo home_url( bp_get_activity_root_slug() . '/#my-favorites/' ) ?></link>
<description><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'Favorite Activity', 'buddypress' ) ?></description>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate>
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
<language><?php echo get_option('rss_language'); ?></language>
<?php do_action('bp_activity_favorites_feed_head'); ?>
<?php
......@@ -34,9 +41,10 @@ header('Status: 200 OK');
<?php if ( bp_has_activities( 'include=' . $fav_ids . '&max=50&display_comments=stream' ) ) : ?>
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<item>
<guid><?php bp_activity_thread_permalink() ?></guid>
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
<title><?php bp_activity_feed_item_title() ?></title>
<link><?php echo bp_activity_thread_permalink() ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
......@@ -54,10 +62,13 @@ header('Status: 200 OK');
<?php endif; ?>
]]>
</description>
<?php do_action('bp_activity_favorites_feed_item'); ?>
</item>
<?php endwhile; ?>
<?php endwhile; ?>
<?php endif; ?>
</channel>
</rss>
<?php
/**
* RSS2 Feed Template for displaying a member's friends activity stream.
*
* @package BuddyPress
* @subpackage ActivityFeeds
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
header('Status: 200 OK');
?>
......@@ -18,35 +24,34 @@ header('Status: 200 OK');
>
<channel>
<title><?php echo bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Friends Activity', 'buddypress' ) ?></title>
<title><?php bp_site_name() ?> | <?php bp_displayed_user_fullname(); ?> | <?php _e( 'Friends Activity', 'buddypress' ); ?></title>
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
<link><?php echo $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' ?></link>
<description><?php printf( __( '%s - Friends Activity Feed', 'buddypress' ), $bp->displayed_user->fullname ) ?></description>
<link><?php echo bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed'; ?></link>
<description><?php printf( __( '%s - Friends Activity Feed', 'buddypress' ), bp_get_displayed_user_fullname() ); ?></description>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate>
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
<generator>http://buddypress.org/?v=<?php echo BP_VERSION; ?></generator>
<language><?php echo get_option('rss_language'); ?></language>
<?php do_action('bp_activity_friends_feed_head'); ?>
<?php $friend_ids = implode( ',', friends_get_friend_user_ids( $bp->displayed_user->id ) ); ?>
<?php if ( bp_has_activities( 'user_id=' . $friend_ids . '&max=50&display_comments=stream' ) ) : ?>
<?php if ( bp_has_activities( 'scope=friends&max=50&display_comments=stream' ) ) : ?>
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<item>
<guid><?php bp_activity_thread_permalink() ?></guid>
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
<link><?php echo bp_activity_thread_permalink() ?></link>
<guid><?php bp_activity_thread_permalink(); ?></guid>
<title><?php bp_activity_feed_item_title(); ?></title>
<link><?php echo bp_activity_thread_permalink(); ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
<description>
<![CDATA[
<?php bp_activity_feed_item_description() ?>
<?php bp_activity_feed_item_description(); ?>
<?php if ( bp_activity_can_comment() ) : ?>
<p><?php printf( __( 'Comments: %s', 'buddypress' ), bp_activity_get_comment_count() ); ?></p>
<?php endif; ?>
<?php if ( 'activity_comment' == bp_get_activity_action_name() ) : ?>
<br /><strong><?php _e( 'In reply to', 'buddypress' ) ?></strong> -
<?php bp_activity_parent_content() ?>
<br /><strong><?php _e( 'In reply to', 'buddypress' ); ?></strong> -
<?php bp_activity_parent_content(); ?>
<?php endif; ?>
]]>
</description>
......
<?php
/**
* RSS2 Feed Template for displaying a group activity stream
*
* @package BuddyPress
* @subpackage ActivityFeeds
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
header('Status: 200 OK');
?>
......@@ -18,9 +24,9 @@ header('Status: 200 OK');
>
<channel>
<title><?php echo bp_site_name() ?> | <?php echo $bp->groups->current_group->name ?> | <?php _e( 'Group Activity', 'buddypress' ) ?></title>
<title><?php bp_site_name() ?> | <?php echo $bp->groups->current_group->name ?> | <?php _e( 'Group Activity', 'buddypress' ) ?></title>
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
<link><?php echo bp_get_group_permalink( $bp->groups->current_group ) . $bp->activity->slug . '/feed' ?></link>
<link><?php echo bp_get_group_permalink( $bp->groups->current_group ) . bp_get_activity_slug() . '/feed' ?></link>
<description><?php printf( __( '%s - Group Activity Feed', 'buddypress' ), $bp->groups->current_group->name ) ?></description>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate>
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
......@@ -31,7 +37,7 @@ header('Status: 200 OK');
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<item>
<guid><?php bp_activity_thread_permalink() ?></guid>
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
<title><?php bp_activity_feed_item_title() ?></title>
<link><?php echo bp_activity_thread_permalink() ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
......
<?php
/**
* RSS2 Feed Template for displaying a member's group's activity
*
* @package BuddyPress
* @subpackage ActivityFeeds
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
header('Status: 200 OK');
?>
......@@ -18,9 +24,9 @@ header('Status: 200 OK');
>
<channel>
<title><?php echo bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Mentions', 'buddypress' ) ?></title>
<title><?php bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Mentions', 'buddypress' ) ?></title>
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
<link><?php echo site_url( BP_ACTIVITY_SLUG . '/#mentions/' ) ?></link>
<link><?php echo home_url( bp_get_activity_root_slug() . '/#mentions/' ) ?></link>
<description><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'Mentions', 'buddypress' ) ?></description>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate>
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
......@@ -31,7 +37,7 @@ header('Status: 200 OK');
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<item>
<guid><?php bp_activity_thread_permalink() ?></guid>
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
<title><?php bp_activity_feed_item_title() ?></title>
<link><?php echo bp_activity_thread_permalink() ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
......
<?php
/**
* RSS2 Feed Template for displaying a member's group's activity
*
* @package BuddyPress
* @subpackage ActivityFeeds
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
header('Status: 200 OK');
?>
......@@ -18,9 +24,9 @@ header('Status: 200 OK');
>
<channel>
<title><?php echo bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'My Groups - Public Activity', 'buddypress' ) ?></title>
<title><?php bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'My Groups - Public Activity', 'buddypress' ) ?></title>
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
<link><?php echo site_url( BP_ACTIVITY_SLUG . '/#my-groups/' ) ?></link>
<link><?php echo home_url( bp_get_activity_root_slug() . '/#my-groups/' ) ?></link>
<description><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'My Groups - Public Activity', 'buddypress' ) ?></description>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate>
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
......@@ -36,7 +42,7 @@ header('Status: 200 OK');
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<item>
<guid><?php bp_activity_thread_permalink() ?></guid>
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
<title><?php bp_activity_feed_item_title() ?></title>
<link><?php echo bp_activity_thread_permalink() ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
......
<?php
/**
* RSS2 Feed Template for displaying a member's activity stream.
*
* @package BuddyPress
* @subpackage ActivityFeeds
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
header('Status: 200 OK');
?>
......@@ -18,9 +24,9 @@ header('Status: 200 OK');
>
<channel>
<title><?php echo bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Activity', 'buddypress' ) ?></title>
<title><?php bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Activity', 'buddypress' ) ?></title>
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
<link><?php echo $bp->displayed_user->domain . $bp->activity->slug . '/feed' ?></link>
<link><?php echo bp_displayed_user_domain() . bp_get_activity_slug() . '/feed' ?></link>
<description><?php printf( __( '%s - Activity Feed', 'buddypress' ), $bp->displayed_user->fullname ) ?></description>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate>
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
......@@ -31,7 +37,7 @@ header('Status: 200 OK');
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<item>
<guid><?php bp_activity_thread_permalink() ?></guid>
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
<title><?php bp_activity_feed_item_title() ?></title>
<link><?php echo bp_activity_thread_permalink() ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
......
<?php
/**
* RSS2 Feed Template for displaying the site wide activity stream.
*
* @package BuddyPress
* @subpackage ActivityFeeds
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
header('Status: 200 OK');
?>
......@@ -19,9 +24,9 @@ header('Status: 200 OK');
>
<channel>
<title><?php echo bp_site_name() ?> | <?php _e( 'Site Wide Activity', 'buddypress' ) ?></title>
<title><?php bp_site_name() ?> | <?php _e( 'Site Wide Activity', 'buddypress' ) ?></title>
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
<link><?php echo site_url() . '/' . $bp->activity->slug . '/feed' ?></link>
<link><?php echo bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/feed' ?></link>
<description><?php _e( 'Site Wide Activity Feed', 'buddypress' ) ?></description>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate>
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
......@@ -32,7 +37,7 @@ header('Status: 200 OK');
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<item>
<guid><?php bp_activity_thread_permalink() ?></guid>
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
<title><?php bp_activity_feed_item_title() ?></title>
<link><?php bp_activity_thread_permalink() ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
......
<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
function bp_blogs_redirect_to_random_blog() {
global $bp, $wpdb;
if ( bp_is_blogs_component() && isset( $_GET['random-blog'] ) ) {
$blog = bp_blogs_get_random_blogs( 1, 1 );
bp_core_redirect( get_site_url( $blog['blogs'][0]->blog_id ) );
}
}
add_action( 'bp_actions', 'bp_blogs_redirect_to_random_blog' );
?>
\ No newline at end of file
<?php
/******************************************************************************
* These functions handle the recording, deleting and formatting of activity and
* notifications for the user and for this specific component.
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
function bp_blogs_register_activity_actions() {
global $bp;
if ( !bp_is_active( 'activity' ) )
return false;
bp_activity_set_action( $bp->blogs->id, 'new_blog', __( 'New site created', 'buddypress' ) );
bp_activity_set_action( $bp->blogs->id, 'new_blog_post', __( 'New post published', 'buddypress' ) );
bp_activity_set_action( $bp->blogs->id, 'new_blog_comment', __( 'New post comment posted', 'buddypress' ) );
do_action( 'bp_blogs_register_activity_actions' );
}
add_action( 'bp_register_activity_actions', 'bp_blogs_register_activity_actions' );
function bp_blogs_record_activity( $args = '' ) {
global $bp;
if ( !bp_is_active( 'activity' ) )
return false;
$defaults = array(
'user_id' => $bp->loggedin_user->id,
'action' => '',
'content' => '',
'primary_link' => '',
'component' => $bp->blogs->id,
'type' => false,
'item_id' => false,
'secondary_item_id' => false,
'recorded_time' => bp_core_current_time(),
'hide_sitewide' => false
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
// Remove large images and replace them with just one image thumbnail
if ( bp_is_active( 'activity' ) && !empty( $content ) )
$content = bp_activity_thumbnail_content_images( $content, $primary_link );
if ( !empty( $action ) )
$action = apply_filters( 'bp_blogs_record_activity_action', $action );
if ( !empty( $content ) )
$content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ), $content );
// Check for an existing entry and update if one exists.
$id = bp_activity_get_activity_id( array(
'user_id' => $user_id,
'component' => $component,
'type' => $type,
'item_id' => $item_id,
'secondary_item_id' => $secondary_item_id
) );
return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
}
function bp_blogs_delete_activity( $args = true ) {
global $bp;
if ( bp_is_active( 'activity' ) ) {
$defaults = array(
'item_id' => false,
'component' => $bp->blogs->id,
'type' => false,
'user_id' => false,
'secondary_item_id' => false
);
$params = wp_parse_args( $args, $defaults );
extract( $params, EXTR_SKIP );
bp_activity_delete_by_item_id( array(
'item_id' => $item_id,
'component' => $component,
'type' => $type,
'user_id' => $user_id,
'secondary_item_id' => $secondary_item_id
) );
}
}
?>
\ No newline at end of file
<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
// *** "My Blogs" Menu ********
function bp_adminbar_blogs_menu() {
global $bp;
if ( !is_user_logged_in() || !bp_is_active( 'blogs' ) )
return false;
if ( !is_multisite() )
return false;
if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', 'bp' ) ) {
$blogs = bp_blogs_get_blogs_for_user( $bp->loggedin_user->id, true );
wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', $blogs, 'bp' );
}
$counter = 0;
if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
echo '<li id="bp-adminbar-blogs-menu"><a href="' . trailingslashit( $bp->loggedin_user->domain . bp_get_blogs_slug() ) . '">';
_e( 'My Sites', 'buddypress' );
echo '</a>';
echo '<ul>';
foreach ( (array)$blogs['blogs'] as $blog ) {
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
$site_url = esc_attr( $blog->siteurl );
echo '<li' . $alt . '>';
echo '<a href="' . $site_url . '">' . esc_html( $blog->name ) . '</a>';
echo '<ul>';
echo '<li class="alt"><a href="' . $site_url . 'wp-admin/">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';
echo '<li><a href="' . $site_url . 'wp-admin/post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
echo '<li class="alt"><a href="' . $site_url . 'wp-admin/edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
echo '<li><a href="' . $site_url . 'wp-admin/edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
echo '</ul>';
do_action( 'bp_adminbar_blog_items', $blog );
echo '</li>';
$counter++;
}
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
if ( bp_blog_signup_enabled() ) {
echo '<li' . $alt . '>';
echo '<a href="' . bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create/">' . __( 'Create a Site!', 'buddypress' ) . '</a>';
echo '</li>';
}
echo '</ul>';
echo '</li>';
}
}
add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
?>
\ No newline at end of file
<?php
/*******************************************************************************
* Caching
*
* Caching functions handle the clearing of cached objects and pages on specific
* actions throughout BuddyPress.
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
function bp_blogs_clear_blog_object_cache( $blog_id, $user_id ) {
wp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' );
wp_cache_delete( 'bp_total_blogs_for_user_' . $user_id, 'bp' );
}
function bp_blogs_format_clear_blog_cache( $recorded_blog_obj ) {
bp_blogs_clear_blog_object_cache( false, $recorded_blog_obj->user_id );
wp_cache_delete( 'bp_total_blogs', 'bp' );
}
// List actions to clear object caches on
add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 );
// List actions to clear super cached pages on, if super cache is installed
add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' );
add_action( 'bp_blogs_remove_comment', 'bp_core_clear_cache' );
add_action( 'bp_blogs_remove_post', 'bp_core_clear_cache' );
add_action( 'bp_blogs_remove_blog_for_user', 'bp_core_clear_cache' );
add_action( 'bp_blogs_remove_blog', 'bp_core_clear_cache' );
add_action( 'bp_blogs_new_blog_comment', 'bp_core_clear_cache' );
add_action( 'bp_blogs_new_blog_post', 'bp_core_clear_cache' );
add_action( 'bp_blogs_new_blog', 'bp_core_clear_cache' );
add_action( 'bp_blogs_remove_data', 'bp_core_clear_cache' );
?>
\ No newline at end of file
<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
Class BP_Blogs_Blog {
var $id;
......@@ -6,10 +8,13 @@ Class BP_Blogs_Blog {
var $blog_id;
function bp_blogs_blog( $id = null ) {
$this->__construct( $id );
}
function __construct( $id = null ) {
global $bp, $wpdb;
if ( !$user_id )
$user_id = $bp->displayed_user->id;
$user_id = bp_displayed_user_id();
if ( $id ) {
$this->id = $id;
......@@ -32,7 +37,7 @@ Class BP_Blogs_Blog {
$this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
$this->blog_id = apply_filters( 'bp_blogs_blog_id_before_save', $this->blog_id, $this->id );
do_action( 'bp_blogs_blog_before_save', $this );
do_action_ref_array( 'bp_blogs_blog_before_save', array( &$this ) );
// Don't try and save if there is no user ID or blog ID set.
if ( !$this->user_id || !$this->blog_id )
......@@ -53,7 +58,7 @@ Class BP_Blogs_Blog {
if ( !$wpdb->query($sql) )
return false;
do_action( 'bp_blogs_blog_after_save', $this );
do_action_ref_array( 'bp_blogs_blog_after_save', array( &$this ) );
if ( $this->id )
return $this->id;
......@@ -69,20 +74,17 @@ Class BP_Blogs_Blog {
/* Static Functions */
function get( $type, $limit = false, $page = false, $user_id = false, $search_terms = false ) {
function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false ) {
global $bp, $wpdb;
if ( !$bp->blogs )
bp_blogs_setup_globals();
if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
$hidden_sql = "AND wb.public = 1";
else
$hidden_sql = '';
if ( $limit && $page )
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
$pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
if ( $user_id )
$user_sql = $wpdb->prepare( " AND b.user_id = %d", $user_id );
$user_sql = !empty( $user_id ) ? $wpdb->prepare( " AND b.user_id = %d", $user_id ) : '';
switch ( $type ) {
case 'active': default:
......@@ -108,9 +110,13 @@ Class BP_Blogs_Blog {
$total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id {$user_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql}" ) );
}
foreach ( (array)$paged_blogs as $blog ) $blog_ids[] = $blog->blog_id;
$blog_ids = array();
foreach ( (array)$paged_blogs as $blog ) {
$blog_ids[] = $blog->blog_id;
}
$blog_ids = $wpdb->escape( join( ',', (array)$blog_ids ) );
$paged_blogs = BP_Blogs_Blog::get_blog_extras( &$paged_blogs, $blog_ids, $type );
$paged_blogs = BP_Blogs_Blog::get_blog_extras( $paged_blogs, $blog_ids, $type );
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
}
......@@ -118,20 +124,13 @@ Class BP_Blogs_Blog {
function delete_blog_for_all( $blog_id ) {
global $wpdb, $bp;
if ( !$bp->blogs )
bp_blogs_setup_globals();
bp_blogs_delete_blogmeta( $blog_id );
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
}
function delete_blog_for_user( $blog_id, $user_id = null ) {
global $wpdb, $bp;
if ( !$bp->blogs )
bp_blogs_setup_globals();
if ( !$user_id )
$user_id = $bp->loggedin_user->id;
......@@ -141,21 +140,15 @@ Class BP_Blogs_Blog {
function delete_blogs_for_user( $user_id = null ) {
global $wpdb, $bp;
if ( !$bp->blogs )
bp_blogs_setup_globals();
if ( !$user_id )
$user_id = $bp->loggedin_user->id;
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
}
function get_blogs_for_user( $user_id = false, $show_hidden = false ) {
function get_blogs_for_user( $user_id = 0, $show_hidden = false ) {
global $bp, $wpdb;
if ( !$bp->blogs )
bp_blogs_setup_globals();
if ( !$user_id )
$user_id = $bp->displayed_user->id;
......@@ -167,6 +160,7 @@ Class BP_Blogs_Blog {
$total_blog_count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );
$user_blogs = array();
foreach ( (array)$blogs as $blog ) {
$user_blogs[$blog->blog_id] = new stdClass;
$user_blogs[$blog->blog_id]->id = $blog->id;
......@@ -178,12 +172,9 @@ Class BP_Blogs_Blog {
return array( 'blogs' => $user_blogs, 'count' => $total_blog_count );
}
function get_blog_ids_for_user( $user_id = false ) {
function get_blog_ids_for_user( $user_id = 0 ) {
global $bp, $wpdb;
if ( !$bp->blogs )
bp_blogs_setup_globals();
if ( !$user_id )
$user_id = $bp->displayed_user->id;
......@@ -193,18 +184,12 @@ Class BP_Blogs_Blog {
function is_recorded( $blog_id ) {
global $bp, $wpdb;
if ( !$bp->blogs )
bp_blogs_setup_globals();
return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
}
function total_blog_count_for_user( $user_id = null ) {
global $bp, $wpdb;
if ( !$bp->blogs )
bp_blogs_setup_globals();
if ( !$user_id )
$user_id = $bp->displayed_user->id;
......@@ -218,9 +203,6 @@ Class BP_Blogs_Blog {
function search_blogs( $filter, $limit = null, $page = null ) {
global $wpdb, $bp;
if ( !$bp->blogs )
bp_blogs_setup_globals();
$filter = like_escape( $wpdb->escape( $filter ) );
if ( !is_super_admin() )
......@@ -238,14 +220,8 @@ Class BP_Blogs_Blog {
function get_all( $limit = null, $page = null ) {
global $bp, $wpdb;
if ( !$bp->blogs )
bp_blogs_setup_globals();
if ( !is_super_admin() )
$hidden_sql = "AND wb.public = 1";
if ( $limit && $page )
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
$hidden_sql = !is_super_admin() ? "AND wb.public = 1" : '';
$pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
$paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql} {$pag_sql}" ) );
$total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql}" ) );
......@@ -256,9 +232,6 @@ Class BP_Blogs_Blog {
function get_by_letter( $letter, $limit = null, $page = null ) {
global $bp, $wpdb;
if ( !$bp->blogs )
bp_blogs_setup_globals();
$letter = like_escape( $wpdb->escape( $letter ) );
if ( !is_super_admin() )
......@@ -273,13 +246,13 @@ Class BP_Blogs_Blog {
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
}
function get_blog_extras( $paged_blogs, $blog_ids, $type = false ) {
function get_blog_extras( &$paged_blogs, &$blog_ids, $type = false ) {
global $bp, $wpdb;
if ( empty( $blog_ids ) )
return $paged_blogs;
for ( $i = 0; $i < count( $paged_blogs ); $i++ ) {
for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) {
$blog_prefix = $wpdb->get_blog_prefix( $paged_blogs[$i]->blog_id );
$paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" );
}
......@@ -287,7 +260,7 @@ Class BP_Blogs_Blog {
/* Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). */
$blog_descs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, meta_value as description FROM {$bp->blogs->table_name_blogmeta} WHERE meta_key = 'description' AND blog_id IN ( {$blog_ids} )" ) );
for ( $i = 0; $i < count( $paged_blogs ); $i++ ) {
for ( $i = 0, $count = count( $paged_blogs ); $i < $count; ++$i ) {
foreach ( (array)$blog_descs as $desc ) {
if ( $desc->blog_id == $paged_blogs[$i]->blog_id )
$paged_blogs[$i]->description = $desc->description;
......@@ -300,14 +273,10 @@ Class BP_Blogs_Blog {
function is_hidden( $blog_id ) {
global $wpdb;
if ( !$bp->blogs )
bp_blogs_setup_globals();
if ( !(int)$wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT public FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d", $blog_id ) ) )
return true;
return false;
}
}
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment