本文整理汇总了PHP中bp_get_button函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_get_button函数的具体用法?PHP bp_get_button怎么用?PHP bp_get_button使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_get_button函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_mute_get_button
/**
* Create a button.
*
* @since 1.0.0
*
* @param int $muted_id The ID of the muted user.
* @return string
*/
function bp_mute_get_button($muted_id)
{
global $bp, $members_template;
if (!$muted_id) {
return;
}
$obj = new Mute($muted_id, bp_loggedin_user_id());
$action = $obj->id ? '/stop/' : '/start/';
$url = bp_core_get_user_domain($muted_id) . $bp->mute->slug . $action;
$button = array('id' => $obj->id ? 'muted' : 'unmuted', 'link_class' => $obj->id ? 'muted' : 'unmuted', 'link_id' => $obj->id ? 'mute-' . $muted_id : 'mute-' . $muted_id, 'link_title' => $obj->id ? _x('Unmute', 'Button', 'buddypress-mute') : _x('Mute', 'Button', 'buddypress-mute'), 'link_text' => $obj->id ? _x('Unmute', 'Button', 'buddypress-mute') : _x('Mute', 'Button', 'buddypress-mute'), 'link_href' => $obj->id ? wp_nonce_url($url, 'unmute') : wp_nonce_url($url, 'mute'), 'wrapper_class' => 'mute-button', 'component' => 'mute', 'wrapper_id' => 'mute-button-' . $muted_id, 'must_be_logged_in' => true, 'block_self' => true);
return bp_get_button($button);
}
示例2: bp_get_send_public_message_button
/**
* Return button for sending a public message
*
* @since 1.2.0
*
* @param array $args Optional
*
* @uses bp_get_send_public_message_link()
* @uses nxt_parse_args()
* @uses bp_get_button()
* @uses apply_filters() To call the 'bp_get_send_public_message_button' hook
*
* @return string The button for sending a public message
*/
function bp_get_send_public_message_button($args = '')
{
$defaults = array('id' => 'public_message', 'component' => 'activity', 'must_be_logged_in' => true, 'block_self' => true, 'wrapper_id' => 'post-mention', 'link_href' => bp_get_send_public_message_link(), 'link_title' => __('Send a public message on your activity stream.', 'buddypress'), 'link_text' => __('Public Message', 'buddypress'), 'link_class' => 'activity-button mention');
$button = nxt_parse_args($args, $defaults);
// Filter and return the HTML button
return bp_get_button(apply_filters('bp_get_send_public_message_button', $button));
}
示例3: bp_get_blogs_visit_blog_button
/**
* bp_get_blogs_visit_blog_button()
*
* Return button for visiting a blog in a loop
*
* @param array $args Custom button properties
* @return string
*/
function bp_get_blogs_visit_blog_button( $args = '' ) {
$defaults = array(
'id' => 'visit_blog',
'component' => 'blogs',
'must_be_logged_in' => false,
'block_self' => false,
'wrapper_class' => 'blog-button visit',
'link_href' => bp_get_blog_permalink(),
'link_class' => 'visit',
'link_text' => __( 'Visit Blog', 'buddypress' ),
'link_title' => __( 'Visit Blog', 'buddypress' ),
);
$button = wp_parse_args( $args, $defaults );
// Filter and return the HTML button
return bp_get_button( apply_filters( 'bp_get_blogs_visit_blog_button', $button ) );
}
示例4: bp_compliments_get_add_compliment_button
/**
* Returns a compliment button for a given user.
*
* @since 0.0.1
* @package BuddyPress_Compliments
*
* @global object $bp BuddyPress instance.
* @global object $members_template Members template object.
* @param array|string $args {
* Attributes of the $args.
*
* @type int $receiver_id Compliment receiver ID.
* @type int $sender_id Compliment sender ID.
* @type string $link_text Link text.
* @type string $link_title Link title.
* @type string $wrapper_class Link wrapper class.
* @type string $link_class Link class. Default "compliments-popup".
* @type string $wrapper Link wrapper. Default "div".
*
* }
* @return string Button HTML.
*/
function bp_compliments_get_add_compliment_button($args = '')
{
global $bp, $members_template;
$r = wp_parse_args($args, array('receiver_id' => bp_displayed_user_id(), 'sender_id' => bp_loggedin_user_id(), 'link_text' => '', 'link_title' => '', 'wrapper_class' => '', 'link_class' => 'compliments-popup', 'wrapper' => 'div'));
if (!$r['receiver_id'] || !$r['sender_id']) {
return false;
}
// if the logged-in user is the receiver, use already-queried variables
if (bp_loggedin_user_id() && $r['receiver_id'] == bp_loggedin_user_id()) {
$receiver_domain = bp_loggedin_user_domain();
$receiver_fullname = bp_get_loggedin_user_fullname();
// else we do a lookup for the user domain and display name of the receiver
} else {
$receiver_domain = bp_core_get_user_domain($r['receiver_id']);
$receiver_fullname = bp_core_get_user_displayname($r['receiver_id']);
}
// setup some variables
$id = 'compliments';
$action = 'start';
$class = 'compliments';
/**
* Filters the compliment receiver name.
*
* @since 0.0.1
* @package BuddyPress_Compliments
*
* @param string $receiver_fullname Receiver full name.
* @param int $r['receiver_id'] Receiver ID.
*/
$link_text = sprintf(sprintf(__('Send %s', 'bp-compliments'), BP_COMP_SINGULAR_NAME), apply_filters('bp_compliments_receiver_name', bp_get_user_firstname($receiver_fullname), $r['receiver_id']));
if (empty($r['link_text'])) {
$r['link_text'] = $link_text;
}
$wrapper_class = 'compliments-button ' . $id;
if (!empty($r['wrapper_class'])) {
$wrapper_class .= ' ' . esc_attr($r['wrapper_class']);
}
$link_class = $class;
if (!empty($r['link_class'])) {
$link_class .= ' ' . esc_attr($r['link_class']);
}
// make sure we can view the button if a user is on their own page
$block_self = empty($members_template->member) ? true : false;
// if we're using AJAX and a user is on their own profile, we need to set
// block_self to false so the button shows up
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' && bp_is_my_profile()) {
$block_self = false;
}
// setup the button arguments
$button = array('id' => $id, 'component' => 'compliments', 'must_be_logged_in' => true, 'block_self' => $block_self, 'wrapper_class' => $wrapper_class, 'wrapper_id' => 'compliments-button-' . (int) $r['receiver_id'], 'link_href' => wp_nonce_url($receiver_domain . $bp->compliments->compliments->slug . '/' . $action . '/', $action . '_compliments'), 'link_text' => esc_attr($r['link_text']), 'link_title' => esc_attr($r['link_title']), 'link_id' => $class . '-' . (int) $r['receiver_id'], 'link_class' => $link_class, 'wrapper' => !empty($r['wrapper']) ? esc_attr($r['wrapper']) : false);
// Filter and return the HTML button
/**
* Filters the compliment button.
*
* @since 0.0.1
* @package BuddyPress_Compliments
*
* @param string $button Button HTML.
* @param int $r['receiver_id'] Receiver ID.
* @param int $r['sender_id'] Sender ID.
*/
return bp_get_button(apply_filters('bp_compliments_get_add_compliment_button', $button, $r['receiver_id'], $r['sender_id']));
}
示例5: buddyreshare_activity_get_button
/**
* Builds the reshare button
*
* @package BP Reshare
* @since 1.0
*
* @global BP_Activity_Template $activities_template
* @uses buddyreshare_activity_can_reshare() to check if the activity can be reshared
* @uses buddyreshare_activity_get_button_class() to get button's classe
* @uses buddyreshare_activity_get_reshares_count() to get the number of reshares
* @uses bp_get_activity_id() to get activity id
* @uses buddyreshare_get_component_id() to get component's id
* @uses buddyreshare_activity_get_action_url() to get action url
* @uses buddyreshare_activity_get_id_to_reshare() to get the activity id to reshare
* @uses buddyreshare_activity_get_button_title() to get the button title
* @uses bp_get_button() to build the button
* @return string reshare button
*/
function buddyreshare_activity_get_button()
{
global $activities_template;
if (!buddyreshare_activity_can_reshare()) {
return false;
}
$caption = apply_filters('buddyreshare_activity_get_button_caption', buddyreshare_activity_get_button_title());
$link_text = '<span class="' . buddyreshare_activity_get_button_class() . '">' . $caption . '</span><span class="rs-count">' . buddyreshare_activity_get_reshares_count() . '</span>';
$button = array('id' => 'reshare-container-' . bp_get_activity_id(), 'component' => buddyreshare_get_component_id(), 'must_be_logged_in' => true, 'wrapper' => false, 'block_self' => false, 'link_id' => 'bp-reshare-' . bp_get_activity_id(), 'link_href' => buddyreshare_activity_get_action_url(), 'link_rel' => buddyreshare_activity_get_id_to_reshare(), 'link_title' => buddyreshare_activity_get_button_title(), 'link_text' => $link_text, 'link_class' => 'button reshare-button bp-secondary-action');
// Filter and return the HTML button
return bp_get_button(apply_filters('buddyreshare_activity_get_button', $button));
}
示例6: bp_get_group_create_button
/**
* Get the Create a Group button.
*
* @since 2.0.0
*
* @return string
*/
function bp_get_group_create_button()
{
if (!is_user_logged_in()) {
return false;
}
if (!bp_user_can_create_groups()) {
return false;
}
$button_args = array('id' => 'create_group', 'component' => 'groups', 'link_text' => __('Create a Group', 'buddypress'), 'link_title' => __('Create a Group', 'buddypress'), 'link_class' => 'group-create no-ajax', 'link_href' => trailingslashit(bp_get_groups_directory_permalink() . 'create'), 'wrapper' => false, 'block_self' => false);
/**
* Filters the HTML button for creating a group.
*
* @since 2.0.0
*
* @param string $button HTML button for creating a group.
*/
return bp_get_button(apply_filters('bp_get_group_create_button', $button_args));
}
示例7: bp_follow_ajax_action_stop
/**
* AJAX callback when clicking on the "Unfollow" button to unfollow a user.
*
* @uses check_admin_referer() Checks to make sure the WP security nonce matches.
* @uses bp_follow_stop_following() Stops a user following another user.
* @uses bp_follow_is_following() Checks to see if a user is following another user already.
*/
function bp_follow_ajax_action_stop()
{
check_admin_referer('stop_following');
$link_class = !empty($_POST['link_class']) ? str_replace('unfollow ', '', $_POST['link_class']) : false;
// successful unfollow
if (bp_follow_stop_following(array('leader_id' => $_POST['uid'], 'follower_id' => bp_loggedin_user_id()))) {
// output follow button
$output = bp_follow_get_add_follow_button(array('leader_id' => $_POST['uid'], 'follower_id' => bp_loggedin_user_id(), 'wrapper' => false, 'link_class' => $link_class));
// failed unfollow
} else {
// output fallback invalid button
$args = array('id' => 'invalid', 'link_href' => 'javascript:;', 'component' => 'follow', 'wrapper' => false, 'link_class' => $link_class);
if (!bp_follow_is_following(array('leader_id' => $_POST['uid'], 'follower_id' => bp_loggedin_user_id()))) {
$output = bp_get_button(array_merge(array('link_text' => __('Not following', 'bp-follow')), $args));
} else {
$output = bp_get_button(array_merge(array('link_text' => __('Error unfollowing user', 'bp-follow')), $args));
}
}
echo $output;
exit;
}
示例8: bp_button
/**
* Create and output a button.
*
* @since 1.2.6
*
* @see bp_get_button()
*
* @param array|string $args See {@link BP_Button}.
*/
function bp_button($args = '')
{
echo bp_get_button($args);
}
示例9: bp_get_send_message_button
function bp_get_send_message_button() {
return apply_filters( 'bp_get_send_message_button',
bp_get_button( array(
'id' => 'private_message',
'component' => 'messages',
'must_be_logged_in' => true,
'block_self' => true,
'wrapper_id' => 'send-private-message',
'link_href' => bp_get_send_private_message_link(),
'link_class' => 'send-message',
'link_title' => __( 'Send a private message to this user.', 'buddypress' ),
'link_text' => __( 'Send Private Message', 'buddypress' )
) )
);
}
示例10: event_espresso_get_add_register_button
function event_espresso_get_add_register_button($event_id = 0)
{
global $bp, $events_template, $org_options, $wpdb;
if ($event_id == 0) {
return false;
}
$is_active = event_espresso_get_is_active($event_id);
switch ($is_active['status']) {
case 'EXPIRED':
//only show the event description.
$html = _e('<p class="expired_event">This event has passed.</p>', 'event_espresso');
return $html;
break;
case 'REGISTRATION_CLOSED':
//only show the event description.
// if todays date is after $reg_end_date
$html = _e('<p class="expired_event">We are sorry but registration for this event is now closed.</p>', 'event_espresso');
return $html;
break;
case 'REGISTRATION_NOT_OPEN':
//only show the event description.
// if todays date is after $reg_end_date
// if todays date is prior to $reg_start_date
$html = _e('<p class="expired_event">We are sorry but this event is not yet open for registration.</p>', 'event_espresso');
return $html;
break;
}
$event = $wpdb->get_row("select * from " . EVENTS_DETAIL_TABLE . " WHERE id = {$event_id} ");
$externalURL = $event->externalURL;
$registration_url = $externalURL != '' ? $externalURL : home_url() . '/?page_id=' . $org_options['event_page_id'] . '®event_action=register&event_id=' . $event_id;
$button = array('id' => 'register', 'component' => 'events', 'must_be_logged_in' => false, 'block_self' => false, 'wrapper_class' => 'register-button', 'wrapper_id' => 'register-button-' . $event_id, 'link_class' => 'requested', 'link_href' => $registration_url, 'link_text' => __('Register For Event', 'buddypress'), 'link_title' => __('Register For Event', 'buddypress'));
// Filter and return the HTML button
return bp_get_button(apply_filters('event_espresso_get_add_register_button', $button));
}
示例11: action_bp_button
/**
* Adds a 'Switch To' link to each member's profile page and profile listings in BuddyPress.
*
* @return null
*/
public function action_bp_button()
{
global $bp, $members_template;
if (!empty($members_template) and empty($bp->displayed_user->id)) {
$id = absint($members_template->member->id);
} else {
$id = absint($bp->displayed_user->id);
}
if (!($link = self::maybe_switch_url($id))) {
return;
}
$link = add_query_arg(array('redirect_to' => urlencode(bp_core_get_user_domain($id))), $link);
# Workaround for https://buddypress.trac.wordpress.org/ticket/4212
$components = array_keys($bp->active_components);
if (!empty($components)) {
$component = reset($components);
} else {
$component = 'core';
}
echo bp_get_button(array('id' => 'user_switching', 'component' => $component, 'link_href' => $link, 'link_text' => __('Switch To', 'user-switching')));
}
示例12: bp_follow_get_add_follow_button
/**
* Returns a follow / unfollow button for a given user depending on the follower status.
*
* Checks to see if the follower is already following the leader. If is following, returns
* "Stop following" button; if not following, returns "Follow" button.
*
* @param array $args {
* Array of arguments.
* @type int $leader_id The user ID of the person we want to follow.
* @type int $follower_id The user ID initiating the follow request.
* @type string $link_text The anchor text for the link.
* @type string $link_title The title attribute for the link.
* @type string $wrapper_class CSS class for the wrapper container.
* @type string $link_class CSS class for the link.
* @type string $wrapper The element for the wrapper container. Defaults to 'div'.
* }
* @return mixed String of the button on success. Boolean false on failure.
* @uses bp_get_button() Renders a button using the BP Button API
* @author r-a-y
* @since 1.1
*/
function bp_follow_get_add_follow_button($args = '')
{
global $bp, $members_template;
$r = wp_parse_args($args, array('leader_id' => bp_displayed_user_id(), 'follower_id' => bp_loggedin_user_id(), 'link_text' => '', 'link_title' => '', 'wrapper_class' => '', 'link_class' => '', 'wrapper' => 'div'));
if (!$r['leader_id'] || !$r['follower_id']) {
return false;
}
// if we're checking during a members loop, then follow status is already
// queried via bp_follow_inject_member_follow_status()
if (!empty($members_template->in_the_loop) && $r['follower_id'] == bp_loggedin_user_id() && $r['leader_id'] == bp_get_member_user_id()) {
$is_following = $members_template->member->is_following;
// else we manually query the follow status
} else {
$is_following = bp_follow_is_following(array('leader_id' => $r['leader_id'], 'follower_id' => $r['follower_id']));
}
// if the logged-in user is the leader, use already-queried variables
if (bp_loggedin_user_id() && $r['leader_id'] == bp_loggedin_user_id()) {
$leader_domain = bp_loggedin_user_domain();
$leader_fullname = bp_get_loggedin_user_fullname();
// else we do a lookup for the user domain and display name of the leader
} else {
$leader_domain = bp_core_get_user_domain($r['leader_id']);
$leader_fullname = bp_core_get_user_displayname($r['leader_id']);
}
// setup some variables
if ($is_following) {
$id = 'following';
$action = 'stop';
$class = 'unfollow';
$link_text = sprintf(_x('Unfollow', 'Button', 'bp-follow'), apply_filters('bp_follow_leader_name', bp_get_user_firstname($leader_fullname), $r['leader_id']));
if (empty($r['link_text'])) {
$r['link_text'] = $link_text;
}
} else {
$id = 'not-following';
$action = 'start';
$class = 'follow';
$link_text = sprintf(_x('Follow', 'Button', 'bp-follow'), apply_filters('bp_follow_leader_name', bp_get_user_firstname($leader_fullname), $r['leader_id']));
if (empty($r['link_text'])) {
$r['link_text'] = $link_text;
}
}
$wrapper_class = 'follow-button ' . $id;
if (!empty($r['wrapper_class'])) {
$wrapper_class .= ' ' . esc_attr($r['wrapper_class']);
}
$link_class = $class;
if (!empty($r['link_class'])) {
$link_class .= ' ' . esc_attr($r['link_class']);
}
// make sure we can view the button if a user is on their own page
$block_self = empty($members_template->member) ? true : false;
// if we're using AJAX and a user is on their own profile, we need to set
// block_self to false so the button shows up
if (bp_follow_is_doing_ajax() && bp_is_my_profile()) {
$block_self = false;
}
// setup the button arguments
$button = array('id' => $id, 'component' => 'follow', 'must_be_logged_in' => true, 'block_self' => $block_self, 'wrapper_class' => $wrapper_class, 'wrapper_id' => 'follow-button-' . (int) $r['leader_id'], 'link_href' => wp_nonce_url($leader_domain . $bp->follow->followers->slug . '/' . $action . '/', $action . '_following'), 'link_text' => esc_attr($r['link_text']), 'link_title' => esc_attr($r['link_title']), 'link_id' => $class . '-' . (int) $r['leader_id'], 'link_class' => $link_class, 'wrapper' => !empty($r['wrapper']) ? esc_attr($r['wrapper']) : false);
// Filter and return the HTML button
return bp_get_button(apply_filters('bp_follow_get_add_follow_button', $button, $r['leader_id'], $r['follower_id']));
}
示例13: bp_get_send_public_message_button
/**
* bp_get_send_public_message_button( $args )
*
* Return button for sending a public message
*
* @param array $args
* @return string
*/
function bp_get_send_public_message_button( $args = '' ) {
$defaults = array(
'id' => 'public_message',
'component' => 'activity',
'must_be_logged_in' => true,
'block_self' => true,
'wrapper_id' => 'post-mention',
'link_href' => bp_get_send_public_message_link(),
'link_title' => __( 'Mention this user in a new public message, this will send the user a notification to get their attention.', 'buddypress' ),
'link_text' => __( 'Mention this User', 'buddypress' )
);
$button = wp_parse_args( $args, $defaults );
// Filter and return the HTML button
return bp_get_button( apply_filters( 'bp_get_send_public_message_button', $button ) );
}
示例14: action_bp_button
/**
* Adds a 'Switch To' link to each member's profile page and profile listings in BuddyPress.
*/
public function action_bp_button()
{
global $bp, $members_template;
if (!empty($members_template) && empty($bp->displayed_user->id)) {
$user = get_userdata($members_template->member->id);
} else {
$user = get_userdata($bp->displayed_user->id);
}
if (!$user) {
return;
}
if (!($link = self::maybe_switch_url($user))) {
return;
}
$link = add_query_arg(array('redirect_to' => urlencode(bp_core_get_user_domain($user->ID))), $link);
# Workaround for https://buddypress.trac.wordpress.org/ticket/4212
$components = array_keys($bp->active_components);
if (!empty($components)) {
$component = reset($components);
} else {
$component = 'core';
}
// @codingStandardsIgnoreStart
echo bp_get_button(array('id' => 'user_switching', 'component' => $component, 'link_href' => esc_url($link), 'link_text' => esc_html__('Switch To', 'user-switching'), 'wrapper_id' => 'user_switching_switch_to'));
// @codingStandardsIgnoreEnd
}
示例15: bp_get_add_friend_button
function bp_get_add_friend_button($potential_friend_id = 0, $friend_status = false)
{
global $bp, $friends_template;
if (empty($potential_friend_id)) {
$potential_friend_id = bp_get_potential_friend_id($potential_friend_id);
}
$is_friend = bp_is_friend($potential_friend_id);
if (empty($is_friend)) {
return false;
}
switch ($is_friend) {
case 'pending':
$button = array('id' => 'pending', 'component' => 'friends', 'must_be_logged_in' => true, 'block_self' => true, 'wrapper_class' => 'friendship-button pending', 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 'link_href' => trailingslashit($bp->loggedin_user->domain . bp_get_friends_slug() . '/requests'), 'link_text' => __('Friendship Requested', 'buddypress'), 'link_title' => __('Friendship Requested', 'buddypress'), 'link_class' => 'friendship-button pending requested');
break;
case 'is_friend':
$button = array('id' => 'is_friend', 'component' => 'friends', 'must_be_logged_in' => true, 'block_self' => false, 'wrapper_class' => 'friendship-button is_friend', 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 'link_href' => nxt_nonce_url($bp->loggedin_user->domain . bp_get_friends_slug() . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend'), 'link_text' => __('Cancel Friendship', 'buddypress'), 'link_title' => __('Cancel Friendship', 'buddypress'), 'link_id' => 'friend-' . $potential_friend_id, 'link_rel' => 'remove', 'link_class' => 'friendship-button is_friend remove');
break;
default:
$button = array('id' => 'not_friends', 'component' => 'friends', 'must_be_logged_in' => true, 'block_self' => true, 'wrapper_class' => 'friendship-button not_friends', 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 'link_href' => nxt_nonce_url($bp->loggedin_user->domain . bp_get_friends_slug() . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend'), 'link_text' => __('Add Friend', 'buddypress'), 'link_title' => __('Add Friend', 'buddypress'), 'link_id' => 'friend-' . $potential_friend_id, 'link_rel' => 'add', 'link_class' => 'friendship-button not_friends add');
break;
}
// Filter and return the HTML button
return bp_get_button(apply_filters('bp_get_add_friend_button', $button));
}