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


PHP BP_Activity_Activity::delete方法代码示例

本文整理汇总了PHP中BP_Activity_Activity::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Activity_Activity::delete方法的具体用法?PHP BP_Activity_Activity::delete怎么用?PHP BP_Activity_Activity::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BP_Activity_Activity的用法示例。


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

示例1: bp_activity_delete

/**
 * Delete activity item(s).
 *
 * If you're looking to hook into one action that provides the ID(s) of
 * the activity/activities deleted, then use:
 *
 * add_action( 'bp_activity_deleted_activities', 'my_function' );
 *
 * The action passes one parameter that is a single activity ID or an
 * array of activity IDs depending on the number deleted.
 *
 * If you are deleting an activity comment please use bp_activity_delete_comment();
 *
 * @since BuddyPress (1.0.0)
 *
 * @see BP_Activity_Activity::get() For more information on accepted arguments.
 * @uses wp_parse_args()
 * @uses bp_activity_adjust_mention_count()
 * @uses BP_Activity_Activity::delete() {@link BP_Activity_Activity}
 * @uses do_action() To call the 'bp_before_activity_delete' hook.
 * @uses bp_get_user_meta()
 * @uses bp_delete_user_meta()
 * @uses do_action() To call the 'bp_activity_delete' hook.
 * @uses do_action() To call the 'bp_activity_deleted_activities' hook.
 * @uses wp_cache_delete()
 *
 * @param array $args To delete specific activity items, use
 *            $args = array( 'id' => $ids );
 *        Otherwise, to use filters for item deletion, the argument format is
 *        the same as BP_Activity_Activity::get(). See that method for a description.
 * @return bool True on success, false on failure.
 */
function bp_activity_delete($args = '')
{
    // Pass one or more the of following variables to delete by those variables
    $args = bp_parse_args($args, 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));
    do_action('bp_before_activity_delete', $args);
    // Adjust the new mention count of any mentioned member
    bp_activity_adjust_mention_count($args['id'], 'delete');
    $activity_ids_deleted = BP_Activity_Activity::delete($args);
    if (empty($activity_ids_deleted)) {
        return false;
    }
    // Check if the user's latest update has been deleted
    $user_id = empty($args['user_id']) ? bp_loggedin_user_id() : $args['user_id'];
    $latest_update = bp_get_user_meta($user_id, 'bp_latest_update', true);
    if (!empty($latest_update)) {
        if (in_array((int) $latest_update['id'], (array) $activity_ids_deleted)) {
            bp_delete_user_meta($user_id, 'bp_latest_update');
        }
    }
    do_action('bp_activity_delete', $args);
    do_action('bp_activity_deleted_activities', $activity_ids_deleted);
    wp_cache_delete('bp_activity_sitewide_front', 'bp');
    return true;
}
开发者ID:eresyyl,项目名称:mk,代码行数:56,代码来源:bp-activity-functions.php

