Make WordPress Core

Changeset 51202


Ignore:
Timestamp:
06/22/2021 04:54:50 PM (3 years ago)
Author:
desrosj
Message:

Widgets: Stop loading wp-editor and the Block Directory assets on the widgets screen.

When using the text widget, a wp.editor.initialize is not a function notice is encountered. This happens when wp-editor is loaded as a dependency, which assigns wp.oldEditor = wp.editor and then redefines wp.editor.

wp-editor is only used for the Classic block, which is not supported in the new widgets editor. [51198-51199] updated @wordpress/block-library to remove wp-editor as a dependency, but it’s still listed as a dependency of the wp-block-directory script handle.

Since the Block directory is not supported within the widgets editor, the related assets can safely be blocked from enqueueing.

Props noisysocks, gziolo, Mamaduka, mkaz.
Fixes #53437. See #53397.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/widgets-form-blocks.php

    r51200 r51202  
    2929    $block_editor_context
    3030);
     31
     32// The widgets editor does not support the Block Directory, so don't load any of
     33// its assets. This also prevents 'wp-editor' from being enqueued which we
     34// cannot load in the widgets screen because many widget scripts rely on `wp.editor`.
     35remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );
    3136
    3237wp_add_inline_script(
     
    6873?>
    6974
    70 <div id="widgets-editor" class="blocks-widgets-container"></div> 
     75<div id="widgets-editor" class="blocks-widgets-container"></div>
    7176
    7277<?php
Note: See TracChangeset for help on using the changeset viewer.