feedzy-rss-feeds
feedzy-rss-feeds copied to clipboard
Ability to customize the [#item_url] tag
What problem does this address?
Right now, we have the [#item_url] tag that adds a personalized "Read More" link. However, the site admin has no control over the link.
What is your proposed solution?
Implement actions modal with some basic actions:
- [ ] link text - write something else instead of Read More
- [ ] opening behavior - in a new tab/same tab
- [ ] link type - follow/nofollow link
- [ ] tracking parameters/UTMs
Will this feature require documentation? (Optional)
Yes, it requires documentation.
+1 https://secure.helpscout.net/conversation/2451815076/396690?viewId=212385
+1 https://secure.helpscout.net/conversation/2643715617/424596?viewId=212385
+1 https://wordpress.org/support/topic/magic-tag-behavior/
+1 https://secure.helpscout.net/conversation/2655505582/426945?viewId=212385 (nofollow link)
I think having an action for this is too complicated because we have same actions for all tags and creating new actions just for [#item_url] is too much but I would like to have a filter for this that would allow manipulating data.
@girishpanchal30, do you think we can create such a filter? Something like you suggested for custom tags in the past: https://github.com/Codeinwp/feedzy-rss-feeds-pro/issues/447#issuecomment-1014334516
@girishpanchal30, do you think we can create such a filter? Something like you suggested for custom tags in the past:
@vytisbulkevicius Yes, It's better to create a new filter rather than a new action for item_url
.
@AndreeaCristinaRadacina @vytisbulkevicius I've added the new filter and I mentioned the example code in PR https://github.com/Codeinwp/feedzy-rss-feeds/pull/963
@girishpanchal30 amazing!
Everything works well, apart from the link type (rel). I set it to nofollow, but it appears as noopener:
Should I apply other settings for this to work?
Same results if I use: $item_link_data['attr']['rel'] = 'noopener noreferrer nofollow'; // noopener, nofollow.
@AndreeaCristinaRadacina I think it depends on the _target
value.
Ref: https://wpshout.com/noopener/#gref:~:text=When%20checked%2C%20WordPress%20inserts%20target%3D%22%20_blank%22%20in%20the%20code%2C%20which%20prompts%20the%20browser%20to%20open%20the%20link%20in%20a%20new%20tab.%20As%20a%20bonus%2C%20the%20rel%3D%22noopener%22%20value%20also%20ends%20up%20in%20the%20code%20to%20protect%20from%20security%20threats.
@girishpanchal30 I also checked a similar guide before, but it's the same when I use _self/_parent and 'nofollow'.
Is it something we can control?
I also removed this line: $item_link_data['attr']['rel'] = 'nofollow'; // noopener, nofollow. And the rel attribute remains there, so it's like the above line is not considered at all
@AndreeaCristinaRadacina,
I tried to play around and I also can't change it with the filter, its something WordPress doesn't want to allow manipulating for security reasons, another thread about it: https://wordpress.com/forums/topic/remove-relnoopener-wtf/
What worked for me and maybe we can recommend those clients who ask for it is using this one and manipulating DOM (it works without re-doing the import):
add_filter('the_content', 'ensure_rel_attribute', 20);
function ensure_rel_attribute($content) {
// Use DOMDocument to ensure 'rel' attribute is set correctly
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML('<?xml encoding="utf-8" ?>' . $content);
libxml_clear_errors();
$links = $dom->getElementsByTagName('a');
foreach ($links as $link) {
if ($link->getAttribute('class') === 'feedzy-rss-link-icon') {
$rel = $link->getAttribute('rel');
$link->setAttribute('rel', 'nofollow');
}
}
return $dom->saveHTML();
}
I look with it for feedzy-rss-link-icon class which that Read More button has and then change the rel attributes value to nofollow in this case.
@girishpanchal30 what do you think about this approach, any big cons recommending it if someone needs?
@vytisbulkevicius @AndreeaCristinaRadacina I've removed the default WP link rel if found in our filter.
Here: https://github.com/Codeinwp/feedzy-rss-feeds/pull/963/commits/37e3e0d8ec8be67b1dfbdc02c347c294d125b8ac
Please check with the latest build zip.
@girishpanchal30 Thank you!
Now, when I use the filter and declare a rel type, nothing is displayed:
If I comment that line, the default noopener is displayed:
Do you have any suggestions? Should I use this in combination with Vytis' code, or should it have worked as a standalone solution?
@AndreeaCristinaRadacina
Do you have any suggestions? Should I use this in combination with Vytis' code, or should it have worked as a standalone solution?
It should work standalone
I've pushed new changes in PR, Can you please recheck with the latest build zip?
Thanks
@girishpanchal30 Great, it works now!
+1 https://secure.helpscout.net/conversation/2655505582/426945?viewId=212385
:tada: This issue has been resolved in version 4.4.13 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket: