admin管理员组文章数量:1435786
I have a plug-in that spawns a process to carry out a print function. The item to print, in this case a Woocommerce product, is passed via the URL (via product_id
). Before carrying out printing, all registered shortcodes must be stripped from the product description. If I call strip_shortcodes()
it does nothing. I guess the array of registered shortcodes is out of scope? Can anyone suggest an efficient way to enable the process to use strip_shortcodes()
?
I have a plug-in that spawns a process to carry out a print function. The item to print, in this case a Woocommerce product, is passed via the URL (via product_id
). Before carrying out printing, all registered shortcodes must be stripped from the product description. If I call strip_shortcodes()
it does nothing. I guess the array of registered shortcodes is out of scope? Can anyone suggest an efficient way to enable the process to use strip_shortcodes()
?
2 Answers
Reset to default 0You can manually add shortcodes to the array of tags to be stripped in strip_shortcodes()
via filter. If the global $shortcode_tags
either doesn't exist or doesn't contain what it should when your process is running then you'll need to use that filter to add them back in.
$tags_to_remove = apply_filters( 'strip_shortcodes_tagnames', $tags_to_remove, $content );
I needed to bring $shortcode_tags
into scope before calling strip_shortcodes()
I did this by adding the declaration
global $shortcode_tags;
本文标签: shortcodeHow to use stripshortcodes() from a spawned process
版权声明:本文标题:shortcode - How to use strip_shortcodes() from a spawned process? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745647399a2668218.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论