Integration Base Class Reference
WPDAI_Integration_Base is the abstract base class for all integrations. Your integration must extend it and implement every abstract method. The class is in includes/integrations/WPDAI_Integration_Base.php.
Abstract Methods (Required)
get_slug()
Returns: string
Unique identifier for the integration (e.g. 'webhooks', 'my-custom-integration'). Used in URLs (?integrations=slug) and when registering with the manager. Use lowercase and hyphens.
get_label()
Returns: string
Display name shown on the integration card and in the settings header. Should be translatable (e.g. __( 'Webhooks', 'alpha-insights-pro' )).
get_description()
Returns: string
Short description for the card. Translatable.
is_pro()
Returns: bool
Whether this integration is Pro-only. When true and the Pro version is not active, the card shows a Pro badge and clicking it shows an upsell instead of settings.
is_enabled()
Returns: bool
Whether the integration is configured/active. Used to show an “Enabled” or “Disabled” badge on the card. Typically based on options (e.g. API key set, toggle on).
render_settings()
Returns: void
Output the settings HTML for this integration. Rendered inside the main settings form when the user has selected this integration (?integrations=slug). Use the same table/card styles as built-in integrations (e.g. class="wpd-table fixed widefat") and escape all output. Form fields should use name attributes that your save_settings() reads from $_POST.
save_settings( $saved )
Parameters: $saved (array) – Associative array of “label” => success (bool) for each saved group. You add an entry and return the modified array.
Returns: array – The modified $saved array.
Called via the wpd_ai_save_settings filter when the user saves the main settings page. Check for your $_POST keys, sanitize input, update options, and set e.g. $saved['My Integration Name'] = update_option( 'my_option', $data );, then return $saved.
Inherited Methods
__construct()
Calls setup_hooks(). Do not override unless you call parent::__construct() and still run setup_hooks().
setup_hooks()
Returns: void
Registers the default filter: add_filter( 'wpd_ai_save_settings', array( $this, 'save_settings' ), 10 );. Override to add more hooks but call parent::setup_hooks() so save continues to work.
get_settings_url()
Returns: string
URL to this integration’s settings: adds page, subpage=integrations, and integrations=<slug> to admin_url( 'admin.php' ). Override if you need a different link.
Usage Notes
- Require the base class before your class if it is not autoloaded:
require_once WPD_AI_PATH . 'includes/integrations/WPDAI_Integration_Base.php'; - Use the text domain
alpha-insights-profor translatable strings so they are consistent with the plugin. - Built-in integrations (e.g. Webhooks, ShipStation) live in
includes/integrations/register/andregister/pro/and are auto-discovered byload_and_register_from_directory(); third-party integrations register onwpd_ai_register_integrations.
Related Documentation
- Creating a Custom Integration – Step-by-step implementation
- Hooks and Registration – Registration hooks and
wpd_ai_save_settings - Integrations Overview – How the manager uses the base class