Basically, I’ve got a plugin that searches for certain tokens in the entire page and replaces the tokens with images. The problem is, I’ve got one of those tokens in the footer and, as far as I can tell, there’s no filter for the footer.
So the question is, is there a way to make a custom filter? And is that the best way to go about doing this? My plugin does a preg_match in the content and, if it finds, for example “{picture here}”, it replaces it. I’m not sure how to extend this functionality to the footer, though?
Most of the footer is straight-up PHP/HTML markup. You apply filters to dynamic content, which is why there isn’t a typical footer “filter.” That said, it’s relatively easy to add your own filters to WordPress.
Let’s say your
footer.php
consists of the following:And lets say you want to dynamically replace the word “copyright” with the standard C image using your filter. You’d replace this with:
This creates a custom filter called “my_footer_filter” and applies it to the text “Copyright 2011 By Me.” In your
functions.php
file, you can use this filter just like you would any other: