# WordPress 7.0 AI Integration Strategy

**Document:** WP Agentic Writer Integration with WordPress 7.0 Native AI
**Date:** 2026-05-17
**Status:** 📋 ANALYSIS COMPLETE

---

## Executive Summary

WordPress 7.0 (released April 9, 2026) introduces a native AI infrastructure that fundamentally changes how AI features work in WordPress. This document analyzes:

1. What WordPress 7.0 brings natively for AI
2. How WP Agentic Writer currently implements AI
3. Integration opportunities to eliminate duplicate setup
4. Strategic recommendations for unified AI experience

**Key Finding:** WordPress 7.0 introduces the **AI Client SDK** and **Connectors screen** - exactly what WP Agentic Writer needs to leverage instead of maintaining its own provider configuration.

---

## WordPress 7.0 AI Features Overview

### 1. AI Client SDK (Core)

WordPress 7.0 ships with a built-in, provider-agnostic AI client:

```php
// The entry point - all AI calls go through this
$builder = wp_ai_client_prompt();

// Text generation
$text = wp_ai_client_prompt( 'Summarize this content.' )
    ->using_temperature( 0.7 )
    ->generate_text();

// Image generation
$image = wp_ai_client_prompt( 'A futuristic WordPress logo' )
    ->generate_image();

// Feature detection (no API calls)
if ( $builder->is_supported_for_text_generation() ) {
    // Show text generation UI
}
```

**Key Features:**
- Provider-agnostic (works with OpenAI, Anthropic, Google)
- Multimodal (text, image, audio, video)
- JSON schema support for structured responses
- Feature detection without API calls
- REST API integration built-in
- Hook system for security (`wp_ai_client_prevent_prompt` filter)

### 2. Connectors Screen (Core)

A new WordPress core screen for AI provider configuration:
- Centralized credentials storage
- Provider selection UI
- One place for ALL AI settings
- Replaces per-plugin API key management

**Available Provider Packages:**
- `wp-openai-connector` - OpenAI models
- `wp-anthropic-connector` - Claude models
- `wp-google-ai-connector` - Gemini models

### 3. Abilities API

Standardized way to register AI capabilities:

```php
// Register a custom ability
register_ai_ability( 'my-plugin', 'generate-alt-text', array(
    'label' => 'Generate alt text',
    'description' => 'AI-powered alt text generation',
    'callback' => 'my_generate_alt_text',
) );
```

Abilities become tool-callable by AI models natively, enabling:
- Cross-plugin AI coordination
- Centralized AI governance
- Audit logging of AI operations

### 4. Built-in AI Features (WordPress AI Assistant)

WordPress 7.0 includes basic AI features:
- Title generation
- Excerpt generation
- Image creation
- Alt text generation
- Summarization

---

## Current WP Agentic Writer Architecture

### AI Provider Integration

WP Agentic Writer currently manages its own:
- Provider selection (OpenRouter, Local Backend, Codex)
- API key storage
- Model selection
- Cost tracking
- Request handling

### Components with Custom AI Logic

| Component | Current AI Implementation |
|-----------|---------------------------|
| Chat Handler | Own API calls via OpenRouter |
| Content Generation | Own streaming implementation |
| Refinement | Own refinement endpoints |
| SEO Audit | Own API calls for analysis |
| Intent Detection | Own clarification flow |
| Context Optimization | Own summarization |
| Image Generation | Own DALL-E/SDXL integration |

### Settings Architecture

```
Settings Page
├── General Tab
│   ├── OpenRouter API Key
│   ├── Default Model
│   └── Monthly Budget
├── Providers Tab
│   ├── OpenRouter Configuration
│   ├── Local Backend URL
│   └── Codex Settings
└── Advanced Tab
    └── Custom Model Presets
```

---

## Integration Opportunities

### Phase 1: Leverage WordPress AI Client SDK

**What:** Replace internal AI calls with `wp_ai_client_prompt()`

**Benefits:**
- Single API key configuration
- Built-in rate limiting
- Automatic retry logic
- Unified cost tracking
- Provider fallback support

