From 116d0d1978040d72ee91f25fe51d953a2187e6a3 Mon Sep 17 00:00:00 2001 From: Alec Geatches Date: Thu, 5 Mar 2026 16:42:57 -0700 Subject: [PATCH 1/2] Backport gutenberg#76223 - disable RTC on site editor --- src/wp-includes/collaboration.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/collaboration.php b/src/wp-includes/collaboration.php index 1da7f2c367140..e7ac2d54206b1 100644 --- a/src/wp-includes/collaboration.php +++ b/src/wp-includes/collaboration.php @@ -14,11 +14,24 @@ * @access private */ function wp_collaboration_inject_setting() { - if ( get_option( 'enable_real_time_collaboration' ) ) { - wp_add_inline_script( - 'wp-core-data', - 'window._wpCollaborationEnabled = true;', - 'after' - ); + global $pagenow; + + if ( ! get_option( 'wp_enable_real_time_collaboration' ) ) { + return; + } + + // Disable real-time collaboration on the site editor. + $enabled = true; + if ( + 'site-editor.php' === $pagenow || + ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'site-editor-v2' === $_GET['page'] ) + ) { + $enabled = false; } + + wp_add_inline_script( + 'wp-core-data', + 'window._wpCollaborationEnabled = ' . ( $enabled ? 'true' : 'false' ) . ';', + 'after' + ); } From 80728c6a7616c71cc0f78070362e9ab66f4e9467 Mon Sep 17 00:00:00 2001 From: Alec Geatches Date: Wed, 11 Mar 2026 12:26:08 -0600 Subject: [PATCH 2/2] Address PR feedback: Add global usage doc, remove site-editor-v2, use wp_json_encode instead of strings --- src/wp-includes/collaboration.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/collaboration.php b/src/wp-includes/collaboration.php index e7ac2d54206b1..31f816c87b670 100644 --- a/src/wp-includes/collaboration.php +++ b/src/wp-includes/collaboration.php @@ -12,6 +12,8 @@ * @since 7.0.0 * * @access private + * + * @global string $pagenow The filename of the current screen. */ function wp_collaboration_inject_setting() { global $pagenow; @@ -22,16 +24,13 @@ function wp_collaboration_inject_setting() { // Disable real-time collaboration on the site editor. $enabled = true; - if ( - 'site-editor.php' === $pagenow || - ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'site-editor-v2' === $_GET['page'] ) - ) { + if ( 'site-editor.php' === $pagenow ) { $enabled = false; } wp_add_inline_script( 'wp-core-data', - 'window._wpCollaborationEnabled = ' . ( $enabled ? 'true' : 'false' ) . ';', + 'window._wpCollaborationEnabled = ' . wp_json_encode( $enabled ) . ';', 'after' ); }