Make WordPress Core

Changeset 49102


Ignore:
Timestamp:
10/08/2020 01:19:10 AM (4 years ago)
Author:
noisysocks
Message:

Editor: Only call should_load_block_editor_scripts_and_styles on admin screens

Do not call the should_load_block_editor_scripts_and_styles filter on non-admin
screens. This makes it less likely that one will accidentally call
get_current_screen() when it doesn't exist.

Follow-up to [49080].
Props noahtallen.
See #51330.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r49101 r49102  
    21862186 */
    21872187function wp_common_block_scripts_and_styles() {
    2188     if ( is_admin() && ! wp_should_load_block_editor_scripts_and_styles() ) {
     2188    if ( ! wp_should_load_block_editor_scripts_and_styles() ) {
    21892189        return;
    21902190    }
     
    22202220    global $current_screen;
    22212221
     2222    if ( ! is_admin() ) {
     2223        return false;
     2224    }
     2225
    22222226    $is_block_editor_screen = ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor();
    22232227
    22242228    /**
    22252229     * Filters the flag that decides whether or not block editor scripts and
    2226      * styles are going to be enqueued on the current screen.
     2230     * styles are going to be enqueued on the current admin screen.
    22272231     *
    22282232     * @since 5.6.0
Note: See TracChangeset for help on using the changeset viewer.