Feature: Customization filter hooks#104
Open
s3rgiosan wants to merge 18 commits intofeature/data-api-backbonefrom
Open
Feature: Customization filter hooks#104s3rgiosan wants to merge 18 commits intofeature/data-api-backbonefrom
s3rgiosan wants to merge 18 commits intofeature/data-api-backbonefrom
Conversation
…ship-component # Conflicts: # assets/js/components/relationship-manager.tsx
…e for long titles
…ship-component # Conflicts: # dist/js/wp-content-connect.asset.php # dist/js/wp-content-connect.js
…ship-component # Conflicts: # assets/js/components/RelationshipManager/index.tsx # assets/js/components/RelationshipsPanel/index.tsx # assets/js/index.ts # dist/js/wp-content-connect.asset.php # dist/js/wp-content-connect.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the Change
This PR introduces WordPress JavaScript filter hooks in Content Connect's
RelationshipManagercomponent, enabling projects to customize search results, picked items, and preview components in the Block Editor UI. These filters are context-aware allowing both global and per-relationship customization.Problem
Content Connect's Block Editor UI uses hardcoded filter functions that cannot be customized by projects. This limits flexibility when projects need to:
Solution
Added three WordPress JavaScript filter hooks that receive full relationship context:
contentConnect.searchResultFilter- Customizes search result items before displaycontentConnect.pickedItemFilter- Customizes picked item data before displaycontentConnect.pickedItemPreviewComponent- Allows replacing the preview component with custom React componentsAll filters receive a context object containing:
rel_key: The relationship keyrel_type: 'post-to-post' or 'post-to-user'postId: Current post IDmode: Content search mode ('post' | 'user' | 'term')Filter Usage Examples
Global Customization:
Per-Relationship Customization:
Custom Preview Component:
How to Test the Change
npm run build(from root directory)npm run wp-env:start(or your preferred method)contentConnect.searchResultFilter:contentConnect.pickedItemFilter:contentConnect.pickedItemPreviewComponent:context.rel_keyorcontext.rel_typeChangelog Entry
Credits
Props @s3rgiosan
Checklist: