Yoast\WP\SEO\Services\Importing\Aioseo

Aioseo_Replacevar_Service::transform()publicYoast 1.0

Transforms AIOSEO replacevars into Yoast replacevars.

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

Хуков нет.

Возвращает

Строку. The Yoast replacevar.

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

$Aioseo_Replacevar_Service = new Aioseo_Replacevar_Service();
$Aioseo_Replacevar_Service->transform( $aioseo_replacevar );
$aioseo_replacevar(строка) (обязательный)
The AIOSEO replacevar.

Код Aioseo_Replacevar_Service::transform() Yoast 19.2

public function transform( $aioseo_replacevar ) {
	$yoast_replacevar = \str_replace( \array_keys( $this->replace_vars_map ), \array_values( $this->replace_vars_map ), $aioseo_replacevar );

	// Transform the '#custom_field-<custom_field>' tags into '%%cf_<custom_field>%%' ones.
	$yoast_replacevar = \preg_replace_callback(
		'/#custom_field-([a-zA-Z0-9_-]+)/',
		static function ( $cf_matches ) {
			return '%%cf_' . $cf_matches[1] . '%%';
		},
		$yoast_replacevar
	);

	// Transform the '#tax_name-<custom-tax-name>' tags into '%%ct_<custom-tax-name>%%' ones.
	$yoast_replacevar = \preg_replace_callback(
		'/#tax_name-([a-zA-Z0-9_-]+)/',
		static function ( $ct_matches ) {
			return '%%ct_' . $ct_matches[1] . '%%';
		},
		$yoast_replacevar
	);

	return $yoast_replacevar;
}