Project
Each brief below is a piece of work to do on a local site, with a list to check it against when you are done.
Set up #
Run a local site with npx wp-env start, as in Run locally. It comes with the debugger: click the heart in the admin bar to see every row in the rooms you are in.
Brief 1: a custom room #
Show who else has a screen open that is not a post, such as a plugin's settings page or an order.
Builds on Rows and rooms, Writers and Heartbeat and tabs. Start from Custom rooms in the README.
Done when:
- Two users, in two browsers, each see the other's name on the screen.
- Closing one browser removes that name from the other within 150 seconds.
wp presence liston your room shows one row per person, under your plugin's own prefix.
Brief 2: a push transport #
Refresh a tab the moment a row changes, instead of at the next Heartbeat tick.
Builds on Readers and Push transports.
Done when:
- While your filter returns
falsefrompresence-api.keepalive, thedate_gmtof youruser-{id}row stops moving unless your code writes it. - Your code writes that row with the state
wp_presence_admin_state()builds. - A listener on
set_presencemakes open tabs firepresence-api.roomChanged, and the admin bar updates without waiting for a tick.