Skip to content

RTC: Add filter for plugins to register additional synced post properties#75876

Closed
smithjw1 wants to merge 1 commit intoWordPress:trunkfrom
smithjw1:smithjw1/crdt-type-fix
Closed

RTC: Add filter for plugins to register additional synced post properties#75876
smithjw1 wants to merge 1 commit intoWordPress:trunkfrom
smithjw1:smithjw1/crdt-type-fix

Conversation

@smithjw1
Copy link
Copy Markdown
Contributor

@smithjw1 smithjw1 commented Feb 24, 2026

Summary

  • Adds a crdt.additionalPostProperties filter so plugins can register custom post properties for real-time collaboration sync (additive-only — default properties cannot be removed)
  • Automatically registers all custom taxonomy rest_base values for CRDT sync when taxonomy entities are loaded from the REST API, so plugins with show_in_rest taxonomies work with RTC out of the box
  • Adds @wordpress/hooks as a dependency to @wordpress/core-data

This means plugins like Co-Authors Plus (which uses a custom taxonomy) no longer need to set redundant meta to participate in real-time collaboration — their taxonomy is auto-synced.

Security

  • Only taxonomies returned by /wp/v2/taxonomies are registered (these already have show_in_rest: true)
  • The REST API enforces assign_terms capabilities server-side on save
  • The editor UI already checks wp:action-assign-{rest_base} link relations before rendering term controls
  • Custom taxonomy terms are simple number[] arrays, handled by the existing default code path (same as categories / tags)

Closes #75875

Test plan

  • Verify existing CRDT unit tests pass: npm run test:unit -- --testPathPattern="packages/core-data/src/utils/test/crdt"
  • Verify new tests pass for registerTaxonomyRestBases (dynamically registered taxonomy properties sync in both directions)
  • Verify a custom taxonomy with show_in_rest: true auto-syncs between collaborators without any plugin-side filter registration
  • Verify the crdt.additionalPostProperties filter still works for non-taxonomy properties

🤖 Generated with Claude Code

…ties

Adds a `crdt.additionalPostProperties` filter so plugins can register
custom taxonomy rest_base values or other post properties for real-time
collaboration sync. The filter is additive-only — default properties
cannot be removed, preventing plugins from accidentally breaking
collaborative editing.

Closes WordPress#75875

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@smithjw1 smithjw1 requested a review from nerrad as a code owner February 24, 2026 17:37
@github-actions github-actions bot added the [Package] Core data /packages/core-data label Feb 24, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 24, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: smithjw1 <smithjw1@git.wordpress.org>
Co-authored-by: chriszarate <czarate@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @smithjw1! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Feb 24, 2026
@smithjw1 smithjw1 added [Type] Enhancement A suggestion for improvement. [Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration labels Feb 24, 2026
@chriszarate
Copy link
Copy Markdown
Contributor

How are these fields registered against the rest_base? Is there a way they can be added automatically without a filter?

@smithjw1
Copy link
Copy Markdown
Contributor Author

For Co-authors Plus they are registered here:

// Register new taxonomy so that we can store all the relationships.
		$args = array(
			'hierarchical' => false,
			'labels'       => array(
				'name'      => __( 'Authors', 'co-authors-plus' ),
				'all_items' => __( 'All Authors', 'co-authors-plus' ),
			),
			'query_var'    => false,
			'rewrite'      => false,
			'public'       => false,
			'sort'         => true,
			'args'         => array( 'orderby' => 'term_order' ),
			'show_ui'      => false,
			'show_in_rest' => true,
			'rest_base'    => 'coauthors',
		);

		// If we use the nasty SQL query, we need our custom callback. Otherwise, we still need to flush cache.
		if ( apply_filters( 'coauthors_plus_should_query_post_author', true ) ) {
			$args['update_count_callback'] = array( $this, '_update_users_posts_count' );
		} else {
			add_action( 'edited_term_taxonomy', array( $this, 'action_edited_term_taxonomy_flush_cache' ), 10, 2 );
		}

		register_taxonomy( $this->coauthor_taxonomy, $this->supported_post_types(), $args );

$this->coauthor_taxonomy resolves to "author" and $this->supported_post_types() does a bunch of things, but in general limits to post types that support author.

I haven't been able to find a way to get this taxonomy to reliably sync without adding placeholder meta.

@chriszarate
Copy link
Copy Markdown
Contributor

Closing in favor of #75983

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Core data /packages/core-data [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RTC: [Engine] - Allow plugins to filter synced properties

2 participants