You've already forked wp-bootstrap
fix: decode WordPress title entities before Twig to prevent double-encoding (v1.0.10)
WordPress's get_the_title() pre-encodes & as &. Twig autoescape re-encoded the & in & to &#038;, rendering as literal & in the browser. Wrapped all 6 get_the_title() calls in ContextBuilder with wp_specialchars_decode() so Twig can properly re-encode once. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -153,7 +153,7 @@ class ContextBuilder
|
||||
|
||||
return [
|
||||
'id' => $post->ID,
|
||||
'title' => get_the_title(),
|
||||
'title' => wp_specialchars_decode( get_the_title() ),
|
||||
'url' => get_permalink(),
|
||||
'content' => apply_filters('the_content', get_the_content()),
|
||||
'excerpt' => get_the_excerpt(),
|
||||
@@ -184,7 +184,7 @@ class ContextBuilder
|
||||
$wp_query->the_post();
|
||||
$posts[] = [
|
||||
'id' => get_the_ID(),
|
||||
'title' => get_the_title(),
|
||||
'title' => wp_specialchars_decode( get_the_title() ),
|
||||
'url' => get_permalink(),
|
||||
'excerpt' => get_the_excerpt(),
|
||||
'date' => get_the_date(),
|
||||
@@ -349,14 +349,14 @@ class ContextBuilder
|
||||
|
||||
if ($prev) {
|
||||
$navigation['previous'] = [
|
||||
'title' => get_the_title($prev),
|
||||
'title' => wp_specialchars_decode( get_the_title($prev) ),
|
||||
'url' => get_permalink($prev),
|
||||
];
|
||||
}
|
||||
|
||||
if ($next) {
|
||||
$navigation['next'] = [
|
||||
'title' => get_the_title($next),
|
||||
'title' => wp_specialchars_decode( get_the_title($next) ),
|
||||
'url' => get_permalink($next),
|
||||
];
|
||||
}
|
||||
@@ -384,7 +384,7 @@ class ContextBuilder
|
||||
$query->the_post();
|
||||
$posts[] = [
|
||||
'id' => get_the_ID(),
|
||||
'title' => get_the_title(),
|
||||
'title' => wp_specialchars_decode( get_the_title() ),
|
||||
'url' => get_permalink(),
|
||||
'date' => get_the_date(),
|
||||
'date_iso' => get_the_date('c'),
|
||||
@@ -438,7 +438,7 @@ class ContextBuilder
|
||||
while ($query->have_posts()) {
|
||||
$query->the_post();
|
||||
$posts[] = [
|
||||
'title' => get_the_title(),
|
||||
'title' => wp_specialchars_decode( get_the_title() ),
|
||||
'url' => get_permalink(),
|
||||
'date' => get_the_date(),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user