=== ConnectSphere ===
Contributors: tlloancy
Donate link: https://donorbox.org/wordpress-plugins
Tags: webrtc, video, webinar, education, chat
Requires at least: 5.0
Tested up to: 7.1
Stable tag: 1.7.0
Requires PHP: 8.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Put live video class, chat, and screen sharing on your WordPress site. Students stay on your domain — you connect a Janus server.

== Description ==
Sending a Zoom or Meet link pulls learners off your course site, breaks your branding, and leaves attendance to a third-party tab. **ConnectSphere** embeds a live classroom *on your own pages*: camera, microphone, public and private chat, and screen sharing, using the [Janus WebRTC Gateway](https://janus.conf.meetecho.com/) you control.

**Who it is for**

* Course authors who want a live session inside a lesson page, not a separate meeting URL.
* Tutors and training teams who already run WordPress and can host (or commission) a Janus server.
* Sites that must keep media on infrastructure they choose (self-hosted gateway + STUN/TURN).

**What you get in the room**

* Video, audio, public chat, private chat, screen sharing
* Raise Hand, live participant count, connection-quality bars (RTT + packet loss)
* Leave (stops camera/mic and releases WebRTC resources)
* Dark or Light room theme (front-end only)
* French translation included

**What this plugin is not**

ConnectSphere is **not** a hosted video SaaS. It is a WordPress front-end for **your** Janus Videoroom + Textroom. A shared demo gateway is included so you can click around; it is unmonitored and **not** for paying students. Production use needs a dedicated Janus server with TLS/WSS and a TURN server for users behind strict NAT.

Insert the room with `[connectsphere_room]` or the **ConnectSphere Room** block. Settings live under the ConnectSphere admin menu.

== Installation ==
1. Install and activate ConnectSphere from Plugins.
2. Open **ConnectSphere** in the admin menu. Set the Janus URL (`wss://…`), STUN (`stun:…`), and TURN (`turn:…`) plus TURN credentials.
3. Pick Dark or Light for the public room.
4. Add `[connectsphere_room]` to a page, or insert the **ConnectSphere Room** block.
5. On the page: enter a username and room ID, then Create or Join.

== Frequently Asked Questions ==
= Do I need my own Janus server? =
Yes for any real audience. The default URL is a shared demo. For live courses you need Janus Gateway (videoroom + textroom), WSS, and usually coturn.

= How do I put the room on a page? =
Shortcode `[connectsphere_room]` (same as 1.6.0) or the Gutenberg block **ConnectSphere Room**. Both render the same template and load Janus only on that page.

= Can I run 100 participants? =
Janus can, if the *server* has CPU, RAM, and bandwidth. Plan a dedicated VPS (about 2 vCPU / 2 GB RAM) once you pass roughly ten concurrent publishers. The WordPress plugin does not magically scale the gateway.

= Why can’t some users connect? =
They are likely behind a firewall that blocks peer-to-peer. Configure a working TURN server (not only STUN). URLs must use the `stun:` / `turn:` prefixes; Janus must be `wss://`.

= Can I match the room to a light site? =
Yes. **ConnectSphere → Room appearance → Light**. That setting does not restyle wp-admin.

= Is there a Premium / recording / LMS plugin? =
A Pro with recording, waiting room, and LMS hooks is planned, not shipped. Do not expect those features in 1.7.0.

= How much is a professional Janus install? =
The author offers installation (Janus, coturn, TLS/WSS, firewall, test) from €249 on your VPS, or a turnkey package from €449. See https://profiles.wordpress.org/tlloancy/

== Changelog ==
= 1.7.0 =
August 25, 2026:
* Compat: Tested up to WordPress 7.1. Version constant `CONNECTSPHERE_VERSION`.
* Editor: Gutenberg block `connectsphere/room` (`block.json`, dynamic render). `[connectsphere_room]` is unchanged. Assets also enqueue when the room is rendered (widgets / block themes).
* Design: Settings screen uses native WordPress admin (`form-table`, `.wrap`, `.card`). Removed ice-blue glow, pulsing background, and floating spheres.
* Docs: wordpress.org listing rewritten around the real product (self-hosted Janus classroom). `docs/USER-GUIDE.md` (English) and `docs/MODE-DEMPLOI.md` (French).
* The Janus client (`assets/js/connectsphere.js`, `janus.js`, `adapter.js`) is not rewritten.

= 1.6.0 = (2026-05-28)
## Compatibility
- Tested up to WordPress 7.0.

## New Features
- **Participant counter**: The participants panel now shows a live count of people in the room.
- **Raise Hand**: New button lets participants signal the host. A hand icon (✋) appears on the video bubble and in the participant list for all attendees.
- **Connection quality indicator**: Three-bar signal indicator in the control bar, powered by WebRTC `getStats()` (RTT + packet loss).
- **Light theme**: New color theme option in Settings > ConnectSphere > Room Appearance. Dark (default) or Light — with a live preview in the settings page.
- **Leave button**: Cleanly stops camera/mic tracks, releases all WebRTC handles, and resets the room state. Previously, leaving was only possible by closing the tab.
- **Auto-join after create**: Creating a room now immediately joins it. No need to click "Join" separately.

## UX & Architecture
- Status ticker now spans full width below the control buttons, no longer squeezed to a few pixels.
- Join logic extracted into `performJoin()` to eliminate duplicated code between the Create and Join flows.
- Professional Janus server installation service documented in FAQ and admin settings page.

## Bug Fixes & i18n
- Fixed missing `load_plugin_textdomain()` — PHP-side translations now load correctly.
- Fixed broken ICE retry paths that referenced undeclared `videoroomHandle` / `textroomHandle` variables (now correctly using `videoroom` / `textroom`).
- Fixed notification sound using a site-root absolute path; now uses the correct plugin URL via `connectSphere.plugin_url`.
- Removed dead `wp_ajax_connectsphere_join_room` registration (endpoint was never called from the front-end).
- Fixed PHP fatal error risk: apostrophe inside single-quoted string in capabilities check.
- All remaining hard-coded French strings in PHP and JS replaced with English base strings wrapped in i18n functions.
- Added missing CSS classes: `.unread-badge`, `.new-message-highlight`, `.disabled`, `.hand-raised`.
- `plugin_url` added to localized JS data; removed unused `ajax_url` / `nonce`.

= 1.5.0 = (2026-04-25)
## User Experience & Admin Ergonomics
- **Shortcode Quick-Copy**: Added a dedicated "Usage" section in the settings page featuring a one-click copy button for the `[connectsphere_room]` shortcode.
- **Copy Feedback**: Integrated a visual "Copied!" confirmation using WordPress native Dashicons for a better user experience.
## Internal Logic & i18n
- **JS Dependency Update**: Added `sprintf` to the `wp-i18n` imports in `connectsphere.js` to support complex dynamic translations.

= 1.4.0 (2026-04-24) =
### Internationalization (i18n) & Localization
- **Full Multilingual Support**: Added `Domain Path` for native translation.
- **wp-i18n Integration**: Scripts now explicitly depend on `wp-i18n` for secure string translation.
- **String Standardization**: All UI messages harmonized to English for global compatibility.

### Improved Resilience & Performance
- **Aggressive Reconnection Logic**: Reduced reconnection timeouts from 15 seconds to **4 seconds** for both `videoroom` and `textroom` plugins. This ensures much faster recovery after network drops.
- **Enhanced Connection Stability**: Refined the Janus initialization flow to handle session drops more proactively.
- **Version Bump**: Updated to 1.4.0 to force cache refreshing for all assets.

= 1.3.1 (2026-04-24) =
### Sécurité & Stabilité
- **Renforcement de la sécurité (Nonce)** : Correction de la faille de vérification des jetons de sécurité dans l'administration. Désormais, les réglages sont protégés par `check_admin_referer` pour prévenir les attaques CSRF.
- **Optimisation du chargement des scripts** : Les fichiers JS (Janus, adapter.js) et CSS ne sont plus chargés sur tout le site. Ils sont désormais injectés uniquement sur les pages utilisant le shortcode `[connectsphere_room]`, améliorant drastiquement les performances du site.

### Interface & Responsive
- **Full Responsive Design** : Refonte complète du CSS pour mobile et tablette. La grille vidéo et la barre de contrôle s'adaptent désormais parfaitement aux petits écrans.
- **Z-Index Fix** : Ajustement de la profondeur de l'interface pour garantir la visibilité des menus de navigation WordPress au-dessus du salon vidéo.

= 1.3.0 (2026-04-23) =
### UI Overhaul, Ad-Free & CSS Refactoring

- **Removed all integrated advertisements**: Banners and marketing popups are now gone for a 100% professional experience.
- **New Activity Log Ticker**: Replaced intrusive "Toast" notifications with a sleek, terminal-style status bar in the control panel.
- **Cyber-Terminal Aesthetics**: Implemented scrolling marquee effects for system messages to prevent blocking the video grid.
- **CSS Refactoring**: Completely reorganized the stylesheet. Cleaned up legacy notification styles and unminified key components for better maintainability.
- **Layout Stabilization**: Fixed the 100vw horizontal overflow bug and optimized control bar responsiveness using modern Flexbox.
- **Cleanup**: Removed unused DOM manipulation logic from the JS core to improve performance.

= 1.2.0 =
### Enhanced screen-sharing support with explicit media direction

- Replaced generic `media: { audio: true, video: true }` with precise recvonly settings.
- Now explicitly sets `audioRecv: true` and `videoRecv: true` while disabling local capture.
- Ensures compatibility with system audio during screen sharing.
- Follows Janus Gateway's recommended pattern for subscriber answer creation.

= 1.1.0 =
* 6.9 Ok
* A little too much advertisings

= 1.0.9 =
* Fixed textroom error (error_code: 422) by adding a 500ms delay for the join request and handling specific retries.
* Improved connection management with a 30-second keep-alive interval and progressive retry delays (15s, 30s, 60s).
* Public messages are now visible to all participants with username, date, time, and content.
* Resolved connection errors (DTLS alert, ICE disconnected) with better handle management.

= 1.0.8 =
* Fixed textroom errors (error_code: 415) for join and message requests by using textroom.data() to send via the WebRTC data channel.
* Public messages are now visible to all participants with username, date, time, and content.
* Improved connection error handling (DTLS alert, connection loss) with 15-second reconnection delays.
* Resolved PeerConnection errors (error_code: 416) by properly detaching handles.

= 1.0.7 =
* Fixed textroom errors (error_code: 415) for join and message requests by using the correct format (textroom: 'join', textroom: 'message').
* Public messages are now visible to all participants with username, date, time, and content.
* Improved connection error handling (DTLS alert, connection loss) with increased reconnection delays to 15 seconds.
* Resolved PeerConnection errors (error_code: 416) by properly detaching handles.

= 1.0.6 =
* Fixed chat issue: public messages are now visible to all participants with username, date, time, and content.
* Resolved textroom errors (error_code: 413) by correcting the format of join and message requests.
* Improved connection error handling (DTLS alert, connection loss).

= 1.0.5 =
* Fixed PHP syntax error in connectsphere.php (line 84).
* Improved message handling to include username, date, time, and content.

= 1.0.4 =
* Fixed chat issue: public messages are now visible to all with username, date, time, and content.
* Improved message styles for better readability.
* Fixed textroom connection errors (error_code: 415).

= 1.0.3 =
* Fixed chat styling for a dark icy background and improved text readability.

= 1.0.2 =
* Added specific CSS styles for the settings page (admin.php?page=connectsphere).
* Added dynamic resizing of input fields.
* Fixed issue with CSS styles not applying on the settings page.

= 1.0.1 =
* Added STUN/TURN server configuration in settings.
* Improved settings interface with an icy blue theme.
* Added an animated background with connected spheres.

= 1.0.0 =
* Initial release with WebRTC, chat, and integrated marketing.
