Make WordPress Core


Ignore:
Timestamp:
05/23/2024 07:37:08 PM (9 months ago)
Author:
ellatrix
Message:

Editor: Update npm packages.

Updates the editor npm packages to latest versions.

See https://github.com/WordPress/wordpress-develop/pull/6612.

Props ellatrix, mukesh27, youknowriad, mamaduka.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks/file.php

    r57619 r58187  
    99 * When the `core/file` block is rendering, check if we need to enqueue the `wp-block-file-view` script.
    1010 *
     11 * @since 5.8.0
     12 *
    1113 * @param array    $attributes The block attributes.
    1214 * @param string   $content    The block content.
     
    1618 */
    1719function render_block_core_file( $attributes, $content ) {
    18     // Update object's aria-label attribute if present in block HTML.
    19     // Match an aria-label attribute from an object tag.
    20     $pattern = '@<object.+(?<attribute>aria-label="(?<filename>[^"]+)?")@i';
    21     $content = preg_replace_callback(
    22         $pattern,
    23         static function ( $matches ) {
    24             $filename     = ! empty( $matches['filename'] ) ? $matches['filename'] : '';
    25             $has_filename = ! empty( $filename ) && 'PDF embed' !== $filename;
    26             $label        = $has_filename ?
    27                 sprintf(
    28                     /* translators: %s: filename. */
    29                     __( 'Embed of %s.' ),
    30                     $filename
    31                 )
    32                 : __( 'PDF embed' );
    33 
    34             return str_replace( $matches['attribute'], sprintf( 'aria-label="%s"', $label ), $matches[0] );
    35         },
    36         $content
    37     );
    38 
    3920    // If it's interactive, enqueue the script module and add the directives.
    4021    if ( ! empty( $attributes['displayPreview'] ) ) {
     
    5839        $processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
    5940        $processor->set_attribute( 'hidden', true );
     41
     42        $filename     = $processor->get_attribute( 'aria-label' );
     43        $has_filename = ! empty( $filename ) && 'PDF embed' !== $filename;
     44        $label        = $has_filename ? sprintf(
     45            /* translators: %s: filename. */
     46            __( 'Embed of %s.' ),
     47            $filename
     48        ) : __( 'PDF embed' );
     49
     50        // Update object's aria-label attribute if present in block HTML.
     51        // Match an aria-label attribute from an object tag.
     52        $processor->set_attribute( 'aria-label', $label );
     53
    6054        return $processor->get_updated_html();
    6155    }
     
    6660/**
    6761 * Registers the `core/file` block on server.
     62 *
     63 * @since 5.8.0
    6864 */
    6965function register_block_core_file() {
Note: See TracChangeset for help on using the changeset viewer.