PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / trunk
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts vtrunk
2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 All 28 releases
← All changes | admin/ajax/ajax.php +11 -0 2.7.0trunk View file →
@@ -310,8 +310,19 @@
310 310 if ( empty( $snippet_code ) ) {
311 311 wp_send_json_success( [ 'valid' => true ] );
312 312 }
313 313
314 + $redeclaration = WINP_Code_Validator::find_function_redeclaration( $snippet_code, $snippet_type );
315 + if ( null !== $redeclaration ) {
316 + wp_send_json_error(
317 + [
318 + 'valid' => false,
319 + // translators: %1$d is the line number, %2$s is the fully qualified function name.
320 + 'message' => sprintf( __( 'Line %1$d: Cannot redeclare function %2$s(). Rename the function or guard its declaration with function_exists().', 'insert-php' ), $redeclaration['line'], $redeclaration['name'] ),
321 + ]
322 + );
323 + }
324 +
314 325 // Validate using the same logic as validate_code method.
315 326 $validation_errors = [];
316 327
317 328 // Set custom error handler to catch warnings and notices.