Make WordPress Core

Opened 6 years ago

Last modified 5 years ago

#50074 new enhancement

Add filter on post/etc action links in the REST API

Reported by: rmccue Owned by:
Priority: normal Milestone: Future Release
Component: REST API Version: 4.9.8
Severity: normal Keywords: good-first-bug has-patch
Cc: Focuses:

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)

schema_links_added_filter.PNG​ (60.4 KB ) - added by muhammadfaizanhaidar 5 years ago.
Added filter to get schema links function
removed_space_schema_links_filter.PNG​ (65.8 KB ) - added by muhammadfaizanhaidar 5 years ago.
Removed space to pass phpcs test

Download all attachments as: .zip

Change History (7)

#1 @TimothyBlynJacobs
6 years ago

  • Keywords good-first-bug added
  • Milestone Awaiting Review → Future Release
  • Type defect (bug) → enhancement
  • Version → 4.9.8

This makes sense to me. We'd probably also want a filter on get_schema_links.

#2 @patopaiar
6 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.


5 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 @muhammadfaizanhaidar
5 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 );
Last edited 5 years ago by muhammadfaizanhaidar (previous) (diff)

@muhammadfaizanhaidar
5 years ago

Added filter to get schema links function

@muhammadfaizanhaidar
5 years ago

Removed space to pass phpcs test

This ticket was mentioned in ​Slack in #core-editor by muhammadfaizanhaidar. ​View the logs.


5 years ago

Note: See TracTickets for help on using tickets.