delete_(meta_type)_metadata_by_mid хук-фильтрWP 5.0.0

Short-circuits deleting metadata of a specific type by meta ID.

The dynamic portion of the hook name, $meta_type, refers to the meta object type (post, comment, term, user, or any other type with an associated meta table). Returning a non-null value will effectively short-circuit the function.

Possible hook names include:

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

add_filter( 'delete_(meta_type)_metadata_by_mid', 'wp_kama_delete_meta_type_metadata_by_mid_filter', 10, 2 );

/**
 * Function for `delete_(meta_type)_metadata_by_mid` filter-hook.
 * 
 * @param null|bool $delete  Whether to allow metadata deletion of the given type.
 * @param int       $meta_id Meta ID.
 *
 * @return null|bool
 */
function wp_kama_delete_meta_type_metadata_by_mid_filter( $delete, $meta_id ){

	// filter...
	return $delete;
}
$delete(null|true|false)
Whether to allow metadata deletion of the given type.
$meta_id(int)
Meta ID.

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

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

Где вызывается хук

delete_metadata_by_mid()
delete_(meta_type)_metadata_by_mid
wp-includes/meta.php 1020
$check = apply_filters( "delete_{$meta_type}_metadata_by_mid", null, $meta_id );

Где используется хук в WordPress

wp-includes/default-filters.php 128
add_filter( 'delete_term_metadata_by_mid', 'wp_check_term_meta_support_prefilter' );
wp-includes/ms-default-filters.php 67
add_filter( 'delete_blog_metadata_by_mid', 'wp_check_site_meta_support_prefilter' );