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
This commit is contained in:
Jonny Harris
2023-09-25 12:15:06 +00:00
parent f9299148b7
commit 4ae2d1a533

View File

@@ -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];
}