# gutenberg/24.0.0/lib/experimental/collaboration/rest-api.php

Gutenberg, version 24.0.0. 32 lines.

- Page: https://pluginprobe.com/plugins/gutenberg/24.0.0/code/lib/experimental/collaboration/rest-api.php
- Raw: https://pluginprobe.com/plugins/gutenberg/24.0.0/raw/lib/experimental/collaboration/rest-api.php
- Modified: 2026-08-19T11:08:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/gutenberg/24.0.0/code/lib/experimental/collaboration/rest-api.php#L10-L20`.

```php
<?php
/**
 * REST API compatibility functions for real-time collaboration.
 *
 * @package gutenberg
 */

/**
 * Overrides the default REST controller for autosaves to fix real-time
 * collaboration on draft posts.
 *
 * When RTC is enabled, regular draft autosaves are stored as revisions instead
 * of updating the parent post based on its lock and author. Auto-drafts are
 * still promoted to drafts.
 *
 * Only overrides when RTC is enabled and autosave_rest_controller_class is not
 * explicitly set, i.e. when WP_REST_Autosaves_Controller would be used by
 * default. Post types with their own specialized autosave controller (e.g.
 * templates) are left alone.
 *
 * @param array $args Array of arguments for registering a post type.
 * @return array Modified array of arguments.
 */
function gutenberg_override_autosaves_rest_controller( $args ) {
	if ( empty( $args['autosave_rest_controller_class'] ) && wp_is_collaboration_enabled() ) {
		$args['autosave_rest_controller_class'] = 'Gutenberg_REST_Autosaves_Controller';
	}
	return $args;
}

add_filter( 'register_post_type_args', 'gutenberg_override_autosaves_rest_controller', 10, 1 );

```
