Yoast\WP\SEO\Actions\Importing\Aioseo

Aioseo_Posts_Importing_Action::map()publicYoast 1.0

Maps AIOSEO meta data to Yoast meta data.

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

Хуков нет.

Возвращает

Indexable. The created indexables.

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

$Aioseo_Posts_Importing_Action = new Aioseo_Posts_Importing_Action();
$Aioseo_Posts_Importing_Action->map( $indexable, $aioseo_indexable );
$indexable(Indexable) (обязательный)
The Yoast indexable.
$aioseo_indexable(массив) (обязательный)
The AIOSEO indexable.

Код Aioseo_Posts_Importing_Action::map() Yoast 22.4

public function map( $indexable, $aioseo_indexable ) {
	foreach ( $this->aioseo_to_yoast_map as $aioseo_key => $yoast_mapping ) {
		// For robots import.
		if ( isset( $yoast_mapping['robots_import'] ) && $yoast_mapping['robots_import'] ) {
			$yoast_mapping['subtype']                  = $indexable->object_sub_type;
			$indexable->{$yoast_mapping['yoast_name']} = $this->transform_import_data( $yoast_mapping['transform_method'], $aioseo_indexable, $aioseo_key, $yoast_mapping, $indexable );

			continue;
		}

		// For social images, like open graph and twitter image.
		if ( isset( $yoast_mapping['social_image_import'] ) && $yoast_mapping['social_image_import'] ) {
			$image_url = $this->transform_import_data( $yoast_mapping['transform_method'], $aioseo_indexable, $aioseo_key, $yoast_mapping, $indexable );

			// Update the indexable's social image only where there's actually a url to import, so as not to lose the social images that we came up with when we originally built the indexable.
			if ( ! empty( $image_url ) ) {
				$indexable->{$yoast_mapping['yoast_name']} = $image_url;

				$image_source_key             = $yoast_mapping['social_setting_prefix_yoast'] . 'image_source';
				$indexable->$image_source_key = 'imported';

				$image_id_key             = $yoast_mapping['social_setting_prefix_yoast'] . 'image_id';
				$indexable->$image_id_key = $this->image->get_attachment_by_url( $image_url );

				if ( $yoast_mapping['yoast_name'] === 'open_graph_image' ) {
					$indexable->open_graph_image_meta = null;
				}
			}
			continue;
		}

		// For twitter import, take the respective open graph data if the appropriate setting is enabled.
		if ( isset( $yoast_mapping['twitter_import'] ) && $yoast_mapping['twitter_import'] && $aioseo_indexable['twitter_use_og'] ) {
			$aioseo_indexable['twitter_title']       = $aioseo_indexable['og_title'];
			$aioseo_indexable['twitter_description'] = $aioseo_indexable['og_description'];
		}

		if ( ! empty( $aioseo_indexable[ $aioseo_key ] ) ) {
			$indexable->{$yoast_mapping['yoast_name']} = $this->transform_import_data( $yoast_mapping['transform_method'], $aioseo_indexable, $aioseo_key, $yoast_mapping, $indexable );
		}
	}

	return $indexable;
}