Create an Add-on
Since June 2024, the AI Engine has begun supporting add-ons, which are plugins related to the AI Engine. We believe this approach helps to avoid clutter in the WordPress Admin and conveniently organizes everything. Therefore, all plugins related to the AI Engine are located in the Add-ons section.
How to insert your Add-on
It's quite straightforward. You just need to add a filter on mwai_addons and register your own add-on. The placement of the add-on settings within the WP Admin is entirely at your discretion. If you plan to sell an add-on, it's your responsibility to implement a licensing system. For a free add-on, it's advisable to host it on the WordPress repository, if possible, for easy updates. If that's not feasible, you'll need to construct your own system.
add_filter( 'mwai_addons', array( $this, 'refresh_addons' ), 1 );
function refresh_addons( $addons ) {
$addons[] = [
'slug' => "your-addon",
'name' => "Your Add-on",
'icon_url' => 'https://yoursite.com/favicon.png', // Useless for now
'description' => "This add-on does this and that.",
'install_url' => "https://yoursite.com", // This link will show up if the plugin is disabled.
'settings_url' => null, // This link will be used by the button "Settings".
'enabled' => true // If the add-on is installed (probably always true).
];
return $addons;
}
Add AI Engine logs
If you want your Add-on to log messages, you don’t have to build your own logger or use the PHP error logs. There is a built in class Meow_MWAI_Logging with static functions you can call from anywhere. This will add your logs directly in the AI Engine Dev Tools console reader.
Meow_MWAI_Logging::warn( "..." ); Meow_MWAI_Logging::error( "..." ); Meow_MWAI_Logging::log( "..." ); Meow_MWAI_Logging::deprecated( "..." ); Meow_MWAI_Logging::clear();