# BW Babel — Phase 2 Roadmap

**Phase 1 Status:** ✅ COMPLETE  
**Phase 2 Target:** Schema Output + Frontend Integration  
**Estimated Duration:** 5-7 days  

---

## Phase 2 Overview

Phase 1 built a solid admin foundation. Phase 2 outputs the actual schema markup that search engines need. This is where the plugin's core value is realized.

**Phase 2 Tasks:**

1. Frontend schema markup system
2. Organization & LocalBusiness schema
3. Person & team schema
4. Article schema for posts
5. Breadcrumb navigation schema
6. Cache strategy for schema output

---

## Task 2.1: Frontend Schema Output System

**Goal:** Create the rendering pipeline for schema markup

**What to build:**

```
includes/
├── class-bw-babel-schema-renderer.php   (Main renderer)
├── class-bw-babel-schema-validator.php  (JSON-LD validation)
└── schema-types/
    ├── class-bw-babel-schema-base.php
    ├── class-bw-babel-schema-organization.php
    ├── class-bw-babel-schema-localbusiness.php
    ├── class-bw-babel-schema-person.php
    ├── class-bw-babel-schema-article.php
    ├── class-bw-babel-schema-breadcrumb.php
    └── class-bw-babel-schema-faqpage.php
```

**Key Features:**
- ✓ Base schema class (common methods)
- ✓ Schema-specific renderers (inherit from base)
- ✓ Validation against schema.org specs
- ✓ Caching rendered output
- ✓ Hook for custom schemas (extensibility)

**Entry Point:**
```php
// Hook in wp_head
add_action( 'wp_head', 'bw_babel_output_schema' );

function bw_babel_output_schema() {
    $schemas = BW_Babel_Schema_Renderer::get_page_schemas();
    foreach ( $schemas as $schema ) {
        echo '<script type="application/ld+json">' 
            . wp_json_encode( $schema ) 
            . '</script>';
    }
}
```

**Estimated:** 2-3 days

---

## Task 2.2: Organization & LocalBusiness Schema

**Goal:** Output organization info + location schema

**What to build:**

1. **BW_Babel_Schema_Organization** (200 lines)
   - Render from Service_Organization data
   - Include logo, contact, social profiles
   - Handle business types (LocalBusiness, Restaurant, etc.)

2. **BW_Babel_Schema_LocalBusiness** (150 lines)
   - Per-location schema
   - Address, phone, hours, services
   - Maps integration
   - Service area polygon (if configured)

3. **Integration Tests**
   - Test schema validation
   - Check JSON-LD structure
   - Verify required fields

**Front-end Output:**
```html
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "LocalBusiness",
  "name": "Business Name",
  "image": "logo.jpg",
  "description": "Business description",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "123 Main St",
    "addressLocality": "City",
    "postalCode": "12345",
    "addressCountry": "US"
  },
  "telephone": "+1-555-555-5555",
  "url": "https://example.com"
}
</script>
```

**Estimated:** 1-2 days

---

## Task 2.3: Person & Team Schema

**Goal:** Output author/team member schema

**What to build:**

1. **BW_Babel_Schema_Person** (200 lines)
   - Team member profile schema
   - Author schema on posts
   - Biographical info
   - Social profiles

2. **Author Integration** (100 lines)
   - Hook into single post template
   - Output `author` field in Article schema
   - Author redirect handling

3. **Team Page Schema**
   - Person collection schema
   - Team directory page

**Front-end Output:**
```html
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Person",
  "name": "Team Member Name",
  "jobTitle": "Role",
  "url": "https://example.com/team/member",
  "image": "photo.jpg",
  "description": "Biography"
}
</script>
```

**Estimated:** 1-2 days

---

## Task 2.4: Article Schema for Posts

**Goal:** Rich snippets for blog posts

**What to build:**

1. **BW_Babel_Schema_Article** (200 lines)
   - Output for single posts
   - Author reference
   - Featured image
   - Publish/modified dates
   - Article body (optional)

2. **Post Meta Integration**
   - Hook `wp_head` on single posts
   - Query post data + author
   - Render schema

3. **NewsArticle Variant** (optional Phase 2.5)
   - For news-style posts
   - Headline, byline, etc.

**Front-end Output:**
```html
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "Post Title",
  "image": "featured.jpg",
  "author": { "@type": "Person", "name": "Author" },
  "datePublished": "2026-08-05",
  "dateModified": "2026-08-05"
}
</script>
```

