Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
code_snippets/before_execute_snippet filter #25
I implemented a must use plugin that allows me to recover from coding errors or disable plugins or the current theme for testing purposes, to do this i defined various options that are controlled by a parameter in the $_GET variable, one of them is an option to disable code snippets by defining CODE_SNIPPETS_SAFE_MODE as true, i was thinking to maybe extend this to disable a single snippet this way.
I suggest you add a filter that could allow to change the code before it is executed, this implementation requires that you also read the snippet id from the db, this filter would open the door to write code where i could check the snippet id and maybe return and empty string to not allow the snippet to execute depending of the situation.
Now that i write down this idea, i don´t now if this filter could be a security problem, another approach would be to make the filter a switch, instead of changing the snippet code, the filter could return true/false to allow the snippet to execute.
What do you think?
added a commit
May 18, 2015
This is a great idea, thanks. I've decided to use the second method you suggested, though it seems like you have a bug with the
The old filter was really only added for the sake of having an action there; it didn't serve much useful purpose, so I've removed it.