**Implementation:**
```php
// Before: Custom implementation
$response = $this->openrouter_provider->chat($messages, $params, $task);

// After: Use WordPress AI Client
$builder = wp_ai_client_prompt()
    ->with_text($prompt)
    ->using_model_preference('claude-sonnet-4-6', 'gpt-4o', 'gemini-2.5')
    ->using_temperature($temperature);

$result = $builder->generate_text_result();
```

### Phase 2: Connectors Integration

**What:** Use WordPress Connectors instead of custom provider settings

**Migration Path:**
1. Detect if WordPress 7.0+ with AI Client is available
2. If available, use `wp_ai_client_prompt()` as primary
3. Fall back to custom implementation for advanced features not in core
4. Deprecate custom API key fields (show migration notice)

**Backward Compatibility:**
```php
// Check if WordPress AI Client is available
if ( function_exists( 'wp_ai_client_prompt' ) ) {
    // Use WordPress AI Client
} else {
    // Use legacy OpenRouter implementation
}
```

### Phase 3: Abilities API Registration

**What:** Register WP Agentic Writer abilities for coordination

```php
// Register advanced writing abilities
register_ai_ability( 'wp-agentic-writer', 'article-generation', array(
    'label' => 'Generate Full Article',
    'description' => 'Generate a complete article with outline-based structure',
    'modalities' => array( 'text' ),
) );

register_ai_ability( 'wp-agentic-writer', 'content-refinement', array(
    'label' => 'Refine Content',
    'description' => 'Improve existing content for clarity, SEO, and quality',
    'modalities' => array( 'text' ),
) );

register_ai_ability( 'wp-agentic-writer', 'outline-creation', array(
    'label' => 'Create Article Outline',
    'description' => 'Generate structured outline from topic description',
    'modalities' => array( 'text' ),
) );
```

### Phase 4: Unified Settings Experience

**What:** Merge with WordPress Connectors screen

| Current (Plugin Settings) | WordPress 7.0 Native |
|--------------------------|---------------------|
| OpenRouter API Key | Via Connectors |
| Model Selection | Via Connectors + Preferences |
| Cost Tracking | Shared infrastructure |
| Monthly Budget | User preference |

**Recommendation:** Keep advanced features in plugin settings (local backend, custom presets), use core for standard AI operations.

---

## Feature Comparison Matrix

| Feature | WP 7.0 Native | WP Agentic Writer | Integration Strategy |
|---------|---------------|-------------------|---------------------|
| Basic text generation | ✅ | ✅ | Use core |
| Basic image generation | ✅ | ✅ | Use core for simple, plugin for advanced |
| Title generation | ✅ | ✅ | Use core |
| Excerpt generation | ✅ | ✅ | Use core |
| Alt text generation | ✅ | ✅ | Use core |
| Streaming responses | ❌ | ✅ | Keep in plugin |
| Complex prompts | ❌ | ✅ | Keep in plugin |
| Article planning | ❌ | ✅ | Keep in plugin |
| Multi-section writing | ❌ | ✅ | Keep in plugin |
| Block-level refinement | ❌ | ✅ | Keep in plugin |
| SEO optimization | ❌ | ✅ | Keep in plugin |
| GEO scoring | ❌ | ✅ | Keep in plugin |
| Context management | ❌ | ✅ | Keep in plugin |
| @mention system | ❌ | ✅ | Keep in plugin |
| Cost tracking | Basic | Advanced | Plugin tracks, core provides infrastructure |

---

## Recommended Architecture

### Unified AI Layer

```
┌─────────────────────────────────────────────────────────────┐
│                    WP AGENTIC WRITER                         │
├─────────────────────────────────────────────────────────────┤
│  FRONTEND (Gutenberg Sidebar)                               │
│  ├── Planning Mode (outline creation)                      │
│  ├── Writing Mode (section-by-section)                     │
│  ├── Refinement Mode (block targeting)                    │
│  ├── SEO Mode (audit & optimization)                      │
│  └── GEO Mode (AI Overview scoring)                        │
├─────────────────────────────────────────────────────────────┤
│  BACKEND AI LAYER (Hybrid)                                 │
│  ┌─────────────────┐    ┌─────────────────────────────┐  │
│  │ WordPress Core   │    │ Plugin-Specific Logic        │  │
│  │ AI Client SDK    │    │ • Streaming responses        │  │
│  │ (Basic Tasks)    │    │ • Article pipeline           │  │
│  │ • Title/Excerpt  │    │ • Block refinement          │  │
│  │ • Alt text       │    │ • SEO/GEO analysis          │  │
│  │ • Summaries      │    │ • Context optimization      │  │
│  └────────┬─────────┘    │ • Cost tracking              │  │
│           │              └──────────────┬──────────────┘  │
│           │                             │                  │
│           └──────────┬──────────────────┘                  │
│                      ▼                                     │
│  ┌─────────────────────────────────────────────────────┐  │
│  │           CONNECTORS (Unified Credentials)           │  │
│  │   OpenAI  │  Anthropic  │  Google  │  Local Backend  │  │
│  └─────────────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────────┘
```

