I have some shortcodes that are dynamically generated in a post.
[shortcode 1][shortcode 2][shortcode 3] ... [shortcode 77]
I'm using the WP filter function to content_save_pre to run a preg_match on the content and remove all numbers from the shortcodes.
So:
[shortcode 1] becomes [shortcode]
...
[shortcode 77] becomes [shortcode]
This is what I use now
add_filter( 'content_save_pre' , 'preg_replace' , 10, 1);
funtion preg_replace ($content){
$content = preg_replace('/shortcode .]/', 'shortcode]', $content);
return $content;
}
My problem is that on some ocasions the double digit shortcodes do not get changed. This way seams to work (having 2 dots) but there surely is a better way to target the digits so that all of them get removed, regardless of home may there are.
$content = preg_replace('/shortcode ..]/', 'shortcode]', $content);