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;
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745647400a4638053.html
评论列表(0条)