'hp_vendor', 'author' => $user_id, 'posts_per_page' => 1, 'post_status' => 'publish', ) ); if ( ! empty( $vendor_posts ) ) { $vid = $vendor_posts[0]->ID; $tid = get_post_thumbnail_id( $vid ); if ( $tid ) { return wp_get_attachment_image_url( $tid, 'thumbnail' ); } $iid = get_post_meta( $vid, 'hp_image', true ); if ( $iid ) { return wp_get_attachment_image_url( $iid, 'thumbnail' ); } } $avatar = get_avatar_data( $user_id, array( 'size' => 96 ) ); return $avatar['url'] ?? ''; } /** * Textes de l'interface du widget dans une langue. * * @param string $lang Code langue. * @return array */ function askbot_widget_texts( $lang ) { $texts = array( 'fr' => array( 'placeholder' => 'Écrivez votre message…', 'send' => 'Envoyer', 'online' => 'En ligne', 'open' => 'Ouvrir le chat', 'close' => 'Fermer', 'credit' => 'Propulsé par', ), 'ar' => array( 'placeholder' => 'اكتب رسالتك...', 'send' => 'إرسال', 'online' => 'متصل', 'open' => 'افتح الدردشة', 'close' => 'إغلاق', 'credit' => 'مدعوم بواسطة', ), 'en' => array( 'placeholder' => 'Type your message…', 'send' => 'Send', 'online' => 'Online', 'open' => 'Open chat', 'close' => 'Close', 'credit' => 'Powered by', ), ); return $texts[ $lang ] ?? $texts['fr']; } add_action( 'wp_enqueue_scripts', 'askbot_enqueue_assets' ); function askbot_enqueue_assets() { if ( askbot_is_hidden_on_current_page() ) { return; } wp_enqueue_style( 'askbot-css', ASKBOT_URL . 'assets/chat.css', array(), ASKBOT_VERSION ); wp_enqueue_script( 'askbot-js', ASKBOT_URL . 'assets/chat.js', array(), ASKBOT_VERSION, true ); $colors = askbot_get_colors(); $page_lang = askbot_get_language(); $bottom_offset = (int) get_option( 'askbot_bottom_offset', 24 ); if ( $bottom_offset < 16 || $bottom_offset > 200 ) { $bottom_offset = 24; } $box_bottom = $bottom_offset + 80; $css = ':root{'; $css .= '--askbot-primary:' . $colors['primary'] . ';'; $css .= '--askbot-bot-bubble:' . $colors['bot'] . ';'; $css .= '--askbot-user-bubble:' . $colors['user'] . ';'; $css .= '}'; $css .= '#askbot-button{bottom:' . $bottom_offset . 'px !important;right:24px !important;left:auto !important;}'; $css .= '#askbot-box{bottom:' . $box_bottom . 'px !important;right:24px !important;left:auto !important;}'; $css .= '.askbot-msg.user .askbot-bubble{color:#333;}'; wp_add_inline_style( 'askbot-css', $css ); $display_name = askbot_get_display_name( $page_lang ); $config = array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'askbot_chat_nonce' ), 'botName' => $display_name, 'welcomeMsg' => askbot_get_welcome_message( $page_lang ), 'lang' => $page_lang, 'i18n' => askbot_widget_texts( $page_lang ), 'botAvatar' => askbot_get_avatar_url(), 'userAvatar' => askbot_get_user_avatar(), 'soundEnabled' => get_option( 'askbot_sound_enabled', '1' ) === '1' ? '1' : '0', 'autoOpenDelay' => (int) get_option( 'askbot_auto_open_delay', 0 ), 'maxLength' => ASKBOT_MAX_MESSAGE_CHARS, ); /** * Permet à une extension d'ajouter des données de configuration au widget. */ $config = (array) apply_filters( 'askbot_widget_config', $config, $page_lang ); wp_localize_script( 'askbot-js', 'askbotConfig', $config ); } add_action( 'wp_footer', 'askbot_render_widget' ); function askbot_render_widget() { // Même garde-fou que pour le chargement du CSS/JS : sur une page masquée, // rien ne doit être imprimé (sinon le balisage apparaît sans style). if ( askbot_is_hidden_on_current_page() ) { return; } $page_lang = askbot_get_language(); $display_name = askbot_get_display_name( $page_lang ); $avatar_url = askbot_get_avatar_url(); $ui = askbot_widget_texts( $page_lang ); ?>
<?php echo esc_attr( $display_name ); ?>