The call screen
The Better Messages call screens on any page, with no JavaScript to write: a call button, a group call button, the ring for incoming calls, and the call window with the usual controls, in the corner of the page or in a place of its own in it. With them come the other ready-made parts of Better Messages: who is in a room (presence) and the chat, with its call in it (events). The live stream player and studio are ready-made too (live streams).
Optional, as every ready-made part: from your own code and your own screen below place, answer and draw calls with no element.
add_action( 'wp_enqueue_scripts', function () {
if ( is_user_logged_in() ) {
wordplus_realtime()->call_screen();
}
} );
<call-button to="34" call="support:34:42" type="video" name="Ann" avatar="https://…/ann.jpg">Call Ann</call-button>
<room-button room="staff:daily" type="video" title="Staff meeting">Join the staff meeting</room-button>
<online-list room="shop" call="support:{pair}" type="video"></online-list> <!-- a call button on the row of every member -->
{pair} in call is filled in with the page user and the one called, in order, on either element: support:{pair} is support:34:42 whichever of the two calls.
Who may call whom is still for your plugin to decide, in its calls() and group_calls() rules (calls, group calls). The screen shows the refusal it gets.

The elements
| Element | What it is |
|---|---|
<call-button> | a button that calls someone |
<room-button> | a button that joins a group call |
<call-spot> | a place in the page for a call, in place of the window in the corner |
<call-screen> | where the call screen draws, with templates of your own |
<online-list> | who is in a presence room, with call buttons |
<online-count> | how many are in a room |
<typing-line> | who is typing in a room |
<chat-room> | a conversation on a room, and with call, its call in it (its call) |
<live-stream> | a live stream, or one of its parts |
<stream-studio> | the studio of a live stream, for its host |
call_screen() or ui() loads all but the last two, which stream_screen() loads. An element on the page before its script loads draws once it has.
Where to load it
call_screen() enqueues the screen and everything it runs on (realtime-ui.min.js after the calls script), and returns false on a site without credentials. Call it while scripts are enqueued (wp_enqueue_scripts):
- On the pages with the buttons, so they work.
- On every page a person may be called on. A call rings only on pages that load the screen (or your own calls code). The calls of a support agent ring on any page of the site they have open, when every page loads it.
ui()loads the same parts on a page that should not ring: its buttons, who is in a room and the chat work, and the page holds no line, so the user calls ring only on their other pages.call_screen( array( 'ring' => false ) )is the same.
The media client for group calls loads only when one is joined.
<call-button>
A button that places a call between two people.
| Attribute | |
|---|---|
to | the user id to call |
call | the call name, which your calls() rule owns. {pair} is the page user and to in order, {me} the page user, {id} is to |
type | video (default) or audio |
name, avatar | how the window shows the person called |
Its content is the text of the button. The button is the part button: call-button::part(button) { … }.
<room-button>
A button that joins a group call.
| Attribute | |
|---|---|
room | the group call name, which your group_calls() rule owns |
type | video (default) or audio |
title | the window title |
Its content is the text of the button, the part button.
<call-spot>
A call shows in a window in the corner, over the page. A <call-spot> shows the calls it names in the page itself, where you put it:
<call-spot call="support:{a}:{b}" style="height: 480px">
<img src="https://example.com/agent.jpg" alt="Your support agent">
</call-spot>
| Attribute | |
|---|---|
call | the calls it shows: the name of a call (support:34:42), a pattern as your rules write them (support:{a}:{b}), or a group call (staff:daily). Without it, every call. Where two spots on a page take the same call, the one that names it most closely wins: its name, then a pattern, then every call |
- It moves, and goes on: a call shows in the spot as it starts, or as the spot comes onto the page, and goes back to the window in the corner when the spot leaves the page, going on throughout.
- Another page of the site loads anew, and that ends the call: keep the spot on the page the call happens on.
- Its size is the one your page gives it, 360px high when you give none, and the call fills it.
- What is inside shows while no call is there. With nothing inside, the spot takes no place until a call comes.
data-callholds the name of the call while one is in it, for your CSS:call-spot[data-call] { … }.- The ring still shows in the corner, on any page.
A chat shows its own call too, beside its messages: its call.
<call-screen>
The call screen draws by itself, in an element of its own at the end of the page. Write <call-screen> on the page, in a template or in wp_footer, to give it templates of your own:
<call-screen>
<template slot="ring-card">
<div class="ring"><b data-field="name"></b> is calling
<button data-action="answer">Pick up</button> <button data-action="reject">Not now</button></div>
</template>
<template slot="control" data-control="raise" data-label="Raise hand" data-icon="raisehand"></template>
</call-screen>
- Templates:
ring-card,call-status, andcontrol, a button of yours in the call controls. When it is pressed, the page hearsrealtime-control, withdetail.controlits name. - Parts:
ring-card,call-window,call-status,video-tile,self-view,call-controls,grid-tile:call-screen::part(call-window) { … }. - More on templates and parts, element by element: customizing the screens.
The ring and the call window
- The ring: when the page user is called, the Better Messages ring says who calls, with Accept and Decline, and a ring tone plays (where the browser allows sound before a click). It goes as soon as the call stops ringing anywhere: answered or declined on another tab or device, called off, or unanswered. A ring into a group call says who is adding the user.
- The call window: the picture and sound of the other side, the camera of the page, the status, a timer, and mute, camera, screen share and hang up. A group call grid with the speakers marked. A lock says when its media is encrypted end to end.
- Add person, once a call is up, when your plugin lists people the user may add (below). The window goes on as the group call the call became.
- A host of a group call, whom its rule answers
admin: true, gets Mute Microphone, Block Broadcast, Allow Broadcast and Kick User on the tile of each of the others (the host).
It opens the camera and the microphone when the call starts, and stops them when it ends, so the camera light goes off with the call.

