# SEOBot AI – AI SEO Automation & Content Optimizer for WordPress

The all-in-one AI SEO plugin for WordPress — automate internal linking, generate optimized content, research keywords, audit categories & author profiles, connect Google Search Console, and boost rankings with E-E-A-T scoring.

[![WordPress](https://img.shields.io/badge/WordPress-5.8%2B-blue.svg)](https://wordpress.org/)
[![PHP](https://img.shields.io/badge/PHP-7.4%2B-purple.svg)](https://php.net/)
[![License](https://img.shields.io/badge/License-GPL--2.0%2B-green.svg)](https://www.gnu.org/licenses/gpl-2.0.html)

## Features

### 🔗 Intelligent Internal Linking
- Scans your entire site and suggests contextually relevant internal links
- AI-generated anchor texts optimized for SEO
- One-click apply or cherry-pick individual link suggestions
- Counts existing internal links per post

### ✍️ AI Article Creator
- Generate full SEO-optimized articles in 3 steps: Topic → Outline → Publish
- AI creates detailed outlines with heading hierarchy, FAQ section, and image placements
- Configurable tone (professional, casual, formal, friendly, technical)
- Target word count from 1,000 to 5,000 words
- AI image generation (GPT Image) with 8 style presets + custom prompt
- Optional YouTube video embed
- Creates WordPress post as draft or publishes directly
- Featured image auto-set from first generated image

### 📊 Keyword Research & Suggestions (Google Ads)
- Real keyword data: search volume, CPC, competition scores
- Extracts seed keywords from post titles automatically
- Manual keyword lookup with instant metrics
- Top keywords dashboard across all posts

### 📈 Google Search Console Integration
- OAuth 2.0 connection with property selection
- View impressions, clicks, CTR, and average position
- Discover keyword opportunities and underperforming pages
- All data accessible directly in WordPress

### 📝 Content Planner
- AI-generated editorial calendars with keyword targeting
- Manage article statuses: planned, approved, generating, published
- Go from content plan to published post seamlessly

### 🏅 E-E-A-T Scorer
- Evaluate content against Google's E-E-A-T quality guidelines
- Detailed scoring across Experience, Expertise, Authoritativeness, Trustworthiness
- Actionable recommendations to improve E-E-A-T signals

### 👥 Users / Author Optimizer
- Audit every author profile for SEO issues
- Detect missing bios, short descriptions, no avatar, inactive accounts
- AI generates optimized bios and professional display names
- Bulk AI bio generation across all users
- Score each author profile 0–100 for SEO health

### 📂 Categories Optimizer
- Full taxonomy audit with AI-powered **keep / delete / merge** verdicts
- Auto-generate SEO-optimized category descriptions
- Detect empty, thin, deeply nested, and duplicate categories
- Score each category 0–100 for SEO health
- Bulk actions: generate descriptions, delete selected

### ✏️ AI Content Enrichment
- Score content quality (0–100) using AI
- Suggestions for new sections, FAQs, statistics, better headings
- Individual apply per suggestion — full control
- Full AI rewrite mode with preview before applying

### 🔄 Duplicate & Cannibalization Detection
- Fast pre-filter using title similarity (Levenshtein + word overlap)
- Accurate comparison via OpenAI text embeddings (cosine similarity)
- Configurable similarity threshold (50%–99%)
- AI-powered content merge — intelligently combines two posts
- Auto 301 redirect meta on the merged post

### 📅 Smart Date Updater
- Scans titles and content for outdated year references
- Bulk scan across all posts with one click
- Preview before/after changes
- Automatic `post_modified` timestamp refresh

### 🔗 Backlink Exchange Network
- Opt-in/opt-out program for exchanging contextual backlinks
- Niche matching with quality controls
- DoFollow/NoFollow control, competitor domain exclusion
- AI-powered contextual link placement within content
- Full removal on opt-out

### 💾 Version History & Backups
- Automatic backup before every AI change
- Side-by-side diff viewer
- One-click restore to any previous version

### 🧙 AI-Powered Setup Wizard
- AI analyzes your entire site (posts, pages, categories, menus, theme)
- Auto-detects language and configures AI accordingly
- Infers business type, niche, target audience, and competitive advantage
- Step-by-step guided flow: Analyse → Review → Confirm

### 🖼️ Image Style Settings
- 8 built-in style presets: Photorealistic, Modern Illustration, Watercolor Art, 3D Render, Minimalist, Infographic, Isometric, Hand-Drawn Sketch
- Custom prompt option for brand-specific styles

## Requirements

- **WordPress** 5.8+
- **PHP** 7.4+
- **OpenAI API key** (for AI features) — [Get one here](https://platform.openai.com/api-keys)
- **Google Ads API credentials** (optional, for keyword research) — [Set up here](https://developers.google.com/google-ads/api/docs/get-started/introduction)
- **Google Cloud Console project** (optional, for Search Console) — [Create one here](https://console.cloud.google.com/)

## Installation

1. Upload the `seobot-ai` folder to `/wp-content/plugins/`
2. Activate the plugin through the **Plugins** menu
3. Navigate to **SEOBot AI → Setup Wizard** to configure the plugin
4. Enter your **OpenAI API key** in Settings
5. Start analyzing from the **Dashboard**

## Configuration

### OpenAI Settings
| Setting | Description | Default |
|---------|-------------|---------|
| API Key | Your OpenAI API key (`sk-…`) | — |
| Model | GPT model to use | `gpt-4o` |

### Google Ads Keyword Planner Settings (Optional)
| Setting | Description | Default |
|---------|-------------|--------|
| Developer Token | Your Google Ads API developer token | — |
| OAuth Client ID | OAuth 2.0 Client ID from Google Cloud Console | — |
| OAuth Client Secret | OAuth 2.0 Client Secret | — |
| Refresh Token | OAuth 2.0 refresh token for offline access | — |
| Customer ID | Your Google Ads account customer ID | — |
| Language | Target language for keywords (Google language constant ID) | `1000` (English) |
| Location | Target country (Google geo-target constant ID) | `2840` (US) |

### Google Search Console (Optional)
| Setting | Description |
|---------|-------------|
| Client ID | OAuth 2.0 Client ID from Google Cloud Console |
| Client Secret | OAuth 2.0 Client Secret |

### Analysis Settings
| Setting | Description | Default |
|---------|-------------|---------|
| Duplicate Threshold | Similarity % to flag duplicates | `85%` |

### Image Style
| Setting | Description | Default |
|---------|-------------|---------|
| Style Preset | Visual style for AI-generated images | `Photorealistic` |
| Custom Prompt | Custom style instructions (when "Custom" is selected) | — |

## Admin Pages

| Page | Description |
|------|-------------|
| **Dashboard** | Overview stats + quick actions |
| **Posts Analysis** | Browse all posts, run per-post analysis, bulk actions |
| **Keywords** | Keyword data + Google Search Console analytics |
| **Article Creator** | 3-step AI article generation |
| **Content Plan** | AI editorial calendar with status management |
| **Backlink Exchange** | Opt-in network for contextual backlinks |
| **Users Optimizer** | Audit & optimize author profiles with AI |
| **Categories Optimizer** | Taxonomy audit with AI keep/delete/merge verdicts |
| **Setup Wizard** | AI-powered site analysis and configuration |
| **Backups** | Version history with restore & diff viewer |
| **Settings** | API keys, model, thresholds, image styles, GSC |
| **Addons** | Discover and manage premium add-ons |

## Architecture

```
seobot-ai/
├── seobot-ai.php                   # Bootstrap, constants, autoloader, activation
├── uninstall.php                  # Clean removal of all data
├── assets/
│   ├── css/admin.css              # Admin UI styles
│   └── js/admin.js                # AJAX-driven admin interactions
├── includes/
│   ├── class-plugin.php           # Singleton orchestrator
│   ├── class-admin.php            # Menus, settings, asset enqueue
│   ├── class-ajax-handler.php     # All wp_ajax endpoints
│   ├── class-ai-provider.php      # OpenAI API abstraction
│   ├── class-google-ads-api.php  # Google Ads Keyword Planner API client
│   ├── class-search-console.php   # Google Search Console OAuth + API
│   ├── class-post-fetcher.php     # WP_Query wrapper
│   ├── class-internal-linker.php  # Link analysis & insertion
│   ├── class-content-enricher.php # Content scoring & AI rewrite
│   ├── class-content-planner.php  # AI editorial calendar
│   ├── class-eeat-scorer.php      # E-E-A-T evaluation
│   ├── class-date-updater.php     # Year reference scanning & updating
│   ├── class-duplicate-handler.php# Duplicate detection & merging
│   ├── class-keyword-suggester.php# Google Ads keyword research
│   ├── class-setup-wizard.php     # AI-powered site analysis wizard
│   ├── class-article-creator.php  # Full article generation
│   ├── class-image-generator.php  # GPT Image generation with style presets
│   ├── class-backlink-exchange.php# Backlink exchange network
│   ├── class-backup-manager.php   # Version history & restore
│   └── class-logger.php           # Custom DB table logging
└── templates/
    ├── admin-dashboard.php
    ├── admin-posts.php
    ├── admin-keywords.php
    ├── admin-article-creator.php
    ├── admin-content-plan.php
    ├── admin-backlinks.php
    ├── admin-users.php
    ├── admin-categories.php
    ├── admin-wizard.php
    ├── admin-backups.php
    ├── admin-settings.php
    ├── admin-addons.php
    └── admin-upgrade.php
```

## Database

The plugin creates two custom tables on activation:

- **`{prefix}_seobot_logs`** — Activity log with action type, post reference, message, and JSON details
- **`{prefix}_seobot_keywords`** — Keyword data with search volume, competition, CPC, and source

All tables and post meta are fully cleaned up on uninstall.

## Scheduled Tasks

A daily WP-Cron job runs lightweight scans:
- Date reference scanning across all posts
- Duplicate post detection

## Security

- All AJAX endpoints verify nonces and `manage_options` capability
- Input is sanitized with `sanitize_text_field`, `absint`, and `wp_kses_post`
- API keys are stored in `wp_options` (encrypted at rest if your host supports it)
- Google Search Console uses OAuth 2.0 with state nonce verification

## License

GPL-2.0+ — see [LICENSE](https://www.gnu.org/licenses/gpl-2.0.html)
