An open API service indexing awesome lists of open source software.

https://github.com/wpsignal/wordsocket

Sends realtime events from WordPress to browsers via api.wpsignal.io. Connects via WebSocket (SSE fallback) and exposes a public JS API for other plugins to share the connection. Also provider a WebSocket based provider for WordPress's Realtime Collaboration.
https://github.com/wpsignal/wordsocket

io php php8 realtime sse sse-client typescript websocket websockets wordpress-plugin yjs yjs-provider

Last synced: about 2 months ago
JSON representation

Sends realtime events from WordPress to browsers via api.wpsignal.io. Connects via WebSocket (SSE fallback) and exposes a public JS API for other plugins to share the connection. Also provider a WebSocket based provider for WordPress's Realtime Collaboration.

Awesome Lists containing this project

README

          

# WordSocket

The official WordPress plugin for [WPSignal](https://wpsignal.io). WordSocket enables developers to connect their site to a secure WebSocket relay.

## Install:

### WP.org:

The easiest way is to download is wordpress.org/plugins/wordsocket.

### WP CLI:

```bash
wp plugin install wordsocket --activate
```

## Minimal example:

### Create a trigger:

```php
// Fire on any WordPress action hook
WPS::trigger( 'comment.posted' )
->on( 'wp_insert_comment', 10, 2 )
->channel( 'events' )
->data( fn( $id, $comment ) => [ 'author' => $comment->comment_author ] )
->register();
```

### Listen and act on trigger when it fires:

```ts
type Comment = {
// ...
};
// Handle it in the browser
document.addEventListener( 'wpsignal:comment.posted', (e: CustomEvent) => {
console.log(e.detail);
});
```

## Documentation

Full documentation, API reference, and guides are at wpsignal.io/docs/getting-started.

## Changelog

**0.15.1** - Fixed: skip Yjs update and awareness messages when no peers are connected.

Full changelog can be viewed in [CHANGELOG.md](https://github.com/wpsignal/wordsocket/blob/main/CHANGELOG.md)

## License

GPL-2.0-or-later