PluginProbe
Gutenberg / 23.7.2
Gutenberg v23.7.2
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / experimental / collaboration / rest-api.php

rest-api.php in Gutenberg 23.7.2, at lib/experimental/collaboration/rest-api.php

31 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 );
31