### Implementation Priority

| Priority | Task | Effort | Benefit |
|----------|------|--------|---------|
| 🔴 HIGH | Add WP AI Client detection | Low | Foundation |
| 🔴 HIGH | Use `wp_ai_client_prompt()` for simple tasks | Medium | Eliminate duplicate setup |
| 🟡 MEDIUM | Register Abilities API | Medium | Ecosystem integration |
| 🟡 MEDIUM | Migrate settings to Connectors | High | Unified UX |
| 🟢 LOW | Deprecate legacy provider code | Medium | Maintenance |

---

## Code Migration Examples

### 1. Simple AI Call Migration

**Before (Current Implementation):**
```php
public function generate_title( $content ) {
    $provider = WP_Agentic_Writer_Provider_Manager::get_provider_for_task( 'title' );
    $messages = array(
        array(
            'role' => 'user',
            'content' => "Generate a catchy title for: $content"
        )
    );
    $response = $provider->chat( $messages, array(), 'title_generation' );
    return $response['content'];
}
```

**After (With Core Integration):**
```php
public function generate_title( $content ) {
    // Check if WordPress AI Client is available
    if ( function_exists( 'wp_ai_client_prompt' ) ) {
        $result = wp_ai_client_prompt()
            ->with_text( "Generate a catchy, SEO-friendly title (max 60 chars) for: $content" )
            ->using_model_preference( 'claude-sonnet-4-6', 'gpt-4o' )
            ->using_max_tokens( 50 )
            ->generate_text();

        if ( ! is_wp_error( $result ) ) {
            return $result->get_text();
        }
    }

    // Fallback to legacy implementation
    return $this->legacy_generate_title( $content );
}
```

### 2. Feature Detection

```php
public function render_ai_controls() {
    $ai_available = function_exists( 'wp_ai_client_prompt' );
    $supports_text = false;
    $supports_images = false;

    if ( $ai_available ) {
        $builder = wp_ai_client_prompt( 'test' );
        $supports_text = $builder->is_supported_for_text_generation();
        $supports_images = $builder->is_supported_for_image_generation();
    }

    // Render appropriate UI based on capabilities
    ?>
    <?php if ( $ai_available && $supports_text ) : ?>
        <p>AI features available via WordPress</p>
    <?php else : ?>
        <p>Configure AI in Settings → Connectors</p>
    <?php endif; ?>
    <?php
}
```

### 3. Abilities Registration

```php
public function register_ai_abilities() {
    if ( ! function_exists( 'register_ai_ability' ) ) {
        return;
    }

    // Article generation ability
    register_ai_ability( 'wp-agentic-writer', 'article-generation', array(
        'name'        => 'article_generation',
        'label'       => __( 'Generate Article', 'wp-agentic-writer' ),
        'description' => __( 'Generate a complete structured article from an outline', 'wp-agentic-writer' ),
        'input'       => array(
            'outline' => array(
                'type'        => 'string',
                'description' => 'Article outline in JSON format',
                'required'    => true,
            ),
            'focus_keyword' => array(
                'type'        => 'string',
                'description' => 'SEO focus keyword',
                'required'    => false,
            ),
        ),
        'output'      => 'string',
    ) );

    // SEO analysis ability
    register_ai_ability( 'wp-agentic-writer', 'seo-analysis', array(
        'name'        => 'seo_analysis',
        'label'       => __( 'Analyze SEO', 'wp-agentic-writer' ),
        'description' => __( 'Analyze content for SEO optimization', 'wp-agentic-writer' ),
        'input'       => 'string',
        'output'      => 'object',
    ) );
}
```

