WordPress.org

Make WordPress Core

Changeset 44249


Ignore:
Timestamp:
12/17/2018 12:14:27 AM (10 months ago)
Author:
SergeyBiryukov
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.
Merges [43893] and [43894] to trunk.
Fixes #45302.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/script-loader.php

    r44247 r44249  
    24712471    global $current_screen;
    24722472
    2473     if ( is_admin() && ! $current_screen->is_block_editor() ) {
     2473    if ( is_admin() && ( $current_screen instanceof WP_Screen ) && ! $current_screen->is_block_editor() ) {
    24742474        return;
    24752475    }
     
    25052505    global $current_screen;
    25062506
    2507     $is_editor = ( is_admin() && $current_screen->is_block_editor() );
     2507    $is_editor = ( ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor() );
    25082508
    25092509    $block_registry = WP_Block_Type_Registry::get_instance();
Note: See TracChangeset for help on using the changeset viewer.