From 4ae2d1a533c6f6dc3b7d82505763dc732924e0f0 Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Mon, 25 Sep 2023 12:15:06 +0000 Subject: [PATCH] Themes: Use instanceof in block_has_support. In [50761], the block_has_support function was introduced. However, using `property_exists` within this function negatively impacted its performance. This commit replaces the `property_exists` function call with `instanceof WP_Block_Type`, resulting in improved performance. Props mukesh27, gziolo, spacedmonkey. Fixes #59441. git-svn-id: https://develop.svn.wordpress.org/trunk@56678 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/blocks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 31baf119ff..323719efc4 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1589,7 +1589,7 @@ function unregister_block_style( $block_name, $block_style_name ) { */ function block_has_support( $block_type, $feature, $default_value = false ) { $block_support = $default_value; - if ( $block_type && property_exists( $block_type, 'supports' ) ) { + if ( $block_type instanceof WP_Block_Type ) { if ( is_array( $feature ) && count( $feature ) === 1 ) { $feature = $feature[0]; }