当前位置: 首页>>代码示例>>PHP>>正文


PHP bp_activity_user_can_mark_spam函数代码示例

本文整理汇总了PHP中bp_activity_user_can_mark_spam函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_activity_user_can_mark_spam函数的具体用法?PHP bp_activity_user_can_mark_spam怎么用?PHP bp_activity_user_can_mark_spam使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bp_activity_user_can_mark_spam函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bp_legacy_theme_spam_activity

/**
 * AJAX spam an activity item or comment
 *
 * @return mixed String on error, void on success
 * @since BuddyPress (1.6)
 */
function bp_legacy_theme_spam_activity()
{
    $bp = buddypress();
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Check that user is logged in, Activity Streams are enabled, and Akismet is present.
    if (!is_user_logged_in() || !bp_is_active('activity') || empty($bp->activity->akismet)) {
        exit('-1');
    }
    // Check an item ID was passed
    if (empty($_POST['id']) || !is_numeric($_POST['id'])) {
        exit('-1');
    }
    // Is the current user allowed to spam items?
    if (!bp_activity_user_can_mark_spam()) {
        exit('-1');
    }
    // Load up the activity item
    $activity = new BP_Activity_Activity((int) $_POST['id']);
    if (empty($activity->component)) {
        exit('-1');
    }
    // Check nonce
    check_admin_referer('bp_activity_akismet_spam_' . $activity->id);
    /** This action is documented in bp-activity/bp-activity-actions.php */
    do_action('bp_activity_before_action_spam_activity', $activity->id, $activity);
    // Mark as spam
    bp_activity_mark_as_spam($activity);
    $activity->save();
    /** This action is documented in bp-activity/bp-activity-actions.php */
    do_action('bp_activity_action_spam_activity', $activity->id, $activity->user_id);
    exit;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:41,代码来源:buddypress-functions.php

示例2: bp_dtheme_spam_activity

/**
 * AJAX spam an activity item or comment
 *
 * @global BuddyPress $bp The one true BuddyPress instance
 * @return mixed String on error, void on success
 * @since BuddyPress (1.6)
 */
function bp_dtheme_spam_activity()
{
    global $bp;
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Check that user is logged in, Activity Streams are enabled, and Akismet is present.
    if (!is_user_logged_in() || !bp_is_active('activity') || empty($bp->activity->akismet)) {
        exit('-1');
    }
    // Check an item ID was passed
    if (empty($_POST['id']) || !is_numeric($_POST['id'])) {
        exit('-1');
    }
    // Is the current user allowed to spam items?
    if (!bp_activity_user_can_mark_spam()) {
        exit('-1');
    }
    // Load up the activity item
    $activity = new BP_Activity_Activity((int) $_POST['id']);
    if (empty($activity->component)) {
        exit('-1');
    }
    // Check nonce
    check_admin_referer('bp_activity_akismet_spam_' . $activity->id);
    // Call an action before the spamming so plugins can modify things if they want to
    do_action('bp_activity_before_action_spam_activity', $activity->id, $activity);
    // Mark as spam
    bp_activity_mark_as_spam($activity);
    $activity->save();
    do_action('bp_activity_action_spam_activity', $activity->id, $activity->user_id);
    exit;
}
开发者ID:raminjan,项目名称:logicalbones_hug,代码行数:41,代码来源:ajax.php

示例3: bp_activity_action_spam_activity

/**
 * Mark specific activity item as spam and redirect to previous page.
 *
 * @since 1.6.0
 *
 * @param int $activity_id Activity id to be deleted. Defaults to 0.
 * @return bool False on failure.
 */
function bp_activity_action_spam_activity($activity_id = 0)
{
    $bp = buddypress();
    // Not viewing activity, or action is not spam, or Akismet isn't present.
    if (!bp_is_activity_component() || !bp_is_current_action('spam') || empty($bp->activity->akismet)) {
        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;
    }
    // Is the current user allowed to spam items?
    if (!bp_activity_user_can_mark_spam()) {
        return false;
    }
    // Load up the activity item.
    $activity = new BP_Activity_Activity($activity_id);
    if (empty($activity->id)) {
        return false;
    }
    // Check nonce.
    check_admin_referer('bp_activity_akismet_spam_' . $activity->id);
    /**
     * Fires before the marking activity as spam so plugins can modify things if they want to.
     *
     * @since 1.6.0
     *
     * @param int    $activity_id Activity ID to be marked as spam.
     * @param object $activity    Activity object for the ID to be marked as spam.
     */
    do_action('bp_activity_before_action_spam_activity', $activity->id, $activity);
    // Mark as spam.
    bp_activity_mark_as_spam($activity);
    $activity->save();
    // Tell the user the spamming has been successful.
    bp_core_add_message(__('The activity item has been marked as spam and is no longer visible.', 'buddypress'));
    /**
     * Fires after the marking activity as spam so plugins can act afterwards based on the activity.
     *
     * @since 1.6.0
     *
     * @param int $activity_id Activity ID that was marked as spam.
     * @param int $user_id     User ID associated with activity.
     */
    do_action('bp_activity_action_spam_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());
    }
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:63,代码来源:bp-activity-actions.php

示例4: add_activity_comment_spam_button

 /**
  * Adds a "mark as spam" button to each activity COMMENT item for site admins.
  *
  * This function is intended to be used inside the activity stream loop.
  *
  * @since BuddyPress (1.6)
  */
 public function add_activity_comment_spam_button()
 {
     if (!bp_activity_user_can_mark_spam()) {
         return;
     }
     // By default, only handle activity updates and activity comments.
     $current_comment = bp_activity_current_comment();
     if (empty($current_comment) || !in_array($current_comment->type, BP_Akismet::get_activity_types())) {
         return;
     }
     bp_button(array('block_self' => false, 'component' => 'activity', 'id' => 'activity_make_spam_' . bp_get_activity_comment_id(), 'link_class' => 'bp-secondary-action spam-activity-comment confirm', 'link_href' => wp_nonce_url(bp_get_root_domain() . '/' . bp_get_activity_slug() . '/spam/' . bp_get_activity_comment_id() . '/?cid=' . bp_get_activity_comment_id(), 'bp_activity_akismet_spam_' . bp_get_activity_comment_id()), 'link_text' => __('Spam', 'buddypress'), 'wrapper' => false));
 }
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:19,代码来源:bp-activity-akismet.php

示例5: bp_activity_action_spam_activity

/**
 * Mark specific activity item as spam and redirect to previous page.
 *
 * @since BuddyPress (1.6)
 *
 * @global object $bp BuddyPress global settings
 * @param int $activity_id Activity id to be deleted. Defaults to 0.
 * @return bool False on failure.
 */
function bp_activity_action_spam_activity($activity_id = 0)
{
    global $bp;
    // Not viewing activity, or action is not spam, or Akismet isn't present
    if (!bp_is_activity_component() || !bp_is_current_action('spam') || empty($bp->activity->akismet)) {
        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;
    }
    // Is the current user allowed to spam items?
    if (!bp_activity_user_can_mark_spam()) {
        return false;
    }
    // Load up the activity item
    $activity = new BP_Activity_Activity($activity_id);
    if (empty($activity->id)) {
        return false;
    }
    // Check nonce
    check_admin_referer('bp_activity_akismet_spam_' . $activity->id);
    // Call an action before the spamming so plugins can modify things if they want to
    do_action('bp_activity_before_action_spam_activity', $activity->id, $activity);
    // Mark as spam
    bp_activity_mark_as_spam($activity);
    $activity->save();
    // Tell the user the spamming has been succesful
    bp_core_add_message(__('The activity item has been marked as spam and is no longer visible.', 'buddypress'));
    do_action('bp_activity_action_spam_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());
    }
}
开发者ID:eresyyl,项目名称:mk,代码行数:49,代码来源:bp-activity-actions.php


注:本文中的bp_activity_user_can_mark_spam函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。