WordPress Hooks Reference
Frontend Asset Enqueueing
The Supervised AI Bots plugin integrates its core styles and scripts using the standard WordPress wp_enqueue_scripts hook. This ensures that assets are only loaded when necessary and can be safely managed or overridden by theme developers.
Script and Style Handles
If you need to modify the loading priority or dequeue the default assets to provide your own custom implementations, use the following handles:
| Asset Type | Handle | Source File |
| :--- | :--- | :--- |
| CSS | wpai-custom-popup-style | custom-popup-style.css |
| JavaScript | wpai-custom-popup-script | custom-popup-script.js |
Modifying Styles
The plugin's layout is defined in custom-popup-style.css. You can override the chatbot's appearance (such as the circle button color or popup dimensions) by adding higher-specificity CSS to your theme or by using the wp_dequeue_style function.
Example: Dequeueing the default styles
If you wish to provide your own styling entirely, add the following to your theme's functions.php:
add_action('wp_enqueue_scripts', 'my_custom_theme_remove_wpai_styles', 20);
function my_custom_theme_remove_wpai_styles() {
wp_dequeue_style('wpai-custom-popup-style');
}
JavaScript Interactions
The frontend logic resides in custom-popup-script.js and handles the visibility of the chatbot interface. It exposes two global functions that can be called by other scripts:
togglePopup(): Switches the visibility state of the chatbot window.closePopup(): Explicitly hides the chatbot window.
Example: Triggering the chatbot from a custom button You can trigger the plugin's popup from any custom element on your site by calling the public function:
<button onclick="togglePopup()">Chat with our Assistant</button>
Shortcode Implementation
The primary method for rendering the chatbot is via the [supervised_ai_bot] shortcode. This hook dynamically generates the required HTML structure, including the iframe container and the floating trigger button.
Shortcode Attributes
| Attribute | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| id | Integer | Yes | The row index (starting from 1) of the bot URL configured in the plugin settings. |
Usage Example:
[supervised_ai_bot id="1"]
Internal Hook Usage
While the plugin does not currently offer custom Action or Filter hooks for third-party developers, it utilizes the following WordPress core hooks:
admin_menu: Used to register the "Supervised AI Bots" settings page in the dashboard.admin_init: Used to register and sanitize the chatbot URL settings.wp_enqueue_scripts: Used to load the CSS and JS for the popup interface on the frontend.init: Used to register the[supervised_ai_bot]shortcode.