[label, detector callable returning bool, selector]. * * @return array */ public function known_plugins() { return array( 'ai-engine' => array( 'label' => 'AI Engine', 'active' => class_exists( 'Meow_MWAI_Core' ) || defined( 'MWAI_VERSION' ), 'selector' => '.mwai-chatbot, .mwai-chatbot-container', ), 'mxchat' => array( 'label' => 'MxChat', 'active' => defined( 'MXCHAT_VERSION' ) || function_exists( 'mxchat_activate' ) || class_exists( 'MxChat_Admin' ), 'selector' => '#mxchat-chatbot, .mxchat-chatbot-wrapper', ), 'chatbot-kognetiks' => array( 'label' => 'Kognetiks Chatbot', 'active' => function_exists( 'chatbot_chatgpt_activate' ) || defined( 'CHATBOT_CHATGPT_VERSION' ), 'selector' => '#chatbot-chatgpt, .chatbot-container', ), ); } /** * Known embedded SaaS chat widgets (client-side detection config). * * The front-end script watches for these selectors appearing in the DOM * (most widgets inject asynchronously) and attaches the disclosure badge. * * @return array */ public function known_embeds() { $embeds = array( 'tidio' => array( 'label' => 'Tidio', 'selector' => '#tidio-chat, tidio-chat', ), 'chatbase' => array( 'label' => 'Chatbase', 'selector' => '#chatbase-bubble-button, iframe[src*="chatbase.co"]', ), 'intercom' => array( 'label' => 'Intercom', 'selector' => '.intercom-lightweight-app, #intercom-container', ), 'crisp' => array( 'label' => 'Crisp', 'selector' => '#crisp-chatbox', ), 'hubspot' => array( 'label' => 'HubSpot Chat', 'selector' => '#hubspot-messages-iframe-container', ), 'tawkto' => array( 'label' => 'Tawk.to', 'selector' => 'iframe[title="chat widget"], #tawkchat-container', ), 'livechat' => array( 'label' => 'LiveChat', 'selector' => '#chat-widget-container', ), 'botpress' => array( 'label' => 'Botpress', 'selector' => '#bp-web-widget, .bpw-widget-btn', ), 'voiceflow' => array( 'label' => 'Voiceflow', 'selector' => '#voiceflow-chat, iframe[src*="voiceflow.com"]', ), ); /** * Filter the list of known embedded chat widgets. * * @param array $embeds Widget config keyed by id. */ return apply_filters( 'adfc_known_embeds', $embeds ); } /** * Detected active chatbot plugins. * * @return array id => label */ public function active_chatbot_plugins() { $found = array(); foreach ( $this->known_plugins() as $id => $config ) { if ( ! empty( $config['active'] ) ) { $found[ $id ] = $config['label']; } } return $found; } /** * CSS selectors the front-end script should watch, based on settings. * * @param ADFC_Plugin $plugin Plugin instance for settings access. * @return array list of [id, label, selector] */ public function frontend_watch_list( $plugin ) { $watch = array(); foreach ( $this->known_plugins() as $id => $config ) { if ( ! empty( $config['active'] ) ) { $watch[] = array( 'id' => $id, 'label' => $config['label'], 'selector' => $config['selector'], ); } } if ( $plugin->get_setting( 'auto_detect_embeds' ) ) { foreach ( $this->known_embeds() as $id => $config ) { $watch[] = array( 'id' => $id, 'label' => $config['label'], 'selector' => $config['selector'], ); } } $custom = trim( (string) $plugin->get_setting( 'custom_selectors' ) ); if ( '' !== $custom ) { $lines = preg_split( '/[\r\n,]+/', $custom ); foreach ( $lines as $i => $line ) { $line = trim( $line ); if ( '' !== $line ) { $watch[] = array( 'id' => 'custom-' . $i, 'label' => 'Custom', 'selector' => $line, ); } } } return $watch; } }