Skip to content

Commit ae0f8d9

Browse files
committed
Ensure error is fatal before showing Don't Panic message
1 parent 725ef5b commit ae0f8d9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ private function unshare_network_snippet( $snippet_id ) {
142142
private function code_error_callback( $out ) {
143143
$error = error_get_last();
144144

145+
if ( is_null( $error ) || ! in_array( $error['type'], array( E_ERROR, E_COMPILE_ERROR, E_USER_ERROR ) ) ) {
146+
return $out;
147+
}
148+
145149
$m = '<h2>' . __( "Don't Panic", 'code-snippets' ) . '</h2>';
146150
$m .= '<p>' . sprintf( __( 'The code snippet you are trying to save produced a fatal error on line %d:', 'code_snippets' ), $error['line'] ) . '</p>';
147151
$m .= '<strong>' . $error['message'] . '</strong>';

0 commit comments

Comments
 (0)