Recently I was asked to build a new WordPress theme for a project. As I was looking through some of the old content I kept noticing different shortcodes that must have existed in the previous theme or plugins. I wanted to clean these up by removing them but this site had 1000s of posts and it would be time consuming to find all of the post with shortcodes and then remove them.
I looked for an existing plugin and found a few, but you needed to enter the shortcodes into a field for them to be ignored. In this case I did not know what the shortcode was without finding it first.
I knew there had to be a better way to go about this. So I started by looking into the core code in WP for shortcodes to see if there was a filter to use to catch shortcodes that no longer existed. However when I first found the regex for shorcodes I noticed it only looked for shortcodes that were registered in WP. Kinda a dead end on that. I then decided it must be possible to use the same regex(it is a complicated one) with a few changes and find anything that looked like a shortcode. This continued to a plugin that logged all of the non-existing shortcodes.
As I monitored the log I started to notice a few false positives, that is things that were being hidden and should not have been. I knew at this point my plugin would need to account for this and be able to handle it. I then added some actions you can take on the found shortcode. You can Allow the shortcode to show, remove it from the post or edit the post in case it was a typo or something. I found this plugin pretty helpful for myself during this project so I put it up on github.
Let me know if you questions or comments about the plugin. I will be submitting it to the wp.org repo soon. I want to test it a bit more before I put it up there.
You can download Hide Old Shortcodes here.