# taxonomy_meta_box_sanitize_cb_input()

URL: https://chugunov.pro/api-wordpress/functions/taxonomy_meta_box_sanitize_cb_input/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 5.1.0.

## Сигнатура

```php
taxonomy_meta_box_sanitize_cb_input( string $taxonomy, array|string $terms ): array
```

## Описание

Очищает значения POST из метабокса таксономии с текстовым вводом.

## Параметры

- `$taxonomy` `string` — обязательный. Имя таксономии.
- `$terms` `array|string` — обязательный. Необработанные данные термина из поля 'tax_input'.

## Возвращаемое значение

`array`

## Исходный код

Файл: `wp-admin/includes/post.php:2258`

```php
function taxonomy_meta_box_sanitize_cb_input( $taxonomy, $terms ) {
	/*
	 * Assume that a 'tax_input' string is a comma-separated list of term names.
	 * Some languages may use a character other than a comma as a delimiter, so we standardize on
	 * commas before parsing the list.
	 */
	if ( ! is_array( $terms ) ) {
		$comma = _x( ',', 'tag delimiter' );
		if ( ',' !== $comma ) {
			$terms = str_replace( $comma, ',', $terms );
		}
		$terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
	}

	$clean_terms = array();
	foreach ( $terms as $term ) {
		// Empty terms are invalid input.
		if ( empty( $term ) ) {
			continue;
		}

		$_term = get_terms(
			array(
				'taxonomy'   => $taxonomy,
				'name'       => $term,
				'fields'     => 'ids',
				'hide_empty' => false,
			)
		);

		if ( ! empty( $_term ) ) {
			$clean_terms[] = (int) $_term[0];
		} else {
			// No existing term was found, so pass the string. A new term will be created.
			$clean_terms[] = $term;
		}
	}

	return $clean_terms;
}
```

## История изменений

- 5.1.0 — Introduced.

## Связанные

Использует: [`get_terms`](https://chugunov.pro/api-wordpress/functions/get_terms/), [`_x`](https://chugunov.pro/api-wordpress/functions/_x/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/taxonomy_meta_box_sanitize_cb_input/
