本文整理汇总了PHP中bp_is_action_variable函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_is_action_variable函数的具体用法?PHP bp_is_action_variable怎么用?PHP bp_is_action_variable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_is_action_variable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: friends_screen_requests
function friends_screen_requests()
{
if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_accept_friendship');
if (friends_accept_friendship(bp_action_variable(1))) {
bp_core_add_message(__('Friendship accepted', 'buddypress'));
} else {
bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error');
}
bp_core_redirect(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action());
} elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_reject_friendship');
if (friends_reject_friendship(bp_action_variable(1))) {
bp_core_add_message(__('Friendship rejected', 'buddypress'));
} else {
bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error');
}
bp_core_redirect(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action());
}
do_action('friends_screen_requests');
if (isset($_GET['new'])) {
bp_core_delete_notifications_by_type(bp_loggedin_user_id(), 'friends', 'friendship_request');
}
bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home'));
}
示例2: friends_screen_requests
/**
* Catch and process the Requests page.
*/
function friends_screen_requests()
{
if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_accept_friendship');
if (friends_accept_friendship(bp_action_variable(1))) {
bp_core_add_message(__('Friendship accepted', 'buddypress'));
} else {
bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error');
}
bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
} elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_reject_friendship');
if (friends_reject_friendship(bp_action_variable(1))) {
bp_core_add_message(__('Friendship rejected', 'buddypress'));
} else {
bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error');
}
bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
} elseif (bp_is_action_variable('cancel', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_withdraw_friendship');
if (friends_withdraw_friendship(bp_loggedin_user_id(), bp_action_variable(1))) {
bp_core_add_message(__('Friendship request withdrawn', 'buddypress'));
} else {
bp_core_add_message(__('Friendship request could not be withdrawn', 'buddypress'), 'error');
}
bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
}
do_action('friends_screen_requests');
bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home'));
}
示例3: bp_groupblog_add_js
/**
* bp_groupblog_add_js()
*/
function bp_groupblog_add_js()
{
if (bp_is_groups_component() && bp_is_action_variable('group-blog')) {
if (file_exists(get_stylesheet_directory() . '/groupblog/js/general.js')) {
wp_enqueue_script('bp-groupblog-js', get_stylesheet_directory_uri() . '/groupblog/js/general.js', array('jquery'));
} else {
wp_enqueue_script('bp-groupblog-js', plugins_url() . '/bp-groupblog/groupblog/js/general.js', array('jquery'));
}
}
}
示例4: bp_example_high_five_save
/**
* Check to see if a high five is being given, and if so, save it.
*
* Hooked to bp_actions, this function will fire before the screen function. We use our function
* bp_is_example_component(), along with the bp_is_current_action() and bp_is_action_variable()
* functions, to detect (based on the requested URL) whether the user has clicked on "send high
* five". If so, we do a bit of simple logic to see what should happen next.
*
* @package BuddyPress_Skeleton_Component
* @since 1.6
*/
function bp_example_high_five_save()
{
if (bp_is_example_component() && bp_is_current_action('screen-one') && bp_is_action_variable('send-h5', 0)) {
// The logged in user has clicked on the 'send high five' link
if (bp_is_my_profile()) {
// Don't let users high five themselves
bp_core_add_message(__('No self-fives! :)', 'bp-example'), 'error');
} else {
if (bp_example_send_highfive(bp_displayed_user_id(), bp_loggedin_user_id())) {
bp_core_add_message(__('High-five sent!', 'bp-example'));
} else {
bp_core_add_message(__('High-five could not be sent.', 'bp-example'), 'error');
}
}
bp_core_redirect(bp_displayed_user_domain() . bp_get_example_slug() . '/screen-one');
}
}
示例5: xprofile_action_delete_avatar
/**
* This function runs when an action is set for a screen:
* example.com/members/andy/profile/change-avatar/ [delete-avatar]
*
* The function will delete the active avatar for a user.
*
* @package BuddyPress Xprofile
* @uses bp_core_delete_avatar() Deletes the active avatar for the logged in user.
* @uses add_action() Runs a specific function for an action when it fires.
*/
function xprofile_action_delete_avatar()
{
if (!bp_is_user_change_avatar() || !bp_is_action_variable('delete-avatar', 0)) {
return false;
}
// Check the nonce
check_admin_referer('bp_delete_avatar_link');
if (!bp_is_my_profile() && !bp_current_user_can('bp_moderate')) {
return false;
}
if (bp_core_delete_existing_avatar(array('item_id' => bp_displayed_user_id()))) {
bp_core_add_message(__('Your avatar was deleted successfully!', 'buddypress'));
} else {
bp_core_add_message(__('There was a problem deleting that avatar, please try again.', 'buddypress'), 'error');
}
bp_core_redirect(wp_get_referer());
}
示例6: friends_screen_requests
/**
* Catch and process the Requests page.
*/
function friends_screen_requests()
{
if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_accept_friendship');
if (friends_accept_friendship(bp_action_variable(1))) {
bp_core_add_message(__('Friendship accepted', 'buddypress'));
} else {
bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error');
}
bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
} elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_reject_friendship');
if (friends_reject_friendship(bp_action_variable(1))) {
bp_core_add_message(__('Friendship rejected', 'buddypress'));
} else {
bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error');
}
bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
} elseif (bp_is_action_variable('cancel', 0) && is_numeric(bp_action_variable(1))) {
// Check the nonce
check_admin_referer('friends_withdraw_friendship');
if (friends_withdraw_friendship(bp_loggedin_user_id(), bp_action_variable(1))) {
bp_core_add_message(__('Friendship request withdrawn', 'buddypress'));
} else {
bp_core_add_message(__('Friendship request could not be withdrawn', 'buddypress'), 'error');
}
bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
}
/**
* Fires before the loading of template for the friends requests page.
*
* @since BuddyPress (1.0.0)
*/
do_action('friends_screen_requests');
/**
* Filters the template used to display the My Friends page.
*
* @since BuddyPress (1.0.0)
*
* @param string $template Path to the friends request template to load.
*/
bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home'));
}
示例7: get_current_view
/**
* Sets up the current view when viewing a user page
*
* @since 1.2
*/
function get_current_view($view, $item_type)
{
global $wp_rewrite;
if ($item_type == 'user') {
$current_action = bp_current_action();
if (empty($current_action) || in_array($current_action, array(BP_DOCS_STARTED_SLUG, BP_DOCS_EDITED_SLUG))) {
// An empty $bp->action_variables[0] means that you're looking at a list.
// A url like members/terry/docs/started/page/3 also means you're looking at a list.
$view = 'list';
} else {
if ($current_action == BP_DOCS_CATEGORY_SLUG) {
// Category view
$view = 'category';
} else {
if ($current_action == BP_DOCS_CREATE_SLUG) {
// Create new doc
$view = 'create';
} else {
if (!bp_action_variable(0)) {
// $bp->action_variables[1] is the slug for this doc. If there's no
// further chunk, then we're attempting to view a single item
$view = 'single';
} else {
if (bp_is_action_variable(BP_DOCS_EDIT_SLUG, 0)) {
// This is an edit page
$view = 'edit';
} else {
if (bp_is_action_variable(BP_DOCS_DELETE_SLUG, 0)) {
// This is an delete request
$view = 'delete';
} else {
if (bp_is_action_variable(BP_DOCS_HISTORY_SLUG, 0)) {
// This is a history request
$view = 'history';
}
}
}
}
}
}
}
}
return $view;
}
示例8: messages_action_bulk_delete
function messages_action_bulk_delete()
{
if (!bp_is_messages_component() || !bp_is_action_variable('bulk-delete', 0)) {
return false;
}
$thread_ids = $_POST['thread_ids'];
if (!$thread_ids || !messages_check_thread_access($thread_ids)) {
bp_core_redirect(trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action()));
} else {
if (!check_admin_referer('messages_delete_thread')) {
return false;
}
if (!messages_delete_thread($thread_ids)) {
bp_core_add_message(__('There was an error deleting messages.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('Messages deleted.', 'buddypress'));
}
bp_core_redirect(trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action()));
}
}
示例9: get_current_view
/**
* Sets up the current view when viewing a user page
*
* @since 1.2
*/
function get_current_view($view, $item_type)
{
if ($item_type == 'user') {
if (!bp_current_action()) {
// An empty $bp->action_variables[0] means that you're looking at a list
$view = 'list';
} else {
if (bp_is_current_action(BP_DOCS_CATEGORY_SLUG)) {
// Category view
$view = 'category';
} else {
if (bp_is_current_action(BP_DOCS_CREATE_SLUG)) {
// Create new doc
$view = 'create';
} else {
if (!bp_action_variable(0)) {
// $bp->action_variables[1] is the slug for this doc. If there's no
// further chunk, then we're attempting to view a single item
$view = 'single';
} else {
if (bp_is_action_variable(BP_DOCS_EDIT_SLUG, 0)) {
// This is an edit page
$view = 'edit';
} else {
if (bp_is_action_variable(BP_DOCS_DELETE_SLUG, 0)) {
// This is an delete request
$view = 'delete';
} else {
if (bp_is_action_variable(BP_DOCS_HISTORY_SLUG, 0)) {
// This is a history request
$view = 'history';
}
}
}
}
}
}
}
}
return $view;
}
示例10: view_single
public function view_single()
{
$bp = buddypress();
if (function_exists('bp_is_group') && !bp_is_group()) {
return;
}
//do not catch the request for creating new post
if (bp_is_action_variable('create', 0)) {
return;
}
$current_group = groups_get_current_group();
if (bcg_is_disabled($current_group->id)) {
return;
}
//if the group is private/hidden and user is not member, return
if (($current_group->status == 'private' || $current_group->status == 'hidden') && (!is_user_logged_in() || !groups_is_user_member(bp_loggedin_user_id(), $current_group->id))) {
return;
//avoid prioivacy troubles
}
if (bcg_is_component() && !empty($bp->action_variables[0])) {
//should we check for the existence of the post?
add_action('bp_template_content', array($this, 'get_single_post_contents'));
}
}
示例11: bp_has_forum_topic_posts
/**
* Initiate the loop for a single topic's posts.
*
* @param array $args {
* Arguments for limiting the contents of the topic posts loop.
* @type int $topic_id ID of the topic to which the posts belong.
* @type int $per_page Number of items to return per page. Default: 15.
* @type int $max Max items to return. Default: false.
* @type string $order 'ASC' or 'DESC'.
* }
* @return bool True when posts are found corresponding to the args,
* otherwise false.
*/
function bp_has_forum_topic_posts( $args = '' ) {
global $topic_template;
$defaults = array(
'topic_id' => false,
'per_page' => 15,
'max' => false,
'order' => 'ASC'
);
$r = bp_parse_args( $args, $defaults, 'has_forum_topic_posts' );
extract( $r, EXTR_SKIP );
if ( empty( $topic_id ) && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) && bp_action_variable( 1 ) )
$topic_id = bp_forums_get_topic_id_from_slug( bp_action_variable( 1 ) );
elseif ( empty( $topic_id ) && bp_is_forums_component() && bp_is_current_action( 'topic' ) && bp_action_variable( 0 ) )
$topic_id = bp_forums_get_topic_id_from_slug( bp_action_variable( 0 ) );
if ( empty( $topic_id ) ) {
return false;
} else {
$topic_template = new BP_Forums_Template_Topic( (int) $topic_id, $per_page, $max, $order );
// Current topic forum_id needs to match current_group forum_id
if ( bp_is_groups_component() && $topic_template->forum_id != groups_get_groupmeta( bp_get_current_group_id(), 'forum_id' ) )
return false;
}
/**
* Filters whether or not there are topics to display.
*
* @since BuddyPress (1.1.0)
*
* @param bool $value Whether or not there are topics.
* @param BP_Forums_Template_Topic $topic_template Topic template global to use when rendering.
*/
return apply_filters( 'bp_has_topic_posts', $topic_template->has_posts(), $topic_template );
}
示例12: bp_friends_header_tabs
/**
* Displays Friends header tabs
*
* @deprecated 1.6.0
* @deprecated No longer used
*/
function bp_friends_header_tabs()
{
_deprecated_function(__FUNCTION__, '1.6', 'Since BuddyPress 1.2, BP has not supported ordering of friend lists by URL parameters.');
?>
<li<?php
if (!bp_action_variable(0) || bp_is_action_variable('recently-active', 0)) {
?>
class="current"<?php
}
?>
><a href="<?php
echo trailingslashit(bp_displayed_user_domain() . bp_get_friends_slug() . '/my-friends/recently-active');
?>
"><?php
_e('Recently Active', 'buddypress');
?>
</a></li>
<li<?php
if (bp_is_action_variable('newest', 0)) {
?>
class="current"<?php
}
?>
><a href="<?php
echo trailingslashit(bp_displayed_user_domain() . bp_get_friends_slug() . '/my-friends/newest');
?>
"><?php
_e('Newest', 'buddypress');
?>
</a></li>
<li<?php
if (bp_is_action_variable('alphabetically', 0)) {
?>
class="current"<?php
}
?>
><a href="<?php
echo trailingslashit(bp_displayed_user_domain() . bp_get_friends_slug() . '/my-friends/alphabetically');
?>
"><?php
_e('Alphabetically', 'buddypress');
?>
</a></li>
<?php
do_action('friends_header_tabs');
}
示例13: groups_screen_group_admin_manage_members
/**
* This function handles actions related to member management on the group admin.
*/
function groups_screen_group_admin_manage_members()
{
if ('manage-members' != bp_get_group_current_admin_tab()) {
return false;
}
if (!bp_is_item_admin()) {
return false;
}
$bp = buddypress();
if (bp_action_variable(1) && bp_action_variable(2) && bp_action_variable(3)) {
if (bp_is_action_variable('promote', 1) && (bp_is_action_variable('mod', 2) || bp_is_action_variable('admin', 2)) && is_numeric(bp_action_variable(3))) {
$user_id = bp_action_variable(3);
$status = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_promote_member')) {
return false;
}
// Promote a user.
if (!groups_promote_member($user_id, $bp->groups->current_group->id, $status)) {
bp_core_add_message(__('There was an error when promoting that user. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User promoted successfully', 'buddypress'));
}
/**
* Fires before the redirect after a group member has been promoted.
*
* @since 1.0.0
*
* @param int $user_id ID of the user being promoted.
* @param int $id ID of the group user is promoted within.
*/
do_action('groups_promoted_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
}
if (bp_action_variable(1) && bp_action_variable(2)) {
if (bp_is_action_variable('demote', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_demote_member')) {
return false;
}
// Stop sole admins from abandoning their group.
$group_admins = groups_get_group_admins($bp->groups->current_group->id);
if (1 == count($group_admins) && $group_admins[0]->user_id == $user_id) {
bp_core_add_message(__('This group must have at least one admin', 'buddypress'), 'error');
} elseif (!groups_demote_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error when demoting that user. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User demoted successfully', 'buddypress'));
}
/**
* Fires before the redirect after a group member has been demoted.
*
* @since 1.0.0
*
* @param int $user_id ID of the user being demoted.
* @param int $id ID of the group user is demoted within.
*/
do_action('groups_demoted_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
if (bp_is_action_variable('ban', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_ban_member')) {
return false;
}
// Ban a user.
if (!groups_ban_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error when banning that user. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User banned successfully', 'buddypress'));
}
/**
* Fires before the redirect after a group member has been banned.
*
* @since 1.0.0
*
* @param int $user_id ID of the user being banned.
* @param int $id ID of the group user is banned from.
*/
do_action('groups_banned_member', $user_id, $bp->groups->current_group->id);
bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/manage-members/');
}
if (bp_is_action_variable('unban', 1) && is_numeric(bp_action_variable(2))) {
$user_id = bp_action_variable(2);
// Check the nonce first.
if (!check_admin_referer('groups_unban_member')) {
return false;
}
// Remove a ban for user.
if (!groups_unban_member($user_id, $bp->groups->current_group->id)) {
bp_core_add_message(__('There was an error when unbanning that user. Please try again.', 'buddypress'), 'error');
} else {
bp_core_add_message(__('User ban removed successfully', 'buddypress'));
}
//.........这里部分代码省略.........
示例14: bp_forums_add_forum_topic_to_page_title
/**
* bp_forums_add_forum_topic_to_page_title( $title )
*
* Append forum topic to page title
*
* @global object $bp
* @param string $title New page title; see bp_modify_page_title()
* @param string $title Original page title
* @param string $sep How to separate the various items within the page title.
* @param string $seplocation Direction to display title
* @return string
* @see bp_modify_page_title()
*/
function bp_forums_add_forum_topic_to_page_title($title, $original_title, $sep, $seplocation)
{
global $bp;
if (bp_is_current_action('forum') && bp_is_action_variable('topic', 0)) {
if (bp_has_forum_topic_posts()) {
$title .= bp_get_the_topic_title() . " {$sep} ";
}
}
return $title;
}
示例15: bp_follow_my_following_feed
/**
* Add RSS feed support for a user's following activity.
*
* eg. example.com/members/USERNAME/activity/following/feed/
*
* Only available in BuddyPress 1.8+.
*
* @since 1.2.1
* @author r-a-y
*/
function bp_follow_my_following_feed()
{
// only available in BP 1.8+
if (!class_exists('BP_Activity_Feed')) {
return;
}
if (!bp_is_user_activity() || !bp_is_current_action(constant('BP_FOLLOWING_SLUG')) || !bp_is_action_variable('feed', 0)) {
return false;
}
global $bp;
// setup the feed
$bp->activity->feed = new BP_Activity_Feed(array('id' => 'myfollowing', 'title' => sprintf(__('%1$s | %2$s | Following Activity', 'bp-follow'), bp_get_site_name(), bp_get_displayed_user_fullname()), 'link' => trailingslashit(bp_displayed_user_domain() . bp_get_activity_slug() . '/' . constant('BP_FOLLOWING_SLUG')), 'description' => sprintf(__("Activity feed for people that %s is following.", 'buddypress'), bp_get_displayed_user_fullname()), 'activity_args' => array('user_id' => bp_get_following_ids(), 'display_comments' => 'threaded')));
}