Reference implementation showing how to build experiments for the AI plugin.
- Extends
Abstract_Feature - Adds footer markup for logged-in users
- Modifies the document title while
WP_DEBUGis true - Registers a REST endpoint at
/wp-json/ai/v1/example
This experiment registers a REST endpoint to demonstrate how to expose experiment data.
Endpoint: GET /wp-json/ai/v1/example
Permission: manage_options
Example Response:
{
"experiment_id": "example-experiment",
"label": "Example Experiment",
"description": "Demonstrates the AI experiment system with example hooks and functionality.",
"enabled": true,
"message": "Example experiment is active!"
}Use the experiment-specific filter:
add_filter( 'wpai_feature_example-experiment_enabled', '__return_false' );Or use the generic filter to disable all experiments:
add_filter( 'wpai_features_enabled', '__return_false' );- Duplicate this folder and rename the namespace/class.
- Extend
WordPress\AI\Abstracts\Abstract_Feature. - Set experiment properties (
$id,$label,$description) in the constructor. - Register hooks in the
register()method.
See Example_Experiment.php for a complete reference.