'defer', 'in_footer' => true] ); add_filter('script_loader_tag', 'adwings_chat_filter_script_tag', 10, 2); } function adwings_chat_filter_script_tag($tag, $handle) { if ($handle !== 'adwings-chat-platform-widget') { return $tag; } $site_key = get_option('adwings_chat_site_key'); $server_url = get_option('adwings_chat_server_url'); if (empty($server_url)) { $server_url = ADWINGS_CHAT_DEFAULT_SERVER_URL; } $color = get_option('adwings_chat_widget_color', '#4F46E5'); $position = get_option('adwings_chat_widget_position', 'bottom-right'); $auto_open = get_option('adwings_chat_widget_auto_open', '0') === '1'; return str_replace( ' src=', sprintf( ' data-key="%s" data-server="%s" data-color="%s" data-position="%s"%s src=', esc_attr($site_key), esc_url($server_url), esc_attr($color), esc_attr($position), $auto_open ? ' data-auto-open="true"' : '' ), $tag ); } add_action('wp_enqueue_scripts', 'adwings_chat_enqueue_widget');