---

## Settings Migration Strategy

### Phase 1: Detection (Backward Compatible)

```php
class WP_Agentic_Writer_Settings {
    public function __construct() {
        $this->ai_client_available = function_exists( 'wp_ai_client_prompt' );
    }

    public function render_api_settings() {
        if ( $this->ai_client_available ) {
            $this->render_unified_settings();
        } else {
            $this->render_legacy_settings();
        }
    }

    private function render_unified_settings() {
        ?>
        <div class="wpaw-settings-section">
            <h3><?php _e( 'AI Configuration', 'wp-agentic-writer' ); ?></h3>
            <p>
                <?php _e( 'WP Agentic Writer uses WordPress 7.0 AI infrastructure. Configure your AI provider in', 'wp-agentic-writer' ); ?>
                <a href="<?php echo admin_url( 'admin.php?page=ai-connectors' ); ?>">
                    <?php _e( 'Settings → Connectors', 'wp-agentic-writer' ); ?>
                </a>.
            </p>

            <?php $this->render_advanced_settings(); ?>
        </div>
        <?php
    }

    private function render_advanced_settings() {
        // Keep plugin-specific settings only
        ?>
        <h4><?php _e( 'Agentic Writer Advanced', 'wp-agentic-writer' ); ?></h4>
        <?php
        $this->render_setting( 'local_backend_url', 'Local Backend URL' );
        $this->render_setting( 'custom_model_presets', 'Custom Model Presets' );
        $this->render_setting( 'monthly_budget', 'Monthly Budget' );
    }
}
```

### Phase 2: Settings Sync

```php
public function sync_with_wordpress_ai() {
    if ( ! $this->ai_client_available ) {
        return;
    }

    // Get WordPress AI settings
    $wp_ai_settings = get_option( 'wp_ai_settings', array() );

    // Sync to plugin settings for internal use
    if ( ! empty( $wp_ai_settings['active_provider'] ) ) {
        update_option( 'wpaw_active_provider', $wp_ai_settings['active_provider'] );
    }

    if ( ! empty( $wp_ai_settings['default_model'] ) ) {
        update_option( 'wpaw_default_model', $wp_ai_settings['default_model'] );
    }
}
```

---

## Governance & Compliance

### WordPress 7.0 Security Features

| Feature | WP Agentic Writer Use Case |
|---------|---------------------------|
| `wp_ai_client_prevent_prompt` filter | Restrict AI features by user role |
| Audit logging | Track AI operations for compliance |
| Centralized credentials | Single point for API key management |
| Provider abstraction | Easy provider switching without code changes |

### Implementation Example

```php
// Restrict AI writing features to editors and above
add_filter( 'wp_ai_client_prevent_prompt', function( $prevent, $builder ) {
    $ability = $builder->get_ability_name();

    // Check if this is an Agentic Writer ability
    if ( strpos( $ability, 'wp-agentic-writer' ) === 0 ) {
        // Require editor role for article generation
        if ( ! current_user_can( 'edit_posts' ) ) {
            return true;
        }
    }

    return $prevent;
}, 10, 2 );
```

---

## Competition Analysis

### How WP Agentic Writer Differs from Native Features

| WordPress AI Assistant | WP Agentic Writer |
|-----------------------|-------------------|
| Basic title/excerpt | Full article pipeline |
| Simple prompts | Context-aware generation |
| No outline | Outline-based writing |
| No refinement | Block-level refinement |
| No SEO/GEO | Complete SEO optimization |
| Generic AI | Writing-specialized AI |
| Single-shot | Multi-session workflow |

### Competitive Position

**WP Agentic Writer Advantage:**
- Sophisticated writing workflow (planning → writing → refinement)
- Block-level targeting with @mentions
- SEO + GEO optimization
- Context management across sessions
- Cost tracking and budget control
- Local backend support (privacy-first)

**Opportunity:**
WordPress 7.0 AI is basic. WP Agentic Writer fills the gap for serious content creators who need more than titles and excerpts.

---

## Implementation Roadmap

