Make WordPress Core


Ignore:
Timestamp:
01/29/2024 09:04:18 PM (5 months ago)
Author:
youknowriad
Message:

Editor: Update the WordPress packages to the Gutenberg 16.7 RC2 version.

This patch, somewhat small brings a lot to WordPress.
This includes features like:

  • DataViews.
  • Customization tools like box shadow, background size and repeat.
  • UI improvements in the site editor.
  • Preferences sharing between the post and site editors.
  • Unified panels and editors between post and site editors.
  • Improved template mode in the post editor.
  • Iterations to multiple interactive blocks.
  • Preparing the blocks and UI for pattern overrides.
  • and a lot more.

Props luisherranz, gziolo, isabel_brison, costdev, jonsurrell, peterwilsoncc, get_dave, antonvlasenko, desrosj.
See #60315.

File:
1 edited

Legend:

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

    r57034 r57377  
    1515 * @return string Returns the block content.
    1616 */
    17 function render_block_core_file( $attributes, $content, $block ) {
    18     $should_load_view_script = ! empty( $attributes['displayPreview'] );
    19     $view_js_file            = 'wp-block-file-view';
    20     // If the script already exists, there is no point in removing it from viewScript.
    21     if ( ! wp_script_is( $view_js_file ) ) {
    22         $script_handles = $block->block_type->view_script_handles;
    23 
    24         // If the script is not needed, and it is still in the `view_script_handles`, remove it.
    25         if ( ! $should_load_view_script && in_array( $view_js_file, $script_handles, true ) ) {
    26             $block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
    27         }
    28         // If the script is needed, but it was previously removed, add it again.
    29         if ( $should_load_view_script && ! in_array( $view_js_file, $script_handles, true ) ) {
    30             $block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
    31         }
    32     }
    33 
     17function render_block_core_file( $attributes, $content ) {
    3418    // Update object's aria-label attribute if present in block HTML.
    35 
    3619    // Match an aria-label attribute from an object tag.
    3720    $pattern = '@<object.+(?<attribute>aria-label="(?<filename>[^"]+)?")@i';
     
    5437    );
    5538
    56     // If it uses the Interactivity API, add the directives.
    57     if ( $should_load_view_script ) {
     39    // If it's interactive, enqueue the script module and add the directives.
     40    if ( ! empty( $attributes['displayPreview'] ) ) {
     41        wp_enqueue_script_module( '@wordpress/block-library/file' );
     42
    5843        $processor = new WP_HTML_Tag_Processor( $content );
    5944        $processor->next_tag();
    60         $processor->set_attribute( 'data-wp-interactive', '' );
     45        $processor->set_attribute( 'data-wp-interactive', '{"namespace":"core/file"}' );
    6146        $processor->next_tag( 'object' );
    62         $processor->set_attribute( 'data-wp-bind--hidden', '!selectors.core.file.hasPdfPreview' );
     47        $processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
    6348        $processor->set_attribute( 'hidden', true );
    6449        return $processor->get_updated_html();
     
    6752    return $content;
    6853}
    69 
    70 /**
    71  * Ensure that the view script has the `wp-interactivity` dependency.
    72  *
    73  * @since 6.4.0
    74  *
    75  * @global WP_Scripts $wp_scripts
    76  */
    77 function block_core_file_ensure_interactivity_dependency() {
    78     global $wp_scripts;
    79     if (
    80         isset( $wp_scripts->registered['wp-block-file-view'] ) &&
    81         ! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-file-view']->deps, true )
    82     ) {
    83         $wp_scripts->registered['wp-block-file-view']->deps[] = 'wp-interactivity';
    84     }
    85 }
    86 
    87 add_action( 'wp_print_scripts', 'block_core_file_ensure_interactivity_dependency' );
    8854
    8955/**
     
    9763        )
    9864    );
     65
     66    wp_register_script_module(
     67        '@wordpress/block-library/file',
     68        defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/file.min.js' ) : includes_url( 'blocks/file/view.min.js' ),
     69        array( '@wordpress/interactivity' ),
     70        defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
     71    );
    9972}
    10073add_action( 'init', 'register_block_core_file' );
Note: See TracChangeset for help on using the changeset viewer.