Changeset 54257 for trunk/src/wp-includes/blocks/file.php
- Timestamp:
- 09/20/2022 03:14:54 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/file.php
r53157 r54257 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 }
Note: See TracChangeset
for help on using the changeset viewer.