Skip to content

Add WordPress Playground blueprint with relative-date demo data - #37

Open
datengraben wants to merge 4 commits into
masterfrom
claude/wordpress-playground-booking-blueprint-uuyfi1
Open

Add WordPress Playground blueprint with relative-date demo data#37
datengraben wants to merge 4 commits into
masterfrom
claude/wordpress-playground-booking-blueprint-uuyfi1

Conversation

@datengraben

Copy link
Copy Markdown
Owner

Summary

Adds a WordPress Playground blueprint that boots a throwaway WordPress instance in the browser with CommonsBooking pre-installed and populated with sample data. The key innovation is that all booking dates are expressed as relative offsets from the current time, ensuring the demo always appears current regardless of when it's accessed.

Changes

  • playground/blueprint.json — WordPress Playground blueprint configuration that:

    • Pins PHP 8.1 and WordPress 6.9 (matching .wp-env.json)
    • Sets timezone to Europe/Berlin before data generation
    • Installs and activates CommonsBooking from wordpress.org
    • Deploys the demo data generator as a must-use plugin
    • Lands users on the bookings admin list
  • playground/generate-demo-data.php — Must-use plugin that generates demo data on first request:

    • Creates 2 locations and 2 items
    • Creates wide bookable timeframes (7 days past to 30 days future)
    • Generates 6 sample bookings with relative date offsets:
      • Past completed booking (6-4 days ago)
      • Booking ending today (-1 to 0 days)
      • Booking starting today (0-2 days)
      • Upcoming confirmed bookings (5-7 and 12-14 days ahead)
      • Pending unconfirmed request (3-4 days ahead)
    • Creates a front page with [cb_items_table] shortcode
    • Uses one-shot option guard to run exactly once per Playground instance
  • playground/README.md — Documentation covering:

    • How to access the demo via a shareable Playground URL
    • What the blueprint does and why
    • How the data generator works
    • Instructions for updating the embedded PHP in the blueprint JSON

Implementation Details

  • The generator runs as a must-use plugin (not via runPHP step) to execute within a fully booted WordPress context
  • All dates anchor to a single current_time('timestamp') call that respects the site's timezone setting
  • Post type slugs and meta keys are kept as literals (with comments referencing CommonsBooking constants) to avoid compile-time dependencies and ensure robustness across boot ordering
  • The blueprint is self-contained; generate-demo-data.php is the source of truth and can be re-embedded into the JSON via a provided jq command

https://claude.ai/code/session_01DgRcdn1jVhMAUVZBKJQGoJ

claude added 4 commits July 21, 2026 18:07
Introduce a self-contained WordPress Playground blueprint that boots a
throwaway WordPress, installs CommonsBooking, and seeds sample data whose
dates are relative offsets from the current time (never hardcoded), so the
demo always looks current.

- playground/blueprint.json: pins preferredVersions (WP 6.9 / PHP 8.1),
  sets timezone_string before data generation, logs in as admin, installs
  CommonsBooking from wordpress.org, and drops the generator as a mu-plugin
  via writeFile (no runPHP step, no static WXR import).
- playground/generate-demo-data.php: mu-plugin that runs inside a fully
  booted request and, guarded to run once per instance, creates locations,
  items, bookable timeframes and bookings using
  strtotime('+N days', current_time('timestamp')) offsets. Mirrors the
  proven pattern in tests/php/CPTCreationTrait.php.
- playground/README.md: ready-to-click playground.wordpress.net URL, an
  explanation of each blueprint step, and the follow-up scope for installing
  the latest master (nightly) build instead of the released plugin.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgRcdn1jVhMAUVZBKJQGoJ
WordPress Playground's blueprint schema requires an 'author' property on
the 'meta' object; booting without it failed with InvalidBlueprintError.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgRcdn1jVhMAUVZBKJQGoJ
Add a one-click Playground launch button to the root README, matching the
WordPress Playground examples gallery style, pointing at the blueprint on
master via ?blueprint-url=. Bundle the official Playground button SVG and
exclude the playground/ demo tooling from the distributed plugin zip.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgRcdn1jVhMAUVZBKJQGoJ
Extract the inline PHP generator out of blueprint.json into its own
playground/test-data.php (renamed from generate-demo-data.php). The blueprint's
writeFile step now references the file by URL (a 'url' resource) instead of
embedding a copy, making test-data.php the single source of truth and shrinking
blueprint.json from ~10KB to ~1KB.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgRcdn1jVhMAUVZBKJQGoJ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants