WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Implement Core Data Model: Events and Speakers #17

@mariobehling

Description

@mariobehling

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

  1. Create the core CPTs:

    • event – stores individual event pages (title, description, date, venue, etc.)

    • speaker – stores speaker profiles (name, organization, photo URL, bio)

  2. Register relations between events and speakers via post meta.

  3. Implement meta boxes / REST fields for these attributes.

  4. Ensure full internationalization (i18n) and sanitization.

  5. Provide a minimal seed or WP-CLI command to populate 2–3 sample entries (no bundled images).

  6. 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_event and /wp-json/wp/v2/wpfa_speaker return valid data.

  • Adding an event with speakers correctly stores relationships.

  • CPT archives display properly with permalinks flushed.


✅ Acceptance Criteria

  • wpfa_event and wpfa_speaker CPTs 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.md updated


🔗 References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions