Make WordPress Core


Ignore:
Timestamp:
03/24/2026 12:18:06 PM (17 hours ago)
Author:
zieladam
Message:

Real-Time Collaboration: Define WP_ALLOW_COLLABORATION in wp_is_collaboration_allowed()

#62075 introduced the WP_ALLOW_COLLABORATION constant to help hosts disable RTC at the platform level. The constant was defined in wp_functionality_constants(), which runs in wp-settings.php after collaboration.php is loaded. That created a boot-order edge case where wp_is_collaboration_enabled() could be called before the constant existed – for instance via SHORTINIT.

This commit moves the constant definition into a new wp_is_collaboration_allowed() function in collaboration.php. The function checks the constant, and if it's missing, defines it on the spot from the environment variable (defaulting to true). wp_is_collaboration_enabled() now delegates to wp_is_collaboration_allowed() for the constant check, and the admin UI calls wp_is_collaboration_allowed() directly to decide whether to show the checkbox or a "disabled" notice. It also slightly improves the label of the "enable RTC" checkbox on the settings page.

Props peterwilsoncc, mcsf, joen, ingeniumed.

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

See #64904.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/options-writing.php

    r62078 r62100  
    113113<th scope="row"><?php _e( 'Collaboration' ); ?></th>
    114114<td>
    115     <?php if ( defined( 'WP_ALLOW_COLLABORATION' ) && false === WP_ALLOW_COLLABORATION ) : ?>
     115    <?php if ( wp_is_collaboration_allowed() ) : ?>
     116        <label for="wp_collaboration_enabled">
     117            <input name="wp_collaboration_enabled" type="checkbox" id="wp_collaboration_enabled" value="1" <?php checked( '1', (bool) get_option( 'wp_collaboration_enabled' ) ); ?> />
     118            <?php _e( "Enable early access to real-time collaboration. Real-time collaboration may affect your website's performance." ); ?>
     119        </label>
     120    <?php else : ?>
    116121        <div class="notice notice-warning inline">
    117122            <p><?php _e( '<strong>Note:</strong> Real-time collaboration has been disabled.' ); ?></p>
    118123        </div>
    119     <?php else : ?>
    120         <label for="wp_collaboration_enabled">
    121             <input name="wp_collaboration_enabled" type="checkbox" id="wp_collaboration_enabled" value="1" <?php checked( '1', (bool) get_option( 'wp_collaboration_enabled' ) ); ?> />
    122             <?php _e( 'Enable real-time collaboration' ); ?>
    123         </label>
    124124    <?php endif; ?>
    125125</td>
Note: See TracChangeset for help on using the changeset viewer.