acf_delete_metadata()ACF 5.2.3

acf_delete_metadata

Deletes metadata from the database.

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

Возвращает

true|false.

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

acf_delete_metadata( $post_id, $name, $hidden );
$post_id((int|string))
The post id.
$name(строка)
The meta name.
По умолчанию: ''
$hidden(true|false)
If the meta is hidden (starts with an underscore).
По умолчанию: false

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

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

Код acf_delete_metadata() ACF 5.10.2

function acf_delete_metadata( $post_id = 0, $name = '', $hidden = false ) {

	// Allow filter to short-circuit logic.
	$pre = apply_filters( 'acf/pre_delete_metadata', null, $post_id, $name, $hidden );
	if ( $pre !== null ) {
		return $pre;
	}

	// Decode $post_id for $type and $id.
	extract( acf_decode_post_id( $post_id ) );

	// Hidden meta uses an underscore prefix.
	$prefix = $hidden ? '_' : '';

	// Bail early if no $id (possible during new acf_form).
	if ( ! $id ) {
		return false;
	}

	// Determine CRUD function.
	// - Relies on decoded post_id result to identify option or meta types.
	// - Uses xxx_metadata(type) instead of xxx_type_meta() to bypass additional logic that could alter the ID.
	if ( $type === 'option' ) {
		return delete_option( "{$prefix}{$id}_{$name}" );
	} else {
		return delete_metadata( $type, $id, "{$prefix}{$name}" );
	}
}