WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта с помощью браузерных PUSH уведомлений
функция не описана

WPSEO_Taxonomy_Meta::validate_term_meta_data() public Yoast 1.0

Validate the meta data for one individual term and removes default values (no need to save those).

{} Это метод класса: WPSEO_Taxonomy_Meta{}

Хуки из метода
Возвращает

Массив. Validated and filtered value.

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

$result = WPSEO_Taxonomy_Meta::validate_term_meta_data( $meta_data, $old_meta );
$meta_data(массив) (обязательный)
New values.
$old_meta(массив) (обязательный)
The original values.

Код WPSEO_Taxonomy_Meta::validate_term_meta_data() Yoast 16.2

<?php
public static function validate_term_meta_data( $meta_data, $old_meta ) {

	$clean     = self::$defaults_per_term;
	$meta_data = array_map( [ 'WPSEO_Utils', 'trim_recursive' ], $meta_data );

	if ( ! is_array( $meta_data ) || $meta_data === [] ) {
		return $clean;
	}

	foreach ( $clean as $key => $value ) {
		switch ( $key ) {

			case 'wpseo_noindex':
				if ( isset( $meta_data[ $key ] ) ) {
					if ( isset( self::$no_index_options[ $meta_data[ $key ] ] ) ) {
						$clean[ $key ] = $meta_data[ $key ];
					}
				}
				elseif ( isset( $old_meta[ $key ] ) ) {
					// Retain old value if field currently not in use.
					$clean[ $key ] = $old_meta[ $key ];
				}
				break;

			case 'wpseo_canonical':
				if ( isset( $meta_data[ $key ] ) && $meta_data[ $key ] !== '' ) {
					$url = WPSEO_Utils::sanitize_url( $meta_data[ $key ] );
					if ( $url !== '' ) {
						$clean[ $key ] = $url;
					}
					unset( $url );
				}
				break;

			case 'wpseo_bctitle':
				if ( isset( $meta_data[ $key ] ) ) {
					$clean[ $key ] = WPSEO_Utils::sanitize_text_field( $meta_data[ $key ] );
				}
				elseif ( isset( $old_meta[ $key ] ) ) {
					// Retain old value if field currently not in use.
					$clean[ $key ] = $old_meta[ $key ];
				}
				break;

			case 'wpseo_keywordsynonyms':
				if ( isset( $meta_data[ $key ] ) && is_string( $meta_data[ $key ] ) ) {
					// The data is stringified JSON. Use `json_decode` and `json_encode` around the sanitation.
					$input         = json_decode( $meta_data[ $key ], true );
					$sanitized     = array_map( [ 'WPSEO_Utils', 'sanitize_text_field' ], $input );
					$clean[ $key ] = WPSEO_Utils::format_json_encode( $sanitized );
				}
				elseif ( isset( $old_meta[ $key ] ) ) {
					// Retain old value if field currently not in use.
					$clean[ $key ] = $old_meta[ $key ];
				}
				break;

			case 'wpseo_focuskeywords':
				if ( isset( $meta_data[ $key ] ) && is_string( $meta_data[ $key ] ) ) {
					// The data is stringified JSON. Use `json_decode` and `json_encode` around the sanitation.
					$input = json_decode( $meta_data[ $key ], true );

					// This data has two known keys: `keyword` and `score`.
					$sanitized = [];
					foreach ( $input as $entry ) {
						$sanitized[] = [
							'keyword' => WPSEO_Utils::sanitize_text_field( $entry['keyword'] ),
							'score'   => WPSEO_Utils::sanitize_text_field( $entry['score'] ),
						];
					}

					$clean[ $key ] = WPSEO_Utils::format_json_encode( $sanitized );
				}
				elseif ( isset( $old_meta[ $key ] ) ) {
					// Retain old value if field currently not in use.
					$clean[ $key ] = $old_meta[ $key ];
				}
				break;

			case 'wpseo_focuskw':
			case 'wpseo_title':
			case 'wpseo_desc':
			case 'wpseo_linkdex':
			default:
				if ( isset( $meta_data[ $key ] ) && is_string( $meta_data[ $key ] ) ) {
					$clean[ $key ] = WPSEO_Utils::sanitize_text_field( $meta_data[ $key ] );
				}

				if ( $key === 'wpseo_focuskw' ) {
					$search = [
						'&lt;',
						'&gt;',
						'&#96',
						'<',
						'>',
						'`',
					];

					$clean[ $key ] = str_replace( $search, '', $clean[ $key ] );
				}
				break;
		}

		$clean[ $key ] = apply_filters( 'wpseo_sanitize_tax_meta_' . $key, $clean[ $key ], ( isset( $meta_data[ $key ] ) ? $meta_data[ $key ] : null ), ( isset( $old_meta[ $key ] ) ? $old_meta[ $key ] : null ) );
	}

	// Only save the non-default values.
	return array_diff_assoc( $clean, self::$defaults_per_term );
}