PluginProbe
Gutenberg / 24.0.0
Gutenberg v24.0.0
24.0.0 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 All 403 releases
gutenberg / lib / experimental / collaboration / rest-api.php

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

32 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, regular draft autosaves are stored as revisions instead
13 * of updating the parent post based on its lock and author. Auto-drafts are
14 * still promoted to drafts.
15 *
16 * Only overrides when RTC is enabled and autosave_rest_controller_class is not
17 * explicitly set, i.e. when WP_REST_Autosaves_Controller would be used by
18 * default. Post types with their own specialized autosave controller (e.g.
19 * templates) are left alone.
20 *
21 * @param array $args Array of arguments for registering a post type.
22 * @return array Modified array of arguments.
23 */
24 function gutenberg_override_autosaves_rest_controller( $args ) {
25 if ( empty( $args['autosave_rest_controller_class'] ) && wp_is_collaboration_enabled() ) {
26 $args['autosave_rest_controller_class'] = 'Gutenberg_REST_Autosaves_Controller';
27 }
28 return $args;
29 }
30
31 add_filter( 'register_post_type_args', 'gutenberg_override_autosaves_rest_controller', 10, 1 );
32