From 13c531087be6c6889cc954a0bdf8788b3c8b7d0f Mon Sep 17 00:00:00 2001 From: Alec Geatches Date: Mon, 13 Apr 2026 14:15:48 -0600 Subject: [PATCH 1/2] Use `__rtc_compatible_meta_box` flag to set RTC-compatible metaboxes --- src/wp-admin/includes/post.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index 8d52c1487a7a5..5e87559256c36 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -2406,6 +2406,8 @@ function the_block_editor_meta_boxes() { \n%s\n\n", trim( $script ) ); } + /* + * If collaboration is enabled and any meta boxes are marked as RTC-compatible, + * pass their IDs to the editor so it can determine which meta boxes are safe + * to use alongside real-time collaboration. + */ + if ( wp_is_collaboration_enabled() && ! empty( $rtc_compatible_ids ) ) { + $rtc_script = 'window._wpLoadBlockEditor.then( function() { + wp.data.dispatch( \'core/edit-post\' ).setRtcCompatibleMetaBoxIds( ' + . wp_json_encode( array_values( array_unique( $rtc_compatible_ids ) ) ) + . ' ); + } );'; + + wp_add_inline_script( 'wp-edit-post', $rtc_script ); + + /* + * When `wp-edit-post` is output in the ``, the inline script needs to be + * manually printed. Otherwise, inline scripts for `wp-edit-post` will not be + * printed again after this point. + */ + if ( wp_script_is( 'wp-edit-post', 'done' ) ) { + printf( "\n", trim( $rtc_script ) ); + } + } + /* * If the 'postcustom' meta box is enabled, then we need to perform * some extra initialization on it. From 7cf2453d59286996582add4e0c6d5ef0c214a340 Mon Sep 17 00:00:00 2001 From: Alec Geatches Date: Wed, 15 Apr 2026 11:56:21 -0600 Subject: [PATCH 2/2] Merge refactor from gutenberg#77361 --- src/wp-admin/includes/post.php | 40 +++++++--------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index 5e87559256c36..99b268f5d2650 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -2406,8 +2406,6 @@ function the_block_editor_meta_boxes() { $meta_box['id'], 'title' => $meta_box['title'], ); + + // Mark meta boxes compatible with real-time collaboration. + if ( ! empty( $meta_box['args']['__rtc_compatible_meta_box'] ) ) { + $meta_box_entry['__rtc_compatible'] = true; + } + + $meta_boxes_per_location[ $location ][] = $meta_box_entry; } } } @@ -2466,30 +2466,6 @@ function the_block_editor_meta_boxes() { printf( "\n", trim( $script ) ); } - /* - * If collaboration is enabled and any meta boxes are marked as RTC-compatible, - * pass their IDs to the editor so it can determine which meta boxes are safe - * to use alongside real-time collaboration. - */ - if ( wp_is_collaboration_enabled() && ! empty( $rtc_compatible_ids ) ) { - $rtc_script = 'window._wpLoadBlockEditor.then( function() { - wp.data.dispatch( \'core/edit-post\' ).setRtcCompatibleMetaBoxIds( ' - . wp_json_encode( array_values( array_unique( $rtc_compatible_ids ) ) ) - . ' ); - } );'; - - wp_add_inline_script( 'wp-edit-post', $rtc_script ); - - /* - * When `wp-edit-post` is output in the ``, the inline script needs to be - * manually printed. Otherwise, inline scripts for `wp-edit-post` will not be - * printed again after this point. - */ - if ( wp_script_is( 'wp-edit-post', 'done' ) ) { - printf( "\n", trim( $rtc_script ) ); - } - } - /* * If the 'postcustom' meta box is enabled, then we need to perform * some extra initialization on it.