acf_delete_field()ACF 5.7.10

acf_delete_field

Deletes a field from the database.

Хуки из функции

Возвращает

true|false. True if field was deleted.

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

acf_delete_field( $id );
$id((int|string))
The field ID, key or name.

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

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

Код acf_delete_field() ACF 6.0.4

function acf_delete_field( $id = 0 ) {

	// Get the field.
	$field = acf_get_field( $id );

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

	// Delete post.
	wp_delete_post( $field['ID'], true );

	// Flush field cache.
	acf_flush_field_cache( $field );

	/**
	 * Fires immediately after a field has been deleted.
	 *
	 * @date    12/02/2014
	 * @since   5.0.0
	 *
	 * @param   array $field The field array.
	 */
	do_action( 'acf/delete_field', $field );

	// Return true.
	return true;
}