Yoast\WP\SEO\Helpers

Indexable_To_Postmeta_Helper::social_image_map()publicYoast 1.0

Map social image data only if social image is explicitly set.

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

Хуков нет.

Возвращает

null. Ничего.

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

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

Код Indexable_To_Postmeta_Helper::social_image_map() Yoast 19.2

public function social_image_map( $indexable, $post_meta_key, $indexable_column ) {
	if ( empty( $indexable->{$indexable_column} ) ) {
		return;
	}

	switch ( $indexable_column ) {
		case 'open_graph_image':
		case 'open_graph_image_id':
			$source = $indexable->open_graph_image_source;
			break;
		case 'twitter_image':
		case 'twitter_image_id':
			$source = $indexable->twitter_image_source;
			break;
	}

	// Map the social image data only when the social image is explicitly set.
	if ( $source === 'set-by-user' || $source === 'imported' ) {
		$value = (string) $indexable->{$indexable_column};

		$this->meta->set_value( $post_meta_key, $value, $indexable->object_id );
	}
}