logo
Advanced2min read

Architecture

Internal plugin architecture — class structure, modules and the AI proxy flow.

Plugin Architecture

text
schemafy/
├── 1.0.1.php                           # Main plugin file
├── includes/
│   ├── class-baseo-core.php            # Main orchestrator
│   ├── class-baseo-database.php        # Database operations
│   ├── class-baseo-admin.php           # Admin interface + AJAX handlers
│   ├── class-baseo-validator.php       # JSON + Schema.org validation
│   ├── class-baseo-schema-injector.php # Frontend head injection
│   ├── class-baseo-seo-detector.php    # Detects Yoast, Rank Math, etc.
│   ├── class-baseo-rest-api.php        # REST API endpoints
│   ├── class-baseo-meta-box.php        # Post editor meta boxes
│   ├── class-baseo-gutenberg.php       # Gutenberg sidebar
│   ├── builders/
│   │   ├── class-baseo-field-generator.php  # Form field generation
│   │   └── class-baseo-schema-builder.php   # Smart Builder logic
│   ├── ajax-handler-save-update.php    # Save/update handlers
│   └── ajax-handler-dashboard.php      # Dashboard handlers
├── assets/js/modules/
│   ├── admin-modular.js                # Entry point
│   ├── core/init.js                    # Tab management
│   ├── dashboard/dashboard.js          # Dashboard UI
│   ├── bulk/bulk-manager.js            # Bulk operations
│   ├── operations/schema-crud.js       # CRUD
│   ├── editor/manual-editor.js         # JSON editor
│   ├── ai/ai-generator.js              # AI generation
│   ├── builder/smart-builder.js        # Visual builder
│   └── import-export/csv-handler.js    # CSV tools
└── templates/builder/field-configs/    # JSON config per schema type

AI Generator proxy flow

text
WordPress plugin
    │  POST: page content
    ▼
endpoint-schemafy.vercel.app  ← API key stored here (never in the plugin)
    │  Calls GPT-4o with schema-specific prompt
    ▼
OpenAI
    │  Returns validated JSON-LD
    ▼
Plugin → review UI → user approves → saved to database

What happens when a page loads

  1. WordPress receives the page request
  2. Schemafy queries wp_baseo_custom_schemas for active schemas matching the current URL
  3. Matching schemas are serialized as JSON-LD
  4. JSON-LD is injected into <head> via wp_head at priority 5
  5. Meta tags are injected at priority 1, social tags at priority 2
  6. The visitor sees no difference — JSON-LD is invisible to humans
  7. Google reads it and may use it for rich results

Was this page helpful?