From b9fbcd51aefe0d2443a5289b0a94811749e46965 Mon Sep 17 00:00:00 2001
From: Tetrakern <26898880+Tetrakern@users.noreply.github.com>
Date: Mon, 2 Dec 2024 15:54:59 +0100
Subject: [PATCH] Escape aria labels for checkmarks
---
includes/functions/_helpers-templates.php | 18 ++++++++++++++++++
includes/functions/_setup-shortcodes.php | 7 ++++++-
includes/functions/hooks/_story_hooks.php | 7 ++++++-
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/includes/functions/_helpers-templates.php b/includes/functions/_helpers-templates.php
index 208fb12d..d626962b 100644
--- a/includes/functions/_helpers-templates.php
+++ b/includes/functions/_helpers-templates.php
@@ -294,6 +294,24 @@ if ( ! function_exists( 'fictioneer_get_safe_title' ) ) {
}
}
+function custom_blur_title_with_spoiler( $title, $post_id, $context ) {
+ // Check if the context is relevant to modify the title (don't affect checkmarks)
+ if ( ! in_array( $context, ['story-chapter-list', 'shortcode-chapter-list'] ) ) {
+ return $title;
+ }
+
+ // Check if the title should be treated as a spoiler
+ // $has_spoiler = get_post_meta( $post_id, '_has_spoiler', true ); // Custom meta to mark spoilers
+
+ if ( true ) {
+ // Adds the class to the title without changing the HTML structure
+ $title = '' . $title . ''; // Using a neutral tag like
+ }
+
+ return $title;
+}
+add_filter( 'fictioneer_filter_safe_title', 'custom_blur_title_with_spoiler', 10, 3 );
+
/**
* Returns sanitized safe title
*
diff --git a/includes/functions/_setup-shortcodes.php b/includes/functions/_setup-shortcodes.php
index 1f977aac..29cbec73 100644
--- a/includes/functions/_setup-shortcodes.php
+++ b/includes/functions/_setup-shortcodes.php
@@ -1334,7 +1334,12 @@ function fictioneer_shortcode_chapter_list( $attr ) {
data-id=""
role="checkbox"
aria-checked="false"
- aria-label=""
+ aria-label=""
>
diff --git a/includes/functions/hooks/_story_hooks.php b/includes/functions/hooks/_story_hooks.php
index 377db461..155ab808 100644
--- a/includes/functions/hooks/_story_hooks.php
+++ b/includes/functions/hooks/_story_hooks.php
@@ -671,7 +671,12 @@ function fictioneer_story_chapters( $args ) {
data-id=""
role="checkbox"
aria-checked="false"
- aria-label=""
+ aria-label=""
>