Whom it offers to add
The screen offers no one until your plugin lists people, with people where it declares its calls:
wordplus_realtime()->calls( 'support:{a}:{b}', $rule, array(
'people' => function ( $user_id, $call ) {
return get_users( array( 'role' => 'editor', 'fields' => 'ID' ) ); // the shop staff
},
) );
It answers user ids. The window lists each with their name and picture, leaving out anyone your rule would not let the user call about $call, the user themselves, and anyone already in the call. It asks once a call is up, so a page that never calls never asks.

Its words
The screens carry their own words in English, German, Spanish, French, Italian, Dutch, Polish, Croatian and Hebrew, and show them in the site language (determine_locale()). The filter wordplus_realtime_screen_strings changes any of them by its English text, a plural as a list of its forms:
add_filter( 'wordplus_realtime_screen_strings', function ( $strings ) {
$strings['Add Person'] = __( 'Invite', 'my-plugin' );
return $strings;
} );
Their names
The elements have plain names, so the pages of a site name nothing but the site. The filter wordplus_realtime_element_prefix puts a name of the site before each, for markup all its own, or where another plugin has an element of the same name:
add_filter( 'wordplus_realtime_element_prefix', function () {
return 'shop';
} );
The elements are then <shop-call-button>, <shop-room-button>, <shop-chat-room> and the rest. A plugin writes each name through wordplus_realtime()->element_name( 'call-button' ), so its markup follows whatever the site sets, as stream_element() does for <live-stream>. One prefix a site: lowercase letters and digits, starting with a letter, with hyphens between them.
Its look
The look of Better Messages, drawn in shadow roots, so the styles of a theme do not reach in. Right-to-left pages mirror it.
- Colours and corners are the Better Messages custom properties, such as
--bm-color-accent: 37, 99, 235(red, green and blue). Each element keeps its own in its shadow root, so set them on the elements themselves:call-screen, chat-room, online-list { --bm-color-accent: 37, 99, 235; }. Set there, they hold in light and dark alike. - Light and dark follow the system, or the page when it says which:
bm-messages-lightorbm-messages-darkon<body>, as for the screens of Better Messages, or acolor-schemenaming one alone.
From your own code
The screen is also window.wordplusRealtimeUi:
wordplusRealtimeUi.place( 'support:34:42', 34, 'video', { name: 'Ann' } ); // what <call-button> does
wordplusRealtimeUi.join( 'staff:daily', 'video', 'Staff meeting' ); // what <room-button> does
It starts by itself once the page has loaded, with the settings call_screen() printed. wordplusRealtimeUi.start( { lang, strings, add } ) starts it now, or gives it other settings: lang the language by two letters, strings words of your own by their English text, add whether it offers Add Person. It uses the page rooms and calls (wordplusRealtimeCalls.page()), so your own code on the same page shares its line and its calls.
Your own screen for the calls of your plugin
The screen is shared by every plugin on the site. Your plugin can take the calls it declares onto a screen of its own, and leave the rest on the shared one:
wordplusRealtimeUi.own( 'support:{a}:{b}', ( owned ) => {
if ( owned.kind === 'ring' ) showMyRing( owned.incoming ); // incoming.accept(), incoming.decline()
if ( owned.kind === 'call' ) showMyCall( owned.call ); // the call <call-button> placed
if ( owned.kind === 'group' ) showMyMeeting( owned.group ); // the group call <room-button> joined
} );
- The pattern is that of your rule, as
calls()orgroup_calls()declares it: each{name}is one part between colons. - What you get are the objects of the calls script itself, the ones
wordplusRealtimeCallsgives your own code (JavaScript reference): answer, show and end them as your screen does. - Its rings and calls never reach the shared screen, nor does it answer them busy while it shows another call.
- The Better Messages calls are always its own, on its own screen.
own()answers a function that hands the calls back to the shared screen.
Short of a screen of your own, the shared one takes your pieces too: its colours and words (its look), and the pieces it draws, by ::part() and <template slot> (customizing the screens).