Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
270f468
Bump simple-git
dependabot[bot] Oct 20, 2026
8041a00
Merge pull request #152 from 10up/dependabot/npm_and_yarn/npm_and_yar…
s3rgiosan Oct 20, 2026
f845d90
Bump follow-redirects
dependabot[bot] Oct 20, 2026
71f43e2
Merge pull request #153 from 10up/dependabot/npm_and_yarn/npm_and_yar…
s3rgiosan Oct 20, 2026
798627f
Bump launch-editor
dependabot[bot] Oct 20, 2026
7b47326
Merge pull request #154 from 10up/dependabot/npm_and_yarn/npm_and_yar…
s3rgiosan Oct 21, 2026
5a6d37c
Merge branch 'develop' into feature/abilities
s3rgiosan Oct 22, 2026
3431132
docs: note that the editor UI no longer runs the legacy query filters
s3rgiosan Oct 28, 2026
2e97827
fix: keep relationship data out of anonymous REST responses
s3rgiosan Oct 28, 2026
33b1165
Bump fast-uri
dependabot[bot] Oct 30, 2026
fcdfb95
Merge pull request #156 from 10up/dependabot/npm_and_yarn/npm_and_yar…
s3rgiosan Oct 30, 2026
2dd8622
build(deps): bump the npm_and_yarn group across 1 directory with 4 up…
dependabot[bot] Nov 9, 2026
edb2ba9
Merge pull request #155 from 10up/fix/rest-relationship-exposure
s3rgiosan Nov 9, 2026
6c5071f
Merge pull request #157 from 10up/dependabot/npm_and_yarn/npm_and_yar…
s3rgiosan Nov 10, 2026
4c6e131
build(deps): bump follow-redirects
dependabot[bot] Nov 12, 2026
f4d9c1c
Merge pull request #158 from 10up/dependabot/npm_and_yarn/npm_and_yar…
s3rgiosan Nov 12, 2026
01004f1
fix: keep unpublished related posts when saving from the editor (#145)
s3rgiosan Nov 19, 2026
e2243b4
Return stable empty values from the editor store selectors (#160)
s3rgiosan Nov 19, 2026
3d76103
build(deps-dev): bump fast-xml-parser (#164)
dependabot[bot] Dec 3, 2026
35fa53c
Merge remote-tracking branch 'origin/develop' into feature/abilities
s3rgiosan Dec 3, 2026
3114f93
Point ability descriptions at the Query Loop for related posts (#147)
fabiankaegy Dec 3, 2026
3e2017b
feat: add an ability that returns related posts query loop markup
fabiankaegy Oct 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ All notable changes to this project will be documented in this file, per [the Ke
### Added

- Read-only Abilities API abilities `content-connect/get-relationships`, `content-connect/get-post-relationships`, and `content-connect/get-related-items`, exposed over REST and MCP, registered on WordPress 6.9+ only (props [@s3rgiosan](https://github.com/s3rgiosan)).
- Ability descriptions that point agents to a Query Loop (`core/query`) block filtered by the relationship for displaying related posts (props [@fabiankaegy](https://github.com/fabiankaegy) via [#147](https://github.com/10up/wp-content-connect/pull/147)).
- Read-only ability `content-connect/get-related-query-block` that returns Query Loop markup listing a post's related posts, so agents display related content with a live query instead of a hand-picked list (props [@fabiankaegy](https://github.com/fabiankaegy)).

## [2.0.0] - TBD

### Breaking Changes

2.0.0 is a major rewrite of the editor UI and REST surface. **Stored relationship data and the database schema are unchanged**, and the documented public API is preserved: the relationship objects and their data methods (`add_relationship()`, `delete_relationship()`, `replace_relationships()`, the `save_*_sort_data()` family, etc.), `WP_Query` relationship queries, the helper functions, and the `content-connect/v1/search` endpoint URL all continue to work. No action is required if you use these documented interfaces.

The changes below affect only code that referenced plugin **internals** that were never part of the documented API:
Apart from the editor UI query filters noted in the last item, the changes below affect only code that referenced plugin **internals** that were never part of the documented API:

- **Moved class:** `TenUp\ContentConnect\API\Search` is now `TenUp\ContentConnect\API\V1\Search`. The `content-connect/v1/search` REST endpoint URL is unchanged.
- **Removed UI classes:** `UI\MetaBox`, `UI\PostToPost`, `UI\PostToUser`, and `UI\PostUI` were replaced by the React-based `UI\BlockEditor` and `UI\ClassicEditor`.
- **`Plugin` members:** the `$url`, `$version`, `$meta_box`, `$search`, `$deleted_items`, `$wp_query_integration`, and `$user_query_integration` public properties were removed — use the `CONTENT_CONNECT_URL`, `CONTENT_CONNECT_VERSION`, and `CONTENT_CONNECT_PATH` constants instead. `Plugin::wp_init()` was renamed to `Plugin::init()`.
- **Relationship internals:** `Relationship::setup()`, `PostToPost::setup()`, `PostToUser::setup()`, and the `$from_ui` / `$to_ui` properties were removed. `Registry::define_post_to_post()` and `define_post_to_user()` no longer instantiate UI objects.
- **Editor assets:** the `tenup-content-connect` script handle and the `window.ContentConnectData` global were removed. The Classic Editor metabox markup and save flow changed — relationships now persist through the REST v2 API instead of a `save_post` form submission.
- **Removed filter:** `tenup_content_connect_localize_data`, which only filtered the removed Vue interface's localized payload, no longer fires. The `tenup_content_connect_post_relationship_data` filter is retained (now applied in the data layer, with added `$rel_type`, `$other_post_type`, and `$context` arguments).
- **Editor UI query filters:** the editor UI no longer runs `tenup_content_connect_search_posts_query_args`, `tenup_content_connect_search_users_query_args`, `tenup_content_connect_post_ui_query_args`, or `tenup_content_connect_post_ui_user_query_args`. The search filters still fire only on the deprecated `content-connect/v1/search` endpoint, and the Post UI filters only on `GET /content-connect/v2/post/{post_id}/relationships?context=embed`. The relationship picker searches through the core `wp/v2/search` and `wp/v2/users` endpoints, so use the core `rest_post_search_query` and `rest_user_query` filters to change search results; the request carries the relationship key in the `content_connect` parameter. Selected items load from `GET /content-connect/v2/post/{post_id}/related`, whose readability rule the `tenup_content_connect_related_posts_readable_where` filter replaces. The `contentConnect.searchResultFilter` and `contentConnect.pickedItemFilter` JavaScript hooks change how search results and selected items are shaped in the picker.

### Added

Expand All @@ -30,15 +33,15 @@ The changes below affect only code that referenced plugin **internals** that wer
- REST API v2 endpoint `GET /content-connect/v2/relationships` to retrieve all relationships by type, with optional filtering by key, post type, or from/to post types (props [@s3rgiosan](https://github.com/s3rgiosan) via [#95](https://github.com/10up/wp-content-connect/pull/95)).
- REST API v2 endpoint `GET /content-connect/v2/post/{post_id}/relationships` to retrieve all relationships for a post, with filtering by relationship type, post type, and context (`view`/`embed`) (props [@s3rgiosan](https://github.com/s3rgiosan) via [#95](https://github.com/10up/wp-content-connect/pull/95)).
- REST API v2 endpoints `GET|POST|PUT|DELETE /content-connect/v2/post/{post_id}/related` to retrieve (with pagination and ordering, limited to posts the current user can read), replace, add, and remove related entities for a post, preserving sort order for sortable relationships (props [@s3rgiosan](https://github.com/s3rgiosan) via [#95](https://github.com/10up/wp-content-connect/pull/95), [#143](https://github.com/10up/wp-content-connect/pull/143)).
- Automatic `content-connect:relationships` and `content-connect:related` REST API links on post responses for post types that support REST (props [@s3rgiosan](https://github.com/s3rgiosan) via [#95](https://github.com/10up/wp-content-connect/pull/95)).
- Automatic `content-connect:relationships` and `content-connect:related` REST API links on post responses for post types that support REST, added only for users who can edit the post; the `tenup_content_connect_add_rest_links` filter changes who receives them (props [@s3rgiosan](https://github.com/s3rgiosan) via [#95](https://github.com/10up/wp-content-connect/pull/95)).
- WordPress Data API store (`wp-content-connect`) for managing Content Connect relationships within the Block Editor (props [@fabiankaegy](https://github.com/fabiankaegy), [@barryceelen](https://github.com/barryceelen), [@s3rgiosan](https://github.com/s3rgiosan) via [#94](https://github.com/10up/wp-content-connect/pull/94)).
- React hooks `useRelationships()` and `useRelatedEntities()` for accessing and managing relationships in custom blocks (props [@fabiankaegy](https://github.com/fabiankaegy), [@barryceelen](https://github.com/barryceelen), [@s3rgiosan](https://github.com/s3rgiosan) via [#94](https://github.com/10up/wp-content-connect/pull/94)).
- Block Editor UI integration with automatic relationship panels in the Document Settings sidebar (props [@fabiankaegy](https://github.com/fabiankaegy), [@barryceelen](https://github.com/barryceelen), [@s3rgiosan](https://github.com/s3rgiosan) via [#94](https://github.com/10up/wp-content-connect/pull/94)).
- WordPress JavaScript filter hooks `contentConnect.searchResultFilter`, `contentConnect.pickedItemFilter`, and `contentConnect.pickedItemPreviewComponent` for customizing the Block Editor UI, with relationship context awareness (props [@s3rgiosan](https://github.com/s3rgiosan) via [#104](https://github.com/10up/wp-content-connect/pull/104)).
- WordPress 7.0 compatibility; set WordPress minimum supported version to 6.8 (props [@mphillips](https://github.com/mphillips) via [#120](https://github.com/10up/wp-content-connect/pull/120)).
- WordPress Playground blueprint (`.github/blueprints/blueprint.json`) for a one-click, zero-install plugin demo (props [@s3rgiosan](https://github.com/s3rgiosan) via [#122](https://github.com/10up/wp-content-connect/pull/122)).
- `tenup-content-connect-update-relationships-order` action for developers to run logic after relationship order is saved, firing for post-to-post, post-to-user, and user-to-post relationships (props [@ocean90](https://github.com/ocean90) via [#123](https://github.com/10up/wp-content-connect/pull/123)).
- Query Loop block integration that filters posts by Content Connect relationships, in the editor preview and on the front end (props [@fabiankaegy](https://github.com/fabiankaegy), [@s3rgiosan](https://github.com/s3rgiosan) via [#98](https://github.com/10up/wp-content-connect/pull/98)).
- Query Loop block integration that filters posts by Content Connect relationships, in the editor preview and on the front end. The `relationshipQuery` and `orderByRelationship` params on core `wp/v2` post endpoints apply only for users who can edit posts of the queried type; the `tenup_content_connect_rest_relationship_query_allowed` filter changes who can use them (props [@fabiankaegy](https://github.com/fabiankaegy), [@s3rgiosan](https://github.com/s3rgiosan) via [#98](https://github.com/10up/wp-content-connect/pull/98)).
- PHPStan static analysis and a PHPCompatibility check for PHP 8.2–8.5, run in CI (props [@s3rgiosan](https://github.com/s3rgiosan) via [#135](https://github.com/10up/wp-content-connect/pull/135)).

### Changed
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,25 @@ Content Connect registers a set of `content-connect/v2` REST endpoints used by t
- `PUT /content-connect/v2/post/<id>/related` — Add a single related item (`related_id`).
- `DELETE /content-connect/v2/post/<id>/related` — Remove a single related item (`related_id`).

Post REST responses for post types that support REST also gain `content-connect:relationships` and `content-connect:related` HAL links.
Post REST responses for post types that support REST also gain `content-connect:relationships` and `content-connect:related` HAL links. The links are added only for users who can edit the post. Use the `tenup_content_connect_add_rest_links` filter to change that:

```php
// Never expose the links, not even to editors.
add_filter( 'tenup_content_connect_add_rest_links', '__return_false' );
```

The Query Loop integration adds `relationshipQuery` and `orderByRelationship` params to the core `wp/v2` post endpoints. They apply only for users who can edit posts of the queried type; for anyone else they are ignored. The Query Loop block's front-end rendering does not use REST and is not affected. Use the `tenup_content_connect_rest_relationship_query_allowed` filter to allow other users, for example on a headless front end:

```php
add_filter(
'tenup_content_connect_rest_relationship_query_allowed',
function ( $allowed, $request, $args ) {
return $allowed || 'product' === $args['post_type'];
},
10,
3
);
```

> The legacy `POST /content-connect/v1/search` endpoint is **deprecated** as of 2.0.0. Use the v2 endpoints above.

Expand Down
1 change: 1 addition & 0 deletions assets/js/store/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type GetRelatedEntitiesOptions = {
orderby?: string;
per_page?: number;
page?: number;
post_status?: string | string[];
}

export async function getRelatedEntities(
Expand Down
20 changes: 15 additions & 5 deletions assets/js/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ export function getRelationshipsKey(postId: number, options?: api.GetRelationshi
return `relationships-${postId}-${JSON.stringify(options ?? {})}`;
}

/**
* Empty selector results.
*
* The selectors return these shared values when there is no data, so that
* `useSelect` gets the same reference on each call.
*/
const EMPTY_RELATIONSHIPS: Record<string, { rel_key: string; rel_type: string }> = {};
const EMPTY_RELATED_ENTITIES: ContentConnectRelatedEntities = [];

/**
* Store defaults
*/
Expand Down Expand Up @@ -207,18 +216,18 @@ export const store = createReduxStore(STORE_NAME, {
selectors: {
getRelationships(state: ContentConnectState, postId: number | null, options?: api.GetRelationshipsOptions): Record<string, { rel_key: string; rel_type: string }> {
if (postId === null) {
return {};
return EMPTY_RELATIONSHIPS;
}
const key = getRelationshipsKey(postId, options);
return state.relationships[key] || {};
return state.relationships[key] || EMPTY_RELATIONSHIPS;
},
getRelatedEntities: createSelector(
(state: ContentConnectState, postId: number | null, options: api.GetRelatedEntitiesOptions): ContentConnectRelatedEntities => {
if (postId === null || !options?.rel_key) {
return [];
return EMPTY_RELATED_ENTITIES;
}
const key = getRelatedEntitiesKey(postId, options.rel_key);
return state.relatedEntities[key] || [];
return state.relatedEntities[key] || EMPTY_RELATED_ENTITIES;
},
(state, postId, options) => {
if (postId === null || !options?.rel_key) {
Expand All @@ -240,7 +249,8 @@ export const store = createReduxStore(STORE_NAME, {
},
getRelatedEntities: (postId: number, options: api.GetRelatedEntitiesOptions) => async function thunk({dispatch}) {
const key = getRelatedEntitiesKey(postId, options.rel_key);
const relatedEntities = await api.getAllRelatedEntities(postId, options);
// Saving replaces every related item with this list, so it includes every status.
const relatedEntities = await api.getAllRelatedEntities(postId, { ...options, post_status: 'any' });
dispatch.setRelatedEntities(key, relatedEntities);
},
},
Expand Down
20 changes: 20 additions & 0 deletions assets/js/store/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ describe('relationships selector', () => {
filtered,
);
});

it('returns the same empty object on each call when there is no data', () => {
expect(select(STORE_NAME).getRelationships(null)).toBe(
select(STORE_NAME).getRelationships(null),
);
expect(select(STORE_NAME).getRelationships(404)).toBe(
select(STORE_NAME).getRelationships(404),
);
});
});

describe('relatedEntities selector', () => {
Expand All @@ -128,6 +137,17 @@ describe('relatedEntities selector', () => {
}),
).toEqual(entities);
});

it('returns the same empty array on each call when there is no data', () => {
const options = () => ({ rel_key: 'missing', rel_type: 'post-to-post' });

expect(select(STORE_NAME).getRelatedEntities(null, options())).toBe(
select(STORE_NAME).getRelatedEntities(null, options()),
);
expect(select(STORE_NAME).getRelatedEntities(404, options())).toBe(
select(STORE_NAME).getRelatedEntities(404, options()),
);
});
});

describe('updateRelatedEntities thunk', () => {
Expand Down
2 changes: 1 addition & 1 deletion dist/js/block-editor.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => '6d0a925a82132ef62c65');
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => '422284cb28cfc853f588');
58 changes: 29 additions & 29 deletions dist/js/block-editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/classic-editor.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => '8c6243fbeadf573c3f4b');
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => 'ca65105fb1d2b6f9d18d');
2 changes: 1 addition & 1 deletion dist/js/classic-editor.js

Large diffs are not rendered by default.

Loading
Loading