Go Back to Parent Doc

Developer Reference

AI Content Writer is built to be extended — the Pro plugin itself uses only these public hooks. Text domain: ai-content-writer; option prefix: aicw_; meta prefix: _aicw_.

AI provider framework

Register a custom AI provider by implementing AIContentWriter\Services\ProviderInterface (or extending AbstractProvider / the OpenAI class for OpenAI-compatible APIs):

add_filter( 'aicw_ai_providers', function ( $providers ) {
    $providers['my-llm'] = \MyPlugin\MyProvider::class;
    return $providers;
} );

Your provider automatically appears as a campaign type, in the instant-generation selector, in the Autopilot campaign’s AI Provider dropdown, and in the Test Connection endpoint. Resolve providers with aicw_get_ai_provider( $slug ).

To resolve the provider a campaign should use, call aicw_get_campaign_ai_provider( $campaign_id ) — for AI campaign types the type slug is the provider slug, while Autopilot campaigns store theirs separately in _aicw_ai_provider meta.

Related filters:

  • aicw_default_ai_model — filter the default model per provider.
  • aicw_content_prompt — filter the article prompt (receives the campaign ID and a context array with title, keywords, language, tone).
  • aicw_json_prompt_instructions — extend the structured JSON output schema, pair with aicw_parsed_generated_post to read your extra keys.

Structured output pipeline

  • aicw_parsed_generated_post (filter) — the normalized post data (title, content, excerpt, categories, tags, seo) plus the raw decoded response.
  • aicw_generated_post_parsed (action) — after structured data is persisted on a campaign temp post.
  • aicw_publish_postarr (filter) — the post array right before a generated post is promoted; change the status (quality gates), dates (scheduling), or anything else.
  • aicw_post_published (action) — after a campaign post is promoted; receives post ID and campaign ID.
  • aicw_instant_post_created (action) — after an instant-generation post is created with structured data.

Image sources

add_filter( 'aicw_image_sources', function ( $sources ) {
    $sources['my-source'] = 'My Image Service';
    return $sources;
} );

add_filter( 'aicw_pre_fetch_images', function ( $images, $source, $query, $per_page ) {
    if ( 'my-source' !== $source ) {
        return $images;
    }
    return [ [ 'src' => [ 'original' => $url ], 'alt' => $query, 'photographer' => '', 'url' => '' ] ];
}, 10, 4 );

SEO adapters

Support another SEO plugin by implementing AIContentWriter\Services\SEO\AdapterInterface:

add_filter( 'aicw_seo_adapters', function ( $adapters ) {
    $adapters['my-seo'] = \MyPlugin\MySeoAdapter::class;
    return $adapters;
} );

The stored SEO data lives in _aicw_seo post meta (meta_titlemeta_descriptionfocus_keywordslug); aicw_apply_seo_meta( $post_id ) writes it through the active adapter.

Campaign form & settings

  • aicw_campaign_details_fields (action) — render extra fields on the campaign add/edit form (receives the campaign or null).
  • aicw_save_campaign_meta (action) — persist those fields (nonce/capability already checked).
  • aicw_settings_tabs (filter) + aicw_{tab}_settings (action) + admin_post_aicw_save_{tab}_settings — add your own settings tab.
  • aicw_save_api_settings (action) — save custom provider keys with the API tab.
  • aicw_campaign_frequencies / aicw_campaign_target_max_limit (filters) — extend scheduling options and limits.

Pro hooks

  • aicwp_seo_score (filter) — adjust the computed SEO score.
  • aicwp_image_prompt (filter) — customize the DALL·E image prompt.
  • aicwp_webhook_payload (filter) — extend the publish-webhook JSON payload.

REST API

POST /wp-json/aicw/v1/generateContent powers the editor assistants — authenticated via cookie + wp_rest nonce, requiring the edit_posts capability. Parameters: mode (generate/modify), content_typetopicinstructionsselectiontonelengthlanguage. Returns { text, html }. Both editor integrations send language; an empty value omits the language instruction from the prompt.

Campaign types

Campaign types are branched in Cron::generate_titles() and Cron::generate_content() by the _aicw_campaign_type meta value. The built-in non-provider types are articlesrss-feed, and autopilot (AIContentWriter\Campaigns\Autopilot); anything else is treated as a provider slug.

Autopilot-specific meta:

  • _aicw_ai_provider — the provider slug that writes the articles.
  • _aicw_autopilot_profile — the cached AI-generated site profile.
  • _aicw_autopilot_profile_time — the profile’s timestamp; it is rebuilt weekly.

Filter aicw_languages and aicw_content_tones to extend the language and tone lists shown in campaigns and both editors.

Related

Shopping Cart
  • Your cart is empty.