Skip to content

Conversation

@fabiankaegy
Copy link
Member

@fabiankaegy fabiankaegy commented Feb 18, 2025

Warning

This PR is based on top of #91

Description of the Change

Adds a WordPress Data store to more easily interface with the Content Connect REST API from within the Block Editor.

Closes #45

How to test the Change

  1. Ensure you have a test environment with a few connections configured (For example using the demo plugin: https://github.com/fabiankaegy/wp-content-connect-example-data)
  2. Use the browser console on a post that has connections (in the editor) to run wp.data.select('wp-content-connect').getRelationships(xxx) where xxx is the current post id
  3. This will resolve an empty object at first but if you run it again it will show you the relationships (this is expected since to begin with the relationships are not preloaded. useSelect will smooth this experience)
  4. Now that you have the relationship you can get some actually related posts by running: wp.data.select('wp-content-connect').getRelatedPosts(xxx, 'university_city_university_to_city')
  5. You can also update the relationships by running: wp.data.dispatch('wp-content-connect').updateRelatedPosts( xxx, 'university_city_university_to_city', [ yyy, zzz ] )

Note

This PR is still very much in progress and subject to change :)

Changelog Entry

Added - WordPress Data API store for interacting with the wp-content-connect plugin
Added - Block editor UI

Credits

Props @fabiankaegy @s3rgiosan

@fabiankaegy fabiankaegy self-assigned this Feb 18, 2025
@fabiankaegy fabiankaegy changed the base branch from develop to feature/rest-api-endpoint February 18, 2025 10:16
@fabiankaegy fabiankaegy force-pushed the feature/data-api-backbone branch from 4608980 to 621e135 Compare February 18, 2025 10:55
@fabiankaegy fabiankaegy changed the title Feature: data api backbone Feature: Native Block Editor Interface Feb 18, 2025
@s3rgiosan
Copy link
Member

Hi @fabiankaegy I went ahead and updated the UI to use the new ContentPicker, along with some fixes and improvements for post-to-user relationship support and bi-directional panels in post-to-post relationships. Ready for your review when you can.

@s3rgiosan
Copy link
Member

@fabiankaegy latest update on the sorting experience:

Screen.Recording.2025-05-06.at.6.42.59.PM.mp4

@ocean90
Copy link

ocean90 commented May 6, 2025

Hi @ocean90,
Can you try again when you have a chance to see if the problem still persists?

I just tested the latest changes and the problem doesn't exist anymore. Good job!

Something to consider: The content picker doesn't work well with longer titles. The component uses <Truncate> with no option (like a tooltip) to view the full title anymore. If you have very similar titles, you will no longer be able to distinguish between them.

@s3rgiosan
Copy link
Member

Something to consider: The content picker doesn't work well with longer titles. The component uses <Truncate> with no option (like a tooltip) to view the full title anymore. If you have very similar titles, you will no longer be able to distinguish between them.

Thanks for the suggestion, @ocean90! I'm actually working on a custom picker item for Content Connect here: #99. I'll keep that in mind when I get back to it.

queryFilter={(query) => {
if (relationship?.rel_key) {
return addQueryArgs(query, {
content_connect: relationship.rel_key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this search parameter mainly to give context to the editor-side search when it reaches the rest_post_search_query hook in PHP. One of my clients uses ElasticPress, and I needed a way to disable EP for these specific queries. This parameter can also be used to filter search results based on client-specific requirements. It might also be worth including the current post ID.

Remove commented code
barryceelen and others added 8 commits May 22, 2025 13:49
The JS that renders the content picker already added support for a new
max_items key on the relationship args. This update adds the required
PHP update to support that key.
# Conflicts:
#	includes/API/V2/Route/Relationships.php
@s3rgiosan s3rgiosan requested a review from jeffpaul as a code owner May 26, 2025 11:05
@jeffpaul jeffpaul mentioned this pull request May 27, 2025
4 tasks
@ocean90
Copy link

ocean90 commented Jul 23, 2025

Noticed an issue with the display of relationships which can't be edited by the user: 10up/block-components#390

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

Labels

None yet

Projects

Status: QA Testing

Development

Successfully merging this pull request may close these issues.

6 participants