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


PHP bp_activity_delete_meta函数代码示例

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


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

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

示例2: bp_activity_akismet_delete_old_metadata

/**
 * Delete old spam activity meta data.
 *
 * This is done as a clean-up mechanism, as _bp_akismet_submission meta can
 * grow to be quite large.
 *
 * @since 1.6.0
 *
 * @global wpdb $wpdb WordPress database object.
 */
function bp_activity_akismet_delete_old_metadata()
{
    global $wpdb;
    $bp = buddypress();
    /**
     * Filters the threshold for how many days old Akismet metadata needs to be before being automatically deleted.
     *
     * @since 1.6.0
     *
     * @param integer 15 How many days old metadata needs to be.
     */
    $interval = apply_filters('bp_activity_akismet_delete_meta_interval', 15);
    // Enforce a minimum of 1 day.
    $interval = max(1, absint($interval));
    // _bp_akismet_submission meta values are large, so expire them after $interval days regardless of the activity status
    $sql = $wpdb->prepare("SELECT a.id FROM {$bp->activity->table_name} a LEFT JOIN {$bp->activity->table_name_meta} m ON a.id = m.activity_id WHERE m.meta_key = %s AND DATE_SUB(%s, INTERVAL {$interval} DAY) > a.date_recorded LIMIT 10000", '_bp_akismet_submission', current_time('mysql', 1));
    $activity_ids = $wpdb->get_col($sql);
    if (!empty($activity_ids)) {
        foreach ($activity_ids as $activity_id) {
            bp_activity_delete_meta($activity_id, '_bp_akismet_submission');
        }
    }
}
开发者ID:dcavins,项目名称:buddypress-svn,代码行数:33,代码来源:bp-activity-akismet.php

示例3: deleteCustomFields

 /**
  * Update entity custom fields
  */
 public function deleteCustomFields($identifier)
 {
     global $wpdb;
     $likebtn_entities = _likebtn_get_entities(true, true);
     list($entity_name, $entity_id) = $this->parseIdentifier($identifier);
     $entity_updated = false;
     if (array_key_exists($entity_name, $likebtn_entities) && is_numeric($entity_id)) {
         // set Custom fields
         switch ($entity_name) {
             case LIKEBTN_ENTITY_COMMENT:
                 // Comment
                 $comment = get_comment($entity_id);
                 // check if post exists and is not revision
                 if (!empty($comment) && $comment->comment_type != 'revision') {
                     delete_comment_meta($entity_id, LIKEBTN_META_KEY_LIKES);
                     delete_comment_meta($entity_id, LIKEBTN_META_KEY_DISLIKES);
                     delete_comment_meta($entity_id, LIKEBTN_META_KEY_LIKES_MINUS_DISLIKES);
                     $entity_updated = true;
                 }
                 break;
             case LIKEBTN_ENTITY_BP_ACTIVITY_POST:
             case LIKEBTN_ENTITY_BP_ACTIVITY_UPDATE:
             case LIKEBTN_ENTITY_BP_ACTIVITY_COMMENT:
             case LIKEBTN_ENTITY_BP_ACTIVITY_TOPIC:
                 if (!_likebtn_is_bp_active()) {
                     break;
                 }
                 $bp_activity = $wpdb->get_row("\n                        SELECT id\n                        FROM " . $wpdb->prefix . "bp_activity\n                        WHERE id = {$entity_id}\n                    ");
                 if (!empty($bp_activity)) {
                     bp_activity_delete_meta($entity_id, LIKEBTN_META_KEY_LIKES);
                     bp_activity_delete_meta($entity_id, LIKEBTN_META_KEY_DISLIKES);
                     bp_activity_delete_meta($entity_id, LIKEBTN_META_KEY_LIKES_MINUS_DISLIKES);
                     $entity_updated = true;
                 }
                 break;
             case LIKEBTN_ENTITY_BP_MEMBER:
                 // BuddyPress Member Profile
                 _likebtn_delete_bp_member_votes($entity_id);
                 $entity_updated = true;
                 break;
             case LIKEBTN_ENTITY_BBP_USER:
                 // bbPress Member Profile
                 _likebtn_delete_user_votes($entity_id);
                 $entity_updated = true;
                 break;
             case LIKEBTN_ENTITY_USER:
                 // BuddyPress Member Profile
                 $entity_updated = _likebtn_delete_bp_member_votes($entity_id);
                 // General user and bbPress Member Profile
                 $entity_updated = $entity_updated || _likebtn_delete_user_votes($entity_id);
                 break;
             default:
                 // Post
                 $post = get_post($entity_id);
                 // check if post exists and is not revision
                 if (!empty($post) && !empty($post->post_type) && $post->post_type != 'revision') {
                     delete_post_meta($entity_id, LIKEBTN_META_KEY_LIKES);
                     delete_post_meta($entity_id, LIKEBTN_META_KEY_DISLIKES);
                     delete_post_meta($entity_id, LIKEBTN_META_KEY_LIKES_MINUS_DISLIKES);
                     $entity_updated = true;
                 }
                 break;
         }
     }
     // Check custom item
     $item_db = $wpdb->get_row($wpdb->prepare("SELECT likes, dislikes\n                FROM " . $wpdb->prefix . LIKEBTN_TABLE_ITEM . "\n                WHERE identifier = %s", $identifier));
     // Custom identifier
     if ($item_db || !$entity_updated) {
         $where = array('identifier' => $identifier);
         $result = $wpdb->delete($wpdb->prefix . LIKEBTN_TABLE_ITEM, $where);
         if ($result) {
             $entity_updated = true;
         }
     }
     return $entity_updated;
 }
