get_ga_3_code();
$ga_4_code = $this->get_ga_4_code();
if (! empty($ga_3_code)) {
$data[] = $ga_3_code;
}
if (! empty($ga_4_code)) {
$data[] = $ga_4_code;
}
return $data;
});
if (is_admin()) return;
add_action('wp_print_scripts', function () {
if (is_admin()) return;
if (class_exists('BlocksyExtensionCookiesConsent')) {
if (! \BlocksyExtensionCookiesConsent::has_consent()) {
return;
}
}
echo $this->get_ga_3_code();
echo $this->get_ga_4_code();
});
}
private function get_ga_4_code() {
$analytics_v4_id = blocksy_get_theme_mod('analytics_v4_id', '');
if (empty($analytics_v4_id)) {
return '';
}
ob_start(); ?>
[
'label' => __( 'Google Analytics v4', 'blocksy-companion' ),
'type' => 'text',
'design' => 'block',
'value' => '',
'desc' => blc_safe_sprintf(
__(
'Link your Google Analytics 4 tracking ID. More info and instructions can be found %shere%s.',
'blocksy-companion'
),
'',
''
),
'disableRevertButton' => true,
'setting' => [ 'transport' => 'postMessage' ],
]
];
return $options;
}
}