Skip to content

Commit 73c3d9c

Browse files
committed
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 WordPress/gutenberg#78085. Developed in: #11774. Props maxschmeling, ellatrix, mukesh27. Fixes #65205. git-svn-id: https://develop.svn.wordpress.org/trunk@62334 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 206802b commit 73c3d9c

23 files changed

Lines changed: 32 additions & 3515 deletions

src/js/_enqueues/admin/inline-edit-post.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,7 @@ $( function() {
614614
}
615615
}).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
616616
var locked = data['wp-check-locked-posts'] || {},
617-
isRtc = window._wpCollaborationEnabled,
618-
lockedClass = isRtc ? 'wp-collaborative-editing' : 'wp-locked';
617+
lockedClass = 'wp-locked';
619618

620619
$('#the-list tr').each( function(i, el) {
621620
var key = el.id, row = $(el), lock_data, avatar;
@@ -626,7 +625,7 @@ $( function() {
626625
row.find('.column-title .locked-text').text( lock_data.text );
627626
row.find('.check-column checkbox').prop('checked', false);
628627

629-
if ( ! isRtc && lock_data.avatar_src ) {
628+
if ( lock_data.avatar_src ) {
630629
avatar = $( '<img />', {
631630
'class': 'avatar avatar-18 photo',
632631
width: 18,

src/wp-admin/css/list-tables.css

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -635,22 +635,6 @@ tr.wp-locked .row-actions .trash {
635635
display: none;
636636
}
637637

638-
.wp-collaborative-editing .locked-info {
639-
display: block;
640-
}
641-
642-
.join-action-text {
643-
display: none;
644-
}
645-
646-
.wp-collaborative-editing .edit-action-text {
647-
display: none;
648-
}
649-
650-
.wp-collaborative-editing .join-action-text {
651-
display: inline;
652-
}
653-
654638
#menu-locations-wrap .widefat {
655639
width: 60%;
656640
}

src/wp-admin/includes/class-wp-posts-list-table.php

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,16 +1119,10 @@ public function column_title( $post ) {
11191119
$lock_holder = wp_check_post_lock( $post->ID );
11201120

11211121
if ( $lock_holder ) {
1122-
if ( get_option( 'wp_collaboration_enabled' ) ) {
1123-
$locked_avatar = '';
1124-
/* translators: Collaboration status message for a singular post in the post list. Can be any type of post. */
1125-
$locked_text = esc_html_x( 'Currently being edited', 'post list' );
1126-
} else {
1127-
$lock_holder = get_userdata( $lock_holder );
1128-
$locked_avatar = get_avatar( $lock_holder->ID, 18 );
1129-
/* translators: %s: User's display name. */
1130-
$locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
1131-
}
1122+
$lock_holder = get_userdata( $lock_holder );
1123+
$locked_avatar = get_avatar( $lock_holder->ID, 18 );
1124+
/* translators: %s: User's display name. */
1125+
$locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
11321126
} else {
11331127
$locked_avatar = '';
11341128
$locked_text = '';
@@ -1433,11 +1427,7 @@ public function single_row( $post, $level = 0 ) {
14331427
$lock_holder = wp_check_post_lock( $post->ID );
14341428

14351429
if ( $lock_holder ) {
1436-
if ( get_option( 'wp_collaboration_enabled' ) ) {
1437-
$classes .= ' wp-collaborative-editing';
1438-
} else {
1439-
$classes .= ' wp-locked';
1440-
}
1430+
$classes .= ' wp-locked';
14411431
}
14421432

14431433
if ( $post->post_parent ) {
@@ -1491,44 +1481,13 @@ protected function handle_row_actions( $item, $column_name, $primary ) {
14911481
$title = _draft_or_post_title();
14921482

14931483
if ( $can_edit_post && 'trash' !== $post->post_status ) {
1494-
$is_rtc_enabled = (bool) get_option( 'wp_collaboration_enabled' );
1495-
1496-
/*
1497-
* When RTC is enabled, both "Edit" and "Join" labels are rendered.
1498-
* The visible label is toggled by CSS based on the row's
1499-
* `wp-collaborative-editing` class, which is added or removed by
1500-
* inline-edit-post.js in response to heartbeat ticks.
1501-
*/
1502-
if ( $is_rtc_enabled ) {
1503-
$actions['edit'] = sprintf(
1504-
'<a href="%1$s">'
1505-
. '<span class="edit-action-text">'
1506-
. '<span aria-hidden="true">%2$s</span>'
1507-
. '<span class="screen-reader-text">%3$s</span>'
1508-
. '</span>'
1509-
. '<span class="join-action-text">'
1510-
. '<span aria-hidden="true">%4$s</span>'
1511-
. '<span class="screen-reader-text">%5$s</span>'
1512-
. '</span>'
1513-
. '</a>',
1514-
get_edit_post_link( $post->ID ),
1515-
__( 'Edit' ),
1516-
/* translators: %s: Post title. */
1517-
sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ),
1518-
/* translators: Action link text for a singular post in the post list. Can be any type of post. */
1519-
_x( 'Join', 'post list' ),
1520-
/* translators: %s: Post title. */
1521-
sprintf( __( 'Join editing &#8220;%s&#8221;', 'post list' ), $title )
1522-
);
1523-
} else {
1524-
$actions['edit'] = sprintf(
1525-
'<a href="%s" aria-label="%s">%s</a>',
1526-
get_edit_post_link( $post->ID ),
1527-
/* translators: %s: Post title. */
1528-
esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ),
1529-
__( 'Edit' )
1530-
);
1531-
}
1484+
$actions['edit'] = sprintf(
1485+
'<a href="%s" aria-label="%s">%s</a>',
1486+
get_edit_post_link( $post->ID ),
1487+
/* translators: %s: Post title. */
1488+
esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ),
1489+
__( 'Edit' )
1490+
);
15321491

15331492
/**
15341493
* Filters whether Quick Edit should be enabled for the given post type.

src/wp-admin/includes/misc.php

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,8 +1136,7 @@ function _customizer_mobile_viewport_meta( $viewport_meta ) {
11361136
* @return array The Heartbeat response.
11371137
*/
11381138
function wp_check_locked_posts( $response, $data, $screen_id ) {
1139-
$checked = array();
1140-
$is_rtc_enabled = (bool) get_option( 'wp_collaboration_enabled' );
1139+
$checked = array();
11411140

11421141
if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
11431142
foreach ( $data['wp-check-locked-posts'] as $key ) {
@@ -1153,23 +1152,15 @@ function wp_check_locked_posts( $response, $data, $screen_id ) {
11531152
$user = get_userdata( $user_id );
11541153

11551154
if ( $user && current_user_can( 'edit_post', $post_id ) ) {
1156-
if ( $is_rtc_enabled ) {
1157-
$send = array(
1158-
/* translators: Collaboration status message for a singular post in the post list. Can be any type of post. */
1159-
'text' => _x( 'Currently being edited', 'post list' ),
1160-
'collaborative' => true,
1161-
);
1162-
} else {
1163-
$send = array(
1164-
'name' => $user->display_name,
1165-
/* translators: %s: User's display name. */
1166-
'text' => sprintf( __( '%s is currently editing' ), $user->display_name ),
1167-
);
1168-
1169-
if ( get_option( 'show_avatars' ) ) {
1170-
$send['avatar_src'] = get_avatar_url( $user->ID, array( 'size' => 18 ) );
1171-
$send['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 36 ) );
1172-
}
1155+
$send = array(
1156+
'name' => $user->display_name,
1157+
/* translators: %s: User's display name. */
1158+
'text' => sprintf( __( '%s is currently editing' ), $user->display_name ),
1159+
);
1160+
1161+
if ( get_option( 'show_avatars' ) ) {
1162+
$send['avatar_src'] = get_avatar_url( $user->ID, array( 'size' => 18 ) );
1163+
$send['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 36 ) );
11731164
}
11741165

11751166
$checked[ $key ] = $send;

src/wp-admin/includes/schema.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,6 @@ function populate_options( array $options = array() ) {
563563

564564
// 6.9.0
565565
'wp_notes_notify' => 1,
566-
567-
// 7.0.0
568-
'wp_collaboration_enabled' => 0,
569566
);
570567

571568
// 3.3.0

src/wp-admin/options-writing.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,6 @@
109109
</select>
110110
</td>
111111
</tr>
112-
<tr>
113-
<th scope="row"><?php _e( 'Collaboration' ); ?></th>
114-
<td>
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 : ?>
121-
<div class="notice notice-warning inline">
122-
<p><?php _e( '<strong>Note:</strong> Real-time collaboration has been disabled.' ); ?></p>
123-
</div>
124-
<?php endif; ?>
125-
</td>
126-
</tr>
127112
<?php
128113
if ( get_option( 'link_manager_enabled' ) ) :
129114
?>

src/wp-admin/options.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@
153153
'default_email_category',
154154
'default_link_category',
155155
'default_post_format',
156-
'wp_collaboration_enabled',
157156
),
158157
);
159158
$allowed_options['misc'] = array();

src/wp-includes/collaboration.php

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +0,0 @@
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-
}

0 commit comments

Comments
 (0)