I'm writing a Wordpress plugin that needs to tailor part of its output to be compatible with a page caching plugin (W3 Total Cache). The technique used by the caching plugin to cache most of the page and only execute fragments is to eval()
such code fragments.
However, as my plugin may be invoked in several places within a Wordpress template, I need to keep state between these different instances of my code being eval()
-executed. Basically I need the first piece of code to save data that the other code fragments will then use.
Essentially I need the code in the eval()
to access data outside of the eval()
.
Are there any methods of doing this?
EDIT: I should probably add that each execution of eval()
is also wrapped in a function that is called as a callback from preg_replace_callback()
, so any variables set in the eval()
would need to persist through that also