开发者ID:Omuze,项目名称:barakat,代码行数:79,代码来源:likebtn_like_button.class.php

示例4: buddyreshare_reset_metas

/**
 * In case of a reshare delete, reset some activity metas
 *
 * @package BP Reshare
 * @since    1.0
 * 
 * @param  integer $activity_id the reshared activity id
 * @param  integer $user_id     the user id
 * @uses   bp_activity_get_meta() to get some meta infos about the activity
 * @uses   bp_activity_delete_meta() to delete some meta infos for the activity
 * @uses   bp_activity_update_meta() to save some meta infos for the activity
 * @return boolean true
 */
function buddyreshare_reset_metas($activity_id = 0, $user_id = 0)
{
    if (empty($activity_id) || empty($user_id)) {
        return false;
    }
    $count = bp_activity_get_meta($activity_id, 'reshared_count');
    $count = $count - 1;
    $reshared_by = bp_activity_get_meta($activity_id, 'reshared_by');
    if ($count == 0) {
        // if count is null, then we can delete all metas !
        bp_activity_delete_meta($activity_id, 'reshared_count');
        bp_activity_delete_meta($activity_id, 'reshared_by');
    } else {
        foreach ($reshared_by as $key => $val) {
            if ($user_id == $val) {
                unset($reshared_by[$key]);
            }
        }
        bp_activity_update_meta($activity_id, 'reshared_count', $count);
        bp_activity_update_meta($activity_id, 'reshared_by', $reshared_by);
    }
    return true;
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:36,代码来源:functions.php

示例5: delete_activity_meta_entries

 /**
  * Delete the meta entries associated with a set of activity items.
  *
  * @since 1.2.0
  *
  * @param array $activity_ids Activity IDs whose meta should be deleted.
  * @return bool True on success.
  */
 public static function delete_activity_meta_entries($activity_ids = array())
 {
     $activity_ids = wp_parse_id_list($activity_ids);
     foreach ($activity_ids as $activity_id) {
         bp_activity_delete_meta($activity_id);
     }
     return true;
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:16,代码来源:class-bp-activity-activity.php

示例6: bp_activity_update_meta

/**
 * Update activity meta
 *
 * @since 1.2.0
 *
 * @param int $activity_id
 * @param string $meta_key
 * @param string $meta_value
 *
 * @global object $nxtdb
 * @global object $bp BuddyPress global settings
 * @uses maybe_serialize()
 * @uses bp_activity_delete_meta()
 * @uses nxt_cache_set()
 *
 * @return bool True on success, false on failure
 */
function bp_activity_update_meta($activity_id, $meta_key, $meta_value)
{
    global $nxtdb, $bp;
    // Make sure activity_id is valid
    if (!is_numeric($activity_id)) {
        return false;
    }
    // Sanitize key
    $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
    // Sanitize value
    if (is_string($meta_value)) {
        $meta_value = stripslashes($nxtdb->escape($meta_value));
    }
    // Maybe, just maybe... serialize
    $meta_value = maybe_serialize($meta_value);
    // If value is empty, delete the meta key
    if (empty($meta_value)) {
        return bp_activity_delete_meta($activity_id, $meta_key);
    }
    // See if meta key exists for activity_id
    $cur = $nxtdb->get_row($nxtdb->prepare("SELECT * FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key));
    // Meta key does not exist so INSERT
    if (empty($cur)) {
        $nxtdb->query($nxtdb->prepare("INSERT INTO {$bp->activity->table_name_meta} ( activity_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $activity_id, $meta_key, $meta_value));
    } else {
        if ($cur->meta_value != $meta_value) {
            $nxtdb->query($nxtdb->prepare("UPDATE {$bp->activity->table_name_meta} SET meta_value = %s WHERE activity_id = %d AND meta_key = %s", $meta_value, $activity_id, $meta_key));
        } else {
            return false;
        }
    }
    // Set cache
    nxt_cache_set('bp_activity_meta_' . $meta_key . '_' . $activity_id, $meta_value, 'bp');
    // Victory is ours!
    return true;
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:53,代码来源:bp-activity-functions.php

示例7: bp_like_remove_user_like

/**
 * bp_like_remove_user_like()
 *
 * Registers that the user has unliked a given item.
 *
 */
function bp_like_remove_user_like($item_id = '', $type = 'activity')
{
    global $bp;
    if (!$item_id) {
        return false;
    }
    if (!isset($user_id)) {
        $user_id = $bp->loggedin_user->id;
    }
    if ($user_id == 0) {
        echo bp_like_get_text('must_be_logged_in');
        return false;
    }
    if ($type == 'activity') {
        /* Remove this from the users liked activities. */
        $user_likes = get_user_meta($user_id, 'bp_liked_activities', true);
        unset($user_likes[$item_id]);
        update_user_meta($user_id, 'bp_liked_activities', $user_likes);
        /* Update the total number of users who have liked this activity. */
        $users_who_like = bp_activity_get_meta($item_id, 'liked_count', true);
        unset($users_who_like[$user_id]);
        /* If nobody likes the activity, delete the meta for it to save space, otherwise, update the meta */
        if (empty($users_who_like)) {
            bp_activity_delete_meta($item_id, 'liked_count');
        } else {
            bp_activity_update_meta($item_id, 'liked_count', $users_who_like);
        }
        $liked_count = count($users_who_like);
        /* Remove the update on the users profile from when they liked the activity. */
        $update_id = bp_activity_get_activity_id(array('item_id' => $item_id, 'component' => 'bp-like', 'type' => 'activity_liked', 'user_id' => $user_id));
        bp_activity_delete(array('id' => $update_id, 'item_id' => $item_id, 'component' => 'bp-like', 'type' => 'activity_liked', 'user_id' => $user_id));
    } elseif ($type == 'blogpost') {
        /* Remove this from the users liked activities. */
        $user_likes = get_user_meta($user_id, 'bp_liked_blogposts', true);
        unset($user_likes[$item_id]);
        update_user_meta($user_id, 'bp_liked_blogposts', $user_likes);
        /* Update the total number of users who have liked this blog post. */
        $users_who_like = get_post_meta($item_id, 'liked_count', true);
        unset($users_who_like[$user_id]);
        /* If nobody likes the blog post, delete the meta for it to save space, otherwise, update the meta */
        if (empty($users_who_like)) {
            delete_post_meta($item_id, 'liked_count');
        } else {
            update_post_meta($item_id, 'liked_count', $users_who_like);
        }
        $liked_count = count($users_who_like);
        /* Remove the update on the users profile from when they liked the activity. */
        $update_id = bp_activity_get_activity_id(array('item_id' => $item_id, 'component' => 'bp-like', 'type' => 'blogpost_liked', 'user_id' => $user_id));
        bp_activity_delete(array('id' => $update_id, 'item_id' => $item_id, 'component' => 'bp-like', 'type' => 'blogpost_liked', 'user_id' => $user_id));
    }
    echo bp_like_get_text('like');
    if ($liked_count) {
        echo ' (' . $liked_count . ')';
    }
}
开发者ID:Grendel61,项目名称:BuddyPress-Like,代码行数:61,代码来源:like-functions.php

示例8: bp_activity_akismet_delete_old_metadata

/**
 * Deletes old spam activity meta data, as _bp_akismet_submission meta can be large.
 *
 * @global object $bp BuddyPress global settings
 * @global wpdb $wpdb WordPress database object
 * @since BuddyPress (1.6)
 */
function bp_activity_akismet_delete_old_metadata()
{
    global $bp, $wpdb;
    $interval = apply_filters('bp_activity_akismet_delete_meta_interval', 15);
    // Enforce a minimum of 1 day
    $interval = max(1, absint($interval));
    // _bp_akismet_submission meta values are large, so expire them after $interval days regardless of the activity status
    $sql = $wpdb->prepare("SELECT a.id FROM {$bp->activity->table_name} a LEFT JOIN {$bp->activity->table_name_meta} m ON a.id = m.activity_id WHERE m.meta_key = %s AND DATE_SUB(%s, INTERVAL {$interval} DAY) > a.date_recorded LIMIT 10000", '_bp_akismet_submission', current_time('mysql', 1));
    $activity_ids = $wpdb->get_col($sql);
    if (!empty($activity_ids)) {
        foreach ($activity_ids as $activity_id) {
            bp_activity_delete_meta($activity_id, '_bp_akismet_submission');
        }
    }
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:22,代码来源:bp-activity-akismet.php

示例9: test_query_cache_should_be_invalidated_by_activitymeta_delete

 /**
  * @ticket BP7237
  * @ticket BP6643
  */
 public function test_query_cache_should_be_invalidated_by_activitymeta_delete()
 {
     global $wpdb;
     $activities = $this->factory->activity->create_many(2);
     bp_activity_add_meta($activities[0], 'foo', 'bar');
     bp_activity_add_meta($activities[1], 'foo', 'bar');
     $activity_args = array('meta_query' => array(array('key' => 'foo', 'value' => 'bar')));
     $q1 = bp_activity_get($activity_args);
     $this->assertEqualSets(array($activities[0], $activities[1]), wp_list_pluck($q1['activities'], 'id'));
     bp_activity_delete_meta($activities[1], 'foo', 'bar');
     $q2 = bp_activity_get($activity_args);
     $this->assertEqualSets(array($activities[0]), wp_list_pluck($q2['activities'], 'id'));
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:17,代码来源:cache.php

示例10: bp_blogs_update_post_activity_meta

/**
 * Updates a blog post's activity meta entry during a post edit.
 *
 * @since BuddyPress (2.2.0)
 *
 * @param WP_Post              $post     Post object.
 * @param BP_Activity_Activity $activity Activity object.
 */
function bp_blogs_update_post_activity_meta($post, $activity)
{
    if (empty($activity->id) || 'post' != $post->post_type) {
        return;
    }
    // Update post title in activity meta.
    $existing_title = bp_activity_get_meta($activity->id, 'post_title');
    if ($post->post_title !== $existing_title) {
        bp_activity_update_meta($activity->id, 'post_title', $post->post_title);
        // Now update activity meta for post comments... sigh.
        add_filter('comments_clauses', 'bp_blogs_comments_clauses_select_by_id');
        $comments = get_comments(array('post_id' => $post->ID));
        remove_filter('comments_clauses', 'bp_blogs_comments_clauses_select_by_id');
        if (!empty($comments)) {
            $activity_ids = array();
            $comment_ids = wp_list_pluck($comments, 'comment_ID');
            // Set up activity args.
            $args = array('update_meta_cache' => false, 'show_hidden' => true, 'per_page' => 99999);
            // Query for old-style "new_blog_comment" activity items.
            $args['filter'] = array('object' => buddypress()->blogs->id, 'action' => 'new_blog_comment', 'secondary_id' => implode(',', $comment_ids));
            $activities = bp_activity_get($args);
            if (!empty($activities['activities'])) {
                $activity_ids = (array) wp_list_pluck($activities['activities'], 'id');
            }
            // Query for activity comments connected to a blog post.
            unset($args['filter']);
            $args['meta_query'] = array(array('key' => 'bp_blogs_post_comment_id', 'value' => $comment_ids, 'compare' => 'IN'));
            $args['type'] = 'activity_comment';
            $args['display_comments'] = 'stream';
            $activities = bp_activity_get($args);
            if (!empty($activities['activities'])) {
                $activity_ids = array_merge($activity_ids, (array) wp_list_pluck($activities['activities'], 'id'));
            }
            // Update activity meta for all found activity items.
            if (!empty($activity_ids)) {
                foreach ($activity_ids as $aid) {
                    bp_activity_update_meta($aid, 'post_title', $post->post_title);
                }
            }
            unset($activities, $activity_ids, $comment_ids, $comments);
        }
    }
    // Add post comment status to activity meta if closed.
    if ('closed' == $post->comment_status) {
        bp_activity_update_meta($activity->id, 'post_comment_status', $post->comment_status);
    } else {
        bp_activity_delete_meta($activity->id, 'post_comment_status');
    }
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:57,代码来源:bp-blogs-functions.php

示例11: mpp_activity_delete_associated_comment_id

function mpp_activity_delete_associated_comment_id($activity_id)
{
    return bp_activity_delete_meta($activity_id, '_mpp_comment_id');
}
开发者ID:markc,项目名称:mediapress,代码行数:4,代码来源:mpp-activity-functions.php

示例12: test_bp_activity_delete_meta_with_delete_all

 /**
  * @group activitymeta
  * @group bp_activity_delete_meta
  */
 public function test_bp_activity_delete_meta_with_delete_all()
 {
     // With no meta key, don't delete for all items - just delete
     // all for a single item
     $a1 = $this->factory->activity->create();
     $a2 = $this->factory->activity->create();
     bp_activity_update_meta($a1, 'foo', 'bar');
     bp_activity_update_meta($a1, 'foo1', 'bar1');
     bp_activity_update_meta($a2, 'foo', 'bar');
     bp_activity_update_meta($a2, 'foo1', 'bar1');
     $this->assertTrue(bp_activity_delete_meta($a1, 'foo', '', true));
     $this->assertSame('', bp_activity_get_meta($a1, 'foo'));
     $this->assertSame('', bp_activity_get_meta($a2, 'foo'));
     $this->assertSame('bar1', bp_activity_get_meta($a1, 'foo1'));
     $this->assertSame('bar1', bp_activity_get_meta($a2, 'foo1'));
 }
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:20,代码来源:functions.php

示例13: bp_activity_update_meta

function bp_activity_update_meta( $activity_id, $meta_key, $meta_value ) {
	global $wpdb, $bp;

	if ( !is_numeric( $activity_id ) )
		return false;

	$meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );

	if ( is_string( $meta_value ) )
		$meta_value = stripslashes( $wpdb->escape( $meta_value ) );

	$meta_value = maybe_serialize( $meta_value );

	if ( empty( $meta_value ) ) {
		return bp_activity_delete_meta( $activity_id, $meta_key );
	}

	$cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key ) );

	if ( !$cur ) {
		$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name_meta} ( activity_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $activity_id, $meta_key, $meta_value ) );
	} else if ( $cur->meta_value != $meta_value ) {
		$wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name_meta} SET meta_value = %s WHERE activity_id = %d AND meta_key = %s", $meta_value, $activity_id, $meta_key ) );
	} else {
		return false;
	}

	wp_cache_set( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, $meta_value, 'bp' );

	return true;
}
开发者ID:n-sane,项目名称:zaroka,代码行数:31,代码来源:bp-activity.php

示例14: bp_blogs_update_post

/**
 * Updates a blog post's corresponding activity entry during a post edit.
 *
 * @since BuddyPress (2.0.0)
 *
 * @see bp_blogs_catch_transition_post_status()
 *
 * @param WP_Post $post
 */
function bp_blogs_update_post($post)
{
    if (!bp_is_active('activity')) {
        return;
    }
    $activity_id = bp_activity_get_activity_id(array('component' => buddypress()->blogs->id, 'item_id' => get_current_blog_id(), 'secondary_item_id' => $post->ID, 'type' => 'new_blog_post'));
    // activity ID doesn't exist, so stop!
    if (empty($activity_id)) {
        return;
    }
    // update the activity entry
    $activity = new BP_Activity_Activity($activity_id);
    if (!empty($post->post_content)) {
        // Make sure to update the thumbnail image
        $post_content = bp_activity_thumbnail_content_images($post->post_content, $activity->primary_link, (array) $activity);
        // Make sure to apply the blop post excerpt
        $activity->content = apply_filters('bp_blogs_record_activity_content', bp_create_excerpt($post_content), $post_content, (array) $activity);
    }
    // Save the updated activity
    $activity->save();
    // update post title in activity meta
    $existing_title = bp_activity_get_meta($activity_id, 'post_title');
    if ($post->post_title !== $existing_title) {
        bp_activity_update_meta($activity_id, 'post_title', $post->post_title);
        // now update activity meta for post comments... sigh
        add_filter('comments_clauses', 'bp_blogs_comments_clauses_select_by_id');
        $comments = get_comments(array('post_id' => $post->ID));
        remove_filter('comments_clauses', 'bp_blogs_comments_clauses_select_by_id');
        if (!empty($comments)) {
            $activity_ids = array();
            $comment_ids = wp_list_pluck($comments, 'comment_ID');
            // setup activity args
            $args = array('update_meta_cache' => false, 'show_hidden' => true, 'per_page' => 99999);
            // query for old-style "new_blog_comment" activity items
            $args['filter'] = array('object' => buddypress()->blogs->id, 'action' => 'new_blog_comment', 'secondary_id' => implode(',', $comment_ids));
            $activities = bp_activity_get($args);
            if (!empty($activities['activities'])) {
                $activity_ids = (array) wp_list_pluck($activities['activities'], 'id');
            }
            // query for activity comments connected to a blog post
            unset($args['filter']);
            $args['meta_query'] = array(array('key' => 'bp_blogs_post_comment_id', 'value' => $comment_ids, 'compare' => 'IN'));
            $args['type'] = 'activity_comment';
            $args['display_comments'] = 'stream';
            $activities = bp_activity_get($args);
            if (!empty($activities['activities'])) {
                $activity_ids = array_merge($activity_ids, (array) wp_list_pluck($activities['activities'], 'id'));
            }
            // update activity meta for all found activity items
            if (!empty($activity_ids)) {
                foreach ($activity_ids as $aid) {
                    bp_activity_update_meta($aid, 'post_title', $post->post_title);
                }
            }
            unset($activities, $activity_ids, $comment_ids, $comments);
        }
    }
    // add post comment status to activity meta if closed
    if ('closed' == $post->comment_status) {
        bp_activity_update_meta($activity_id, 'post_comment_status', $post->comment_status);
    } else {
        bp_activity_delete_meta($activity_id, 'post_comment_status');
    }
}
开发者ID:pausaura,项目名称:agora_nodes,代码行数:73,代码来源:bp-blogs-functions.php

示例15: mpp_activity_delete_activity_type

/**
 * Delet MediaPress activity type
 * @param type $activity_id
 * @return type
 */
function mpp_activity_delete_activity_type($activity_id)
{
    return bp_activity_delete_meta($activity_id, '_mpp_activity_type');
}
开发者ID:baden03,项目名称:mediapress,代码行数:9,代码来源:functions.php


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