本文整理汇总了PHP中BP_Activity_Activity::delete_activity_meta_entries方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Activity_Activity::delete_activity_meta_entries方法的具体用法?PHP BP_Activity_Activity::delete_activity_meta_entries怎么用?PHP BP_Activity_Activity::delete_activity_meta_entries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BP_Activity_Activity
的用法示例。
在下文中一共展示了BP_Activity_Activity::delete_activity_meta_entries方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_delete_activity_meta_entries
/**
* @ticket BP4804
* @group delete_activity_meta_entries
* @group activitymeta
*/
public function test_delete_activity_meta_entries()
{
$activity = $this->factory->activity->create(array('type' => 'activity_update'));
bp_activity_update_meta($activity, 'Paul', 'is cool');
BP_Activity_Activity::delete_activity_meta_entries($activity);
$meta = bp_activity_get_meta($activity, 'Paul');
$this->assertSame('', $meta);
}
示例2: delete_pic_cover_group
function delete_pic_cover_group($activity_id)
{
global $bp;
$group_id = $bp->groups->current_group->id;
$activity_id = $_POST['activity_id'];
$attachment_id = bp_activity_get_meta($activity_id, 'all_bp_cover_group', true);
wp_delete_attachment($attachment_id, true);
groups_delete_groupmeta($group_id, 'bp_cover_group');
groups_delete_groupmeta($group_id, 'bp_cover_group_position');
bp_activity_delete(array('id' => $activity_id, 'item_id' => $group_id));
BP_Activity_Activity::delete_activity_meta_entries($activity_id);
}
示例3: delete
function delete($args)
{
global $nxtdb, $bp;
$defaults = array('id' => false, 'action' => false, 'content' => false, 'component' => false, 'type' => false, 'primary_link' => false, 'user_id' => false, 'item_id' => false, 'secondary_item_id' => false, 'date_recorded' => false, 'hide_sitewide' => false);
$params = nxt_parse_args($args, $defaults);
extract($params);
$where_args = false;
if (!empty($id)) {
$where_args[] = $nxtdb->prepare("id = %d", $id);
}
if (!empty($user_id)) {
$where_args[] = $nxtdb->prepare("user_id = %d", $user_id);
}
if (!empty($action)) {
$where_args[] = $nxtdb->prepare("action = %s", $action);
}
if (!empty($content)) {
$where_args[] = $nxtdb->prepare("content = %s", $content);
}
if (!empty($component)) {
$where_args[] = $nxtdb->prepare("component = %s", $component);
}
if (!empty($type)) {
$where_args[] = $nxtdb->prepare("type = %s", $type);
}
if (!empty($primary_link)) {
$where_args[] = $nxtdb->prepare("primary_link = %s", $primary_link);
}
if (!empty($item_id)) {
$where_args[] = $nxtdb->prepare("item_id = %s", $item_id);
}
if (!empty($secondary_item_id)) {
$where_args[] = $nxtdb->prepare("secondary_item_id = %s", $secondary_item_id);
}
if (!empty($date_recorded)) {
$where_args[] = $nxtdb->prepare("date_recorded = %s", $date_recorded);
}
if (!empty($hide_sitewide)) {
$where_args[] = $nxtdb->prepare("hide_sitewide = %d", $hide_sitewide);
}
if (!empty($where_args)) {
$where_sql = 'WHERE ' . join(' AND ', $where_args);
} else {
return false;
}
// Fetch the activity IDs so we can delete any comments for this activity item
$activity_ids = $nxtdb->get_col($nxtdb->prepare("SELECT id FROM {$bp->activity->table_name} {$where_sql}"));
if (!$nxtdb->query($nxtdb->prepare("DELETE FROM {$bp->activity->table_name} {$where_sql}"))) {
return false;
}
if ($activity_ids) {
BP_Activity_Activity::delete_activity_item_comments($activity_ids);
BP_Activity_Activity::delete_activity_meta_entries($activity_ids);
return $activity_ids;
}
return $activity_ids;
}
示例4: delete
//.........这里部分代码省略.........
// ID.
if (!empty($r['id'])) {
$where_args[] = $wpdb->prepare("id = %d", $r['id']);
}
// User ID.
if (!empty($r['user_id'])) {
$where_args[] = $wpdb->prepare("user_id = %d", $r['user_id']);
}
// Action.
if (!empty($r['action'])) {
$where_args[] = $wpdb->prepare("action = %s", $r['action']);
}
// Content.
if (!empty($r['content'])) {
$where_args[] = $wpdb->prepare("content = %s", $r['content']);
}
// Component.
if (!empty($r['component'])) {
$where_args[] = $wpdb->prepare("component = %s", $r['component']);
}
// Type.
if (!empty($r['type'])) {
$where_args[] = $wpdb->prepare("type = %s", $r['type']);
}
// Primary Link.
if (!empty($r['primary_link'])) {
$where_args[] = $wpdb->prepare("primary_link = %s", $r['primary_link']);
}
// Item ID.
if (!empty($r['item_id'])) {
$where_args[] = $wpdb->prepare("item_id = %d", $r['item_id']);
}
// Secondary item ID.
if (!empty($r['secondary_item_id'])) {
$where_args[] = $wpdb->prepare("secondary_item_id = %d", $r['secondary_item_id']);
}
// Date Recorded.
if (!empty($r['date_recorded'])) {
$where_args[] = $wpdb->prepare("date_recorded = %s", $r['date_recorded']);
}
// Hidden sitewide.
if (!empty($r['hide_sitewide'])) {
$where_args[] = $wpdb->prepare("hide_sitewide = %d", $r['hide_sitewide']);
}
// Bail if no where arguments.
if (empty($where_args)) {
return false;
}
// Join the where arguments for querying.
$where_sql = 'WHERE ' . join(' AND ', $where_args);
// Fetch all activities being deleted so we can perform more actions.
$activities = $wpdb->get_results("SELECT * FROM {$bp->activity->table_name} {$where_sql}");
/**
* Action to allow intercepting activity items to be deleted.
*
* @since 2.3.0
*
* @param array $activities Array of activities.
* @param array $r Array of parsed arguments.
*/
do_action_ref_array('bp_activity_before_delete', array($activities, $r));
// Attempt to delete activities from the database.
$deleted = $wpdb->query("DELETE FROM {$bp->activity->table_name} {$where_sql}");
// Bail if nothing was deleted.
if (empty($deleted)) {
return false;
}
/**
* Action to allow intercepting activity items just deleted.
*
* @since 2.3.0
*
* @param array $activities Array of activities.
* @param array $r Array of parsed arguments.
*/
do_action_ref_array('bp_activity_after_delete', array($activities, $r));
// Pluck the activity IDs out of the $activities array.
$activity_ids = wp_parse_id_list(wp_list_pluck($activities, 'id'));
// Handle accompanying activity comments and meta deletion.
if (!empty($activity_ids)) {
// Delete all activity meta entries for activity items.
BP_Activity_Activity::delete_activity_meta_entries($activity_ids);
// Setup empty array for comments.
$comment_ids = array();
// Loop through activity ids and attempt to delete comments.
foreach ($activity_ids as $activity_id) {
// Attempt to delete comments.
$comments = BP_Activity_Activity::delete(array('type' => 'activity_comment', 'item_id' => $activity_id));
// Merge IDs together.
if (!empty($comments)) {
$comment_ids = array_merge($comment_ids, $comments);
}
}
// Merge activity IDs with any deleted comment IDs.
if (!empty($comment_ids)) {
$activity_ids = array_unique(array_merge($activity_ids, $comment_ids));
}
}
return $activity_ids;
}
示例5: delete
/**
* Delete activity items from the database.
*
* To delete a specific activity item, pass an 'id' parameter.
* Otherwise use the filters.
*
* @since BuddyPress (1.2)
*
* @param array $args {
* @int $id Optional. The ID of a specific item to delete.
* @string $action Optional. The action to filter by.
* @string $content Optional. The content to filter by.
* @string $component Optional. The component name to filter by.
* @string $type Optional. The activity type to filter by.
* @string $primary_link Optional. The primary URL to filter by.
* @int $user_id Optional. The user ID to filter by.
* @int $item_id Optional. The associated item ID to filter by.
* @int $secondary_item_id Optional. The secondary associated item ID to filter by.
* @string $date_recorded Optional. The date to filter by.
* @int $hide_sitewide Optional. Default: false.
* }
* @return array|bool An array of deleted activity IDs on success, false on failure.
*/
public static function delete($args = array())
{
global $wpdb, $bp;
$defaults = array('id' => false, 'action' => false, 'content' => false, 'component' => false, 'type' => false, 'primary_link' => false, 'user_id' => false, 'item_id' => false, 'secondary_item_id' => false, 'date_recorded' => false, 'hide_sitewide' => false);
$params = wp_parse_args($args, $defaults);
extract($params);
$where_args = false;
if (!empty($id)) {
$where_args[] = $wpdb->prepare("id = %d", $id);
}
if (!empty($user_id)) {
$where_args[] = $wpdb->prepare("user_id = %d", $user_id);
}
if (!empty($action)) {
$where_args[] = $wpdb->prepare("action = %s", $action);
}
if (!empty($content)) {
$where_args[] = $wpdb->prepare("content = %s", $content);
}
if (!empty($component)) {
$where_args[] = $wpdb->prepare("component = %s", $component);
}
if (!empty($type)) {
$where_args[] = $wpdb->prepare("type = %s", $type);
}
if (!empty($primary_link)) {
$where_args[] = $wpdb->prepare("primary_link = %s", $primary_link);
}
if (!empty($item_id)) {
$where_args[] = $wpdb->prepare("item_id = %d", $item_id);
}
if (!empty($secondary_item_id)) {
$where_args[] = $wpdb->prepare("secondary_item_id = %d", $secondary_item_id);
}
if (!empty($date_recorded)) {
$where_args[] = $wpdb->prepare("date_recorded = %s", $date_recorded);
}
if (!empty($hide_sitewide)) {
$where_args[] = $wpdb->prepare("hide_sitewide = %d", $hide_sitewide);
}
if (!empty($where_args)) {
$where_sql = 'WHERE ' . join(' AND ', $where_args);
} else {
return false;
}
// Fetch the activity IDs so we can delete any comments for this activity item
$activity_ids = $wpdb->get_col("SELECT id FROM {$bp->activity->table_name} {$where_sql}");
if (!$wpdb->query("DELETE FROM {$bp->activity->table_name} {$where_sql}")) {
return false;
}
// Handle accompanying activity comments and meta deletion
if ($activity_ids) {
$activity_ids_comma = implode(',', wp_parse_id_list($activity_ids));
$activity_comments_where_sql = "WHERE type = 'activity_comment' AND item_id IN ({$activity_ids_comma})";
// Fetch the activity comment IDs for our deleted activity items
$activity_comment_ids = $wpdb->get_col("SELECT id FROM {$bp->activity->table_name} {$activity_comments_where_sql}");
// We have activity comments!
if (!empty($activity_comment_ids)) {
// Delete activity comments
$wpdb->query("DELETE FROM {$bp->activity->table_name} {$activity_comments_where_sql}");
// Merge activity IDs with activity comment IDs
$activity_ids = array_merge($activity_ids, $activity_comment_ids);
}
// Delete all activity meta entries for activity items and activity comments
BP_Activity_Activity::delete_activity_meta_entries($activity_ids);
}
return $activity_ids;
}
示例6: buddy_boss_pics_cleanup_db
/**
* CLEANUP DATABASE AND RECONCILE WITH WP MEDIA LIBRARY
*/
function buddy_boss_pics_cleanup_db()
{
global $wpdb;
$activity_table = $wpdb->prefix . "bp_activity";
$activity_meta_table = $wpdb->prefix . "bp_activity_meta";
$posts_table = $wpdb->prefix . "posts";
// Prepare a SQL query to retrieve the activity posts
// that have pictures associated with them
$all_aids_sql = "SELECT am.meta_value, am.activity_id FROM {$activity_table} a \r\n\t\t\t\t\t\t\t\t\t\t INNER JOIN {$activity_meta_table} am ON a.id = am.activity_id \r\n\t\t\t\t\t\t\t\t\t\t WHERE am.meta_key = 'bboss_pics_aid'";
// Now perpare a SQL query to retrieve all attachments
// that are BuddyBoss wall pictures AND are published in the media library
$existing_sql = "SELECT am.meta_value FROM {$activity_table} a \r\n\t\t\t\t\t\t\t\t\t\t INNER JOIN {$activity_meta_table} am ON a.id = am.activity_id \r\n\t\t\t\t\t\t\t\t\t\t INNER JOIN {$posts_table} p ON am.meta_value = p.ID \r\n\t\t\t\t\t\t\t\t\t\t WHERE am.meta_key = 'bboss_pics_aid'\r\n\t\t\t\t\t\t\t\t\t\t AND p.post_status = 'inherit'\r\n\t\t\t\t\t\t\t\t\t\t AND p.post_parent = 0";
// Query the database for all attachment IDS
$all_aids = (array) $wpdb->get_results($all_aids_sql, ARRAY_A);
// Query the database for all pics in the media library that are BuddyBoss pics
$existing_aids = (array) $wpdb->get_col($existing_sql);
// If we have a result set
if (!empty($all_aids)) {
// Prepare array
$attachment_ids = $activity_ids = $aids2activity = array();
foreach ($all_aids as $aid) {
$attachment_ids[] = $aid['meta_value'];
$aids2activity[$aid['meta_value']] = $activity_ids[] = $aid['activity_id'];
}
// Lets get the difference of our published vs. orphaned IDs
$orphans = array_diff($attachment_ids, $existing_aids);
// Delete related activity stream posts
if (!empty($orphans)) {
$orphan_acitivity_ids = array();
foreach ($orphans as $orphan) {
if (isset($aids2activity[$orphan])) {
$orphan_acitivity_ids[] = $aids2activity[$orphan];
}
}
$orphan_acitivity_ids_string = implode(',', $orphan_acitivity_ids);
$sql = $wpdb->prepare("DELETE FROM {$activity_table} WHERE id IN ({$orphan_acitivity_ids_string})");
$deleted = $wpdb->query($sql);
BP_Activity_Activity::delete_activity_item_comments($orphan_acitivity_ids);
BP_Activity_Activity::delete_activity_meta_entries($orphan_acitivity_ids);
}
}
}
示例7: delete_pic_cover
function delete_pic_cover($activity_id)
{
global $bp;
$user_id = bp_loggedin_user_id();
$activity_id = $_POST['activity_id'];
$attachment_id = bp_activity_get_meta($activity_id, 'bp_cover_activity', true);
wp_delete_attachment($attachment_id, true);
delete_post_meta($attachment_id, true);
delete_user_meta($user_id, 'bp_cover');
delete_user_meta($user_id, 'bp_cover_position');
bp_activity_delete(array('id' => $activity_id, 'user_id' => $bp->loggedin_user->id));
BP_Activity_Activity::delete_activity_meta_entries($activity_id);
}
示例8: mpp_delete_activity_by_meta_key_value
function mpp_delete_activity_by_meta_key_value($key, $object_id = null)
{
global $bp, $wpdb;
if (!function_exists('bp_is_active') || !bp_is_active('activity')) {
return false;
//or false?
}
$where_sql = array();
$where_sql[] = $wpdb->prepare('meta_key=%s', $key);
if ($object_id) {
$where_sql[] = $wpdb->prepare('meta_value = %d', $object_id);
}
$where_sql = join(' AND ', $where_sql);
// Fetch the activity IDs so we can delete any comments for this activity item
$activity_ids = $wpdb->get_col("SELECT activity_id FROM {$bp->activity->table_name_meta} WHERE {$where_sql}");
if (empty($activity_ids)) {
return false;
}
$list = '(' . join(',', $activity_ids) . ')';
if (!$wpdb->query("DELETE FROM {$bp->activity->table_name} WHERE id IN {$list}")) {
return false;
}
// Handle accompanying activity comments and meta deletion
$activity_comment_ids = mpp_delete_activity_comments($activity_ids);
$activity_ids = array_merge($activity_ids, $activity_comment_ids);
BP_Activity_Activity::delete_activity_meta_entries($activity_ids);
return $activity_ids;
}
示例9: mpp_delete_activity_by_meta_key_value
function mpp_delete_activity_by_meta_key_value($key, $object_id = null)
{
global $bp, $wpdb;
if (!bp_is_active('activity')) {
return false;
//or false?
}
$where_sql = array();
$where_sql[] = $wpdb->prepare('meta_key=%s', $key);
if ($object_id) {
$where_sql[] = $wpdb->prepare('meta_value = %d', $object_id);
}
$where_sql = join(' AND ', $where_sql);
// Fetch the activity IDs so we can delete any comments for this activity item
$activity_ids = $wpdb->get_col("SELECT activity_id FROM {$bp->activity->table_name_meta} WHERE {$where_sql}");
if (empty($activity_ids)) {
return false;
}
$list = '(' . join(',', $activity_ids) . ')';
if (!$wpdb->query("DELETE FROM {$bp->activity->table_name} WHERE id IN {$list}")) {
return false;
}
// Handle accompanying activity comments and meta deletion
if ($activity_ids) {
$activity_ids_comma = implode(',', wp_parse_id_list($activity_ids));
$activity_comments_where_sql = "WHERE type = 'activity_comment' AND item_id IN ({$activity_ids_comma})";
// Fetch the activity comment IDs for our deleted activity items
$activity_comment_ids = $wpdb->get_col("SELECT id FROM {$bp->activity->table_name} {$activity_comments_where_sql}");
// We have activity comments!
if (!empty($activity_comment_ids)) {
// Delete activity comments
$wpdb->query("DELETE FROM {$bp->activity->table_name} {$activity_comments_where_sql}");
// Merge activity IDs with activity comment IDs
$activity_ids = array_merge($activity_ids, $activity_comment_ids);
}
// Delete all activity meta entries for activity items and activity comments
BP_Activity_Activity::delete_activity_meta_entries($activity_ids);
}
return $activity_ids;
}