Skip to content
bleedingdeaconsPublic

About

Divi 5 module: carousel of upcoming events from The Events Calendar

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

What's On

CI Semgrep Coverage Status PHPStan PHPCS Version PHP Licence

A Divi 5 module that shows upcoming events from The Events Calendar as a carousel, one event at a time: the featured image on the left, and on the right the title with the date and time under it. The whole card links to the event; on a phone the image stacks above the text. The carousel moves to the next event every 5 seconds by default, wrapping from the last back to the first, and pauses while a visitor hovers over or focuses it, or the tab is hidden. Previous / next buttons move it one event at a time, as do swipe, trackpad and the arrow keys when it has focus.

Requires Divi 5 (developed against 5.19.0) and The Events Calendar (6.x). PHP 8.6+.

Module settings

Panel Group Setting
Content Events Number of events, event category slugs (comma-separated), featured only, date format (blank = the site language's regional format), show time, "no events" text
Content Carousel Loop, auto scroll (on by default), auto scroll interval in seconds (default 5), show previous / next buttons
Design Event Card Background, border, box shadow
Design Image Border, filters
Design Title Text / Date Text Full Divi font controls (title heading level defaults to H3)
Design Previous / Next Buttons Arrow colour, background, border, box shadow
Advanced The usual Divi options, plus Custom CSS for track, card, image, title, date and buttons

Only public events that have not ended are shown, soonest first: published (never drafts, pending, scheduled or private events), not password-protected, and not marked "Hide From Event Listings" in The Events Calendar. Past events never appear.

Dates follow the site language's regional format (Settings → General → Site Language), through PHP's intl extension: the locale decides the order of day and month, 12- or 24-hour time and the punctuation. For English (UK):

  • Same day: Fri, 20 Nov 2026, 19:00–21:30
  • All day: Fri, 20 Nov 2026, all day
  • Multi-day: Sat, 21 Nov 2026, 19:00 – Mon, 23 Nov 2026, 16:00

and for English (US) Fri, Nov 20, 2026, 7:00 PM–9:30 PM. A module's own Date Format field (a PHP date format) overrides this, and a server without intl falls back to the Date and Time Formats in Settings → General.

A carousel with only one event shows that event with no previous / next buttons and no auto scroll.

Filters: whats_on/query_args (arguments passed to tribe_get_events()) and whats_on/image_size (default large). Kill switch: define( 'WHATS_ON_KILL', true ); in wp-config.php.

Layout

whats-on.php                     plugin header + bootstrap
modules-json/events-carousel/    module.json: Divi 5 metadata, attributes and settings panels
src/                             PHP (namespace WhatsOn\)
  Plugin.php                     hooks
  Assets.php                     front-end + Visual Builder asset registration
  Divi/EventsCarouselModule.php  Divi render callback, classnames, styles
  Events/                        query options, TEC repository, date formatting
  Render/                        carousel markup (no Divi/WP dependency, unit-tested)
  Rest/EventsController.php      GET /wp-json/whats-on/v1/events (builder preview data)
  Support/Attrs.php              typed reads from Divi attributes, meta and options
assets/src/frontend/             carousel behaviour + CSS (shared with the builder)
assets/src/builder/              Visual Builder module (React edit renderer)
assets/build/                    compiled output (committed so the plugin runs without a build)
tests/php/                       Pest over wp-mocks (the suite's shared WordPress doubles)
tests/js/                        Vitest + jsdom
tests/phpstan/                   PHPStan stubs for the parts of Divi 5 and TEC the plugin calls
bin/dev.ps1                      Local site helper (link, seed, WP-CLI, Composer)
bin/seed.php                     sample events + demo page
build.php                        the suite's build script: npm assets, then the release zip

How the Divi 5 parts fit together:

  • PHP registers the module on divi_module_library_modules_dependency_tree with ModuleRegistration::register_module() and renders it with Module::render().
  • The builder bundle is registered on divi_visual_builder_assets_before_enqueue_scripts through PackageBuildManager, and registers the module on the divi.moduleLibrary.registerModuleLibraryStore.after hook. Its settings panels are generated from module.json ("settings": { "content": "auto", ... }), so the JS only supplies the edit renderer and styles.
  • react and @divi/* imports are mapped to Divi's globals (window.vendor.React, window.divi.module, …) by build.mjs. Nothing from Divi is bundled.
  • The builder preview fetches the same events through the REST endpoint (editors only), and uses the same carousel script as the front end.

Development

The dev environment is the aa-bristol-future site in Local, which has Divi 5 and The Events Calendar. Start it in Local first. To use a different Local site, pass -Site <name> or set WHATS_ON_SITE.

npm run dev:setup

That command installs the JS dependencies, builds the assets, and junctions wp-content/plugins/whats-on to this checkout. It then activates the plugin and seeds the site. After that, edits here are live on the site.

bin/dev.ps1 reads the site's PHP, php.ini and MySQL port from Local's own config and uses Local's bundled WP-CLI and Composer, so nothing else needs installing. Run it with pwsh (PowerShell 7). Windows PowerShell 5 blocks unsigned scripts by default.

Command Does
pwsh bin/dev.ps1 info Resolved paths and URLs
pwsh bin/dev.ps1 seed 13 sample events (one past, one all-day, one multi-day, one without an image, two featured, three categories, and four upcoming but not public: private, draft, password-protected and hidden from listings) and two demo pages: /whats-on-demo/ (the module's defaults) and /whats-on-demo-single/ (one event, centred). Re-running replaces them
pwsh bin/dev.ps1 reset Removes the sample data only. Everything seeded is tagged _whats_on_sample
pwsh bin/dev.ps1 wp … Any WP-CLI command against the site
pwsh bin/dev.ps1 composer … Local's Composer, run in this checkout
pwsh bin/dev.ps1 unlink Removes the junction (with rmdir, never a recursive delete)

Day to day:

npm run watch

The first time, install the PHP dependencies with pwsh bin/dev.ps1 composer install.

Quality gates

CI runs all of these on every PR, on PHP 8.6. Run them locally through bin/dev.ps1, so Composer and every tool it starts use Local's PHP:

Command Gate
pwsh bin/dev.ps1 composer test Pest, over wp-mocks
npm test Vitest (carousel behaviour, builder attribute parsing)
pwsh bin/dev.ps1 composer phpstan PHPStan level 9 with the WordPress extension, no baseline
pwsh bin/dev.ps1 composer phpcs PSR-12 (composer phpcs:fix applies the automatic fixes)
pwsh bin/dev.ps1 composer build:production Builds the release zip; CI also checks assets/build is current

CI also runs composer validate, composer audit, npm audit, a PHP lint and Semgrep, and uploads coverage to Coveralls (advisory).

Release

Merging to main is the release, as for every suite plugin. After the gates pass, CI:

  1. derives the level from the commit prefixes since the last v* tag (feat! → major, feat: → minor, anything else → patch);
  2. writes the new version into the whats-on.php header;
  3. runs composer build:production, which builds the assets, syncs the version into readme.txt and the README badge, and writes build/whats-on-production-<version>.zip;
  4. commits that as chore(release): vX.Y.Z [skip ci] and publishes a GitHub Release with the zip.

/deploy test whats-on then installs it. To release without a merge, run the CI workflow manually (workflow_dispatch).

About

Divi 5 module: carousel of upcoming events from The Events Calendar

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages