You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
foreach ( $active_snippets as $snippet_id => $snippet_code ) {
/* Execute the PHP code */
if ( apply_filters( 'code_snippets/allow_execute_snippet', '', true, $snippet_id ) === true )
execute_snippet( $snippet_code );
}
What do you think?
The text was updated successfully, but these errors were encountered:
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?
The text was updated successfully, but these errors were encountered: