| @@ -375,8 +375,17 @@ | ||
| 375 | 375 | * @param array $items Usable steps. |
| 376 | 376 | * @return void |
| 377 | 377 | */ |
| 378 | 378 | private function maybe_render_schema(array $settings, array $items): void { |
| 379 | + | |
| 380 | + // The Schema master switch and the matrix's per-content-type switch. | |
| 381 | + // This widget echoes its own <script> rather than registering with | |
| 382 | + // Schema_Graph, so gating the graph never reached it and it kept | |
| 383 | + // publishing with Schema switched off (#688). | |
| 384 | + if (class_exists('ThinkRank\\Frontend\\Schema_Graph') | |
| 385 | + && !\ThinkRank\Frontend\Schema_Graph::output_allowed()) { | |
| 386 | + return; | |
| 387 | + } | |
| 379 | 388 | if (empty($settings['outputSchema'])) { |
| 380 | 389 | return; |
| 381 | 390 | } |
| 382 | 391 | |
| @@ -419,9 +428,10 @@ | ||
| 419 | 428 | $heading = trim(wp_strip_all_tags((string) ($settings['heading'] ?? ''))); |
| 420 | 429 | $schema = [ |
| 421 | 430 | '@context' => 'https://schema.org', |
| 422 | 431 | '@type' => 'HowTo', |
| 423 | - 'name' => '' !== $heading ? $heading : (string) get_the_title(), | |
| 432 | + // The fallback is get_the_title(), texturized HTML (#976). | |
| 433 | + 'name' => \ThinkRank\Core\Seo_Text::normalize_schema_name('' !== $heading ? $heading : (string) get_the_title()), | |
| 424 | 434 | 'step' => $step_entities, |
| 425 | 435 | ]; |
| 426 | 436 | |
| 427 | 437 | $description = trim(wp_strip_all_tags((string) ($settings['description'] ?? ''))); |
| @@ -436,9 +446,9 @@ | ||
| 436 | 446 | |
| 437 | 447 | $json = wp_json_encode($schema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); |
| 438 | 448 | |
| 439 | 449 | if (false !== $json) { |
| 440 | - echo '<script type="application/ld+json">' . $json . '</script>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 450 | + echo '<script type="application/ld+json" data-thinkrank="howto">' . $json . '</script>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 441 | 451 | } |
| 442 | 452 | } |
| 443 | 453 | |
| 444 | 454 | /** |