Skip to content

Commit

Permalink
♿️ Improve screen reader button text
Browse files Browse the repository at this point in the history
See #220
  • Loading branch information
MatzeKitt committed May 28, 2024
1 parent 8790248 commit 6c57013
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions inc/class-embed-privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ public function get_output_template( $embed_provider, $embed_provider_lowercase,
$footer_content .= '<span class="embed-privacy-url"><a href="' . \esc_url( $args['embed_url'] ) . '">';
$footer_content .= \sprintf(
/* translators: content name or 'content' */
\esc_html__( 'Open %s directly', 'embed-privacy' ),
\esc_html__( 'Open "%s" directly', 'embed-privacy' ),
! empty( $args['embed_title'] ) ? $args['embed_title'] : \__( 'content', 'embed-privacy' )
);
$footer_content .= '</a></span>';
Expand All @@ -994,8 +994,16 @@ public function get_output_template( $embed_provider, $embed_provider_lowercase,
}
?>
<div class="embed-privacy-container is-disabled <?php echo \esc_attr( $embed_classes ); ?>" data-embed-id="oembed_<?php echo \esc_attr( $embed_md5 ); ?>" data-embed-provider="<?php echo \esc_attr( $embed_provider_lowercase ); ?>"<?php echo ( ! empty( $embed_thumbnail['thumbnail_path'] ) && \file_exists( $embed_thumbnail['thumbnail_path'] ) ? ' style="background-image: url(' . \esc_url( $embed_thumbnail['thumbnail_url'] ) . ');"' : '' ); ?>>
<?php /* translators: embed provider */ ?>
<button class="embed-privacy-enable screen-reader-text"><?php \printf( \esc_html__( 'Display content from %s', 'embed-privacy' ), \esc_html( $embed_provider ) ); ?></button>
<?php
/* translators: embed provider */
$button_text = \sprintf( \__( 'Display content from %s', 'embed-privacy' ), \esc_html( $embed_provider ) );

if ( ! empty( $args['embed_title'] ) ) {
/* translators: 1: embed title, 2: embed provider */
$button_text = \sprintf( \__( 'Display "%1$s" from %2$s', 'embed-privacy' ), $args['embed_title'], \esc_html( $embed_provider ) );
}
?>
<button class="embed-privacy-enable screen-reader-text"><?php echo \esc_html( $button_text ); ?></button>

<div class="embed-privacy-overlay">
<div class="embed-privacy-inner">
Expand Down Expand Up @@ -1177,7 +1185,7 @@ public function get_single_overlay( $content, $embed_provider, $embed_provider_l
}

/* translators: embed title */
$args['embed_title'] = $element->hasAttribute( 'title' ) ? \sprintf( \__( '"%s"', 'embed-privacy' ), $element->getAttribute( 'title' ) ) : '';
$args['embed_title'] = $element->hasAttribute( 'title' ) ? $element->getAttribute( 'title' ) : '';
$args['embed_url'] = $element->getAttribute( $args['element_attribute'] );
$args['height'] = $element->hasAttribute( 'height' ) ? $element->getAttribute( 'height' ) : 0;
$args['width'] = $element->hasAttribute( 'width' ) ? $element->getAttribute( 'width' ) : 0;
Expand Down Expand Up @@ -1982,7 +1990,7 @@ public function replace_embeds_oembed( $output, $url, $args ) {

$embed_title = $this->get_oembed_title( $output );
/* translators: embed title */
$args['embed_title'] = ! empty( $embed_title ) ? \sprintf( \__( '"%s"', 'embed-privacy' ), $embed_title ) : '';
$args['embed_title'] = ! empty( $embed_title ) ? $embed_title : '';
$args['embed_url'] = $url;
$args['strip_newlines'] = true;

Expand Down

0 comments on commit 6c57013

Please sign in to comment.