Skip to content
Permalink
Browse files

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.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43893 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
pento committed Nov 12, 2018
1 parent f2517ba commit 9d9854594b7561c6fe11fdbba93166cecc5b79f5
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/wp-includes/script-loader.php
@@ -2252,7 +2252,7 @@ function script_concat_settings() {
function wp_common_block_scripts_and_styles() {
global $current_screen;
if ( is_admin() && ! $current_screen->is_block_editor() ) {
if ( ( $current_screen instanceof WP_Screen ) && ! $current_screen->is_block_editor() ) {
return;
}
@@ -2286,7 +2286,7 @@ function wp_common_block_scripts_and_styles() {
function wp_enqueue_registered_block_scripts_and_styles() {
global $current_screen;
$is_editor = ( is_admin() && $current_screen->is_block_editor() );
$is_editor = ( ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor() );
$block_registry = WP_Block_Type_Registry::get_instance();
foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {

0 comments on commit 9d98545

Please sign in to comment.
You can’t perform that action at this time.