| @@ -179,12 +179,16 @@ | ||
| 179 | 179 | |
| 180 | 180 | $targetBlock = $found['block']; |
| 181 | 181 | |
| 182 | 182 | if ($rawBlock !== '') { |
| 183 | - $parsed = parse_blocks(wp_unslash($rawBlock)); | |
| 183 | + // From get_json_params, so never slashed — unslashing here stripped | |
| 184 | + // the real backslashes in serialized attrs and corrupted the block. | |
| 185 | + $parsed = parse_blocks($rawBlock); | |
| 184 | 186 | $parsed = array_values(array_filter( |
| 185 | 187 | $parsed, |
| 186 | - static fn ($b) => is_array($b) && !empty($b['blockName']) | |
| 188 | + static function ($b) { | |
| 189 | + return is_array($b) && !empty($b['blockName']); | |
| 190 | + } | |
| 187 | 191 | )); |
| 188 | 192 | if (count($parsed) !== 1) { |
| 189 | 193 | return new \WP_REST_Response([ |
| 190 | 194 | 'error' => 'rawBlock must parse to exactly one block', |
| @@ -312,13 +316,15 @@ | ||
| 312 | 316 | // Rewrite the single anchor's opening tag only — the <p> wrapper and the |
| 313 | 317 | // link text stay byte-for-byte intact. |
| 314 | 318 | return preg_replace_callback( |
| 315 | 319 | '/<a\b[^>]*>/i', |
| 316 | - static fn ($match) => self::setTagAttributes($match[0], [ | |
| 317 | - 'href' => $newHref, | |
| 318 | - 'data-id' => $newHref, | |
| 319 | - 'data-type' => 'tel', | |
| 320 | - ]), | |
| 320 | + static function ($match) use ($newHref) { | |
| 321 | + return self::setTagAttributes($match[0], [ | |
| 322 | + 'href' => $newHref, | |
| 323 | + 'data-id' => $newHref, | |
| 324 | + 'data-type' => 'tel', | |
| 325 | + ]); | |
| 326 | + }, | |
| 321 | 327 | $innerHtml, |
| 322 | 328 | 1 |
| 323 | 329 | ); |
| 324 | 330 | } |
| @@ -420,9 +426,11 @@ | ||
| 420 | 426 | $walk($blocks, []); |
| 421 | 427 | |
| 422 | 428 | $raw = array_values(array_filter( |
| 423 | 429 | $candidates, |
| 424 | - static fn ($c) => BlockFingerprint::matches($c['block'], $fingerprint) | |
| 430 | + static function ($c) use ($fingerprint) { | |
| 431 | + return BlockFingerprint::matches($c['block'], $fingerprint); | |
| 432 | + } | |
| 425 | 433 | )); |
| 426 | 434 | if ($raw) { |
| 427 | 435 | return $raw; |
| 428 | 436 | } |
| @@ -428,13 +436,15 @@ | ||
| 428 | 436 | } |
| 429 | 437 | |
| 430 | 438 | $rendered = array_values(array_filter( |
| 431 | 439 | $candidates, |
| 432 | - static fn ($c) => BlockFingerprint::matches( | |
| 433 | - $c['block'], | |
| 434 | - $fingerprint, | |
| 435 | - self::renderBlockHtml($c['block'], $sourcePost) | |
| 436 | - ) | |
| 440 | + static function ($c) use ($fingerprint, $sourcePost) { | |
| 441 | + return BlockFingerprint::matches( | |
| 442 | + $c['block'], | |
| 443 | + $fingerprint, | |
| 444 | + self::renderBlockHtml($c['block'], $sourcePost) | |
| 445 | + ); | |
| 446 | + } | |
| 437 | 447 | )); |
| 438 | 448 | if ($rendered) { |
| 439 | 449 | return $rendered; |
| 440 | 450 | } |
| @@ -443,9 +453,11 @@ | ||
| 443 | 453 | // the paragraph in the browser, so the live element's text — and thus |
| 444 | 454 | // the fingerprint — is truncated to a prefix of the stored block. |
| 445 | 455 | return array_values(array_filter( |
| 446 | 456 | $candidates, |
| 447 | - static fn ($c) => BlockFingerprint::matches($c['block'], $fingerprint, '', true) | |
| 457 | + static function ($c) use ($fingerprint) { | |
| 458 | + return BlockFingerprint::matches($c['block'], $fingerprint, '', true); | |
| 459 | + } | |
| 448 | 460 | )); |
| 449 | 461 | } |
| 450 | 462 | |
| 451 | 463 | private static function debugSnippet(array $block): string |