admin管理员组文章数量:1022989
WordPress 5.2 destroys structured data by adding rel="noopener noreferrer" to widget output (also to shortcodes): How to display the shortcode output without code change?
This feature was added in 5.2:
Basically there is nothing wrong with adding rel="noopener noreferrer"
to <a href="..." target="_blank"></a>
links, as it will protect from malicious comments or bad authors for instance.
Anyway I have a shortcode from some plugin which is generating structured data (rating stars) for a website and embedded via shortcode. Adding the rel-Attribute there breaks the structured data (as confirmed by /?hl=de).
How can I use the shortcode in a sidebar widget with the code preserved?
WordPress 5.2 destroys structured data by adding rel="noopener noreferrer" to widget output (also to shortcodes): How to display the shortcode output without code change?
This feature was added in 5.2: https://core.trac.wordpress/ticket/43280
Basically there is nothing wrong with adding rel="noopener noreferrer"
to <a href="..." target="_blank"></a>
links, as it will protect from malicious comments or bad authors for instance.
Anyway I have a shortcode from some plugin which is generating structured data (rating stars) for a website and embedded via shortcode. Adding the rel-Attribute there breaks the structured data (as confirmed by https://search.google/structured-data/testing-tool/u/0/?hl=de).
How can I use the shortcode in a sidebar widget with the code preserved?
Share Improve this question edited May 15, 2019 at 16:49 Blackbam asked May 15, 2019 at 16:07 BlackbamBlackbam 57511 silver badges28 bronze badges1 Answer
Reset to default 1Try this code:
add_filter( 'wp_targeted_link_rel', '__return_false', 9999 );
function widget_text_replace($text) {
$search = array('rel="noopener"');
$replace = array('');
$text = str_replace($search, $replace, $text);
return $text;
}
add_filter('widget_text', 'widget_text_replace');
WordPress 5.2 destroys structured data by adding rel="noopener noreferrer" to widget output (also to shortcodes): How to display the shortcode output without code change?
This feature was added in 5.2:
Basically there is nothing wrong with adding rel="noopener noreferrer"
to <a href="..." target="_blank"></a>
links, as it will protect from malicious comments or bad authors for instance.
Anyway I have a shortcode from some plugin which is generating structured data (rating stars) for a website and embedded via shortcode. Adding the rel-Attribute there breaks the structured data (as confirmed by /?hl=de).
How can I use the shortcode in a sidebar widget with the code preserved?
WordPress 5.2 destroys structured data by adding rel="noopener noreferrer" to widget output (also to shortcodes): How to display the shortcode output without code change?
This feature was added in 5.2: https://core.trac.wordpress/ticket/43280
Basically there is nothing wrong with adding rel="noopener noreferrer"
to <a href="..." target="_blank"></a>
links, as it will protect from malicious comments or bad authors for instance.
Anyway I have a shortcode from some plugin which is generating structured data (rating stars) for a website and embedded via shortcode. Adding the rel-Attribute there breaks the structured data (as confirmed by https://search.google/structured-data/testing-tool/u/0/?hl=de).
How can I use the shortcode in a sidebar widget with the code preserved?
Share Improve this question edited May 15, 2019 at 16:49 Blackbam asked May 15, 2019 at 16:07 BlackbamBlackbam 57511 silver badges28 bronze badges1 Answer
Reset to default 1Try this code:
add_filter( 'wp_targeted_link_rel', '__return_false', 9999 );
function widget_text_replace($text) {
$search = array('rel="noopener"');
$replace = array('');
$text = str_replace($search, $replace, $text);
return $text;
}
add_filter('widget_text', 'widget_text_replace');
版权声明:本文标题:filters - Shortcodes within the sidebar texthtml widget: How to preserve the raw HTML output of the shortcode? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745488266a2152843.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论