Work with real-time collaboration: Replace custom Redux store with core entity store#1217
Conversation
…thors
Replace the custom `cap/authors` Redux store and subscribe-based save mechanism
with WordPress's core entity store (`getEditedPostAttribute` / `editPost`). This
lets the block editor treat co-author taxonomy terms as first-class post data,
removing the need for a separate save side-channel.
Key changes:
- Register the `author` taxonomy in the REST API so term IDs flow through the
core entity store automatically.
- Add `authors-by-term-ids` REST endpoint to resolve term IDs to rich author
data for the editor sidebar.
- Add `useCoauthorDetails` hook (with request-scoped caching) to replace the
old store resolver.
- Bridge REST saves to `add_coauthors()` via `rest_after_insert_{post_type}` so
`post_author` sync and legacy filters continue to work.
- Backfill empty coauthor terms from `post_author` in REST responses for posts
that predate the plugin, gated behind `current_user_can('edit_post')`.
- Fire deprecation notices for `coauthors_post_list_pluck_field` and
`coauthors_post_get_coauthor_by_field` filters during REST saves.
- Delete `src/store.js` and the `subscribe()`-based save loop in `src/index.js`.
Closes #1204
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I'll defer to @douglas-johnson , @leogermani , @claudiulodro for the review, but a key bit that's missing is the rationale behind this proposed change. |
Great point @GaryJones. I've updated the title and added a rationale section. Sorry, I knew why I was doing it, but that isn't clear to everyone looking at the PR. |
|
Thanks @smithjw1 , I think this change makes sense and is a good move. We just need to test it thoroughly and evaluate the extent of the impact on things that we and other people might be relying on... We'll have a closer look! |
Can you expand on what exactly doesn't work? In the current state if multiple people try to change authors at the same time they will override each others changes? Is that what we are solving? Or is the idea that collaborative editing will automatically assign a person as a co-author when they make edits to it? |
Yes, that's what happens. Today, if User A and User B are both editing, the "last save wins." With this change, updates made by User B will be immediately reflected to User A. |
|
I tested in a full site editor theme and a hybrid theme with WordPress 7.0-RC2. I did not experience any issues while using the sidebar to add / update co-authors in the post editor or using the co-author blocks in the site editor. |
leogermani
left a comment
There was a problem hiding this comment.
This looks really good and is a great improvement regardless of collaborative editing. Using term-id in the front end was a good idea to avoid ID collisions between authors and guest authors.
I gave it a full round of testing and it seems to be working fine. I left only two minor comments... I'm still unsure if this can have any bugs with really old guest authors because of what I see here. But I think it's fine.
I'll ask some help to review the JS/Store piece of it from more experienced folks on that front.
One thing I know is that this will break any integrations that are relying on the CAP's store for some reason. I know we are. But we can fix it.
chickenn00dle
left a comment
There was a problem hiding this comment.
Just noting I had a look at the JS changes which look good. I left two non-blocking comments. Feel free to ignore.
- Remove unnecessary `cap-` prefix stripping in get_coauthors_by_term_ids() and sync_coauthors_on_rest_save() — get_coauthor_by() already handles this via get_post_meta_key(). - Remove unused hasFinishedResolution destructure from useSelect. - Use `coauthors !== undefined` instead of `!! postId` to determine whether the post entity has resolved, ensuring attributes are available. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I've addressed the PR comments to date, but it would be good to get this out there and tested before releasing a breaking change. What's the best way to communicate that to plugin users? |
|
@GaryJones I should have addressed this question to you: I've addressed the PR comments to date, but it would be good to get this out there and tested before releasing a breaking change. What's the best way to communicate that to plugin users? |
|
@smithjw1 We can tag a beta/RC release, and you can send the link to whichever customers you think are willing to test. |
Forgive my ignorance, but is merging this to the develop branch the first step in that process? Having never run a release of this plugin, I'm unsure. |
The two _deprecated_hook() calls guarding coauthors_post_list_pluck_field and coauthors_post_get_coauthor_by_field originally named Co-Authors Plus 3.8 as the deprecation version, on the assumption that this change would land in the next minor release. The store switch in this PR is a breaking change for consumers that read from the cap/authors Redux store directly (Newspack being a known case), so the release has been re-scoped to 4.0. The version argument to _deprecated_hook() is what WordPress surfaces to developers via deprecation warnings, so it must accurately name the release in which the deprecation actually lands — otherwise plugin authors chasing the warning will look for a 3.8 release that never existed.
|
With Gutenberg v23, and two tabs open (Eddie the Editor, and Admin the Administrator), I was able to show that updating of co-authors was reflected in RTC. Screen.Recording.2026-04-23.at.00.31.19.mov |
Rationale
Real-time collaboration observes the core data store to sync entities among collaborators. By switching the storage mechanism, Co-Authors Plus becomes compatible with real-time collaboration. This only affects how co-authors are manipulated and saved in the editor. The underlying data shape stays the same.
Description
Replaces the custom
cap/authorsRedux store andsubscribe()-based save mechanism with WordPress's core entity store (getEditedPostAttribute/editPost). Co-author taxonomy term IDs now flow through the standard post entity.Adds a new
authors-by-term-idsREST endpoint so the editor sidebar can resolve term IDs to rich author data, auseCoauthorDetailshook with request-scoped caching, and PHP-side bridging logic (sync_coauthors_on_rest_save,backfill_coauthor_terms_in_rest) to keeppost_authorin sync and fire deprecation notices for legacy filters.Closes #1204
Deploy Notes
No new dependencies. The
prop-typesimport was removed from the JS side. The customcap/authorsdata store is no longer registered — any third-party code relying onselect('cap/authors')will need to migrate to the core entity store.Steps to Test
npm run build.post_authoris backfilled as a co-author term.post_authorstays in sync with the first co-author after saves.