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


PHP bp_activity_get函数代码示例

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


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

示例1: test_last_activity_should_bust_activity_with_last_activity_cache

 /**
  * @ticket BP7237
  * @ticket BP6643
  * @ticket BP7245
  */
 public function test_last_activity_should_bust_activity_with_last_activity_cache()
 {
     global $wpdb;
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $time_1 = date('Y-m-d H:i:s', time() - HOUR_IN_SECONDS);
     $time_2 = date('Y-m-d H:i:s', time() - HOUR_IN_SECONDS * 2);
     bp_update_user_last_activity($u1, $time_1);
     bp_update_user_last_activity($u2, $time_2);
     $activity_args_a = array('filter' => array('object' => buddypress()->members->id, 'action' => 'last_activity'), 'max' => 1);
     $activity_args_b = array('filter' => array('action' => 'new_member'), 'fields' => 'ids');
     // Prime bp_activity and bp_activity_with_last_activity caches.
     $a1 = bp_activity_get($activity_args_a);
     $expected = array($u1, $u2);
     $found = array_map('intval', wp_list_pluck($a1['activities'], 'user_id'));
     $this->assertSame($expected, $found);
     $b1 = bp_activity_get($activity_args_b);
     // Bump u2 activity so it should appear first.
     $new_time = date('Y-m-d H:i:s', time() - HOUR_IN_SECONDS);
     bp_update_user_last_activity($u2, $new_time);
     $a2 = bp_activity_get($activity_args_a);
     $expected = array($u2, $u1);
     $found = array_map('intval', wp_list_pluck($a2['activities'], 'user_id'));
     $this->assertSame($expected, $found);
     $num_queries = $wpdb->num_queries;
     // bp_activity cache should not have been touched.
     $b2 = bp_activity_get($activity_args_b);
     $this->assertEqualSets($b1, $b2);
     $this->assertSame($num_queries, $wpdb->num_queries);
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:35,代码来源:cache.php

示例2: bp_media_activity_parent_content_filter

function bp_media_activity_parent_content_filter($activity_content)
{
    global $activities_template;
    $defaults = array('hide_user' => false);
    if (!($parent_id = $activities_template->activity->item_id)) {
        return false;
    }
    if (!isset($bp_media_hidden_activity_cache[$parent_id])) {
        $activities = bp_activity_get(array('in' => $parent_id));
        if (isset($activities['activities'][0])) {
            $bp_media_hidden_activity_cache[$parent_id] = $activities['activities'][0];
        }
    }
    if (empty($bp_media_hidden_activity_cache[$parent_id])) {
        return false;
    }
    if (empty($bp_media_hidden_activity_cache[$parent_id]->content)) {
        $content = $bp_media_hidden_activity_cache[$parent_id]->action;
    } else {
        $content = $bp_media_hidden_activity_cache[$parent_id]->action . ' ' . $bp_media_hidden_activity_cache[$parent_id]->content;
    }
    // Remove the time since content for backwards compatibility
    $content = str_replace('<span class="time-since">%s</span>', '', $content);
    // Remove images
    $content = preg_replace('/<img[^>]*>/Ui', '', $content);
    return $content;
    return $activity_content;
}
开发者ID:nitun,项目名称:buddypress-media,代码行数:28,代码来源:bp-media-filters.php

示例3: test_bp_xprofile_updated_profile_activity_no_existing_activity

 /**
  * @group bp_xprofile_updated_profile_activity
  */
 public function test_bp_xprofile_updated_profile_activity_no_existing_activity()
 {
     $d = $this->setup_updated_profile_data();
     // Fake new/old values to ensure a change
     $old_values = array($this->updated_profile_data['f'] => array('value' => 'foo', 'visibility' => 'public'));
     $new_values = array($this->updated_profile_data['f'] => array('value' => 'foo2', 'visibility' => 'public'));
     $this->assertTrue(bp_xprofile_updated_profile_activity($d['u'], array($d['f']), false, $old_values, $new_values));
     $existing = bp_activity_get(array('max' => 1, 'filter' => array('user_id' => $d['u'], 'object' => buddypress()->profile->id, 'action' => 'updated_profile'), 'count_total' => 'count_query'));
     $this->assertEquals(1, $existing['total']);
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:13,代码来源:activity.php

示例4: test_bp_activity_clear_cache_for_activity

 /**
  * @group bp_activity_clear_cache_for_activity
  */
 public function test_bp_activity_clear_cache_for_activity()
 {
     $u = $this->factory->user->create();
     $a = $this->factory->activity->create(array('component' => buddypress()->activity->id, 'type' => 'activity_update', 'user_id' => $u, 'content' => 'foo bar'));
     $a_fp = bp_activity_get(array('type' => 'activity_update', 'user' => array('filter' => array('user_id' => $u))));
     $activity_updated = new BP_Activity_Activity($a);
     $activity_updated->content = 'bar foo';
     $activity_updated->save();
     $a_fp = bp_activity_get(array('type' => 'activity_update', 'user' => array('filter' => array('user_id' => $u))));
     $this->assertSame('bar foo', $a_fp['activities'][0]->content);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:14,代码来源:cache.php

示例5: getResults

 public function getResults($search)
 {
     $results = array();
     if (!$this->isEnabled()) {
         return $results;
     }
     $results = bp_activity_get(array('filter' => array('action' => 'activity_update'), 'search_terms' => $search));
     return array_map(function ($activity) use($search) {
         return new Expert_Finder_Activity_Stream_Result($activity, $this->options['A'], $search);
     }, $results['activities']);
 }
开发者ID:konnektiv,项目名称:expert-finder,代码行数:11,代码来源:expertfinder-activity-stream-finder-class.php

示例6: test_delete_activity_on_doc_deletion

 /**
  * Make sure doc activity is deleted when the doc is deleted
  */
 function test_delete_activity_on_doc_deletion()
 {
     $doc_id = $this->factory->doc->create();
     $activity_args = array('component' => 'docs', 'item_id' => 1, 'secondary_item_id' => $doc_id, 'type' => 'bp_doc_edited');
     $activity_id = $this->factory->activity->create($activity_args);
     $activity_args2 = array('component' => 'docs', 'item_id' => 1, 'secondary_item_id' => $doc_id, 'type' => 'bp_doc_created');
     $activity_id2 = $this->factory->activity->create($activity_args2);
     // Now delete using the api method
     bp_docs_trash_doc($doc_id);
     $activities = bp_activity_get(array('filter' => array('secondary_id' => $doc_id, 'component' => 'docs')));
     $this->assertEquals($activities['activities'], array());
 }
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:15,代码来源:test-bp-docs.php

示例7: bp_media_upgrade_to_2_2

function bp_media_upgrade_to_2_2()
{
    global $wpdb;
    remove_filter('bp_activity_get_user_join_filter', 'bp_media_activity_query_filter', 10);
    /* @var $wpdb wpdb */
    $media_files = new WP_Query(array('post_type' => 'bp_media', 'posts_per_page' => -1));
    $media_files = $media_files->posts;
    $wall_posts_album_ids = array();
    if (is_array($media_files) && count($media_files)) {
        foreach ($media_files as $media_file) {
            $attachment_id = get_post_meta($media_file->ID, 'bp_media_child_attachment', true);
            $child_activity = get_post_meta($media_file->ID, 'bp_media_child_activity', true);
            update_post_meta($attachment_id, 'bp_media_child_activity', $child_activity);
            $attachment = get_post($attachment_id, ARRAY_A);
            if (isset($wall_posts_album_ids[$media_file->post_author])) {
                $wall_posts_id = $wall_posts_album_ids[$media_file->post_author];
            } else {
                $wall_posts_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_title = 'Wall Posts' AND post_author = '" . $media_file->post_author . "' AND post_type='bp_media_album'");
                if ($wall_posts_id == null) {
                    $album = new BP_Media_Album();
                    $album->add_album('Wall Posts', $media_file->post_author);
                    $wall_posts_id = $album->get_id();
                }
                if (!$wall_posts_id) {
                    continue;
                    //This condition should never be encountered
                }
                $wall_posts_album_ids[$media_file->post_author] = $wall_posts_id;
            }
            $attachment['post_parent'] = $wall_posts_id;
            wp_update_post($attachment);
            update_post_meta($attachment_id, 'bp-media-key', $media_file->post_author);
            $activity = bp_activity_get(array('in' => intval($child_activity)));
            if (isset($activity['activities'][0]->id)) {
                $activity = $activity['activities'][0];
            }
            $bp_media = new BP_Media_Host_Wordpress($attachment_id);
            $args = array('content' => $bp_media->get_media_activity_content(), 'id' => $child_activity, 'type' => 'media_upload', 'action' => apply_filters('bp_media_added_media', sprintf(__('%1$s added a %2$s', 'bp-media'), bp_core_get_userlink($media_file->post_author), '<a href="' . $bp_media->get_url() . '">' . $bp_media->get_media_activity_type() . '</a>')), 'primary_link' => $bp_media->get_url(), 'item_id' => $attachment_id, 'recorded_time' => $activity->date_recorded);
            $act_id = bp_media_record_activity($args);
            bp_activity_delete_meta($child_activity, 'bp_media_parent_post');
            wp_delete_post($media_file->ID);
        }
    }
    update_option('bp_media_db_version', BP_MEDIA_DB_VERSION);
    add_action('admin_notices', 'bp_media_database_updated_notice');
    wp_cache_flush();
}
开发者ID:nitun,项目名称:buddypress-media,代码行数:47,代码来源:bp-media-upgrade-script.php

示例8: wangguard_bp_activity_spam_all_user_data

function wangguard_bp_activity_spam_all_user_data($user_id = 0)
{
    global $bp, $wpdb;
    // Do not delete user data unless a logged in user says so
    if (empty($user_id)) {
        return false;
    }
    // Get all the user's activities.
    $activities = bp_activity_get(array('display_comments' => 'stream', 'filter' => array('user_id' => $user_id), 'show_hidden' => true));
    // Mark each as spam
    foreach ((array) $activities['activities'] as $activity) {
        // Create an activity object
        $activity_obj = new BP_Activity_Activity();
        foreach ($activity as $k => $v) {
            $activity_obj->{$k} = $v;
        }
        // Mark as spam
        bp_activity_mark_as_spam($activity_obj);
        /*
         * If Akismet is present, update the activity history meta.
         *
         * This is usually taken care of when BP_Activity_Activity::save() happens, but
         * as we're going to be updating all the activity statuses directly, for efficency,
         * we need to update manually.
         */
        if (!empty($bp->activity->akismet)) {
            $bp->activity->akismet->update_activity_spam_meta($activity_obj);
        }
        // Tidy up
        unset($activity_obj);
    }
    // Mark all of this user's activities as spam
    $wpdb->query($wpdb->prepare("UPDATE {$bp->activity->table_name} SET is_spam = 1 WHERE user_id = %d", $user_id));
    // Call an action for plugins to use
    do_action('bp_activity_spam_all_user_data', $user_id, $activities['activities']);
}
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:36,代码来源:wangguard-buddypress.php

示例9: post_activity

 /**
  * Posts an activity item on doc save
  *
  * @package BuddyPress Docs
  * @since 1.0-beta
  *
  * @param obj $query The query object created in BP_Docs_Query and passed to the
  *     bp_docs_doc_saved filter
  * @return int $activity_id The id number of the activity created
  */
 function post_activity($query)
 {
     global $bp;
     // todo: exception for autosave?
     if (!bp_is_active('activity')) {
         return false;
     }
     $doc_id = !empty($query->doc_id) ? $query->doc_id : false;
     if (!$doc_id) {
         return false;
     }
     $last_editor = get_post_meta($doc_id, 'bp_docs_last_editor', true);
     // Throttle 'doc edited' posts. By default, one per user per hour
     if (!$query->is_new_doc) {
         // Look for an existing activity item corresponding to this user editing
         // this doc
         $already_args = array('max' => 1, 'sort' => 'DESC', 'show_hidden' => 1, 'filter' => array('user_id' => $last_editor, 'action' => 'bp_doc_edited', 'secondary_id' => $doc_id));
         $already_activity = bp_activity_get($already_args);
         // If any activity items are found, compare its date_recorded with time() to
         // see if it's within the allotted throttle time. If so, don't record the
         // activity item
         if (!empty($already_activity['activities'])) {
             $date_recorded = $already_activity['activities'][0]->date_recorded;
             $drunix = strtotime($date_recorded);
             if (time() - $drunix <= apply_filters('bp_docs_edit_activity_throttle_time', 60 * 60)) {
                 return;
             }
         }
     }
     $doc = get_post($doc_id);
     // Set the action. Filterable so that other integration pieces can alter it
     $action = '';
     $user_link = bp_core_get_userlink($last_editor);
     $doc_url = bp_docs_get_doc_link($doc_id);
     $doc_link = '<a href="' . $doc_url . '">' . $doc->post_title . '</a>';
     if ($query->is_new_doc) {
         $action = sprintf(__('%1$s created the doc %2$s', 'bp-docs'), $user_link, $doc_link);
     } else {
         $action = sprintf(__('%1$s edited the doc %2$s', 'bp-docs'), $user_link, $doc_link);
     }
     $action = apply_filters('bp_docs_activity_action', $action, $user_link, $doc_link, $query->is_new_doc, $query);
     // Get a canonical name for the component. This is a nightmare because of the way
     // the current component and root slug relate in BP 1.3+
     if (function_exists('bp_is_current_component')) {
         foreach ($bp->active_components as $comp => $value) {
             if (bp_is_current_component($comp)) {
                 $component = $comp;
                 break;
             }
         }
     } else {
         $component = bp_current_component();
     }
     // This is only temporary! This item business needs to be component-neutral
     $item = isset($bp->groups->current_group->id) ? $bp->groups->current_group->id : false;
     // Set the type, to be used in activity filtering
     $type = $query->is_new_doc ? 'bp_doc_created' : 'bp_doc_edited';
     $args = array('user_id' => $last_editor, 'action' => $action, 'primary_link' => $doc_url, 'component' => $component, 'type' => $type, 'item_id' => $query->item_id, 'secondary_item_id' => $doc_id, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => apply_filters('bp_docs_hide_sitewide', false, false, $doc, $item, $component));
     do_action('bp_docs_before_activity_save', $args);
     $activity_id = bp_activity_add(apply_filters('bp_docs_activity_args', $args));
     do_action('bp_docs_after_activity_save', $activity_id, $args);
     return $activity_id;
 }
开发者ID:Nightgunner5,项目名称:Pubcomp-CMS,代码行数:73,代码来源:integration-bp.php

示例10: activity_exists_for_post_type

 protected function activity_exists_for_post_type($item_id, $secondary_item_id, $action, $display_comments = false)
 {
     $a = bp_activity_get(array('display_comments' => $display_comments, 'filter' => array('action' => $action, 'primary_id' => $item_id, 'secondary_id' => $secondary_item_id)));
     return !empty($a['activities']);
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:5,代码来源:filters.php

示例11: 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

示例12: cacsp_create_edit_activity

/**
 * Create activity for paper edits.
 *
 * Edit activity is throttled: no more than one activity item per 60 minutes.
 *
 * @param int     $post_id     ID of the post.
 * @param WP_Post $post_after  New post.
 * @param WP_Post $post_before Old post.
 */
function cacsp_create_edit_activity($post_id, WP_Post $post_after, WP_Post $post_before)
{
    if ('cacsp_paper' !== $post_after->post_type) {
        return;
    }
    // We only want to record edits of published posts. Drafts don't get activity, and BP handles publishing.
    if ('publish' !== $post_before->post_status || 'publish' !== $post_after->post_status) {
        return;
    }
    // The author of the edit is the one who wrote the last revision.
    if ($revisions = wp_get_post_revisions($post_id)) {
        // Grab the last revision, but not an autosave.
        foreach ($revisions as $revision) {
            if (false !== strpos($revision->post_name, "{$revision->post_parent}-revision")) {
                $last_revision = $revision;
                break;
            }
        }
    }
    // Either revisions are disabled, or something else has gone wrong. Just use the post author.
    if (!isset($last_revision)) {
        $rev_author = $post_after->post_author;
    } else {
        $rev_author = $last_revision->post_author;
    }
    // Throttle.
    $existing = bp_activity_get(array('filter_query' => array(array('column' => 'component', 'value' => 'cacsp'), array('column' => 'type', 'value' => 'new_cacsp_edit'), array('column' => 'secondary_item_id', 'value' => $post_id), array('column' => 'user_id', 'value' => $rev_author)), 'update_meta_cache' => false, 'per_page' => 1));
    if (!empty($existing['activities'])) {
        /**
         * Filters the number of seconds in the edit throttle.
         *
         * This prevents activity stream flooding by multiple edits of the same paper.
         *
         * @param int $throttle_period Defaults to 6 hours.
         */
        $throttle_period = apply_filters('bpeo_event_edit_throttle_period', 6 * HOUR_IN_SECONDS);
        if (time() - strtotime($existing['activities'][0]->date_recorded) < $throttle_period) {
            return;
        }
    }
    // Poor man's diff. https://coderwall.com/p/3j2hxq/find-and-format-difference-between-two-strings-in-php
    $old = $post_before->post_content;
    $new = $post_after->post_content;
    $from_start = strspn($old ^ $new, "");
    $from_end = strspn(strrev($old) ^ strrev($new), "");
    $old_end = strlen($old) - $from_end;
    $new_end = strlen($new) - $from_end;
    $start = substr($new, 0, $from_start);
    $end = substr($new, $new_end);
    $new_diff = substr($new, $from_start, $new_end - $from_start);
    // Take a few words before the diff.
    $_start = explode(' ', $start);
    $_start = implode(' ', array_slice($_start, -5));
    $content = bp_create_excerpt('&hellip;' . $_start . $new_diff . $end);
    $activity_id = bp_activity_add(array('content' => $content, 'component' => 'cacsp', 'type' => 'new_cacsp_edit', 'primary_link' => get_permalink($post_id), 'user_id' => $rev_author, 'item_id' => get_current_blog_id(), 'secondary_item_id' => $post_id, 'hide_sitewide' => false));
}
开发者ID:sheesh,项目名称:social-paper,代码行数:65,代码来源:hooks-buddypress-activity.php

示例13: bp_activity_post_type_publish

/**
 * Create an activity item for a newly published post type post.
 *
 * @since 2.2.0
 *
 * @param int          $post_id ID of the new post.
 * @param WP_Post|null $post    Post object.
 * @param int          $user_id ID of the post author.
 * @return int|bool The ID of the activity on success. False on error.
 */
function bp_activity_post_type_publish($post_id = 0, $post = null, $user_id = 0)
{
    if (!is_a($post, 'WP_Post')) {
        return;
    }
    // Get the post type tracking args.
    $activity_post_object = bp_activity_get_post_type_tracking_args($post->post_type);
    if ('publish' != $post->post_status || !empty($post->post_password) || empty($activity_post_object->action_id)) {
        return;
    }
    if (empty($post_id)) {
        $post_id = $post->ID;
    }
    $blog_id = get_current_blog_id();
    if (empty($user_id)) {
        $user_id = (int) $post->post_author;
    }
    // Bail if an activity item already exists for this post.
    $existing = bp_activity_get(array('filter' => array('action' => $activity_post_object->action_id, 'primary_id' => $blog_id, 'secondary_id' => $post_id)));
    if (!empty($existing['activities'])) {
        return;
    }
    /**
     * Filters whether or not to post the activity.
     *
     * This is a variable filter, dependent on the post type,
     * that lets components or plugins bail early if needed.
     *
     * @since 2.2.0
     *
     * @param bool $value   Whether or not to continue.
     * @param int  $blog_id ID of the current site.
     * @param int  $post_id ID of the current post being published.
     * @param int  $user_id ID of the current user or post author.
     */
    if (false === apply_filters("bp_activity_{$post->post_type}_pre_publish", true, $blog_id, $post_id, $user_id)) {
        return;
    }
    // Record this in activity streams.
    $blog_url = get_home_url($blog_id);
    $post_url = add_query_arg('p', $post_id, trailingslashit($blog_url));
    // Backward compatibility filters for the 'blogs' component.
    if ('blogs' == $activity_post_object->component_id) {
        $activity_content = apply_filters('bp_blogs_activity_new_post_content', $post->post_content, $post, $post_url, $post->post_type);
        $activity_primary_link = apply_filters('bp_blogs_activity_new_post_primary_link', $post_url, $post_id, $post->post_type);
    } else {
        $activity_content = $post->post_content;
        $activity_primary_link = $post_url;
    }
    $activity_args = array('user_id' => $user_id, 'content' => $activity_content, 'primary_link' => $activity_primary_link, 'component' => $activity_post_object->component_id, 'type' => $activity_post_object->action_id, 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_date_gmt);
    if (!empty($activity_args['content'])) {
        // Create the excerpt.
        $activity_summary = bp_activity_create_summary($activity_args['content'], $activity_args);
        // Backward compatibility filter for blog posts.
        if ('blogs' == $activity_post_object->component_id) {
            $activity_args['content'] = apply_filters('bp_blogs_record_activity_content', $activity_summary, $activity_args['content'], $activity_args, $post->post_type);
        } else {
            $activity_args['content'] = $activity_summary;
        }
    }
    // Set up the action by using the format functions.
    $action_args = array_merge($activity_args, array('post_title' => $post->post_title, 'post_url' => $post_url));
    $activity_args['action'] = call_user_func_array($activity_post_object->format_callback, array('', (object) $action_args));
    // Make sure the action is set.
    if (empty($activity_args['action'])) {
        return;
    } else {
        // Backward compatibility filter for the blogs component.
        if ('blogs' == $activity_post_object->component_id) {
            $activity_args['action'] = apply_filters('bp_blogs_record_activity_action', $activity_args['action']);
        }
    }
    $activity_id = bp_activity_add($activity_args);
    /**
     * Fires after the publishing of an activity item for a newly published post type post.
     *
     * @since 2.2.0
     *
     * @param int     $activity_id   ID of the newly published activity item.
     * @param WP_Post $post          Post object.
     * @param array   $activity_args Array of activity arguments.
     */
    do_action('bp_activity_post_type_published', $activity_id, $post, $activity_args);
    return $activity_id;
}
开发者ID:humanmade,项目名称:BuddyPress,代码行数:95,代码来源:bp-activity-functions.php

示例14: __construct

 function __construct($page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude = false, $in = false)
 {
     global $bp;
     $this->pag_page = isset($_REQUEST['acpage']) ? intval($_REQUEST['acpage']) : $page;
     $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page;
     // Check if blog/forum replies are disabled
     $this->disable_blogforum_replies = isset($bp->site_options['bp-disable-blogforum-comments']) ? $bp->site_options['bp-disable-blogforum-comments'] : false;
     // Get an array of the logged in user's favorite activities
     $this->my_favs = maybe_unserialize(bp_get_user_meta($bp->loggedin_user->id, 'bp_favorite_activities', true));
     // Fetch specific activity items based on ID's
     if (!empty($include)) {
         $this->activities = bp_activity_get_specific(array('activity_ids' => explode(',', $include), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden));
     } else {
         $this->activities = bp_activity_get(array('display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in));
     }
     if (!$max || $max >= (int) $this->activities['total']) {
         $this->total_activity_count = (int) $this->activities['total'];
     } else {
         $this->total_activity_count = (int) $max;
     }
     $this->activities = $this->activities['activities'];
     if ($max) {
         if ($max >= count($this->activities)) {
             $this->activity_count = count($this->activities);
         } else {
             $this->activity_count = (int) $max;
         }
     } else {
         $this->activity_count = count($this->activities);
     }
     $this->full_name = $bp->displayed_user->fullname;
     // Fetch parent content for activity comments so we do not have to query in the loop
     foreach ((array) $this->activities as $activity) {
         if ('activity_comment' != $activity->type) {
             continue;
         }
         $parent_ids[] = $activity->item_id;
     }
     if (!empty($parent_ids)) {
         $activity_parents = bp_activity_get_specific(array('activity_ids' => $parent_ids));
     }
     if (!empty($activity_parents['activities'])) {
         foreach ($activity_parents['activities'] as $parent) {
             $this->activity_parents[$parent->id] = $parent;
         }
         unset($activity_parents);
     }
     if ((int) $this->total_activity_count && (int) $this->pag_num) {
         $this->pag_links = paginate_links(array('base' => add_query_arg('acpage', '%#%'), 'format' => '', 'total' => ceil((int) $this->total_activity_count / (int) $this->pag_num), 'current' => (int) $this->pag_page, 'prev_text' => _x('&larr;', 'Activity pagination previous text', 'buddypress'), 'next_text' => _x('&rarr;', 'Activity pagination next text', 'buddypress'), 'mid_size' => 1));
     }
 }
开发者ID:nxtclass,项目名称:NXTClass,代码行数:51,代码来源:bp-activity-template.php

示例15: 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


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