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


PHP bp_activity_recurse_comments_activity_ids函数代码示例

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


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

示例1: bp_blogs_sync_delete_from_activity_comment

/**
 * Deletes the blog comment when the associated activity comment is deleted.
 *
 * Note: This is hooked on the 'bp_activity_delete_comment_pre' filter instead
 * of the 'bp_activity_delete_comment' action because we need to fetch the
 * activity comment children before they are deleted.
 *
 * @since BuddyPress (2.0.0)
 *
 * @param bool $retval
 * @param int $parent_activity_id The parent activity ID for the activity comment.
 * @param int $activity_id The activity ID for the pending deleted activity comment.
 */
function bp_blogs_sync_delete_from_activity_comment( $retval, $parent_activity_id, $activity_id ) {
	// check if parent activity is a blog post
	$parent_activity = new BP_Activity_Activity( $parent_activity_id );
	if ( 'new_blog_post' != $parent_activity->type ) {
		return $retval;
	}

	// fetch the activity comments for the activity item
	$activity = bp_activity_get( array(
		'in'               => $activity_id,
		'display_comments' => 'stream',
	) );

	// get all activity comment IDs for the pending deleted item
	$activity_ids   = bp_activity_recurse_comments_activity_ids( $activity );
	$activity_ids[] = $activity_id;

	// handle multisite
	// switch to the blog where the comment was made
	switch_to_blog( $parent_activity->item_id );

	// remove associated blog comments
	bp_blogs_remove_associated_blog_comments( $activity_ids, current_user_can( 'moderate_comments' ) );

	// multisite again!
	restore_current_blog();

	// rebuild activity comment tree
	// emulate bp_activity_delete_comment()
	BP_Activity_Activity::rebuild_activity_comment_tree( $parent_activity_id );

	// we're overriding the default bp_activity_delete_comment() functionality
	// so we need to return false
	return false;
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:48,代码来源:bp-blogs-activity.php

示例2: bp_blogs_sync_delete_from_activity_comment

/**
 * Deletes the blog comment when the associated activity comment is deleted.
 *
 * Note: This is hooked on the 'bp_activity_delete_comment_pre' filter instead
 * of the 'bp_activity_delete_comment' action because we need to fetch the
 * activity comment children before they are deleted.
 *
 * @since 2.0.0
 * @since 2.5.0 Add the $delected parameter
 *
 * @param bool $retval             Whether BuddyPress should continue or not.
 * @param int  $parent_activity_id The parent activity ID for the activity comment.
 * @param int  $activity_id        The activity ID for the pending deleted activity comment.
 * @param bool $deleted            Whether the comment was deleted or not.
 * @return bool
 */
function bp_blogs_sync_delete_from_activity_comment($retval, $parent_activity_id, $activity_id, &$deleted)
{
    // Check if parent activity is a blog post.
    $parent_activity = new BP_Activity_Activity($parent_activity_id);
    // if parent activity isn't a post type having the buddypress-activity support, stop now!
    if (!bp_activity_type_supports($parent_activity->type, 'post-type-comment-tracking')) {
        return $retval;
    }
    // Fetch the activity comments for the activity item.
    $activity = bp_activity_get(array('in' => $activity_id, 'display_comments' => 'stream', 'spam' => 'all'));
    // Get all activity comment IDs for the pending deleted item.
    $activity_ids = bp_activity_recurse_comments_activity_ids($activity);
    $activity_ids[] = $activity_id;
    // Handle multisite
    // switch to the blog where the comment was made.
    switch_to_blog($parent_activity->item_id);
    // Remove associated blog comments.
    bp_blogs_remove_associated_blog_comments($activity_ids, current_user_can('moderate_comments'));
    // Multisite again!
    restore_current_blog();
    // Rebuild activity comment tree
    // emulate bp_activity_delete_comment().
    BP_Activity_Activity::rebuild_activity_comment_tree($parent_activity_id);
    // Avoid the error message although the comments were successfully deleted
    $deleted = true;
    // We're overriding the default bp_activity_delete_comment() functionality
    // so we need to return false.
    return false;
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:45,代码来源:bp-blogs-activity.php

示例3: bp_activity_recurse_comments_activity_ids

/**
 * Recurse through all activity comments and return the activity comment IDs.
 *
 * @since BuddyPress (2.0.0)
 *
 * @param array $activity Array of activities generated from {@link bp_activity_get()}.
 * @param array $activity_ids Used for recursion purposes in this function.
 * @return array
 */
function bp_activity_recurse_comments_activity_ids($activity = array(), $activity_ids = array())
{
    if (is_array($activity) && !empty($activity['activities'])) {
        $activity = $activity['activities'][0];
    }
    if (!empty($activity->children)) {
        foreach ($activity->children as $child) {
            $activity_ids[] = $child->id;
            if (!empty($child->children)) {
                $activity_ids = bp_activity_recurse_comments_activity_ids($child, $activity_ids);
            }
        }
    }
    return $activity_ids;
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:24,代码来源:bp-activity-template.php

示例4: bp_blogs_remove_comment

/**
 * Remove a blog comment activity item from the activity stream.
 *
 * @param int $comment_id ID of the comment to be removed.
 */
function bp_blogs_remove_comment($comment_id)
{
    global $wpdb;
    // activity comments are disabled for blog posts
    // which means that individual activity items exist for blog comments
    if (bp_disable_blogforum_comments()) {
        // Delete the individual activity stream item
        bp_blogs_delete_activity(array('item_id' => $wpdb->blogid, 'secondary_item_id' => $comment_id, 'type' => 'new_blog_comment'));
        // activity comments are enabled for blog posts
        // remove the associated activity item
    } else {
        // get associated activity ID from comment meta
        $activity_id = get_comment_meta($comment_id, 'bp_activity_comment_id', true);
        // delete the associated activity comment
        //
        // also removes child post comments and associated activity comments
        if (!empty($activity_id) && bp_is_active('activity')) {
            // fetch the activity comments for the activity item
            $activity = bp_activity_get(array('in' => $activity_id, 'display_comments' => 'stream'));
            // get all activity comment IDs for the pending deleted item
            if (!empty($activity['activities'])) {
                $activity_ids = bp_activity_recurse_comments_activity_ids($activity);
                $activity_ids[] = $activity_id;
                // delete activity items
                foreach ($activity_ids as $activity_id) {
                    bp_activity_delete(array('id' => $activity_id));
                }
                // remove associated blog comments
                bp_blogs_remove_associated_blog_comments($activity_ids);
                // rebuild activity comment tree
                BP_Activity_Activity::rebuild_activity_comment_tree($activity['activities'][0]->item_id);
            }
        }
    }
    /**
     * Fires after a blog comment activity item was removed from activity stream.
     *
     * @since BuddyPress (1.0.0)
     *
     * @param int $blogid     Item ID for the blog associated with the removed comment.
     * @param int $comment_id ID of the comment being removed.
     * @param int $value      ID of the current logged in user.
     */
    do_action('bp_blogs_remove_comment', $wpdb->blogid, $comment_id, bp_loggedin_user_id());
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:50,代码来源:bp-blogs-functions.php

示例5: bp_blogs_post_type_remove_comment

/**
 * Remove a synced activity comment from the activity stream.
 *
 * @since 2.5.0
 *
 * @param bool   $deleted              True when a comment post type activity was successfully removed.
 * @param int    $comment_id           ID of the comment to be removed.
 * @param object $activity_post_object The post type tracking args object.
 * @param string $activity_type        The post type comment activity type.
 *
 * @return bool True on success. False on error.
 */
function bp_blogs_post_type_remove_comment($deleted, $comment_id, $activity_post_object, $activity_type = '')
{
    // Remove synced activity comments, if needed.
    if (!bp_disable_blogforum_comments()) {
        // Get associated activity ID from comment meta
        $activity_id = get_comment_meta($comment_id, 'bp_activity_comment_id', true);
        /**
         * Delete the associated activity comment & also remove
         * child post comments and associated activity comments.
         */
        if (!empty($activity_id)) {
            // fetch the activity comments for the activity item
            $activity = bp_activity_get(array('in' => $activity_id, 'display_comments' => 'stream', 'spam' => 'all'));
            // get all activity comment IDs for the pending deleted item
            if (!empty($activity['activities'])) {
                $activity_ids = bp_activity_recurse_comments_activity_ids($activity);
                $activity_ids[] = $activity_id;
                // delete activity items
                foreach ($activity_ids as $activity_id) {
                    bp_activity_delete(array('id' => $activity_id));
                }
                // remove associated blog comments
                bp_blogs_remove_associated_blog_comments($activity_ids);
                // rebuild activity comment tree
                BP_Activity_Activity::rebuild_activity_comment_tree($activity['activities'][0]->item_id);
                // Set the result
                $deleted = true;
            }
        }
    }
    // Backcompat for comments about the 'post' post type.
    if ('new_blog_comment' === $activity_type) {
        /**
         * Fires after a blog comment activity item was removed from activity stream.
         *
         * @since 1.0.0
         *
         * @param int $value      ID for the blog associated with the removed comment.
         * @param int $comment_id ID of the comment being removed.
         * @param int $value      ID of the current logged in user.
         */
        do_action('bp_blogs_remove_comment', get_current_blog_id(), $comment_id, bp_loggedin_user_id());
    }
    return $deleted;
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:57,代码来源:bp-blogs-functions.php


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