Yoast\WP\SEO\Abilities\Infrastructure

Abstract_SEO_Field_Map::apply_to_indexable │ public │ Yoast 1.0

Applies a validated input patch onto an indexable.

Only fields present in the input are touched (patch semantics); a present but empty/null value clears the field by setting its column to null. The mutated indexable is the desired state, which the caller cascades to the source of truth. Flags left out of the patch keep their current value, so advanced-robots flags merge for free.

Метод класса: Abstract_SEO_Field_Map{}

Хуков нет.

Возвращает

array<string>. The indexable columns the patch touched, so the caller can cascade only those.

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

$Abstract_SEO_Field_Map = new Abstract_SEO_Field_Map();
$Abstract_SEO_Field_Map->apply_to_indexable( $input, $indexable ): array;
$input(array<string, int|строка|true|false|null>) (обязательный)
The validated input patch.
$indexable(Indexable) (обязательный)
The indexable to mutate.

Код Abstract_SEO_Field_Map::apply_to_indexable() Yoast 28.9

public function apply_to_indexable( array $input, Indexable $indexable ): array {
	$changed_columns = [];

	foreach ( $this->get_string_fields() as $input_key => $column ) {
		if ( \array_key_exists( $input_key, $input ) ) {
			$value                = $input[ $input_key ];
			$indexable->{$column} = ( $value === null || $value === '' ) ? null : (string) $value;
			$changed_columns[]    = $column;
		}
	}

	foreach ( $this->get_boolean_fields() as $input_key => $column ) {
		if ( \array_key_exists( $input_key, $input ) ) {
			$indexable->{$column} = (bool) $input[ $input_key ];
			$changed_columns[]    = $column;
		}
	}

	if ( \array_key_exists( 'noindex', $input ) ) {
		// Tri-state: null resets to the default, true = noindex, false = index.
		$indexable->is_robots_noindex = ( $input['noindex'] === null ) ? null : (bool) $input['noindex'];
		$changed_columns[]            = 'is_robots_noindex';
	}

	return $changed_columns;
}