```
Phase 1: Foundation (Week 1-2)
├── Add WP AI Client detection helper
├── Create backward-compatible wrapper class
├── Migrate simple tasks (title, excerpt) to core
└── Test fallback to legacy implementation

Phase 2: Abilities (Week 3-4)
├── Register custom abilities with WordPress
├── Create ability handlers for advanced features
├── Enable cross-plugin AI coordination
└── Update documentation

Phase 3: Settings (Week 5-6)
├── Add migration notice for users upgrading to WP 7.0
├── Create unified settings UI
├── Deprecate legacy provider fields
└── Add Connectors link and guidance

Phase 4: Advanced Features (Week 7-8)
├── Keep streaming for article generation
├── Keep block refinement logic
├── Keep SEO/GEO analysis
└── Use core for all basic AI operations

Phase 5: Cleanup (Week 9-10)
├── Remove legacy code paths
├── Update provider manager architecture
├── Finalize settings migration
└── Publish integration documentation
```

---

## Technical Considerations

### Backward Compatibility

```php
// Always check for WordPress AI Client
if ( function_exists( 'wp_ai_client_prompt' ) ) {
    // Use new approach
} else {
    // Use legacy approach (WP < 7.0 or no connectors)
}

// Check specific capabilities
$supports_streaming = ! function_exists( 'wp_ai_client_prompt' ); // Core doesn't support streaming yet
```

### Performance

- WordPress AI Client adds HTTP overhead - cache responses
- Plugin-specific features (streaming) remain faster for large content
- Consider async processing for complex operations

### Testing

```php
class WP_Agentic_Writer_Test {
    public function test_ai_client_integration() {
        // Test with core AI Client
        if ( function_exists( 'wp_ai_client_prompt' ) ) {
            $result = wp_ai_client_prompt( 'Test prompt' )->generate_text();
            $this->assertNotInstanceOf( 'WP_Error', $result );
        }

        // Test fallback
        $result = $this->plugin->generate_text_legacy( 'Test prompt' );
        $this->assertNotEmpty( $result );
    }
}
```

---

## Recommendations Summary

### Do

1. **Adopt WordPress AI Client** for all basic text generation tasks
2. **Register Abilities** to integrate with the WordPress AI ecosystem
3. **Keep advanced features** (streaming, refinement, SEO/GEO) in plugin
4. **Unify settings** with Connectors screen where possible
5. **Maintain backward compatibility** for WP < 7.0 users

### Don't

1. **Don't replace** the entire AI implementation with core
2. **Don't duplicate** what WordPress does natively
3. **Don't break existing features** for users without WP 7.0
4. **Don't abandon** the specialized writing workflow

### Value Proposition After Integration

| Before | After Integration |
|--------|-------------------|
| Separate API keys | Single AI configuration |
| Duplicate provider setup | Unified Connectors |
| Basic AI features | Basic (core) + Advanced (plugin) |
| Isolated AI operations | Coordinated AI ecosystem |
| Plugin-specific governance | Platform-level governance |

---

## Conclusion

WordPress 7.0's native AI infrastructure is a significant opportunity for WP Agentic Writer:

1. **Eliminate duplicate setup** - Use Connectors instead of custom API keys
2. **Focus on differentiation** - Keep advanced writing features in plugin
3. **Join the ecosystem** - Register abilities for cross-plugin coordination
4. **Provide better UX** - Unified settings experience

The plugin remains essential for serious content creation workflows that require more than basic title and excerpt generation. WordPress core handles the foundation; WP Agentic Writer handles the writing expertise.

---

## References

- [WordPress 7.0 AI Client Documentation](https://make.wordpress.org/core/2026/03/24/introducing-the-ai-client-in-wordpress-7-0/)
- [PHP AI Client GitHub](https://github.com/WordPress/php-ai-client)
- [Abilities API Proposal](https://make.wordpress.org/core/2026/02/03/proposal-for-merging-wp-ai-client-into-wordpress-7-0/)
- [AI in WordPress 2026 Guide](https://ost.agency/blog/wordpress-ai-guide-for-business-2026/)

---

**Document Version:** 1.0
**Last Updated:** 2026-05-17
**Author:** Claude (AI Assistant)
