Skip to content

Commit 013159a

Browse files
committed
Prevent snippets with named functions from running twice for error checking
1 parent ae0f8d9 commit 013159a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

php/admin-menus/class-edit-menu.php

+5
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ private function validate_code( Snippet $snippet ) {
169169
return false;
170170
}
171171

172+
/* Skip snippets that contain named functions */
173+
if ( preg_match( '/(?:function|class)\s+\w+/i', $snippet->code ) ) {
174+
return false;
175+
}
176+
172177
ob_start( array( $this, 'code_error_callback' ) );
173178
$result = eval( $snippet->code );
174179
ob_end_clean();

0 commit comments

Comments
 (0)