Make WordPress Core


Ignore:
Timestamp:
05/08/2026 02:03:18 PM (7 weeks ago)
Author:
ellatrix
Message:

Remove real-time collaboration.

Removes all RTC related code from core. There will still be RTC related code in Gutenberg, but effectively disabled for core since nothing turns it on. The wp.sync global has also been hidden by bundling in https://github.com/WordPress/gutenberg/pull/78085.

Developed in: https://github.com/WordPress/wordpress-develop/pull/11774.

Props maxschmeling, ellatrix, mukesh27.
Fixes #65205.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/collaboration.php

    r62100 r62334  
    1 <?php
    2 /**
    3  * Bootstraps collaborative editing.
    4  *
    5  * @package WordPress
    6  * @since 7.0.0
    7  */
    8 
    9 /**
    10  * Determines whether real-time collaboration is enabled.
    11  *
    12  * If the WP_ALLOW_COLLABORATION constant is false,
    13  * collaboration is always disabled regardless of the database option.
    14  * Otherwise, falls back to the 'wp_collaboration_enabled' option.
    15  *
    16  * @since 7.0.0
    17  *
    18  * @return bool Whether real-time collaboration is enabled.
    19  */
    20 function wp_is_collaboration_enabled() {
    21     return (
    22         wp_is_collaboration_allowed() &&
    23         (bool) get_option( 'wp_collaboration_enabled' )
    24     );
    25 }
    26 
    27 /**
    28  * Determines whether real-time collaboration is allowed.
    29  *
    30  * If the WP_ALLOW_COLLABORATION constant is false,
    31  * collaboration is not allowed and cannot be enabled.
    32  * The constant defaults to true, unless the WP_ALLOW_COLLABORATION
    33  * environment variable is set to string "false".
    34  *
    35  * @since 7.0.0
    36  *
    37  * @return bool Whether real-time collaboration is enabled.
    38  */
    39 function wp_is_collaboration_allowed() {
    40     if ( ! defined( 'WP_ALLOW_COLLABORATION' ) ) {
    41         $env_value = getenv( 'WP_ALLOW_COLLABORATION' );
    42         if ( false === $env_value ) {
    43             // Environment variable is not defined, default to allowing collaboration.
    44             define( 'WP_ALLOW_COLLABORATION', true );
    45         } else {
    46             /*
    47              * Environment variable is defined, let's confirm it is actually set to
    48              * "true" as it may still have a string value "false" – the preceeding
    49              * `if` branch only tests for the boolean `false`.
    50              */
    51             define( 'WP_ALLOW_COLLABORATION', 'true' === $env_value );
    52         }
    53     }
    54 
    55     return WP_ALLOW_COLLABORATION;
    56 }
    57 
    58 /**
    59  * Injects the real-time collaboration setting into a global variable.
    60  *
    61  * @since 7.0.0
    62  *
    63  * @access private
    64  *
    65  * @global string $pagenow The filename of the current screen.
    66  */
    67 function wp_collaboration_inject_setting() {
    68     global $pagenow;
    69 
    70     if ( ! wp_is_collaboration_enabled() ) {
    71         return;
    72     }
    73 
    74     // Disable real-time collaboration on the site editor.
    75     $enabled = true;
    76     if ( 'site-editor.php' === $pagenow ) {
    77         $enabled = false;
    78     }
    79 
    80     wp_add_inline_script(
    81         'wp-core-data',
    82         'window._wpCollaborationEnabled = ' . wp_json_encode( $enabled ) . ';',
    83         'after'
    84     );
    85 }
Note: See TracChangeset for help on using the changeset viewer.