Plugin File Structure
Plugin File Structure
The Supervised AI Bots plugin is designed with a lightweight architecture to ensure minimal impact on site performance while providing a robust interface for chatbot integration. Below is an overview of the core files and their roles within the package.
1. Main Plugin File (supervised-ai-bots.php)
This is the primary entry point for the plugin. It handles the core WordPress integration, including administrative settings and the public-facing shortcode.
- Role: Internal logic for shortcode registration and admin menu creation.
- Public Interface: Provides the
[supervised_ai_bot]shortcode. - Shortcode Usage:
[supervised_ai_bot id="1"]- id (string/int): Corresponds to the row number of the chatbot URL saved in the plugin settings.
2. Stylesheet (custom-popup-style.css)
This file manages the visual presentation of the chatbot widget on the front end. It defines the appearance of the floating trigger button and the iframe container.
- Key Selectors for Customization:
.circle-button: Styles the floating launcher (default: blue circle, bottom-right)..popup-container: Controls the dimensions and positioning of the chat window (default: 400px width, 670px height)..iframe-container: Manages the responsive wrapper for the Supervised AI bot iframe.
- Usage: Site administrators can override these classes in their theme's "Additional CSS" section to match their brand identity.
3. JavaScript Controller (custom-popup-script.js)
This script manages the client-side interactivity of the chatbot interface, specifically handling how the chat window opens and closes.
- Public Functions:
togglePopup(): A global function that switches the visibility of the chatbot betweenblockandnone. This is triggered when a user clicks the floating action button.closePopup(): Explicitly hides the chatbot window.
- Role: Although these functions are used internally by the plugin's UI components, they can be called by custom theme elements if you wish to trigger the bot from a custom menu item or button.
4. Administrative Interface
While not a standalone file in the directory, the plugin generates a settings page within the WordPress Dashboard.
- Purpose: Allows users to input chatbot URLs (one per line).
- Data Handling: Each line is indexed starting from 1, which maps directly to the
idattribute used in the shortcode.