Я добавляю следующий скрипт (виджет чата zendesk) в заголовок. php - на сайте wordpress domain.com, двумя способами ни один из них не работает. Виджет чата отображается только на всех страницах, если мы вошли в WordPress, в противном случае он будет отображаться на некоторых внутренних страницах, например: domain.com/some-inner-pages
Первый добавленный скрипт выглядит так
<script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=<key>">
</script>
Затем проверил domain.com, и он не работал, но если я go domain.com/some-inner-pages, он будет работать, также он будет работать, если я войду как администратор.
Вторая попытка была
<script>
function loadZendeskWidget() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.id = 'ze-snippet';
script.async = true;
script.src = 'https://static.zdassets.com/ekr/snippet.js?key=<key>';
document.getElementsByTagName('head')[0].appendChild(script);
};
</script>
<script type="text/javascript">
loadZendeskWidget();
console.log("test");
</script>
То же поведение, что и при первой попытке.
В любом случае я могу отладить это или исправить это? Спасибо за любую помощь
заголовок. php файл
<!doctype html>
<html <?php language_attributes(); ?> class="no-js">
<head>
<!-- Meta Tags -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php
$options = get_nectar_theme_options();
if ( ! empty( $options['responsive'] ) && $options['responsive'] == 1 ) { ?>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
<?php } else { ?>
<meta name="viewport" content="width=1200" />
<?php } ?>
<!--Shortcut icon-->
<?php if ( ! empty( $options['favicon'] ) && ! empty( $options['favicon']['url'] ) ) { ?>
<link rel="shortcut icon" href="<?php echo esc_url( nectar_options_img( $options['favicon'] ) ); ?>" />
<?php }
wp_head();
if ( ! empty( $options['google-analytics'] ) ) {
echo $options['google-analytics'];}
?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-154156568-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-154156568-1');
</script>
<!-- Start of Zendesk Widget script -->
<script>
function loadZendeskWidget() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.id = 'ze-snippet';
script.async = true;
script.src = 'https://static.zdassets.com/ekr/snippet.js?key=XX';
document.getElementsByTagName('head')[0].appendChild(script);
};
</script>
<script type="text/javascript">
loadZendeskWidget();
console.log("test");
</script>
<!--<script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=XX">
</script> -->
<!-- End of Zendesk Widget script -->
</head>
<?php
global $post;
global $woocommerce;
$nectar_header_options = nectar_get_header_variables();
?>
<body <?php body_class(); nectar_body_attributes(); ?>>
<?php
nectar_hook_after_body_open();
if ( $nectar_header_options['theme_skin'] == 'material' ) {
echo '<div class="ocm-effect-wrap"><div class="ocm-effect-wrap-inner">';
}
if ( $nectar_header_options['n_boxed_style'] ) {
echo '<div id="boxed">';
}
nectar_page_trans_markup();
get_template_part( 'includes/partials/header/secondary-navigation' );
get_template_part( 'includes/partials/header/header-space' );
?>
<div id="header-outer" <?php nectar_header_nav_attributes(); ?>>
<?php
if ( empty( $options['theme-skin'] ) || ( ! empty( $options['theme-skin'] ) && $nectar_header_options['theme_skin'] != 'ascend' && $nectar_header_options['header_format'] != 'left-header' ) ) {
get_template_part( 'includes/header-search' );
}
get_template_part( 'includes/partials/header/header-menu' );
if ( ! empty( $options['enable-cart'] ) && $options['enable-cart'] == '1' && $nectar_header_options['theme_skin'] != 'material' ) {
if ( $woocommerce ) {
echo nectar_header_cart_output();
}
}
?>
</div><!--/header-outer-->
<?php
if ( ! empty( $options['enable-cart'] ) && $options['enable-cart'] == '1' ) {
get_template_part( 'includes/partials/header/woo-slide-in-cart' );
}
if ( $nectar_header_options['theme_skin'] == 'ascend' || $nectar_header_options['header_format'] == 'left-header' ) {
if ( $nectar_header_options['header_search'] != 'false' ) {
get_template_part( 'includes/header-search' ); }
}
if ( $nectar_header_options['mobile_fixed'] != '1' ) {
get_template_part( 'includes/partials/header/classic-mobile-nav' );
}
?>
<div id="ajax-content-wrap">
<?php
if ( $nectar_header_options['side_widget_area'] == '1' && $nectar_header_options['side_widget_class'] == 'fullscreen' ) {
echo '<div class="blurred-wrap">';
}
Вот скриншоты заголовка

