Make WordPress Core

Changeset 61833


Ignore:
Timestamp:
03/05/2026 12:27:39 AM (7 weeks ago)
Author:
peterwilsoncc
Message:

Real-time collaboration: Rename option for positive intent.

This reverts the real time collaboration option name back to wp_enable_real_time_collaboration to avoid the need to turn on a checkbox in order to turn off the feature. This is to reduce the cognitive load on both users and developers of an on is off paradigm.

To ensure Real Time Collaboration is enabled prior to the upgrade routine running on multi-site installs, the option default is filtered on the default_option_wp_enable_real_time_collaboration hook to enable the option by default.

Developed in: https://github.com/WordPress/wordpress-develop/pull/11161
Follow up to r61828.

Props peterwilsoncc, czarate, sergeybiryukov.
Fixes #64622.

Location:
trunk
Files:
13 edited

Legend:

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

    r61828 r61833  
    564564        // 6.9.0
    565565        'wp_notes_notify'                   => 1,
     566
     567        // 7.0.0
     568        'wp_enable_real_time_collaboration' => 1,
    566569    );
    567570
  • trunk/src/wp-admin/options-writing.php

    r61828 r61833  
    111111</tr>
    112112<tr>
    113 <th scope="row"><label for="wp_disable_real_time_collaboration"><?php _e( 'Collaboration' ); ?></label></th>
    114 <td>
    115     <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' ) ); ?> />
    116     <label for="wp_disable_real_time_collaboration"><?php _e( 'Disable real-time collaboration' ); ?></label>
     113<th scope="row"><label for="wp_enable_real_time_collaboration"><?php _e( 'Collaboration' ); ?></label></th>
     114<td>
     115    <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' ) ); ?> />
     116    <label for="wp_enable_real_time_collaboration"><?php _e( 'Enable real-time collaboration' ); ?></label>
    117117</td>
    118118</tr>
  • trunk/src/wp-admin/options.php

    r61829 r61833  
    154154        'default_link_category',
    155155        'default_post_format',
    156         'wp_disable_real_time_collaboration',
     156        'wp_enable_real_time_collaboration',
    157157    ),
    158158);
  • trunk/src/wp-includes/collaboration.php

    r61828 r61833  
    1515 */
    1616function wp_collaboration_inject_setting() {
    17     if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) {
     17    if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
    1818        wp_add_inline_script(
    1919            'wp-core-data',
  • trunk/src/wp-includes/default-filters.php

    r61707 r61833  
    486486add_filter( 'pre_option_gmt_offset', 'wp_timezone_override_offset' );
    487487
    488 // If the upgrade hasn't run yet, assume link manager is used.
    489 add_filter( 'default_option_link_manager_enabled', '__return_true' );
     488// If the upgrade hasn't run yet, set some default options.
     489add_filter( 'default_option_link_manager_enabled', '__return_true' ); // Assume link manager is used.
     490add_filter( 'default_option_wp_enable_real_time_collaboration', '__return_true' ); // Enable real-time collaboration.
    490491
    491492// This option no longer exists; tell plugins we always support auto-embedding.
  • trunk/src/wp-includes/option.php

    r61828 r61833  
    28882888    register_setting(
    28892889        'writing',
    2890         'wp_disable_real_time_collaboration',
     2890        'wp_enable_real_time_collaboration',
    28912891        array(
    28922892            'type'              => 'boolean',
    2893             'description'       => __( 'Disable real-time collaboration' ),
     2893            'description'       => __( 'Enable Real-Time Collaboration' ),
    28942894            'sanitize_callback' => 'rest_sanitize_boolean',
    28952895            'default'           => false,
  • trunk/src/wp-includes/post.php

    r61828 r61833  
    658658    );
    659659
    660     if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) {
     660    if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
    661661        register_post_type(
    662662            'wp_sync_storage',
     
    86728672    );
    86738673
    8674     if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) {
     8674    if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
    86758675        register_meta(
    86768676            'post',
  • trunk/src/wp-includes/rest-api.php

    r61828 r61833  
    431431
    432432    // Collaboration.
    433     if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) {
     433    if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
    434434        $sync_storage = new WP_Sync_Post_Meta_Storage();
    435435        $sync_server  = new WP_HTTP_Polling_Sync_Server( $sync_storage );
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php

    r61828 r61833  
    255255         *   document, which can lead to duplicate inserts or deletions.
    256256         */
    257         $is_collaboration_disabled = boolval( get_option( 'wp_disable_real_time_collaboration' ) );
    258 
    259         if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock && $is_collaboration_disabled ) {
     257        $is_collaboration_enabled = get_option( 'wp_enable_real_time_collaboration' );
     258
     259        if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock && ! $is_collaboration_enabled ) {
    260260            /*
    261261             * Draft posts for the same author: autosaving updates the post and does not create a revision.
  • trunk/tests/phpunit/tests/rest-api/rest-autosaves-controller.php

    r61828 r61833  
    571571
    572572    public function test_rest_autosave_draft_post_same_author() {
    573         add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' );
     573        add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_zero' ); // Zero as false doesn't work for pre-flight options.
    574574
    575575        wp_set_current_user( self::$editor_id );
     
    607607
    608608        wp_delete_post( $post_id );
    609         remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' );
    610609    }
    611610
     
    748747
    749748    public function test_update_item_draft_page_with_parent() {
    750         add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' );
     749        add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_zero' ); // Zero as false doesn't work for pre-flight options.
    751750
    752751        wp_set_current_user( self::$editor_id );
     
    767766        $this->assertSame( self::$child_draft_page_id, $data['id'] );
    768767        $this->assertSame( self::$parent_page_id, $data['parent'] );
    769 
    770         remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' );
    771768    }
    772769
     
    934931     */
    935932    public function test_rest_autosave_draft_post_same_author_with_rtc() {
    936         add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
     933        add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' );
    937934
    938935        wp_set_current_user( self::$editor_id );
     
    973970
    974971        wp_delete_post( $post_id );
    975         remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
    976972    }
    977973
     
    981977     */
    982978    public function test_update_item_draft_page_with_parent_with_rtc() {
    983         add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
     979        add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' );
    984980
    985981        wp_set_current_user( self::$editor_id );
     
    1001997        $this->assertNotSame( self::$child_draft_page_id, $data['id'] );
    1002998        $this->assertSame( self::$child_draft_page_id, $data['parent'] );
    1003 
    1004         remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
    1005999    }
    10061000}
  • trunk/tests/phpunit/tests/rest-api/rest-settings-controller.php

    r61828 r61833  
    120120            'default_comment_status',
    121121            'site_icon', // Registered in wp-includes/blocks/site-logo.php
    122             'wp_disable_real_time_collaboration',
     122            'wp_enable_real_time_collaboration',
    123123            // Connectors API keys are registered in _wp_register_default_connector_settings() in wp-includes/connectors.php.
    124124            'connectors_ai_anthropic_api_key',
  • trunk/tests/phpunit/tests/rest-api/rest-sync-server.php

    r61828 r61833  
    1515
    1616    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
    17         add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
    18 
    1917        self::$editor_id     = $factory->user->create( array( 'role' => 'editor' ) );
    2018        self::$subscriber_id = $factory->user->create( array( 'role' => 'subscriber' ) );
     
    2624        self::delete_user( self::$subscriber_id );
    2725        wp_delete_post( self::$post_id, true );
    28         remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
    2926    }
    3027
    3128    public function set_up() {
    3229        parent::set_up();
     30
     31        // Enable option for tests.
     32        add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' );
    3333
    3434        // Reset storage post ID cache to ensure clean state after transaction rollback.
  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r61828 r61833  
    1115911159                            "required": false
    1116011160                        },
    11161                         "wp_disable_real_time_collaboration": {
     11161                        "wp_enable_real_time_collaboration": {
    1116211162                            "title": "",
    11163                             "description": "Disable real-time collaboration",
     11163                            "description": "Enable Real-Time Collaboration",
    1116411164                            "type": "boolean",
    1116511165                            "required": false
     
    1477814778    "default_category": 1,
    1477914779    "default_post_format": "0",
    14780     "wp_disable_real_time_collaboration": false,
     14780    "wp_enable_real_time_collaboration": true,
    1478114781    "posts_per_page": 10,
    1478214782    "show_on_front": "posts",
Note: See TracChangeset for help on using the changeset viewer.