ACF_Internal_Post_Type::delete_postpublicACF 6.1

Deletes an ACF post.

Метод класса: ACF_Internal_Post_Type{}

Хуки из метода

Возвращает

true|false.

Использование

$ACF_Internal_Post_Type = new ACF_Internal_Post_Type();
$ACF_Internal_Post_Type->delete_post( $id );
$id(int|строка)
The ID of the ACF post to delete.

Список изменений

С версии 6.1 Введена.

Код ACF_Internal_Post_Type::delete_post() ACF 6.4.2

public function delete_post( $id = 0 ) {
	// Disable filters to ensure ACF loads data from DB.
	acf_disable_filters();

	// Get the post.
	$post = $this->get_post( $id );

	// Bail early if post was not found.
	if ( ! $post || ! $post['ID'] ) {
		return false;
	}

	// Delete post and flush cache.
	wp_delete_post( $post['ID'], true );
	$this->flush_post_cache( $post );

	/**
	 * Fires immediately after an ACF post has been deleted.
	 *
	 * @date 12/02/2014
	 * @since 5.0.0
	 *
	 * @param array $post The ACF post array.
	 */
	do_action( "acf/delete_{$this->hook_name}", $post );

	return true;
}