示例2: test_delete_with_secondary_item_id

 /**
  * @group delete
  */
 public function test_delete_with_secondary_item_id()
 {
     $a1 = $this->factory->activity->create(array('secondary_item_id' => 523));
     $a2 = $this->factory->activity->create(array('secondary_item_id' => 1888));
     $activity = BP_Activity_Activity::delete(array('secondary_item_id' => 523));
     $this->assertEquals(array($a1), $activity);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:10,代码来源:class.BP_Activity_Activity.php

示例3: delete

 /**
  * Delete activity items from the database.
  *
  * To delete a specific activity item, pass an 'id' parameter.
  * Otherwise use the filters.
  *
  * @since 1.2.0
  *
  * @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 = buddypress();
     $r = wp_parse_args($args, 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));
     // Setup empty array from where query arguments.
     $where_args = array();
     // 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.
      *
//.........这里部分代码省略.........
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:101,代码来源:class-bp-activity-activity.php

示例4: bp_activity_delete

/**
 * Delete activity item(s).
 *
 * If you're looking to hook into one action that provides the ID(s) of
 * the activity/activities deleted, then use:
 *
 * add_action( 'bp_activity_deleted_activities', 'my_function' );
 *
 * The action passes one parameter that is a single activity ID or an
 * array of activity IDs depending on the number deleted.
 *
 * If you are deleting an activity comment please use bp_activity_delete_comment();
 *
 * @since 1.0.0
 *
 * @see BP_Activity_Activity::get() For more information on accepted arguments.
 * @uses wp_parse_args()
 * @uses bp_activity_adjust_mention_count()
 * @uses BP_Activity_Activity::delete() {@link BP_Activity_Activity}
 * @uses do_action() To call the 'bp_before_activity_delete' hook.
 * @uses bp_get_user_meta()
 * @uses bp_delete_user_meta()
 * @uses do_action() To call the 'bp_activity_delete' hook.
 * @uses do_action() To call the 'bp_activity_deleted_activities' hook.
 * @uses wp_cache_delete()
 *
 * @param array|string $args To delete specific activity items, use
 *                           $args = array( 'id' => $ids ); Otherwise, to use
 *                           filters for item deletion, the argument format is
 *                           the same as BP_Activity_Activity::get().
 *                           See that method for a description.
 * @return bool True on success, false on failure.
 */
function bp_activity_delete($args = '')
{
    // Pass one or more the of following variables to delete by those variables.
    $args = bp_parse_args($args, 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));
    /**
     * Fires before an activity item proceeds to be deleted.
     *
     * @since 1.5.0
     *
     * @param array $args Array of arguments to be used with the activity deletion.
     */
    do_action('bp_before_activity_delete', $args);
    // Adjust the new mention count of any mentioned member.
    bp_activity_adjust_mention_count($args['id'], 'delete');
    $activity_ids_deleted = BP_Activity_Activity::delete($args);
    if (empty($activity_ids_deleted)) {
        return false;
    }
    // Check if the user's latest update has been deleted.
    $user_id = empty($args['user_id']) ? bp_loggedin_user_id() : $args['user_id'];
    $latest_update = bp_get_user_meta($user_id, 'bp_latest_update', true);
    if (!empty($latest_update)) {
        if (in_array((int) $latest_update['id'], (array) $activity_ids_deleted)) {
            bp_delete_user_meta($user_id, 'bp_latest_update');
        }
    }
    /**
     * Fires after the activity item has been deleted.
     *
     * @since 1.0.0
     *
     * @param array $args Array of arguments used with the activity deletion.
     */
    do_action('bp_activity_delete', $args);
    /**
     * Fires after the activity item has been deleted.
     *
     * @since 1.2.0
     *
     * @param array $activity_ids_deleted Array of affected activity item IDs.
     */
    do_action('bp_activity_deleted_activities', $activity_ids_deleted);
    wp_cache_delete('bp_activity_sitewide_front', 'bp');
    return true;
}
开发者ID:humanmade,项目名称:BuddyPress,代码行数:78,代码来源:bp-activity-functions.php

示例5: bp_activity_delete

function bp_activity_delete( $args = '' ) {
	global $bp;

	/* Pass one or more the of following variables to delete by those variables */
	$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
	);

	$args = wp_parse_args( $args, $defaults );

	if ( !$activity_ids_deleted = BP_Activity_Activity::delete( $args ) )
		return false;

	/* Check if the user's latest update has been deleted */
	if ( empty( $args['user_id'] ) )
		$user_id = $bp->loggedin_user->id;
	else
		$user_id = $args['user_id'];

	$latest_update = get_user_meta( $user_id, 'bp_latest_update', true );
	if ( !empty( $latest_update ) ) {
		if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) )
			delete_user_meta( $user_id, 'bp_latest_update' );
	}

	do_action( 'bp_activity_delete', $args );
	do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );

	wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );

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

示例6: bp_activity_delete

function bp_activity_delete($item_id, $component_name, $component_action, $user_id, $secondary_item_id)
{
    if (!BP_Activity_Activity::delete($item_id, $component_name, $component_action, $user_id, $secondary_item_id)) {
        return false;
    }
    do_action('bp_activity_delete', $item_id, $component_name, $component_action, $user_id, $secondary_item_id);
    return true;
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:8,代码来源:bp-activity.php


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