-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Goal: Re-implement the functionality shown in the old MVP plugin using a clean, extensible, and standards-compliant structure.
🧭 Context
The initial MVP plugin contained a hard-coded list of events and speakers directly embedded in PHP templates and bundled with image assets.
While it served as a demo, it’s not maintainable or reusable.
We now have a proper plugin skeleton (PR 1). The next step is to build the data model for events and speakers using native WordPress constructs — Custom Post Types (CPTs) and metadata — without any embedded media or hard-coded data.
🎯 Objectives
-
Create the core CPTs:
-
event– stores individual event pages (title, description, date, venue, etc.) -
speaker– stores speaker profiles (name, organization, photo URL, bio)
-
-
Register relations between events and speakers via post meta.
-
Implement meta boxes / REST fields for these attributes.
-
Ensure full internationalization (i18n) and sanitization.
-
Provide a minimal seed or WP-CLI command to populate 2–3 sample entries (no bundled images).
-
Prepare for later PRs that will add UI rendering (shortcodes/blocks).
🏗️ Implementation Details
1️⃣ Custom Post Type: Event
register_post_type( 'wpfa_event', [
'labels' => [
'name' => __( 'Events', 'wpfa-event' ),
'singular_name' => __( 'Event', 'wpfa-event' ),
],
'public' => true,
'menu_icon' => 'dashicons-calendar-alt',
'supports' => [ 'title', 'editor', 'excerpt', 'thumbnail' ],
'show_in_rest' => true,
'rewrite' => [ 'slug' => 'events' ],
] );
Meta Fields:
| Key | Type | Description |
|---|---|---|
| wpfa_event_start_date | date | Event start date |
| wpfa_event_end_date | date | Event end date |
| wpfa_event_location | string | Venue / location |
| wpfa_event_url | string | External link (Eventyay page, etc.) |
| wpfa_event_speakers | array | Related speaker IDs |
3️⃣ Relationships
Use bidirectional links via post meta or the REST API:
-
When assigning speakers to an event, store their IDs in
wpfa_event_speakers. -
Optionally sync reverse relations in
wpfa_speaker_events.
Later PRs (Admin UI) can improve this with a relationship selector.
4️⃣ Meta Boxes
Add meta boxes for both CPTs in the admin interface:
-
Event Editor → date fields + location + speakers (multiselect by name)
-
Speaker Editor → org + position + photo URL + related events
Use wp_nonce_field() and sanitize_text_field(), esc_url_raw(), etc.
5️⃣ REST API Integration
Expose meta fields through the REST API via:
register_post_meta( 'wpfa_event', 'wpfa_event_start_date', [
'show_in_rest' => true,
'single' => true,
'type' => 'string',
] );
All fields should be accessible for future frontend rendering (React block or shortcode).
6️⃣ Sample Seeder Command (optional)
Provide a simple WP-CLI command:
wp wpfa seed --minimal
that inserts 2 events and 3 speakers with placeholder content and CC0 image URLs (e.g. https://via.placeholder.com/150).
7️⃣ Testing & Validation
-
After activation, both CPTs appear in the WP Admin menu.
-
REST API endpoints
/wp-json/wp/v2/wpfa_eventand/wp-json/wp/v2/wpfa_speakerreturn valid data. -
Adding an event with speakers correctly stores relationships.
-
CPT archives display properly with permalinks flushed.
✅ Acceptance Criteria
-
wpfa_eventandwpfa_speakerCPTs registered with correct labels & icons -
Meta fields registered and visible in REST
-
Admin meta boxes implemented with nonce checks and data sanitization
-
Minimal seeder or importer exists (no bundled media)
-
i18n applied for all strings
-
PHPCS passes with no errors
-
Documentation in
README.mdupdated