Skip to content

Commit 326239e

Browse files
t-hamanoMamadukaim3dabasiaingeniumed
authored
Move real-time collaboration code to lib/experimental/collaboration (#80469)
* Move real-time collaboration code to lib/experimental/collaboration RTC is not part of WordPress 7.1, and whether it lands in a future release is still undecided. Move the sync/save servers, storage, the collaboration bootstrap, the RTC autosaves controller and its REST override, and the RTC meta-box compat out of compat/wordpress-7.1 into a dedicated experimental/collaboration directory. The autosaves controller extends WP_REST_Autosaves_Controller, so it stays inside the class_exists( 'WP_REST_Controller' ) guard; the meta-box compat moves to the unconditional Experimental features section. Co-Authored-By: Claude <noreply@anthropic.com> * Use 'default' text domain for reused core strings in collaboration row actions The "Edit &#8220;%s&#8221;" and "Edit" strings reuse WordPress Core translations, so pass the 'default' text domain explicitly to satisfy WordPress.WP.I18n.MissingArgDomainDefault and reuse core's existing translations. Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org> Co-authored-by: ingeniumed <ingeniumed@git.wordpress.org>
1 parent 6755a4d commit 326239e

11 files changed

Lines changed: 39 additions & 31 deletions

lib/compat/wordpress-7.1/rest-api.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,3 @@ function gutenberg_override_attachments_rest_controller( $args, $post_type ) {
7373
return $args;
7474
}
7575
add_filter( 'register_post_type_args', 'gutenberg_override_attachments_rest_controller', 10, 2 );
76-
77-
/**
78-
* Overrides the default REST controller for autosaves to fix real-time
79-
* collaboration on draft posts.
80-
*
81-
* When RTC is enabled, draft autosaves from all users update the post directly
82-
* instead of creating per-user autosave revisions depending on post lock and
83-
* assigned author.
84-
*
85-
* Only overrides when autosave_rest_controller_class is not explicitly set,
86-
* i.e. when WP_REST_Autosaves_Controller would be used by default. Post types
87-
* with their own specialized autosave controller (e.g. templates) are left alone.
88-
*
89-
* @param array $args Array of arguments for registering a post type.
90-
* @return array Modified array of arguments.
91-
*/
92-
function gutenberg_override_autosaves_rest_controller( $args ) {
93-
if ( empty( $args['autosave_rest_controller_class'] ) ) {
94-
$args['autosave_rest_controller_class'] = 'Gutenberg_REST_Autosaves_Controller';
95-
}
96-
return $args;
97-
}
98-
99-
add_filter( 'register_post_type_args', 'gutenberg_override_autosaves_rest_controller', 10, 1 );

lib/compat/wordpress-7.1/class-gutenberg-rest-autosaves-controller.php renamed to lib/experimental/collaboration/class-gutenberg-rest-autosaves-controller.php

File renamed without changes.

lib/compat/wordpress-7.1/class-wp-http-polling-sync-server.php renamed to lib/experimental/collaboration/class-wp-http-polling-sync-server.php

File renamed without changes.
File renamed without changes.

lib/compat/wordpress-7.1/class-wp-sync-post-meta-storage.php renamed to lib/experimental/collaboration/class-wp-sync-post-meta-storage.php

File renamed without changes.

lib/compat/wordpress-7.1/class-wp-sync-save-server.php renamed to lib/experimental/collaboration/class-wp-sync-save-server.php

File renamed without changes.

lib/compat/wordpress-7.1/collaboration.php renamed to lib/experimental/collaboration/collaboration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,8 @@ function gutenberg_post_list_collaboration_row_actions( $actions, $post ) {
580580
. '<span class="join-action-text"><a href="%1$s" aria-label="%4$s">%5$s</a></span>',
581581
esc_url( get_edit_post_link( $post->ID ) ),
582582
/* translators: %s: Post title. */
583-
esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ),
584-
__( 'Edit' ),
583+
esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;', 'default' ), $title ) ),
584+
__( 'Edit', 'default' ),
585585
/* translators: %s: Post title. */
586586
esc_attr( sprintf( __( 'Join editing &#8220;%s&#8221;', 'gutenberg' ), $title ) ),
587587
/* translators: Action link text for a singular post in the post list. Can be any type of post. */

lib/compat/wordpress-7.1/interface-wp-sync-storage.php renamed to lib/experimental/collaboration/interface-wp-sync-storage.php

File renamed without changes.
File renamed without changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* REST API compatibility functions for real-time collaboration.
4+
*
5+
* @package gutenberg
6+
*/
7+
8+
/**
9+
* Overrides the default REST controller for autosaves to fix real-time
10+
* collaboration on draft posts.
11+
*
12+
* When RTC is enabled, draft autosaves from all users update the post directly
13+
* instead of creating per-user autosave revisions depending on post lock and
14+
* assigned author.
15+
*
16+
* Only overrides when autosave_rest_controller_class is not explicitly set,
17+
* i.e. when WP_REST_Autosaves_Controller would be used by default. Post types
18+
* with their own specialized autosave controller (e.g. templates) are left alone.
19+
*
20+
* @param array $args Array of arguments for registering a post type.
21+
* @return array Modified array of arguments.
22+
*/
23+
function gutenberg_override_autosaves_rest_controller( $args ) {
24+
if ( empty( $args['autosave_rest_controller_class'] ) ) {
25+
$args['autosave_rest_controller_class'] = 'Gutenberg_REST_Autosaves_Controller';
26+
}
27+
return $args;
28+
}
29+
30+
add_filter( 'register_post_type_args', 'gutenberg_override_autosaves_rest_controller', 10, 1 );

0 commit comments

Comments
 (0)