Automattic\WooCommerce\Blocks\Domain\Services

GoogleAnalytics::async_script_loader_tags()publicWC 1.0

Add async to script tags with defined handles.

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

Хуков нет.

Возвращает

Строку.

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

$GoogleAnalytics = new GoogleAnalytics();
$GoogleAnalytics->async_script_loader_tags( $tag, $handle, $src );
$tag(строка) (обязательный)
HTML for the script tag.
$handle(строка) (обязательный)
Handle of script.
$src(строка) (обязательный)
Src of script.

Код GoogleAnalytics::async_script_loader_tags() WC 8.7.0

public function async_script_loader_tags( $tag, $handle, $src ) {
	if ( ! in_array( $handle, array( 'google-tag-manager' ), true ) ) {
		return $tag;
	}
	// If script was output manually in wp_head, abort.
	if ( did_action( 'woocommerce_gtag_snippet' ) ) {
		return '';
	}
	return str_replace( '<script src', '<script async src', $tag );
}