2 min read 2 days ago

Sell your Add-on

Since June 2024, the AI Engine has begun supporting add-ons, which are plugins related to 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.

If you are a developer, you can build your own plugin that extends AI Engine—for example, a plugin that adds settings to customize cache behavior—and sell it to your clients. To make things clearer and easier for them, you can register your plugin as an AI Engine addon so it’s visible and easily accessible within the AI Engine interface.

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();