WP Manifestindependent plugin directory
manifest / ai / ai-content-assistant

AI Content Assistant

A small, production-minded WordPress plugin that generates post content **from inside the block editor** using the **OpenAI** or **Claude (Anthropic)** API.

by Vinay Paudel · github.com/paudelvinay/ai-content-assistant · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/paudelvinay/ai-content-assistant/archive/refs/heads/main.zip

Readme

AI Content Assistant

A small, production-minded WordPress plugin that generates post content from inside the block editor using the OpenAI or Claude (Anthropic) API.

It adds:

  • a Gutenberg block ("AI Content Generator") — type a prompt, click Generate, get editable paragraphs;
  • a secure REST endpoint (POST /wp-json/aica/v1/generate) that the block calls;
  • a provider abstraction so the same call works against OpenAI or Anthropic;
  • a settings page (Settings → AI Content Assistant) for provider, API key and model.

Built as a compact, readable example of custom plugin + Gutenberg block + WP REST API + AI integration, following WordPress security practices.

Why it's structured this way

The AI never writes raw markup. The block sends a plain-text prompt to a REST endpoint; the server calls the provider and returns text, which lands in an editable RichText field. Output stays predictable and the editor stays in control — the same principle I'd apply to a larger AI-driven site builder.

How it works

Editor block ──POST /aica/v1/generate──▶ REST controller ──▶ Provider (OpenAI | Anthropic) ──▶ text
   ▲  (capability + nonce checked)              (prompt sanitised)                                │
   └──────────────── editable RichText ◀─────────────────────────────────────────────────────────┘
  • ai-content-assistant.php — bootstraps the plugin and registers the block script/style with explicit dependencies.
  • includes/class-settings.php — settings screen + sanitised option access.
  • includes/class-provider.php — OpenAI and Anthropic request handling via wp_remote_post().
  • includes/class-rest-controller.php — the REST route, with permission_callback and argument sanitisation.
  • src/ — the block (block.json, index.js, editor.css).

Security notes

  • REST route requires current_user_can( 'edit_posts' ); apiFetch sends the WordPress nonce automatically.
  • Prompt is sanitised with sanitize_textarea_field and validated as non-empty.
  • API key can be overridden with a AICA_API_KEY constant in wp-config.php so it never has to live in the database on production.
  • Direct file access is blocked (ABSPATH guard) and output is escaped.

Install

  1. Copy the ai-content-assistant folder into wp-content/plugins/.
  2. Activate AI Content Assistant in Plugins.
  3. Go to Settings → AI Content Assistant, choose a provider, paste your API key, set a model (gpt-4o-mini for OpenAI, claude-3-5-sonnet-latest for Anthropic).
  4. In any post, add the AI Content Generator block, enter a prompt, and click Generate.

Configuration

Recommended for production — keep the key out of the database:

// wp-config.php
define( 'AICA_API_KEY', 'sk-...' );

Requirements

  • WordPress 6.0+
  • PHP 7.4+
  • An OpenAI or Anthropic API key

Notes on the build

The block is written in plain JavaScript so the plugin runs with no build step. In a production project I'd author it in JSX and compile with @wordpress/scripts (npm run build), which also generates the dependency/version asset file automatically.

License

GPL-2.0-or-later

Read the full README on GitHub →