本文整理汇总了PHP中bp_get_friends_slug函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_get_friends_slug函数的具体用法?PHP bp_get_friends_slug怎么用?PHP bp_get_friends_slug使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_get_friends_slug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: friends_notification_new_request
function friends_notification_new_request($friendship_id, $initiator_id, $friend_id)
{
$initiator_name = bp_core_get_user_displayname($initiator_id);
if ('no' == bp_get_user_meta((int) $friend_id, 'notification_friends_friendship_request', true)) {
return false;
}
$ud = get_userdata($friend_id);
$all_requests_link = bp_core_get_user_domain($friend_id) . bp_get_friends_slug() . '/requests/';
$settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
$settings_link = trailingslashit(bp_core_get_user_domain($friend_id) . $settings_slug . '/notifications');
$initiator_link = bp_core_get_user_domain($initiator_id);
// Set up and send the message
$to = $ud->user_email;
$subject = bp_get_email_subject(array('text' => sprintf(__('New friendship request from %s', 'buddypress'), $initiator_name)));
$message = sprintf(__('%1$s wants to add you as a friend.
To view all of your pending friendship requests: %2$s
To view %3$s\'s profile: %4$s
---------------------
', 'buddypress'), $initiator_name, $all_requests_link, $initiator_name, $initiator_link);
// Only show the disable notifications line if the settings component is enabled
if (bp_is_active('settings')) {
$message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
}
/* Send the message */
$to = apply_filters('friends_notification_new_request_to', $to);
$subject = apply_filters('friends_notification_new_request_subject', $subject, $initiator_name);
$message = apply_filters('friends_notification_new_request_message', $message, $initiator_name, $initiator_link, $all_requests_link, $settings_link);
wp_mail($to, $subject, $message);
do_action('bp_friends_sent_request_email', $friend_id, $subject, $message, $friendship_id, $initiator_id);
}
示例2: friends_notification_new_request
function friends_notification_new_request($friendship_id, $initiator_id, $friend_id)
{
global $bp;
$initiator_name = bp_core_get_user_displayname($initiator_id);
if ('no' == bp_get_user_meta((int) $friend_id, 'notification_friends_friendship_request', true)) {
return false;
}
$ud = get_userdata($friend_id);
$initiator_ud = get_userdata($initiator_id);
$all_requests_link = bp_core_get_user_domain($friend_id) . bp_get_friends_slug() . '/requests/';
$settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
$settings_link = bp_core_get_user_domain($friend_id) . $settings_slug . '/notifications';
$initiator_link = bp_core_get_user_domain($initiator_id);
// Set up and send the message
$to = $ud->user_email;
$sitename = nxt_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
$subject = '[' . $sitename . '] ' . sprintf(__('New friendship request from %s', 'buddypress'), $initiator_name);
$message = sprintf(__('%1$s wants to add you as a friend.
To view all of your pending friendship requests: %2$s
To view %3$s\'s profile: %4$s
---------------------
', 'buddypress'), $initiator_name, $all_requests_link, $initiator_name, $initiator_link);
$message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
/* Send the message */
$to = apply_filters('friends_notification_new_request_to', $to);
$subject = apply_filters('friends_notification_new_request_subject', $subject, $initiator_name);
$message = apply_filters('friends_notification_new_request_message', $message, $initiator_name, $initiator_link, $all_requests_link, $settings_link);
nxt_mail($to, $subject, $message);
do_action('bp_friends_sent_request_email', $friend_id, $subject, $message, $friendship_id, $initiator_id);
}
示例3: friends_format_notifications
/**
* Format the BuddyBar/Toolbar notifications for the Friends component
*
* @package BuddyPress
*
* @param string $action The kind of notification being rendered
* @param int $item_id The primary item id
* @param int $secondary_item_id The secondary item id
* @param int $total_items The total number of messaging-related notifications waiting for the user
* @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar
*/
function friends_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
{
switch ($action) {
case 'friendship_accepted':
$link = trailingslashit(bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends');
// Set up the string and the filter
if ((int) $total_items > 1) {
$text = sprintf(__('%d friends accepted your friendship requests', 'buddypress'), (int) $total_items);
$filter = 'bp_friends_multiple_friendship_accepted_notification';
} else {
$text = sprintf(__('%s accepted your friendship request', 'buddypress'), bp_core_get_user_displayname($item_id));
$filter = 'bp_friends_single_friendship_accepted_notification';
}
break;
case 'friendship_request':
$link = bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/?new';
// Set up the string and the filter
if ((int) $total_items > 1) {
$text = sprintf(__('You have %d pending friendship requests', 'buddypress'), (int) $total_items);
$filter = 'bp_friends_multiple_friendship_request_notification';
} else {
$text = sprintf(__('You have a friendship request from %s', 'buddypress'), bp_core_get_user_displayname($item_id));
$filter = 'bp_friends_single_friendship_request_notification';
}
break;
}
// Return either an HTML link or an array, depending on the requested format
if ('string' == $format) {
$return = apply_filters($filter, '<a href="' . $link . '">' . $text . '</a>', (int) $total_items);
} else {
$return = apply_filters($filter, array('link' => $link, 'text' => $text), (int) $total_items);
}
do_action('friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $return);
return $return;
}
示例4: setup_nav
/**
* Setup BuddyBar navigation
*
* @global obj $bp
*/
function setup_nav()
{
global $bp;
// Add 'Friends' to the main navigation
$main_nav = array('name' => sprintf(__('Friends <span>%d</span>', 'buddypress'), friends_get_total_friend_count()), 'slug' => $this->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id);
$friends_link = trailingslashit($bp->loggedin_user->domain . bp_get_friends_slug());
// Add the subnav items to the friends nav item
$sub_nav[] = array('name' => __('Friendships', 'buddypress'), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => bp_get_friends_slug(), 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends');
$sub_nav[] = array('name' => __('Requests', 'buddypress'), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => bp_get_friends_slug(), 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_is_my_profile());
parent::setup_nav($main_nav, $sub_nav);
}
示例5: test_bp_has_members_friendship_requests_with_no_requests
/**
* @group bp_has_members
* @group friends
* @ticket BP5071
*/
public function test_bp_has_members_friendship_requests_with_no_requests()
{
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
$old_user = get_current_user_id();
$this->set_current_user($u2);
// For some reason, in all the user switching, the cache gets
// confused. Never comes up when BP runs normally, because the
// loggedin_user doesn't change on a pageload. @todo Fix for
// real in BP
wp_cache_delete('bp_user_domain_' . $u2, 'bp');
$this->go_to(bp_core_get_user_domain($u2) . bp_get_friends_slug() . '/requests/');
$this->restore_admins();
global $members_template;
bp_has_members(array('include' => bp_get_friendship_requests($u2)));
$requests = is_array($members_template->members) ? array_values($members_template->members) : array();
$request_ids = wp_list_pluck($requests, 'ID');
$this->assertEquals(array(), $request_ids);
$this->set_current_user($old_user);
}
示例6: setup_nav
/**
* Setup BuddyBar navigation
*
* @global BuddyPress $bp The one true BuddyPress instance
*/
public function setup_nav($main_nav = array(), $sub_nav = array())
{
global $bp;
$sub_nav = array();
// Add 'Friends' to the main navigation
$main_nav = array('name' => sprintf(__('Friends <span>%d</span>', 'buddypress'), friends_get_total_friend_count()), 'slug' => $this->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id);
// Determine user to use
if (bp_displayed_user_domain()) {
$user_domain = bp_displayed_user_domain();
} elseif (bp_loggedin_user_domain()) {
$user_domain = bp_loggedin_user_domain();
} else {
return;
}
$friends_link = trailingslashit($user_domain . bp_get_friends_slug());
// Add the subnav items to the friends nav item
$sub_nav[] = array('name' => __('Friendships', 'buddypress'), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => bp_get_friends_slug(), 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends');
$sub_nav[] = array('name' => __('Requests', 'buddypress'), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => bp_get_friends_slug(), 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_core_can_edit_settings());
parent::setup_nav($main_nav, $sub_nav);
}
示例7: widget
/**
* Display the widget.
*
* @param array $args Widget arguments.
* @param array $instance The widget settings, as saved by the user.
*/
function widget($args, $instance)
{
extract($args);
if (!bp_displayed_user_id()) {
return;
}
$min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script('bp_core_widget_friends-js', buddypress()->plugin_url . "bp-friends/js/widget-friends{$min}.js", array('jquery'), bp_get_version());
$user_id = bp_displayed_user_id();
$link = trailingslashit(bp_displayed_user_domain() . bp_get_friends_slug());
$instance['title'] = sprintf(__('%s’s Friends', 'buddypress'), bp_get_displayed_user_fullname());
if (empty($instance['friend_default'])) {
$instance['friend_default'] = 'active';
}
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
$title = $instance['link_title'] ? '<a href="' . esc_url($link) . '">' . esc_html($title) . '</a>' : esc_html($title);
echo $before_title . $title . $after_title;
$members_args = array('user_id' => absint($user_id), 'type' => sanitize_text_field($instance['friend_default']), 'max' => absint($instance['max_friends']), 'populate_extras' => 1);
?>
<?php
if (bp_has_members($members_args)) {
?>
<div class="item-options" id="friends-list-options">
<a href="<?php
bp_members_directory_permalink();
?>
" id="newest-friends" <?php
if ($instance['friend_default'] == 'newest') {
?>
class="selected"<?php
}
?>
><?php
_e('Newest', 'buddypress');
?>
</a>
| <a href="<?php
bp_members_directory_permalink();
?>
" id="recently-active-friends" <?php
if ($instance['friend_default'] == 'active') {
?>
class="selected"<?php
}
?>
><?php
_e('Active', 'buddypress');
?>
</a>
| <a href="<?php
bp_members_directory_permalink();
?>
" id="popular-friends" <?php
if ($instance['friend_default'] == 'popular') {
?>
class="selected"<?php
}
?>
><?php
_e('Popular', 'buddypress');
?>
</a>
</div>
<ul id="friends-list" class="item-list">
<?php
while (bp_members()) {
bp_the_member();
?>
<li class="vcard">
<div class="item-avatar">
<a href="<?php
bp_member_permalink();
?>
" title="<?php
bp_member_name();
?>
"><?php
bp_member_avatar();
?>
</a>
</div>
<div class="item">
<div class="item-title fn"><a href="<?php
bp_member_permalink();
?>
" title="<?php
bp_member_name();
?>
"><?php
bp_member_name();
//.........这里部分代码省略.........
示例8: bp_get_friend_reject_request_link
function bp_get_friend_reject_request_link()
{
global $members_template;
if (!($friendship_id = wp_cache_get('friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id()))) {
$friendship_id = friends_get_friendship_id($members_template->member->id, bp_loggedin_user_id());
wp_cache_set('friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp');
}
return apply_filters('bp_get_friend_reject_request_link', wp_nonce_url(bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/reject/' . $friendship_id, 'friends_reject_friendship'));
}
示例9: bp_is_user_friends_activity
/**
* Is the current page a user's Friends activity stream?
*
* Eg http://example.com/members/joe/friends/
*
* @since 1.1.0
*
* @return bool True if the current page is a user's Friends activity stream.
*/
function bp_is_user_friends_activity()
{
if (!bp_is_active('friends')) {
return false;
}
$slug = bp_get_friends_slug();
if (empty($slug)) {
$slug = 'friends';
}
if (bp_is_user_activity() && bp_is_current_action($slug)) {
return true;
}
return false;
}
示例10: bp_members_directory_permalink
?>
" role="navigation">
<ul>
<li class="selected" id="members-all"><a href="<?php
bp_members_directory_permalink();
?>
"><?php
printf(__('All Members %s', 'buddypress'), '<span>' . bp_get_total_member_count() . '</span>');
?>
</a></li>
<?php
if (is_user_logged_in() && bp_is_active('friends') && bp_get_total_friend_count(bp_loggedin_user_id())) {
?>
<li id="members-personal"><a href="<?php
echo esc_url(bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends/');
?>
"><?php
printf(__('My Friends %s', 'buddypress'), '<span>' . bp_get_total_friend_count(bp_loggedin_user_id()) . '</span>');
?>
</a></li>
<?php
}
?>
<?php
/**
* Fires inside the members directory member types.
*
* @since 1.2.0
*/
示例11: bp_site_name
<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_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>
<language><?php
示例12: bp_activity_action_friends_feed
/**
* Load a user's friends feed.
*
* @since BuddyPress (1.0)
*
* @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 $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;
}
示例13: friends_format_notifications
/**
* Notification formatting callback for bp-friends notifications.
*
* @param string $action The kind of notification being rendered.
* @param int $item_id The primary item ID.
* @param int $secondary_item_id The secondary item ID.
* @param int $total_items The total number of messaging-related notifications
* waiting for the user.
* @param string $format 'string' for BuddyBar-compatible notifications;
* 'array' for WP Toolbar. Default: 'string'.
* @return array|string
*/
function friends_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
{
switch ($action) {
case 'friendship_accepted':
$link = trailingslashit(bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends');
// $action and $amount are used to generate dynamic filter names.
$action = 'accepted';
// Set up the string and the filter.
if ((int) $total_items > 1) {
$text = sprintf(__('%d friends accepted your friendship requests', 'buddypress'), (int) $total_items);
$amount = 'multiple';
} else {
$text = sprintf(__('%s accepted your friendship request', 'buddypress'), bp_core_get_user_displayname($item_id));
$amount = 'single';
}
break;
case 'friendship_request':
$link = bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/?new';
$action = 'request';
// Set up the string and the filter.
if ((int) $total_items > 1) {
$text = sprintf(__('You have %d pending friendship requests', 'buddypress'), (int) $total_items);
$amount = 'multiple';
} else {
$text = sprintf(__('You have a friendship request from %s', 'buddypress'), bp_core_get_user_displayname($item_id));
$amount = 'single';
}
break;
}
// Return either an HTML link or an array, depending on the requested format.
if ('string' == $format) {
/**
* Filters the format of friendship notifications based on type and amount * of notifications pending.
*
* This is a variable filter that has four possible versions.
* The four possible versions are:
* - bp_friends_single_friendship_accepted_notification
* - bp_friends_multiple_friendship_accepted_notification
* - bp_friends_single_friendship_request_notification
* - bp_friends_multiple_friendship_request_notification
*
* @since 1.0.0
*
* @param string|array $value Depending on format, an HTML link to new requests profile
* tab or array with link and text.
* @param int $total_items The total number of messaging-related notifications
* waiting for the user.
* @param int $item_id The primary item ID.
*/
$return = apply_filters('bp_friends_' . $amount . '_friendship_' . $action . '_notification', '<a href="' . esc_url($link) . '">' . esc_html($text) . '</a>', (int) $total_items, $item_id);
} else {
/** This filter is documented in bp-friends/bp-friends-notifications.php */
$return = apply_filters('bp_friends_' . $amount . '_friendship_' . $action . '_notification', array('link' => $link, 'text' => $text), (int) $total_items, $item_id);
}
/**
* Fires at the end of the bp-friends notification format callback.
*
* @since 1.0.0
*
* @param string $action The kind of notification being rendered.
* @param int $item_id The primary item ID.
* @param int $secondary_item_id The secondary item ID.
* @param int $total_items The total number of messaging-related notifications
* waiting for the user.
* @param array|string $return Notification text string or array of link and text.
*/
do_action('friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $return);
return $return;
}
示例14: friends_notification_new_request
/**
* Send notifications related to a new friendship request.
*
* When a friendship is requested, an email and a BP notification are sent to
* the user of whom friendship has been requested ($friend_id).
*
* @since 1.0.0
*
* @param int $friendship_id ID of the friendship object.
* @param int $initiator_id ID of the user who initiated the request.
* @param int $friend_id ID of the request recipient.
*/
function friends_notification_new_request($friendship_id, $initiator_id, $friend_id)
{
if ('no' == bp_get_user_meta((int) $friend_id, 'notification_friends_friendship_request', true)) {
return;
}
$unsubscribe_args = array('user_id' => $friend_id, 'notification_type' => 'friends-request');
$args = array('tokens' => array('friend-requests.url' => esc_url(bp_core_get_user_domain($friend_id) . bp_get_friends_slug() . '/requests/'), 'friend.id' => $friend_id, 'friendship.id' => $friendship_id, 'initiator.id' => $initiator_id, 'initiator.url' => esc_url(bp_core_get_user_domain($initiator_id)), 'initiator.name' => bp_core_get_user_displayname($initiator_id), 'unsubscribe' => esc_url(bp_email_get_unsubscribe_link($unsubscribe_args))));
bp_send_email('friends-request', $friend_id, $args);
}
示例15: bp_get_friend_reject_request_link
/**
* Return the URL for rejecting the current friendship request in the loop.
*
* @return string reject-friendship URL.
*/
function bp_get_friend_reject_request_link()
{
global $members_template;
if (!($friendship_id = wp_cache_get('friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id()))) {
$friendship_id = friends_get_friendship_id($members_template->member->id, bp_loggedin_user_id());
wp_cache_set('friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp');
}
/**
* Filters the URL for rejecting the current friendship request in the loop.
*
* @since 1.0.0
*
* @param string $value Reject-friendship URL.
*/
return apply_filters('bp_get_friend_reject_request_link', wp_nonce_url(bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/reject/' . $friendship_id, 'friends_reject_friendship'));
}