Skip to content

sethshoultes/wp-content-engine

Repository files navigation

WP Content Engine

AI content generator with voice matching and SEO integration for the WordPress block editor.

WP Content Engine lives inside the Gutenberg sidebar. Describe your topic, pick a content type, and receive three AI-generated options that match your existing writing voice. It reads your focus keyword from Yoast or Rank Math, suggests internal links, and outputs native WordPress blocks ready to insert.

Features

  • Block editor sidebar -- generate content without leaving the post editor
  • Voice matching -- analyzes your published posts to learn your tone, sentence structure, vocabulary, and punctuation style
  • Three options per generation -- each with slightly different temperature for variety
  • SEO integration -- auto-reads focus keywords from Yoast SEO or Rank Math
  • Internal linking -- suggests links to related published posts based on your keyword
  • Two content types -- full blog posts and landing page sections (hero, benefit, CTA)
  • Meta title and description -- generated alongside content for SEO completeness
  • Voice confidence scoring -- each option shows how closely it matches your voice profile
  • Word count control -- short, medium, or long output lengths
  • Generation tracking -- logs every generation with token usage and voice profile status
  • Free tier with upgrade path -- 5 generations/month free, unlimited on Pro/Agency

Requirements

  • WordPress 6.0+
  • PHP 7.4+
  • Gutenberg block editor (not the Classic Editor)

Installation

  1. Upload the wp-content-engine directory to wp-content/plugins/.
  2. Run composer install inside the plugin directory (or use the bundled autoloader fallback).
  3. Activate the plugin through the WordPress admin.
  4. Navigate to Content Engine > Settings to configure your API connection.

Setup

API Configuration

The plugin uses Claude (Anthropic) as its AI provider. Configure access in one of two ways:

Via SmartWeb Proxy (default): Enter your proxy URL and site token. Credits are managed centrally.

Via Direct API Key: Enter your Anthropic API key directly. The key is encrypted before storage.

Voice Learning

Before generating content, teach the engine your writing voice:

  1. Publish at least 3 blog posts (the more the better, up to 20 are analyzed).
  2. Go to Content Engine > Settings and click Analyze My Voice.
  3. The engine extracts structural metrics (sentence length, vocabulary tier, readability grade, punctuation patterns) and uses Claude to identify tone, humor level, jargon density, and urgency.
  4. A voice profile is stored and refreshed weekly via cron.

What the voice profile captures:

  • Average sentence length and readability grade (Flesch-Kincaid)
  • Vocabulary tier (accessible, mid-professional, technical)
  • Punctuation style ratios (em-dashes, semicolons, questions, exclamations)
  • Tone markers (conversational, formal, authoritative)
  • Humor and jargon levels
  • Top 30 characteristic words
  • 2-3 example passages for prompt embedding

If Claude is unavailable during analysis, a heuristic fallback derives tone from sentence length and vocabulary metrics.

Usage

Generating a Blog Post

  1. Create or edit a post in the block editor.
  2. Open the Content Engine sidebar panel (robot icon in the top toolbar).
  3. Enter your topic (e.g., "5 ways to improve WordPress site speed").
  4. Set the focus keyword (or let the engine pull it from your SEO plugin).
  5. Choose length: short (~500 words), medium (~1000 words), or long (~1500+ words).
  6. Click Generate.
  7. Review the three options. Each shows:
    • Preview text (first 100 words)
    • Word count
    • Voice confidence percentage
    • Meta title and description
  8. Click Insert on your preferred option to add the blocks to your editor.

Generating Landing Sections

  1. Switch the content type to Landing Section.
  2. Choose a section type:
    • Hero -- headline, subheadline, CTA button text
    • Benefit -- feature/benefit blocks with supporting copy
    • CTA -- call-to-action section with urgency copy
  3. Enter your topic and optional focus keyword.
  4. Click Generate and insert the result.

Voice Matching

The voice profile is injected into every generation prompt. The AI is instructed to:

  • Match your average sentence length
  • Use your vocabulary tier
  • Mirror your punctuation habits (e.g., frequent em-dashes)
  • Adopt your tone (conversational, formal, etc.)
  • Include your characteristic words naturally

The ToneMatcher then scores each generated option against the profile, giving you a confidence percentage so you can pick the option that sounds most like you.

SEO Plugin Compatibility

