Opened 5 years ago
Last modified 4 years ago
#50074 new enhancement
Add filter on post/etc action links in the REST API
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 4.9.8 |
Component: | REST API | Keywords: | good-first-bug has-patch |
Focuses: | Cc: |
Description
With Gutenberg increasingly using more action links to control behaviour in the block editor, having a filter to adjust these links would be super useful. This allows developers to avoid a shotgun approach of hacking Gutenberg's UI, or using the very low-level filters to remove these actions.
This is probably useful to have as a general API to also add additional actions; e.g. for implementing something similar to Gutenberg's actions.
Attachments (2)
Change History (7)
#1
@
5 years ago
- Keywords good-first-bug added
- Milestone changed from Awaiting Review to Future Release
- Type changed from defect (bug) to enhancement
- Version set to 4.9.8
#2
@
4 years ago
@TimothyBlynJacobs I would like to contribute with this ticket, but I am not 100% sure of which links exactly would be the ones that need a filter added.
For your comment it is clearer, in get_schema_links function line 2452, instead of
$schema_links = $this->get_schema_links();
We can do
$schema_links = apply_filters( "rest_{$this->post_type}_item_schema_links" , $this->get_schema_links() );
But for the action links, how can I figure out which ones to add filters to?
This ticket was mentioned in PR #1616 on WordPress/wordpress-develop by MuhammadFaizanHaidar.
4 years ago
#3
- Keywords has-patch added; needs-patch removed
added filter to get_schema_links() function call
Trac ticket: https://core.trac.wordpress.org/ticket/50074
File details
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php line 2529.
Trac ticket:
#4
in reply to:
↑ description
@
4 years ago
@TimothyBlynJacobs I would like to contribute with this ticket.
For your comment it is clearer, in get_schema_links() function line 2528, 2529 wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php, instead of
<?php $schema_links = $this->get_schema_links(); // I have added. $schema_links = $this->get_schema_links(); $schema_links = apply_filters( "rest_{$this->post_type}_item_schema_links" , $schema_links );
This makes sense to me. We'd probably also want a filter on
get_schema_links
.