PluginProbe
Gutenberg / 14.5.2
Gutenberg v14.5.2
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | build/block-library/blocks/file.php +22 -0 12.6.0 → 14.5.2 View file →
@@ -18,8 +18,30 @@
18 18 if ( $should_load_view_script ) {
19 19 wp_enqueue_script( 'wp-block-file-view' );
20 20 }
21 21
22 + // Update object's aria-label attribute if present in block HTML.
23 +
24 + // Match an aria-label attribute from an object tag.
25 + $pattern = '@<object.+(?<attribute>aria-label="(?<filename>[^"]+)?")@i';
26 + $content = preg_replace_callback(
27 + $pattern,
28 + function ( $matches ) {
29 + $filename = ! empty( $matches['filename'] ) ? $matches['filename'] : '';
30 + $has_filename = ! empty( $filename ) && 'PDF embed' !== $filename;
31 + $label = $has_filename ?
32 + sprintf(
33 + /* translators: %s: filename. */
34 + __( 'Embed of %s.' ),
35 + $filename
36 + )
37 + : __( 'PDF embed' );
38 +
39 + return str_replace( $matches['attribute'], sprintf( 'aria-label="%s"', $label ), $matches[0] );
40 + },
41 + $content
42 + );
43 +
22 44 return $content;
23 45 }
24 46
25 47 /**