Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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)).

## [2.0.0] - TBD

Expand Down
24 changes: 19 additions & 5 deletions includes/Abilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function register_category() {
self::CATEGORY,
array(
'label' => __( 'Content Connect', 'wp-content-connect' ),
'description' => __( 'Post-to-post and post-to-user relationships.', 'wp-content-connect' ),
'description' => __( 'Post-to-post and post-to-user relationships. These abilities read relationship data. To display posts related to a specific post, use a Query Loop (core/query) block with the relationship filter set (showRelated, relationshipKey, sourcePost) and inherit set to false; the list updates when that post\'s relationships change. Query Loop filtering supports post-to-post relationships only.', 'wp-content-connect' ),
)
);
}
Expand Down Expand Up @@ -101,7 +101,7 @@ public function register_abilities() {
'content-connect/get-post-relationships',
array(
'label' => __( 'Get Post Relationships', 'wp-content-connect' ),
'description' => __( 'Lists the relationships that apply to a post, optionally including the related posts and users for each one.', 'wp-content-connect' ),
'description' => __( 'Lists the relationships that apply to a post, optionally including the related posts and users for each one. Read-only; see the category description for displaying related posts.', 'wp-content-connect' ),
'category' => self::CATEGORY,
'input_schema' => self::get_input_schema( self::get_post_input_args( ( new PostRelationshipsRoute() )->get_collection_params() ) ),
'output_schema' => array(
Expand All @@ -124,7 +124,7 @@ public function register_abilities() {
'content-connect/get-related-items',
array(
'label' => __( 'Get Related Items', 'wp-content-connect' ),
'description' => __( 'Lists the published posts or the users related to a post through one relationship, with pagination and ordering.', 'wp-content-connect' ),
'description' => __( 'Lists the published posts or the users related to a post through one relationship, with pagination and ordering. Use it to inspect a relationship. To display related posts on the site, prefer a Query Loop (core/query) block filtered by the relationship over copying these IDs into content, since a copied list goes stale when the relationship changes.', 'wp-content-connect' ),
'category' => self::CATEGORY,
'input_schema' => self::get_input_schema( self::get_post_input_args( $related_args ) ),
'output_schema' => array(
Expand Down Expand Up @@ -395,6 +395,20 @@ private static function get_relationship_side_schema() {
);
}

/**
* Builds the output schema for the relationship name.
*
* @since 2.1.0
*
* @return array
*/
private static function get_rel_name_schema() {
return array(
'type' => 'string',
'description' => __( 'The relationship name. In a relationship query segment it is `name`, paired with `related_to_post` or `related_to_user`. Not unique across post types; use rel_key to identify a relationship.', 'wp-content-connect' ),
);
}

/**
* Builds the output schema for a registered relationship definition.
*
Expand All @@ -411,7 +425,7 @@ private static function get_relationship_definition_schema() {
'properties' => array(
'rel_key' => array( 'type' => 'string' ),
'rel_type' => array( 'type' => 'string' ),
'rel_name' => array( 'type' => 'string' ),
'rel_name' => self::get_rel_name_schema(),
'object_type' => array( 'type' => 'string' ),
'labels' => $side['labels'],
'sortable' => $side['sortable'],
Expand Down Expand Up @@ -455,7 +469,7 @@ private static function get_post_relationship_schema() {
array(
'rel_key' => array( 'type' => 'string' ),
'rel_type' => array( 'type' => 'string' ),
'rel_name' => array( 'type' => 'string' ),
'rel_name' => self::get_rel_name_schema(),
'object_type' => array( 'type' => 'string' ),
'post_type' => array(
'type' => 'array',
Expand Down
Loading