Escape aria labels for checkmarks
This commit is contained in:
parent
8d15f5ccdc
commit
b9fbcd51ae
@ -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 = '<span class="spoiler-title">' . $title . '</span>'; // Using a neutral tag like <span>
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
add_filter( 'fictioneer_filter_safe_title', 'custom_blur_title_with_spoiler', 10, 3 );
|
||||
|
||||
/**
|
||||
* Returns sanitized safe title
|
||||
*
|
||||
|
@ -1334,7 +1334,12 @@ function fictioneer_shortcode_chapter_list( $attr ) {
|
||||
data-id="<?php echo $chapter_id; ?>"
|
||||
role="checkbox"
|
||||
aria-checked="false"
|
||||
aria-label="<?php printf( esc_attr__( 'Chapter checkmark for %s.', 'fictioneer' ), $title ); ?>"
|
||||
aria-label="<?php
|
||||
printf(
|
||||
esc_attr__( 'Chapter checkmark for %s.', 'fictioneer' ),
|
||||
esc_attr( wp_strip_all_tags( $title ) )
|
||||
);
|
||||
?>"
|
||||
><i class="fa-solid fa-check"></i></button>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
|
@ -671,7 +671,12 @@ function fictioneer_story_chapters( $args ) {
|
||||
data-id="<?php echo $chapter['id']; ?>"
|
||||
role="checkbox"
|
||||
aria-checked="false"
|
||||
aria-label="<?php printf( esc_attr__( 'Chapter checkmark for %s.', 'fictioneer' ), $chapter['title'] ); ?>"
|
||||
aria-label="<?php
|
||||
printf(
|
||||
esc_attr__( 'Chapter checkmark for %s.', 'fictioneer' ),
|
||||
esc_attr( wp_strip_all_tags( $chapter['title'] ) )
|
||||
);
|
||||
?>"
|
||||
><i class="fa-solid fa-check"></i></button>
|
||||
<?php endif; ?>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user