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

Yoast\WP\SEO\Integrations\Watchers

Indexable_Post_Type_Archive_Watcher::check_option() public Yoast 1.0

Checks if the home page indexable needs to be rebuild based on option values.

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

Хуков нет.

Возвращает

true|false. Whether or not the option has been saved.

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

$Indexable_Post_Type_Archive_Watcher = new Indexable_Post_Type_Archive_Watcher();
$Indexable_Post_Type_Archive_Watcher->check_option( $old_value, $new_value );
$old_value(массив) (обязательный)
The old value of the option.
$new_value(массив) (обязательный)
The new value of the option.

Код Indexable_Post_Type_Archive_Watcher::check_option() Yoast 16.8

<?php
public function check_option( $old_value, $new_value ) {
	$relevant_keys = [ 'title-ptarchive-', 'metadesc-ptarchive-', 'bctitle-ptarchive-', 'noindex-ptarchive-' ];

	// If this is the first time saving the option, thus when value is false.
	if ( $old_value === false ) {
		$old_value = [];
	}

	if ( ! \is_array( $old_value ) || ! \is_array( $new_value ) ) {
		return false;
	}

	$keys               = \array_unique( \array_merge( \array_keys( $old_value ), \array_keys( $new_value ) ) );
	$post_types_rebuild = [];

	foreach ( $keys as $key ) {
		$post_type = false;
		// Check if it's a key relevant to post type archives.
		foreach ( $relevant_keys as $relevant_key ) {
			if ( \strpos( $key, $relevant_key ) === 0 ) {
				$post_type = \substr( $key, \strlen( $relevant_key ) );
				break;
			}
		}

		// If it's not a relevant key or both values aren't set they haven't changed.
		if ( $post_type === false || ( ! isset( $old_value[ $key ] ) && ! isset( $new_value[ $key ] ) ) ) {
			continue;
		}

		// If the value was set but now isn't, is set but wasn't or is not the same it has changed.
		if (
			! \in_array( $post_type, $post_types_rebuild, true )
			&& (
				! isset( $old_value[ $key ] )
				|| ! isset( $new_value[ $key ] )
				|| $old_value[ $key ] !== $new_value[ $key ]
			)
		) {
			$this->build_indexable( $post_type );
			$post_types_rebuild[] = $post_type;
		}
	}

	return true;
}