Opened 6 years ago
Closed 4 years ago
#47202 closed defect (bug) (reported-upstream)
Gutenberg doesn't honor the wp_targeted_link_rel Filter
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | |
Focuses: | Cc: |
Description
There is some inconsistent behaviour in how Gutenberg honors the wp_targeted_link_rel Filter.
In my filter I outpout just "noopener" instead of "noreferrer noopener" for the rel attribute Links that oben in a new tab/window:
<?php function filter_save_link_rel ( $rel, $link ) { return 'noopener'; } add_filter( 'wp_targeted_link_rel', 'filter_save_link_rel', 10, 2 );
When I write a new Link in a Gutenberg Paragraph Block the Editor automatically adds the rel="noopener noreferrer" attribute to the link.
However, when I remove the rel attribute in the HTML Block Editing Mode, the attribute is replaced with the correct value according to the filter.
Here is a screenshot of a fresh WordPress install displaying this behaviour:
Attachments (1)
Change History (5)
#1
@
6 years ago
I am having the same issue on both classic editor and Gutenberg and ended up coding a workaround to remove "noreferrer", would be great if this filter could be fixed so we can just use this instead.
Editing to add, actually if I change the priority to 999, and remove the # of args setting it seems to be working fine on both Gutenberg and Classic, not sure of the priority needed. It may depend on theme and plugins installed too.
<?php function filter_save_link_rel ( $rel, $link ) { return 'noopener'; } add_filter( 'wp_targeted_link_rel', 'filter_save_link_rel', 999 );
This ticket was mentioned in Slack in #core by desrosj. View the logs.
6 years ago
#3
@
4 years ago
Is there any update on this? I am having the same problem. I even tried installing WordPress 5.6 beta (which has removed noreferrer from wp_targeted_link_rel) but Gutenberg is still adding it.
#4
@
4 years ago
- Milestone Awaiting Review deleted
- Resolution set to reported-upstream
- Status changed from new to closed
Hi there, welcome to WordPress Trac! Thanks for the report.
Please note that any issues for the block editor are tracked on GitHub: https://github.com/WordPress/gutenberg/.
Looks like there is already a Gutenberg issue for this: https://github.com/WordPress/gutenberg/issues/26914, so I'm closing the ticket as reported-upstream
.
Screenshot