Plugin Detection Focus Keyword Source
Yoast SEO WPSEO_VERSION constant YoastAdapter reads _yoast_wpseo_focuskw post meta
Rank Math RANK_MATH_VERSION constant Reads rank_math_focus_keyword post meta
None -- Enter keyword manually in the sidebar

The engine auto-detects which SEO plugin is active and reads the focus keyword for the current post. If no keyword is set, you can enter one manually, or leave it blank for keyword-agnostic content.

Internal Link Suggestions

When a focus keyword is provided, the InternalLinker searches your published posts for related content and passes up to 5 link suggestions to the AI prompt. The generated content naturally weaves in internal links.

REST API

All endpoints are under the wce/v1 namespace and require edit_posts capability.

Generate Content

POST /wp-json/wce/v1/generate

Body (JSON):

{
  "content_type": "blog_post",
  "topic": "WordPress performance optimization tips",
  "length": "medium",
  "focus_keyword": "wordpress speed",
  "post_id": 42
}

For landing sections:

{
  "content_type": "landing_section",
  "topic": "SaaS onboarding flow",
  "section_type": "hero",
  "focus_keyword": "saas onboarding"
}

Response (200):

{
  "success": true,
  "options": [
    {
      "blocks": [
        { "type": "heading", "level": 2, "content": "..." },
        { "type": "paragraph", "content": "..." }
      ],
      "meta_title": "...",
      "meta_description": "...",
      "word_count": 1024,
      "voice_confidence": 87,
      "preview": "First 100 words of the first paragraph..."
    }
  ],
  "remaining": 3,
  "tokens_used": 4521
}

Analyze Voice

POST /wp-json/wce/v1/voice/analyze

Triggers a fresh voice analysis from published posts. Returns the full voice profile.

Get Voice Profile

GET /wp-json/wce/v1/voice/profile

Returns the stored voice profile, or { "analyzed": false } if not yet analyzed.

Get SEO Keywords

GET /wp-json/wce/v1/seo/keywords/{post_id}

Returns the focus keyword, detected SEO plugin, and internal link suggestions for a post.

Development

Project Structure

wp-content-engine/
  src/
    AI/
      ClaudeProvider.php       # Anthropic API client
      PromptBuilder.php        # Blog post + landing section prompt assembly
      ProviderInterface.php    # Provider contract
      VoiceAnalyzer.php        # Voice profiling from published posts
    Admin/
      SettingsPage.php         # Plugin settings UI
    Content/
      ContentGenerator.php     # Generation orchestrator + REST handler
      ToneMatcher.php          # Voice confidence scoring
    Editor/
      BlockEditorPanel.php     # Gutenberg sidebar registration + asset enqueue
      BlockGenerator.php       # Parses AI response into WordPress block arrays
    SEO/
      InternalLinker.php       # Related post search for link suggestions
      SEOIntegration.php       # Auto-detect Yoast/Rank Math, unified keyword access
      YoastAdapter.php         # Yoast-specific meta access
    Plugin.php                 # Singleton bootstrap, DB tables, cron
  assets/
    js/editor-sidebar.js       # Gutenberg sidebar React component
    css/admin.css              # Editor styles
  templates/                   # Admin page templates
  languages/                   # Translation files

Autoloading

PSR-4 via Composer. Namespace ContentEngine\ maps to src/. Falls back to a manual spl_autoload_register if Composer autoload is missing.

Database

One custom table created on activation:

  • {prefix}wce_generations -- logs every generation (post_id, user_id, prompt, response, provider, content_type, tokens_used, voice_profile_used, created_at)

Generation counts are derived from this table (no separate counter).

Cron

A weekly cron job (wce_weekly_voice_refresh) refreshes the voice profile automatically so it stays current as you publish new content.

Coding Standards

composer require --dev squizlabs/php_codesniffer wp-coding-standards/wpcs
./vendor/bin/phpcs --standard=phpcs.xml src/

Free Tier Limits

Tier Generations/Month
Free 5
Pro Unlimited
Agency Unlimited

The limit uses a rolling 30-day window, counted per user from the wce_generations table.

Changelog

1.0.0

  • Initial release
  • Blog post and landing section generation
  • Voice matching with structural metrics and AI tone analysis
  • Yoast SEO and Rank Math integration
  • Internal link suggestions
  • Block editor sidebar panel
  • Three options per generation with voice confidence scoring

License

GPL-2.0-or-later. See LICENSE.

About

AI content generation for WordPress with voice matching and SEO

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors