Yoast\WP\SEO\Services\Importing\Aioseo

Aioseo_Robots_Transformer_Service::transform_robot_setting()publicYoast 1.0

Transforms the robot setting, taking into consideration whether they defer to global defaults.

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

Хуков нет.

Возвращает

true|false. The transformed robot setting.

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

$Aioseo_Robots_Transformer_Service = new Aioseo_Robots_Transformer_Service();
$Aioseo_Robots_Transformer_Service->transform_robot_setting( $setting_name, $setting_value, $mapping );
$setting_name(строка) (обязательный)
The name of the robot setting, eg. noindex.
$setting_value(true|false) (обязательный)
The value of the robot setting.
$mapping(массив) (обязательный)
The mapping of the setting we're working with.

Код Aioseo_Robots_Transformer_Service::transform_robot_setting() Yoast 19.2

public function transform_robot_setting( $setting_name, $setting_value, $mapping ) {
	$aioseo_settings = \json_decode( \get_option( $mapping['option_name'], '' ), true );

	// Let's check first if it defers to global robot settings.
	if ( empty( $aioseo_settings ) || ! isset( $aioseo_settings['searchAppearance'][ $mapping['type'] ][ $mapping['subtype'] ]['advanced']['robotsMeta']['default'] ) ) {
		return $setting_value;
	}

	$defers_to_defaults = $aioseo_settings['searchAppearance'][ $mapping['type'] ][ $mapping['subtype'] ]['advanced']['robotsMeta']['default'];

	if ( $defers_to_defaults ) {
		return $this->robots_provider->get_global_robot_settings( $setting_name );
	}

	return $setting_value;
}