wp_delete_link

Definition:
function wp_delete_link( $link_id ) {}

Delete link specified from database

Parameters

  • int $link_id: ID of the link to delete

Return values

returns:True

Defined actions

  • delete_link
    do_action( 'delete_link', $link_id );
  • deleted_link
    do_action( 'deleted_link', $link_id );

Source code

function wp_delete_link( $link_id ) {

	global $wpdb;



	do_action( 'delete_link', $link_id );



	wp_delete_object_term_relationships( $link_id, 'link_category' );



	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->links WHERE link_id = %d", $link_id ) );



	do_action( 'deleted_link', $link_id );



	clean_bookmark_cache( $link_id );



	return true;

}

3589

wp_delete_comment

Definition:
function wp_delete_comment($comment_id, $force_delete = false) {}

Trashes or deletes a comment.
The comment is moved to trash instead of permanently deleted unless trash is disabled, item is already in the trash, or $force_delete is true.

Parameters

  • int $comment_id: Comment ID
  • bool $force_delete: Whether to bypass trash and force deletion. Default is false.

Return values

returns:False if delete comment query failure, true on success.

Defined actions

  • delete_comment
    do_action('delete_comment', $comment_id);
  • delete_commentmeta
    do_action( 'delete_commentmeta', $meta_ids );
  • deleted_commentmeta
    do_action( 'deleted_commentmeta', $meta_ids );
  • deleted_comment
    do_action('deleted_comment', $comment_id);
  • wp_set_comment_status
    do_action('wp_set_comment_status', $comment_id, 'delete');

Source code

function wp_delete_comment($comment_id, $force_delete = false) {

	global $wpdb;

	if (!$comment = get_comment($comment_id))

		return false;



	if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status($comment_id), array( 'trash', 'spam' ) ) )

		return wp_trash_comment($comment_id);



	do_action('delete_comment', $comment_id);



	// Move children up a level.

	$children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment_id) );

	if ( !empty($children) ) {

		$wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment_id));

		clean_comment_cache($children);

	}



	// Delete metadata

	$meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d ", $comment_id ) );

	if ( !empty($meta_ids) ) {

		do_action( 'delete_commentmeta', $meta_ids );

		$in_meta_ids = "'" . implode("', '", $meta_ids) . "'";

		$wpdb->query( "DELETE FROM $wpdb->commentmeta WHERE meta_id IN ($in_meta_ids)" );

		do_action( 'deleted_commentmeta', $meta_ids );

	}



	if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )

		return false;

	do_action('deleted_comment', $comment_id);



	$post_id = $comment->comment_post_ID;

	if ( $post_id && $comment->comment_approved == 1 )

		wp_update_comment_count($post_id);



	clean_comment_cache($comment_id);



	do_action('wp_set_comment_status', $comment_id, 'delete');

	wp_transition_comment_status('delete', $comment->comment_approved, $comment);

	return true;

}

3587

wp_delete_category

Definition:
function wp_delete_category($cat_ID) {}

Deletes one existing category.

Parameters

  • int $cat_ID

Return values

returns:Returns true if completes delete action; false if term doesnt exist; Zero on attempted deletion of default Category; WP_Error object is also a possibility.

Source code

function wp_delete_category($cat_ID) {

	$cat_ID = (int) $cat_ID;

	$default = get_option('default_category');



	// Don't delete the default cat

	if ( $cat_ID == $default )

		return 0;



	return wp_delete_term($cat_ID, 'category', array('default' => $default));

}

3585

wp_defer_term_counting

Definition:
function wp_defer_term_counting($defer=null) {}

Enable or disable term counting.

Parameters

  • bool $defer: Optional. Enable if true, disable if false.

Return values

returns:Whether term counting is enabled or disabled.

Source code

function wp_defer_term_counting($defer=null) {

	static $_defer = false;



	if ( is_bool($defer) ) {

		$_defer = $defer;

		// flush any deferred counts

		if ( !$defer )

			wp_update_term_count( null, null, true );

	}



	return $_defer;

}

3581