本文整理汇总了PHP中bp_activity_update_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_activity_update_meta函数的具体用法?PHP bp_activity_update_meta怎么用?PHP bp_activity_update_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_activity_update_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: vortex_update_meta
function vortex_update_meta($post_id, $key, $value)
{
$bbp = vortex_is_buddypress($post_id);
if ($bbp) {
return bp_activity_update_meta($post_id, $key, $value);
} else {
return update_post_meta($post_id, $key, $value);
}
}
示例2: bp_course_record_activity_meta
function bp_course_record_activity_meta($args = '')
{
if (!function_exists('bp_activity_update_meta')) {
return false;
}
$defaults = array('id' => false, 'meta_key' => '', 'meta_value' => '');
$r = wp_parse_args($args, $defaults);
extract($r);
return bp_activity_update_meta($id, $meta_key, $meta_value);
}
示例3: test_get_with_meta_query_two_clauses_with_or_relation
/**
* @group get
*/
public function test_get_with_meta_query_two_clauses_with_or_relation()
{
$now = time();
$a1 = $this->factory->activity->create(array('recorded_time' => date('Y-m-d H:i:s', $now)));
$a2 = $this->factory->activity->create(array('recorded_time' => date('Y-m-d H:i:s', $now - 60)));
$a3 = $this->factory->activity->create(array('recorded_time' => date('Y-m-d H:i:s', $now - 120)));
bp_activity_update_meta($a1, 'foo', 'bar');
bp_activity_update_meta($a2, 'foo', 'bar');
bp_activity_update_meta($a1, 'baz', 'barry');
$activity = BP_Activity_Activity::get(array('meta_query' => array('relation' => 'OR', array('key' => 'foo', 'value' => 'bar'), array('key' => 'baz', 'value' => 'barry')), 'count_total' => 'count_query'));
$ids = wp_list_pluck($activity['activities'], 'id');
$this->assertEquals(array($a1, $a2), $ids);
$this->assertEquals(2, $activity['total']);
}
示例4: save_activity
/**
* Saves a BuddyPress Activity
*
* @param stdObject $activity Row from the activity table
* @return boolean (TRUE if there were actually Bible references to save)
*/
public function save_activity($activity)
{
// Add any read passage strings
if (!empty($activity->bfox_read_ref_str)) {
bp_activity_update_meta($activity->id, 'bfox_read_ref_str', $activity->bfox_read_ref_str);
do_action('bfox_save_activity_read_ref_str', $activity);
}
if ($success = $this->save_item($activity->id, apply_filters('bfox_save_activity_ref', $activity->bfox_ref, $activity))) {
// If we successfully saved some Bible references, lets cache the string in the activity meta
// That way we don't have to recalculate it each time which could be a pain
// For example, recalculating the references for a blog post requires switching to that blog, getting the blog post and parsing it
// Instead, we can just use this meta
bp_activity_update_meta($activity->id, 'bfox_ref_str', $activity->bfox_ref->get_string(BibleMeta::name_short));
}
return $success;
}
示例5: test_bp_activity_update_meta_cache
/**
* @group bp_activity_update_meta_cache
*/
public function test_bp_activity_update_meta_cache()
{
$a1 = $this->factory->activity->create();
$a2 = $this->factory->activity->create();
// Set up some data
bp_activity_update_meta($a1, 'foo', 'bar');
bp_activity_update_meta($a1, 'Boone', 'Rules');
bp_activity_update_meta($a2, 'foo', 'baz');
bp_activity_update_meta($a2, 'BuddyPress', 'Is Cool');
// Prime the cache for $a1
bp_activity_get_meta($a1, 'foo');
// Ensure an empty cache for $a2
wp_cache_delete($a2, 'activity_meta');
bp_activity_update_meta_cache(array($a1, $a2));
$expected = array($a1 => array('foo' => array('bar'), 'Boone' => array('Rules')), $a2 => array('foo' => array('baz'), 'BuddyPress' => array('Is Cool')));
$found = array($a1 => wp_cache_get($a1, 'activity_meta'), $a2 => wp_cache_get($a2, 'activity_meta'));
$this->assertEquals($expected, $found);
}
示例6: add_media
//.........这里部分代码省略.........
wp_delete_post($post_id, true);
throw new Exception(__('Error Uploading File', 'bp-media'));
}
$attachment = array();
$url = $file['url'];
$type = $file['type'];
$file = $file['file'];
$title = $name;
$content = $description;
$attachment = array(
'post_mime_type' => $type,
'guid' => $url,
'post_title' => $title,
'post_content' => $content,
'post_parent' => $post_id,
);
bp_media_init_count(bp_loggedin_user_id());
switch ($type) {
case 'video/mp4' :
$type = 'video';
include_once(trailingslashit(BP_MEDIA_PLUGIN_DIR) . 'includes/lib/getid3/getid3.php');
try {
$getID3 = new getID3;
$vid_info = $getID3->analyze($file);
} catch (Exception $e) {
wp_delete_post($post_id, true);
unlink($file);
$activity_content = false;
throw new Exception(__('MP4 file you have uploaded is currupt.', 'bp-media'));
}
if (is_array($vid_info)) {
if (!array_key_exists('error',$vid_info)&& array_key_exists('fileformat', $vid_info) && array_key_exists('video', $vid_info)&&array_key_exists('fourcc',$vid_info['video'])) {
if (!($vid_info['fileformat']=='mp4'&&$vid_info['video']['fourcc']=='avc1')) {
wp_delete_post($post_id, true);
unlink($file);
$activity_content = false;
throw new Exception(__('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'bp-media'));
}
} else {
wp_delete_post($post_id, true);
unlink($file);
$activity_content = false;
throw new Exception(__('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'bp-media'));
}
} else {
wp_delete_post($post_id, true);
unlink($file);
$activity_content = false;
throw new Exception(__('The MP4 file you have uploaded is not a video file.', 'bp-media'));
}
$bp_media_count['videos'] = intval($bp_media_count['videos']) + 1;
break;
case 'audio/mpeg' :
$type = 'audio';
$bp_media_count['audio'] = intval($bp_media_count['audio']) + 1;
break;
case 'image/gif' :
case 'image/jpeg' :
case 'image/png' :
$type = 'image';
$bp_media_count['images'] = intval($bp_media_count['images']) + 1;
break;
default : unlink($file);
wp_delete_post($post_id, true);
unlink($file);
$activity_content = false;
throw new Exception(__('Media File you have tried to upload is not supported. Supported media files are .jpg, .png, .gif, .mp3 and .mp4.', 'bp-media'));
}
$attachment_id = wp_insert_attachment($attachment, $file, $post_id);
if (!is_wp_error($attachment_id)) {
wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
} else {
wp_delete_post($post_id, true);
unlink($file);
throw new Exception(__('Error creating activity for the media file, please try again', 'bp-media'));
}
$postarr['ID'] = $post_id;
$postarr['post_mime_type'] = $type;
$postarr['post_status'] = 'publish';
wp_insert_post($postarr);
$activity_content = '[bp_media_content id="' . $post_id . '"]';
$activity_id = bp_media_record_activity(array(
'action' => '[bp_media_action id="' . $post_id . '"]',
'content' => $activity_content,
'primary_link' => '[bp_media_url id="' . $post_id . '"]',
'type' => 'media_upload'
));
bp_activity_update_meta($activity_id, 'bp_media_parent_post', $post_id);
update_post_meta($post_id, 'bp_media_child_activity', $activity_id);
update_post_meta($post_id, 'bp_media_child_attachment', $attachment_id);
update_post_meta($post_id, 'bp_media_type', $type);
update_post_meta($post_id, 'bp_media_hosting', 'wordpress');
$this->id = $post_id;
$this->name = $name;
$this->description = $description;
$this->owner = bp_loggedin_user_id();
$this->type = $type;
$this->url = $url;
bp_update_user_meta(bp_loggedin_user_id(), 'bp_media_count', $bp_media_count);
}
示例7: add_rating
function add_rating($args = '')
{
global $bp;
$defaults = array('group_id' => $bp->groups->current_group->id, 'score' => false, 'user_id' => $bp->loggedin_user->id, 'activity_id' => false);
$r = wp_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
if (empty($score)) {
return false;
}
// First record the activity meta for this particular rating
bp_activity_update_meta($activity_id, 'bpgr_rating', $score);
// Then add this item to the list of reviews for this group
if (!($ratings = groups_get_groupmeta($group_id, 'bpgr_ratings'))) {
$ratings = array();
}
$ratings[$activity_id] = $score;
// Pull the composite scores and recalculate
if (!($rating = groups_get_groupmeta($group_id, 'bpgr_rating'))) {
$avg_score = 0;
}
if (!($how_many = (int) groups_get_groupmeta($group_id, 'bpgr_how_many_ratings'))) {
$how_many = 0;
}
$how_many++;
groups_update_groupmeta($group_id, 'bpgr_how_many_ratings', $how_many);
$raw_score = 0;
foreach ($ratings as $score) {
$raw_score += (int) $score;
}
$rating = $raw_score / $how_many;
groups_update_groupmeta($group_id, 'bpgr_rating', $rating);
groups_update_groupmeta($group_id, 'bpgr_ratings', $ratings);
}
示例8: dwqa_replace_activity_meta
function dwqa_replace_activity_meta()
{
global $activities_template;
$blog_url = bp_blogs_get_blogmeta($activity->item_id, 'url');
$blog_name = bp_blogs_get_blogmeta($activity->item_id, 'name');
if (empty($blog_url) || empty($blog_name)) {
$blog_url = get_home_url($activity->item_id);
$blog_name = get_blog_option($activity->item_id, 'blogname');
bp_blogs_update_blogmeta($activity->item_id, 'url', $blog_url);
bp_blogs_update_blogmeta($activity->item_id, 'name', $blog_name);
}
$post_url = add_query_arg('p', $activities_template->activity->secondary_item_id, trailingslashit($blog_url));
$post_title = bp_activity_get_meta($activities_template->activity->id, 'post_title');
if (empty($post_title)) {
$post = get_post($activities_template->activity->secondary_item_id);
if (is_a($post, 'WP_Post')) {
$post_title = $post->post_title;
bp_activity_update_meta($activities_template->activity->id, 'post_title', $post_title);
}
}
$post_link = '<a href="' . $post_url . '">' . $post_title . '</a>';
$user_link = bp_core_get_userlink($activities_template->activity->user_id);
if ($activities_template->activity->type == 'new_question') {
$action = sprintf(__('%1$s asked a new question: %2$s', 'dwqa'), $user_link, $post_link);
} elseif ($activities_template->activity->type == 'new_answer') {
$action = sprintf(__('%1$s answered the question: %2$s', 'dwqa'), $user_link, $post_link);
} elseif ($activities_template->activity->type == 'comment_question') {
$action = sprintf(__('%1$s commented on the question: %2$s', 'dwqa'), $user_link, $post_link);
} elseif ($activities_template->activity->type == 'comment_answer') {
$action = sprintf(__('%1$s commented on the answer at: %2$s', 'dwqa'), $user_link, $post_link);
} else {
$action = $activities_template->activity->action;
}
// Strip any legacy time since placeholders from BP 1.0-1.1
$content = str_replace('<span class="time-since">%s</span>', '', $content);
// Insert the time since.
$time_since = apply_filters_ref_array('bp_activity_time_since', array('<span class="time-since">' . bp_core_time_since($activities_template->activity->date_recorded) . '</span>', &$activities_template->activity));
// Insert the permalink
if (!bp_is_single_activity()) {
$content = apply_filters_ref_array('bp_activity_permalink', array(sprintf('%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', $content, bp_activity_get_permalink($activities_template->activity->id, $activities_template->activity), esc_attr__('View Discussion', 'buddypress'), $time_since), &$activities_template->activity));
} else {
$content .= str_pad($time_since, strlen($time_since) + 2, ' ', STR_PAD_BOTH);
}
echo $action . ' ' . $content;
// echo 'abc';
// echo $activities_template->activity->content;
}
示例9: bp_activity_posted_update
function bp_activity_posted_update($content, $user_id, $activity_id)
{
global $wpdb, $bp;
$updated_content = '';
// hook for rtmedia buddypress before activity posted
do_action('rtmedia_bp_before_activity_posted', $content, $user_id, $activity_id);
if (isset($_POST['rtMedia_attached_files']) && is_array($_POST['rtMedia_attached_files'])) {
$updated_content = $wpdb->get_var("select content from {$bp->activity->table_name} where id= {$activity_id}");
$objActivity = new RTMediaActivity($_POST['rtMedia_attached_files'], 0, $updated_content);
$html_content = $objActivity->create_activity_html();
bp_activity_update_meta($activity_id, 'bp_old_activity_content', $html_content);
bp_activity_update_meta($activity_id, 'bp_activity_text', $updated_content);
$wpdb->update($bp->activity->table_name, array('type' => 'rtmedia_update', 'content' => $html_content), array('id' => $activity_id));
$mediaObj = new RTMediaModel();
$sql = "update {$mediaObj->table_name} set activity_id = '" . $activity_id . "' where blog_id = '" . get_current_blog_id() . "' and id in (" . implode(',', $_POST['rtMedia_attached_files']) . ')';
$wpdb->query($sql);
}
// hook for rtmedia buddypress after activity posted
do_action('rtmedia_bp_activity_posted', $updated_content, $user_id, $activity_id);
if (isset($_POST['rtmedia-privacy'])) {
$privacy = -1;
if (is_rtmedia_privacy_enable()) {
if (is_rtmedia_privacy_user_overide()) {
$privacy = $_POST['rtmedia-privacy'];
} else {
$privacy = get_rtmedia_default_privacy();
}
}
bp_activity_update_meta($activity_id, 'rtmedia_privacy', $privacy);
// insert/update activity details in rtmedia activity table
$rtmedia_activity_model = new RTMediaActivityModel();
if (!$rtmedia_activity_model->check($activity_id)) {
$rtmedia_activity_model->insert(array('activity_id' => $activity_id, 'user_id' => $user_id, 'privacy' => $privacy));
} else {
$rtmedia_activity_model->update(array('activity_id' => $activity_id, 'user_id' => $user_id, 'privacy' => $privacy), array('activity_id' => $activity_id));
}
}
}
示例10: bp_embed_activity_save_cache
/**
* Set an activity item's embed cache.
*
* Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
*
* @since BuddyPress (1.5.0)
*
* @see BP_Embed::parse_oembed()
* @uses bp_activity_update_meta()
*
* @param string $cache An empty string passed by BP_Embed::parse_oembed() for
* functions like this one to filter.
* @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
* @param int $id The ID of the activity item.
* @return bool True on success, false on failure.
*/
function bp_embed_activity_save_cache($cache, $cachekey, $id)
{
bp_activity_update_meta($id, $cachekey, $cache);
}
示例11: bp_cover_group_handle_upload
function bp_cover_group_handle_upload($activity_id)
{
global $bp, $wpdb;
$group_id = bp_get_current_group_id();
$activity_table = $wpdb->prefix . "bp_activity";
$activity_meta_table = $wpdb->prefix . "bp_activity_meta";
$sql = "SELECT COUNT(*) as photo_count FROM {$activity_table} a INNER JOIN {$activity_meta_table} am ON a.id = am.activity_id WHERE a.item_id = %d AND meta_key = 'all_bp_cover_group'";
$sql = $wpdb->prepare($sql, $group_id);
$cnt = $wpdb->get_var($sql);
$max_cnt = bp_cover_get_max_total();
if ($cnt < $max_cnt) {
if ($_POST['encodedimg']) {
$file = $_POST['imgsize'];
$max_upload_size = bp_cover_get_max_media_size();
if ($max_upload_size > $file) {
$group_id = $bp->groups->current_group->id;
$imgresponse = array();
$uploaddir = wp_upload_dir();
/* let's decode the base64 encoded image sent */
$img = $_POST['encodedimg'];
$img = str_replace('data:' . $_POST['imgtype'] . ';base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$imgname = wp_unique_filename($uploaddir['path'], $_POST['imgname']);
$filepath = $uploaddir['path'] . '/' . $imgname;
$fileurl = $uploaddir['url'] . '/' . $imgname;
/* now we write the image in dir */
$success = file_put_contents($filepath, $data);
if ($success) {
$imgresponse[0] = "1";
$imgresponse[1] = $fileurl;
$size = @getimagesize($filepath);
$attachment = array('post_mime_type' => $_POST['imgtype'], 'guid' => $fileurl, 'post_title' => $imgname);
require_once ABSPATH . 'wp-admin/includes/image.php';
$attachment_id = wp_insert_attachment($attachment, $filepath);
$attach_data = wp_generate_attachment_metadata($attachment_id, $filepath);
wp_update_attachment_metadata($attachment_id, $attach_data);
groups_update_groupmeta($group_id, 'bp_cover_group', $fileurl);
groups_update_groupmeta($group_id, 'bp_cover_group_position', 0);
$group = groups_get_group(array("group_id" => $group_id));
$activity_id = groups_record_activity(array('action' => sprintf(__('%s uploaded a new cover picture to the group %s', 'bp-cover'), bp_core_get_userlink($bp->loggedin_user->id), '<a href="' . bp_get_group_permalink($group) . '">' . esc_attr($group->name) . '</a>'), 'type' => 'cover_added', 'item_id' => $group_id, 'content' => bp_cover_group_get_image_scr(), 'item_id' => $group_id));
bp_activity_update_meta($activity_id, 'all_bp_cover_group', $attachment_id);
update_post_meta($attachment_id, 'bp_cover_group_thumb', $imgresponse[2]);
} else {
$imgresponse[0] = "0";
$imgresponse[1] = __('Upload Failed! Unable to write the image on server', 'bp-cover');
}
} else {
$imgresponse[0] = "0";
$imgresponse[1] = sprintf(__('The file you uploaded is too big. Please upload a file under %s', 'bp-cover'), size_format($max_upload_size));
}
} else {
$imgresponse[0] = "0";
$imgresponse[1] = __('Upload Failed! No image sent', 'bp-cover');
}
} else {
$imgresponse[0] = "0";
$imgresponse[1] = sprintf(__('Max total images allowed %d in a cover gallery', 'bp-cover'), $max_cnt);
}
/* if everything is ok, we send back url to thumbnail and to full image */
echo json_encode($imgresponse);
die;
}
示例12: bp_checkins_untrashed_place
function bp_checkins_untrashed_place($place_id)
{
// we need to rebuilt the activity type new_place and its activity_meta
if (empty($place_id)) {
return false;
}
$place = get_post($place_id);
if (!in_array($place->post_type, array('places'))) {
return false;
}
/* do we have a group_id ? */
$group_id = get_post_meta($place_id, '_bpci_group_id', true);
/* let's build the activity vars */
$place_name = esc_attr($place->post_title);
$thumbnail = bp_get_checkins_places_featured_image($place_id);
$excerpt = bp_get_checkins_places_excerpt($place->post_content);
$place_content = apply_filters('bp_checkins_place_content_before_activity', $thumbnail . $excerpt);
$args = array('content' => $place_content, 'user_id' => $place->post_author, 'type' => 'new_place', 'place_id' => $place_id, 'place_name' => $place_name, 'recorded_time' => $place->post_date_gmt);
if (!empty($group_id) && $group_id != 0) {
// adding the group_id to args.
$args['group_id'] = $group_id;
$activity_id = bp_checkins_groups_post_update($args);
} else {
$activity_id = bp_checkins_post_update($args);
}
if (!empty($activity_id)) {
/*
* now we store the post meta as activity meta
* this way if cookies of superadmin were writen
* we'll be sure to have the correct values.
*/
$lat = get_post_meta($place_id, 'bpci_places_lat', true);
$lng = get_post_meta($place_id, 'bpci_places_lng', true);
$address = get_post_meta($place_id, 'bpci_places_address', true);
if (empty($lat) || empty($lng) || empty($address)) {
return false;
}
bp_activity_update_meta($activity_id, 'bpci_activity_lat', $lat);
bp_activity_update_meta($activity_id, 'bpci_activity_lng', $lng);
bp_activity_update_meta($activity_id, 'bpci_activity_address', $address);
}
}
示例13: 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;
}
示例14: bp_blogs_sync_add_from_activity_comment
/**
* Syncs activity comments and posts them back as blog comments.
*
* Note: This is only a one-way sync - activity comments -> blog comment.
*
* For blog post -> activity comment, see {@link bp_activity_post_type_comment()}.
*
* @since 2.0.0
* @since 2.5.0 Allow custom post types to sync their comments with activity ones
*
* @param int $comment_id The activity ID for the posted activity comment.
* @param array $params Parameters for the activity comment.
* @param object $parent_activity Parameters of the parent activity item (in this case, the blog post).
*/
function bp_blogs_sync_add_from_activity_comment($comment_id, $params, $parent_activity)
{
// 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;
}
// If activity comments are disabled for blog posts, stop now!
if (bp_disable_blogforum_comments()) {
return;
}
// Get userdata.
if ($params['user_id'] == bp_loggedin_user_id()) {
$user = buddypress()->loggedin_user->userdata;
} else {
$user = bp_core_get_core_userdata($params['user_id']);
}
// Get associated post type and set default comment parent
$post_type = bp_activity_post_type_get_tracking_arg($parent_activity->type, 'post_type');
$comment_parent = 0;
// See if a parent WP comment ID exists.
if (!empty($params['parent_id']) && !empty($post_type)) {
$comment_parent = bp_activity_get_meta($params['parent_id'], "bp_blogs_{$post_type}_comment_id");
}
// Comment args.
$args = array('comment_post_ID' => $parent_activity->secondary_item_id, 'comment_author' => bp_core_get_user_displayname($params['user_id']), 'comment_author_email' => $user->user_email, 'comment_author_url' => bp_core_get_user_domain($params['user_id'], $user->user_nicename, $user->user_login), 'comment_content' => $params['content'], 'comment_type' => '', 'comment_parent' => (int) $comment_parent, 'user_id' => $params['user_id'], 'comment_approved' => 1);
// Prevent separate activity entry being made.
remove_action('comment_post', 'bp_activity_post_type_comment', 10, 2);
// Handle multisite.
switch_to_blog($parent_activity->item_id);
// Handle timestamps for the WP comment after we've switched to the blog.
$args['comment_date'] = current_time('mysql');
$args['comment_date_gmt'] = current_time('mysql', 1);
// Post the comment.
$post_comment_id = wp_insert_comment($args);
// Add meta to comment.
add_comment_meta($post_comment_id, 'bp_activity_comment_id', $comment_id);
// Add meta to activity comment.
if (!empty($post_type)) {
bp_activity_update_meta($comment_id, "bp_blogs_{$post_type}_comment_id", $post_comment_id);
}
// Resave activity comment with WP comment permalink.
//
// in bp_blogs_activity_comment_permalink(), we change activity comment
// permalinks to use the post comment link
//
// @todo since this is done after AJAX posting, the activity comment permalink
// doesn't change on the frontend until the next page refresh.
$resave_activity = new BP_Activity_Activity($comment_id);
$resave_activity->primary_link = get_comment_link($post_comment_id);
/**
* Now that the activity id exists and the post comment was created, we don't need to update
* the content of the comment as there are no chances it has evolved.
*/
remove_action('bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20);
$resave_activity->save();
// Add the edit activity comment hook back.
add_action('bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20);
// Multisite again!
restore_current_blog();
// Add the comment hook back.
add_action('comment_post', 'bp_activity_post_type_comment', 10, 2);
/**
* Fires after activity comments have been synced and posted as blog comments.
*
* @since 2.0.0
*
* @param int $comment_id The activity ID for the posted activity comment.
* @param array $args Array of args used for the comment syncing.
* @param object $parent_activity Parameters of the blog post parent activity item.
* @param object $user User data object for the blog comment.
*/
do_action('bp_blogs_sync_add_from_activity_comment', $comment_id, $args, $parent_activity, $user);
}
示例15: update_meta_data
/**
* Update meta data
*
* @author Alimir
* @param Integer $id
* @param String $key
* @param Integer $data
* @since 2.0
* @updated 2.2
* @return Void
*/
public function update_meta_data($id, $key, $data)
{
if ($key == "_liked" || $key == "_topicliked") {
update_post_meta($id, $key, $data);
} else {
if ($key == "_commentliked") {
update_comment_meta($id, $key, $data);
} else {
if ($key == "_activityliked") {
bp_activity_update_meta($id, $key, $data);
} else {
return 0;
}
}
}
}