Make WordPress Core

Changeset 56678


Ignore:
Timestamp:
09/25/2023 12:15:06 PM (16 months ago)
Author:
spacedmonkey
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r56677 r56678  
    15901590function block_has_support( $block_type, $feature, $default_value = false ) {
    15911591    $block_support = $default_value;
    1592     if ( $block_type && property_exists( $block_type, 'supports' ) ) {
     1592    if ( $block_type instanceof WP_Block_Type ) {
    15931593        if ( is_array( $feature ) && count( $feature ) === 1 ) {
    15941594            $feature = $feature[0];
Note: See TracChangeset for help on using the changeset viewer.