Yoast\WP\SEO\Helpers

Indexable_To_Postmeta_Helper::noindex_map()publicYoast 1.0

Deletes the noindex post_meta key if no noindex in the indexable. Populates the post_meta key appropriately if there is noindex in the indexable.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$Indexable_To_Postmeta_Helper = new Indexable_To_Postmeta_Helper();
$Indexable_To_Postmeta_Helper->noindex_map( $indexable, $post_meta_key );
$indexable(Indexable) (обязательный)
The Yoast indexable.
$post_meta_key(строка) (обязательный)
The post_meta key that will be populated.

Код Indexable_To_Postmeta_Helper::noindex_map() Yoast 22.4

public function noindex_map( $indexable, $post_meta_key ) {
	if ( \is_null( $indexable->is_robots_noindex ) ) {
		$this->meta->delete( $post_meta_key, $indexable->object_id );
		return;
	}

	if ( $indexable->is_robots_noindex === false ) {
		$this->meta->set_value( $post_meta_key, 2, $indexable->object_id );
	}

	if ( $indexable->is_robots_noindex === true ) {
		$this->meta->set_value( $post_meta_key, 1, $indexable->object_id );
	}
}