Make WordPress Core

Changeset 43893


Ignore:
Timestamp:
11/12/2018 11:37:31 PM (5 years ago)
Author:
pento
Message:

Scripts: Fix a PHP error in admin-ajax calls.

When making an ajax request, wp_enqueue_registered_block_scripts_and_styles() checked if is_admin() was true before accessing $current_screen, rather than checking if $current_screen was defined. This is usually fine, execept for in ajax requests.

Props ocean90, foreverpinetree, pento.
See #45203.

File:
1 edited

Legend:

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

    r43891 r43893  
    22532253    global $current_screen;
    22542254
    2255     if ( is_admin() && ! $current_screen->is_block_editor() ) {
     2255    if ( ( $current_screen instanceof WP_Screen ) && ! $current_screen->is_block_editor() ) {
    22562256        return;
    22572257    }
     
    22872287    global $current_screen;
    22882288
    2289     $is_editor = ( is_admin() && $current_screen->is_block_editor() );
     2289    $is_editor = ( ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor() );
    22902290
    22912291    $block_registry = WP_Block_Type_Registry::get_instance();
Note: See TracChangeset for help on using the changeset viewer.