shortcode - How to use strip_shortcodes() from a spawned process?

I have a plug-in that spawns a process to carry out a print function. The item to print, in this case a Woocommerce prod

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()?

Share Improve this question edited Mar 29, 2019 at 2:35 Eje 1654 bronze badges asked Mar 28, 2019 at 18:30 togethernettogethernet 212 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

You 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;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745647400a4638053.html

相关推荐

  • shortcode - How to use strip_shortcodes() from a spawned process?

    I have a plug-in that spawns a process to carry out a print function. The item to print, in this case a Woocommerce prod

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信