Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/wp-admin/includes/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ function populate_options( array $options = array() ) {

// 6.9.0
'wp_notes_notify' => 1,

// 7.0.0
'wp_enable_real_time_collaboration' => 1,
Comment on lines +566 to +568

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary / useful if we are separately filtering the default value?

Copy link
Contributor Author

@peterwilsoncc peterwilsoncc Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The practice has been to add the default options regardless, see link_manager_enabled which uses a similar filter:

Edit to remove dumb example: all the other options that default to a falsey value are included here even though they're not strictly required.

);

// 3.3.0
Expand Down
6 changes: 3 additions & 3 deletions src/wp-admin/options-writing.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@
</td>
</tr>
<tr>
<th scope="row"><label for="wp_disable_real_time_collaboration"><?php _e( 'Collaboration' ); ?></label></th>
<th scope="row"><label for="wp_enable_real_time_collaboration"><?php _e( 'Collaboration' ); ?></label></th>
<td>
<input name="wp_disable_real_time_collaboration" type="checkbox" id="wp_disable_real_time_collaboration" value="1" <?php checked( '1', get_option( 'wp_disable_real_time_collaboration' ) ); ?> />
<label for="wp_disable_real_time_collaboration"><?php _e( 'Disable real-time collaboration' ); ?></label>
<input name="wp_enable_real_time_collaboration" type="checkbox" id="wp_enable_real_time_collaboration" value="1" <?php checked( '1', get_option( 'wp_enable_real_time_collaboration' ) ); ?> />
<label for="wp_enable_real_time_collaboration"><?php _e( 'Enable real-time collaboration' ); ?></label>
</td>
</tr>
<?php
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
'default_email_category',
'default_link_category',
'default_post_format',
'wp_disable_real_time_collaboration',
'wp_enable_real_time_collaboration',
),
);
$allowed_options['misc'] = array();
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/collaboration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @access private
*/
function wp_collaboration_inject_setting() {
if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) {
if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
wp_add_inline_script(
'wp-core-data',
'window._wpCollaborationEnabled = true;',
Expand Down
5 changes: 3 additions & 2 deletions src/wp-includes/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,9 @@
// Timezone.
add_filter( 'pre_option_gmt_offset', 'wp_timezone_override_offset' );

// If the upgrade hasn't run yet, assume link manager is used.
add_filter( 'default_option_link_manager_enabled', '__return_true' );
// If the upgrade hasn't run yet, set some default options.
add_filter( 'default_option_link_manager_enabled', '__return_true' ); // Assume link manager is used.
add_filter( 'default_option_wp_enable_real_time_collaboration', '__return_true' ); // Enable real-time collaboration.

// This option no longer exists; tell plugins we always support auto-embedding.
add_filter( 'pre_option_embed_autourls', '__return_true' );
Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/option.php
Original file line number Diff line number Diff line change
Expand Up @@ -2887,10 +2887,10 @@ function register_initial_settings() {

register_setting(
'writing',
'wp_disable_real_time_collaboration',
'wp_enable_real_time_collaboration',
array(
'type' => 'boolean',
'description' => __( 'Disable real-time collaboration' ),
'description' => __( 'Enable Real-Time Collaboration' ),
'sanitize_callback' => 'rest_sanitize_boolean',
'default' => false,
'show_in_rest' => true,
Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ function create_initial_post_types() {
)
);

if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) {
if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
register_post_type(
'wp_sync_storage',
array(
Expand Down Expand Up @@ -8671,7 +8671,7 @@ function wp_create_initial_post_meta() {
)
);

if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) {
if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
register_meta(
'post',
'_crdt_document',
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ function create_initial_rest_routes() {
$icons_controller->register_routes();

// Collaboration.
if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) {
if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
$sync_storage = new WP_Sync_Post_Meta_Storage();
$sync_server = new WP_HTTP_Polling_Sync_Server( $sync_storage );
$sync_server->register_routes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ public function create_item( $request ) {
* the saved post. This diff is then applied to the in-memory CRDT
* document, which can lead to duplicate inserts or deletions.
*/
$is_collaboration_disabled = boolval( get_option( 'wp_disable_real_time_collaboration' ) );
$is_collaboration_enabled = get_option( 'wp_enable_real_time_collaboration' );

if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock && $is_collaboration_disabled ) {
if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock && ! $is_collaboration_enabled ) {
/*
* Draft posts for the same author: autosaving updates the post and does not create a revision.
* Convert the post object to an array and add slashes, wp_update_post() expects escaped array.
Expand Down
14 changes: 4 additions & 10 deletions tests/phpunit/tests/rest-api/rest-autosaves-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public function test_rest_autosave_published_post() {
}

public function test_rest_autosave_draft_post_same_author() {
add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' );
add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_zero' ); // Zero as false doesn't work for pre-flight options.

wp_set_current_user( self::$editor_id );

Expand Down Expand Up @@ -606,7 +606,6 @@ public function test_rest_autosave_draft_post_same_author() {
$this->assertSame( $post_data['post_excerpt'], $post->post_excerpt );

wp_delete_post( $post_id );
remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' );
}

public function test_rest_autosave_draft_post_different_author() {
Expand Down Expand Up @@ -747,7 +746,7 @@ public function test_get_item_sets_up_postdata() {
}

public function test_update_item_draft_page_with_parent() {
add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' );
add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_zero' ); // Zero as false doesn't work for pre-flight options.

wp_set_current_user( self::$editor_id );
$request = new WP_REST_Request( 'POST', '/wp/v2/pages/' . self::$child_draft_page_id . '/autosaves' );
Expand All @@ -766,8 +765,6 @@ public function test_update_item_draft_page_with_parent() {

$this->assertSame( self::$child_draft_page_id, $data['id'] );
$this->assertSame( self::$parent_page_id, $data['parent'] );

remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' );
}

public function test_schema_validation_is_applied() {
Expand Down Expand Up @@ -933,7 +930,7 @@ public static function data_head_request_with_specified_fields_returns_success_r
* same author should create a revision instead of updating the post directly.
*/
public function test_rest_autosave_draft_post_same_author_with_rtc() {
add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' );

wp_set_current_user( self::$editor_id );

Expand Down Expand Up @@ -972,15 +969,14 @@ public function test_rest_autosave_draft_post_same_author_with_rtc() {
$this->assertSame( $post_data['post_excerpt'], $post->post_excerpt );

wp_delete_post( $post_id );
remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
}

/**
* When real-time collaboration is enabled, autosaving a draft page with
* a parent should create a revision instead of updating the page directly.
*/
public function test_update_item_draft_page_with_parent_with_rtc() {
add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' );

wp_set_current_user( self::$editor_id );
$request = new WP_REST_Request( 'POST', '/wp/v2/pages/' . self::$child_draft_page_id . '/autosaves' );
Expand All @@ -1000,7 +996,5 @@ public function test_update_item_draft_page_with_parent_with_rtc() {
// With RTC enabled, a revision is created instead of updating the page.
$this->assertNotSame( self::$child_draft_page_id, $data['id'] );
$this->assertSame( self::$child_draft_page_id, $data['parent'] );

remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
}
}
2 changes: 1 addition & 1 deletion tests/phpunit/tests/rest-api/rest-settings-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function test_get_items() {
'default_ping_status',
'default_comment_status',
'site_icon', // Registered in wp-includes/blocks/site-logo.php
'wp_disable_real_time_collaboration',
'wp_enable_real_time_collaboration',
// Connectors API keys are registered in _wp_register_default_connector_settings() in wp-includes/connectors.php.
'connectors_ai_anthropic_api_key',
'connectors_ai_google_api_key',
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/tests/rest-api/rest-sync-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class WP_Test_REST_Sync_Server extends WP_Test_REST_Controller_Testcase {
protected static $post_id;

public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );

self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
self::$subscriber_id = $factory->user->create( array( 'role' => 'subscriber' ) );
self::$post_id = $factory->post->create( array( 'post_author' => self::$editor_id ) );
Expand All @@ -25,12 +23,14 @@ public static function wpTearDownAfterClass() {
self::delete_user( self::$editor_id );
self::delete_user( self::$subscriber_id );
wp_delete_post( self::$post_id, true );
remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
}

public function set_up() {
parent::set_up();

// Enable option for tests.
add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' );

// Reset storage post ID cache to ensure clean state after transaction rollback.
$reflection = new ReflectionProperty( 'WP_Sync_Post_Meta_Storage', 'storage_post_ids' );
if ( PHP_VERSION_ID < 80100 ) {
Expand Down
6 changes: 3 additions & 3 deletions tests/qunit/fixtures/wp-api-generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -11158,9 +11158,9 @@ mockedApiResponse.Schema = {
"type": "string",
"required": false
},
"wp_disable_real_time_collaboration": {
"wp_enable_real_time_collaboration": {
"title": "",
"description": "Disable real-time collaboration",
"description": "Enable Real-Time Collaboration",
"type": "boolean",
"required": false
},
Expand Down Expand Up @@ -14777,7 +14777,7 @@ mockedApiResponse.settings = {
"use_smilies": true,
"default_category": 1,
"default_post_format": "0",
"wp_disable_real_time_collaboration": false,
"wp_enable_real_time_collaboration": true,
"posts_per_page": 10,
"show_on_front": "posts",
"page_on_front": 0,
Expand Down
Loading