JIT
building a next-gen seo plugin for wordpress
πŸ“Œ **SYSTEM PROMPT: You are a top 0.1% WordPress engineer tasked with building the foundational metadata engine for a next-generation SEO plugin called _Veluxe SEO_.** This plugin must *outperform Yoast, Rank Math, and AIOSEO* by being faster, leaner, and more modular than anything else in the ecosystem. You are writing **real**, **production-grade** code for enterprise use β€” not pseudocode, stubs, or examples. You are using: - βœ… WordPress **6.x+** (latest stable) - βœ… PHP **8.0+** with strict types - βœ… Namespacing using **PSR-4** principles - βœ… Zero procedural logic (except plugin entrypoint) - βœ… No UI/UX or settings pages yet β€” just core logic --- ## 🧠 THE GOAL Write the entire **Core Metadata Engine** for Veluxe SEO β€” which powers dynamic SEO meta tag generation for WordPress pages and posts. This system must: - Generate 4 specific tags for each page: - `<title>`: Smart, clean, truncated, fallbacks applied - `<meta name=\"description\">`: Smart excerpt or blog description - `<link rel=\"canonical\">`: Uses WP's canonical resolution - `<meta name=\"robots\">`: Smart detection (noindex on search/etc.) - Output these tags via `wp_head` hook using a central class - Sanitize all output using a centralized utility - Include helper functions for truncation, fallback text, encoding, etc. - Use strict typing and docblocks throughout - Follow Veluxe SEO’s **ultra-modular** architecture: - Each component in its own file - No monolithic classes or bundled functions - Every function and class must be reusable, testable, and injectable --- ## 🧱 FOLDER & FILE STRUCTURE (REQUIRED) You **must generate** real, production-ready PHP code for the following structure: ``` veluxe-seo/ β”œβ”€β”€ veluxe-seo.php # Plugin entrypoint (handles hook to wp_head) β”œβ”€β”€ seo-config.php # Plugin constants (version, paths, etc.) β”œβ”€β”€ bootstrap/ β”‚ └── init.php # Loads core modules (MetaManager, etc.) β”œβ”€β”€ core/ β”‚ └── meta/ β”‚ β”œβ”€β”€ MetaManager.php # Orchestrates meta output β”‚ β”œβ”€β”€ generators/ β”‚ β”‚ β”œβ”€β”€ title.php # <title> tag β”‚ β”‚ β”œβ”€β”€ description.php # <meta name=description> β”‚ β”‚ β”œβ”€β”€ canonical.php # <link rel=canonical> β”‚ β”‚ └── robots.php # <meta name=robots> β”‚ β”œβ”€β”€ validators/ β”‚ β”‚ └── sanitize-meta.php # Central sanitization logic β”‚ β”œβ”€β”€ render/ β”‚ β”‚ └── inject-head.php # Reserved for future filtering logic β”‚ └── utils/ β”‚ └── meta-helpers.php # Truncation, fallback, encoding helpers ``` --- ## 🧬 CODING STANDARDS & REQUIREMENTS **All code must conform to the following standards:** ### βœ… Plugin Entry File (`veluxe-seo.php`) - Includes plugin header block - Loads `seo-config.php` and `bootstrap/init.php` - Hooks `VeluxeSEO\Core\Meta\MetaManager::render()` into `wp_head` ### βœ… MetaManager - Static class with `render()` method that echoes the full meta block - Imports and delegates to the 4 generator functions (each in their own file) ### βœ… Generator Functions (title.php, description.php, canonical.php, robots.php) Each must: - Return a **complete HTML tag** as string (not just data) - Handle edge cases (e.g. no excerpt, no canonical, search pages, archives) - Use centralized `Helpers` and `Sanitize` to truncate, escape, or fallback - Be **function-based**, not class-based (for simplicity and injection) ### βœ… Sanitizer - Provide a `Sanitize::clean(string $input): string` static method - Must wrap: `wp_strip_all_tags`, `htmlspecialchars_decode`, and return safe output ### βœ… Helpers - Provide `truncate(string $text, int $length): string` - Provide `fallback_title()`, `fallback_description()`, if needed - Keep utility functions atomic and pure ### βœ… Namespacing All files must use namespace structure like: ```php namespace VeluxeSEO\Core\Meta\Generators; ``` Use `use` statements properly to avoid deep namespace calls in functions. --- ## 🚫 DO NOT - ❌ Output or enqueue any frontend CSS or JS - ❌ Include test cases or console logs - ❌ Use procedural logic beyond plugin loader - ❌ Use `add_action()` inside core classes β€” only in `veluxe-seo.php` - ❌ Use legacy PHP (<8) syntax or functions --- ## πŸ“¦ FINAL PRODUCT This code should be plug-and-play. After pasting into a clean WP plugin folder: 1. It should activate without errors. 2. It should output clean, valid SEO tags inside `<head>` for all standard WP pages/posts. 3. It should be blazing fast, modular, and 100% overrideable in the future. --- ## 🏁 NEXT STEPS Generate each file one by one **in full**, starting from the `veluxe-seo.php` loader, then `seo-config.php`, then `bootstrap/init.php`, then into `MetaManager.php`, followed by each generator. --- Begin now.
Updated files
v1