/** * xprofile_format_notifications() * * Format notifications into something that can be read and displayed * * @package BuddyPress Xprofile * @param $item_id The ID of the specific item for which the activity is recorded (could be a wire post id, user id etc) * @param $action The component action name e.g. 'new_wire_post' or 'updated_profile' * @param $total_items The total number of identical notification items (used for grouping) * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() * @uses bp_core_global_user_fullname() Returns the display name for the user * @return The readable notification item */ function xprofile_format_notifications($action, $item_id, $secondary_item_id, $total_items) { global $bp; if ('new_wire_post' == $action) { if ((int) $total_items > 1) { return apply_filters('bp_xprofile_multiple_new_wire_post_notification', '<a href="' . $bp->loggedin_user->domain . $bp->wire->slug . '" title="' . __('Wire', 'buddypress') . '">' . sprintf(__('You have %d new posts on your wire', 'buddypress'), (int) $total_items) . '</a>', $total_items); } else { $user_fullname = bp_core_global_user_fullname($item_id); return apply_filters('bp_xprofile_single_new_wire_post_notification', '<a href="' . $bp->loggedin_user->domain . $bp->wire->slug . '" title="' . __('Wire', 'buddypress') . '">' . sprintf(__('%s posted on your wire', 'buddypress'), $user_fullname) . '</a>', $user_fullname); } } do_action('xprofile_format_notifications', $action, $item_id, $secondary_item_id, $total_items); return false; }
function groups_format_notifications($action, $item_id, $secondary_item_id, $total_items) { global $bp; switch ($action) { case 'new_membership_request': $group_id = $secondary_item_id; $requesting_user_id = $item_id; $group = new BP_Groups_Group($group_id, false, false); $group_link = bp_get_group_permalink($group); if ((int) $total_items > 1) { return apply_filters('bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/" title="' . __('Group Membership Requests', 'buddypress') . '">' . sprintf(__('%d new membership requests for the group "%s"', 'buddypress'), (int) $total_items, $group->name) . '</a>', $group_link, $total_items, $group->name); } else { $user_fullname = bp_core_global_user_fullname($requesting_user_id); return apply_filters('bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . '/admin/membership-requests/" title="' . $user_fullname . ' requests group membership">' . sprintf(__('%s requests membership for the group "%s"', 'buddypress'), $user_fullname, $group->name) . '</a>', $group_link, $user_fullname, $group->name); } break; case 'membership_request_accepted': $group_id = $item_id; $group = new BP_Groups_Group($group_id, false, false); $group_link = bp_get_group_permalink($group) . '/?new'; if ((int) $total_items > 1) { return apply_filters('bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __('Groups', 'buddypress') . '">' . sprintf(__('%d accepted group membership requests', 'buddypress'), (int) $total_items, $group->name) . '</a>', $total_items, $group_name); } else { return apply_filters('bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '">' . sprintf(__('Membership for group "%s" accepted'), $group->name) . '</a>', $group_link, $group->name); } break; case 'membership_request_rejected': $group_id = $item_id; $group = new BP_Groups_Group($group_id, false, false); $group_link = bp_get_group_permalink($group) . '/?new'; if ((int) $total_items > 1) { return apply_filters('bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . BP_MEMBERS_SLUG . '/' . $bp->groups->slug . '" title="' . __('Groups', 'buddypress') . '">' . sprintf(__('%d rejected group membership requests', 'buddypress'), (int) $total_items, $group->name) . '</a>', $total_items, $group->name); } else { return apply_filters('bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '">' . sprintf(__('Membership for group "%s" rejected'), $group->name) . '</a>', $group_link, $group->name); } break; case 'member_promoted_to_admin': $group_id = $item_id; $group = new BP_Groups_Group($group_id, false, false); $group_link = bp_get_group_permalink($group) . '/?new'; if ((int) $total_items > 1) { return apply_filters('bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __('Groups', 'buddypress') . '">' . sprintf(__('You were promoted to an admin in %d groups', 'buddypress'), (int) $total_items) . '</a>', $total_items); } else { return apply_filters('bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '">' . sprintf(__('You were promoted to an admin in the group %s'), $group->name) . '</a>', $group_link, $group->name); } break; case 'member_promoted_to_mod': $group_id = $item_id; $group = new BP_Groups_Group($group_id, false, false); $group_link = bp_get_group_permalink($group) . '/?new'; if ((int) $total_items > 1) { return apply_filters('bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __('Groups', 'buddypress') . '">' . sprintf(__('You were promoted to a mod in %d groups', 'buddypress'), (int) $total_items) . '</a>', $total_items); } else { return apply_filters('bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '">' . sprintf(__('You were promoted to a mod in the group %s'), $group->name) . '</a>', $group_link, $group->name); } break; case 'group_invite': $group_id = $item_id; $group = new BP_Groups_Group($group_id, false, false); $user_url = bp_core_get_userurl($user_id); if ((int) $total_items > 1) { return apply_filters('bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __('Group Invites', 'buddypress') . '">' . sprintf(__('You have %d new group invitations', 'buddypress'), (int) $total_items) . '</a>', $total_items); } else { return apply_filters('bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __('Group Invites', 'buddypress') . '">' . sprintf(__('You have an invitation to the group: %s', 'buddypress'), $group->name) . '</a>', $group->name); } break; } do_action('groups_format_notifications', $action, $item_id, $secondary_item_id, $total_items); return false; }
function friends_format_notifications($action, $item_id, $secondary_item_id, $total_items) { global $bp; switch ($action) { case 'friendship_accepted': if ((int) $total_items > 1) { return apply_filters('bp_friends_multiple_friendship_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/my-friends/newest" title="' . __('My Friends', 'buddypress') . '">' . sprintf(__('%d friends accepted your friendship requests', 'buddypress'), (int) $total_items) . '</a>', (int) $total_items); } else { $user_fullname = bp_core_global_user_fullname($item_id); $user_url = bp_core_get_userurl($item_id); return apply_filters('bp_friends_single_friendship_accepted_notification', '<a href="' . $user_url . '?new" title="' . $user_fullname . '\'s profile">' . sprintf(__('%s accepted your friendship request', 'buddypress'), $user_fullname) . '</a>', $user_fullname); } break; case 'friendship_request': if ((int) $total_items > 1) { return apply_filters('bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __('Friendship requests', 'buddypress') . '">' . sprintf(__('You have %d pending friendship requests', 'buddypress'), (int) $total_items) . '</a>', $total_items); } else { $user_fullname = bp_core_global_user_fullname($item_id); $user_url = bp_core_get_userurl($item_id); return apply_filters('bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __('Friendship requests', 'buddypress') . '">' . sprintf(__('You have a friendship request from %s', 'buddypress'), $user_fullname) . '</a>', $user_fullname); } break; } do_action('friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items); return false; }
/** * bp_core_setup_globals() * * Sets up default global BuddyPress configuration settings and stores * them in a $bp variable. * * @package BuddyPress Core Core * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() * @global $current_user A WordPress global containing current user information * @global $current_component Which is set up in /bp-core/bp-core-catch-uri.php * @global $current_action Which is set up in /bp-core/bp-core-catch-uri.php * @global $action_variables Which is set up in /bp-core/bp-core-catch-uri.php * @uses bp_core_get_user_domain() Returns the domain for a user */ function bp_core_setup_globals() { global $bp, $wpdb; global $current_user, $current_component, $current_action, $current_blog; global $displayed_user_id; global $action_variables; $current_user = wp_get_current_user(); /* The domain for the root of the site where the main blog resides */ $bp->root_domain = bp_core_get_root_domain(); /* The user ID of the user who is currently logged in. */ $bp->loggedin_user->id = $current_user->ID; /* The domain for the user currently logged in. eg: http://domain.com/members/andy */ $bp->loggedin_user->domain = bp_core_get_user_domain($current_user->ID); /* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */ $bp->displayed_user->id = $displayed_user_id; /* The domain for the user currently being displayed */ $bp->displayed_user->domain = bp_core_get_user_domain($displayed_user_id); /* The component being used eg: http://domain.com/members/andy/ [profile] */ $bp->current_component = $current_component; // type: string /* The current action for the component eg: http://domain.com/members/andy/profile/ [edit] */ $bp->current_action = $current_action; // type: string /* The action variables for the current action eg: http://domain.com/members/andy/profile/edit/ [group] / [6] */ $bp->action_variables = $action_variables; // type: array /* Only used where a component has a sub item, e.g. groups: http://domain.com/members/andy/groups/ [my-group] / home - manipulated in the actual component not in catch uri code.*/ $bp->current_item = ''; // type: string /* Used for overriding the 2nd level navigation menu so it can be used to display custom navigation for an item (for example a group) */ $bp->is_single_item = false; /* The default component to use if none are set and someone visits: http://domain.com/members/andy */ $bp->default_component = 'profile'; /* Sets up the array container for the component navigation rendered by bp_get_nav() */ $bp->bp_nav = array(); /* Sets up the array container for the user navigation rendered by bp_get_user_nav() */ $bp->bp_users_nav = array(); /* Sets up the array container for the component options navigation rendered by bp_get_options_nav() */ $bp->bp_options_nav = array(); /* Sets up container used for the title of the current component option and rendered by bp_get_options_title() */ $bp->bp_options_title = ''; /* Sets up container used for the avatar of the current component being viewed. Rendered by bp_get_options_avatar() */ $bp->bp_options_avatar = ''; /* Fetches the default Gravatar image to use if the user has no avatar or gravatar */ $bp->grav_default = get_site_option('user-avatar-default'); /* Fetch the full name for the logged in and current user */ $bp->loggedin_user->fullname = bp_core_global_user_fullname($bp->loggedin_user->id); $bp->displayed_user->fullname = bp_core_global_user_fullname($bp->displayed_user->id); /* Used to determine if user has admin rights on current content. If the logged in user is viewing their own profile and wants to delete a post on their wire, is_item_admin is used. This is a generic variable so it can be used in other components. It can also be modified, so when viewing a group 'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */ $bp->is_item_admin = bp_is_home(); /* Used to determine if the logged in user is a moderator for the current content. */ $bp->is_item_mod = false; $bp->core->image_base = BP_PLUGIN_URL . '/bp-core/images'; $bp->core->table_name_notifications = $wpdb->base_prefix . 'bp_notifications'; if (!$bp->current_component) { $bp->current_component = $bp->default_component; } }