**Estimated:** 1 day

---

## Task 2.5: Breadcrumb Navigation Schema

**Goal:** Search result breadcrumbs for site navigation

**What to build:**

1. **BW_Babel_Schema_Breadcrumb** (150 lines)
   - Auto-generate from post hierarchy
   - Configurable breadcrumb separator
   - Handle custom post types

2. **Theme Integration**
   - Hook into `wp_head` on all pages
   - Generate from `get_breadcrumb_trail()` helper
   - Cache breadcrumb output

**Front-end Output:**
```html
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    { "@type": "ListItem", "position": 1, "name": "Home", "item": "https://example.com" },
    { "@type": "ListItem", "position": 2, "name": "Blog", "item": "https://example.com/blog" },
    { "@type": "ListItem", "position": 3, "name": "Post Title", "item": "https://example.com/post" }
  ]
}
</script>
```

**Estimated:** 1 day

---

## Task 2.6: Schema Caching & Performance

**Goal:** Cache rendered schema output

**What to build:**

1. **Enhance BW_Babel_Service_Cache**
   - Cache full schema JSON
   - Invalidate on post/option changes
   - Cache key strategy

2. **Invalidation Hooks**
   - Clear on save_post
   - Clear on option update
   - Clear on plugin update

3. **Performance Logging**
   - Track schema render time
   - Log cache hits/misses
   - Health dashboard

**Estimated:** 1 day

---

## Task 2.7: FAQPage Schema (Optional)

**Goal:** FAQ structured data (if site has FAQ feature)

**What to build:**

1. **BW_Babel_Schema_FAQPage** (150 lines)
   - Auto-detect FAQ-type posts
   - Parse Q&A format
   - Render FAQPage schema

**Estimated:** 1 day (optional)

---

## Testing Phase 2

1. **Rich Results Test**
   - https://search.google.com/test/rich-results
   - Paste schema URLs, verify output

2. **Schema.org Validator**
   - https://schema.org
   - Manual validation of each schema type

3. **Frontend Testing**
   - Check `<head>` for `<script type="application/ld+json">`
   - Validate JSON syntax
   - Verify data matches expectations

---

## File Structure After Phase 2

```
bw-babel/
├── admin/                  (Phase 1 — Admin UI)
├── includes/
│   ├── class-bw-babel-*.php         (Phase 1 — Core)
│   ├── class-bw-babel-schema-*.php  (Phase 2 — Rendering)
│   └── schema-types/
│       ├── class-bw-babel-schema-base.php
│       ├── class-bw-babel-schema-organization.php
│       ├── class-bw-babel-schema-localbusiness.php
│       ├── class-bw-babel-schema-person.php
│       ├── class-bw-babel-schema-article.php
│       ├── class-bw-babel-schema-breadcrumb.php
│       └── class-bw-babel-schema-faqpage.php
├── public/                           (Phase 2 — Frontend)
│   ├── class-bw-babel-frontend.php
│   └── hooks/                        (Output hooks)
└── docs/
    ├── BABEL-BUILD.md
    ├── PHASE-1-COMPLETE.md
    └── PHASE-2-ROADMAP.md             (This file)
```

---

## Estimated Timeline

| Task | Days | Status |
|------|------|--------|
| 2.1 Schema System | 2-3 | Planned |
| 2.2 Organization | 1-2 | Planned |
| 2.3 Person | 1-2 | Planned |
| 2.4 Article | 1 | Planned |
| 2.5 Breadcrumb | 1 | Planned |
| 2.6 Caching | 1 | Planned |
| 2.7 FAQ (opt) | 1 | Optional |
| Testing | 1 | Planned |
| **Total** | **5-7** | |

---

## When Phase 2 is Done

✓ Every page outputs schema markup  
✓ Search engines understand site structure  
✓ Rich results appear in Google Search  
✓ Articles show with author & images  
✓ Local businesses show with location & hours  
✓ All schema validated & tested  

---

## Phase 3 Preview (Post Phase 2)

After Phase 2, Phase 3 would cover:

- **Advanced Schemas** — Recipe, Event, Video
- **Settings UI Polish** — Full editors for locations, rooms
- **WP-CLI Integration** — Command-line tools
- **REST API** — Headless schema access
- **Analytics** — Track schema performance
- **Integrations** — Yoast SEO, WP SEO, etc.

---

**Next: Begin Phase 2 Task 2.1 (Schema Rendering System)**
