mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Themes: Use instanceof in get_hooked_blocks.
In [56610], the get_hooked_blocks 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 gziolo, spacedmonkey. See #59383. git-svn-id: https://develop.svn.wordpress.org/trunk@56677 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -749,10 +749,10 @@ function get_dynamic_block_names() {
|
||||
* @return array Associative array of `$block_type_name => $position` pairs.
|
||||
*/
|
||||
function get_hooked_blocks( $name, $relative_position = '' ) {
|
||||
$block_types = WP_Block_Type_Registry::get_instance()->get_all_registered();
|
||||
$block_types = WP_Block_Type_Registry::get_instance()->get_all_registered();
|
||||
$hooked_blocks = array();
|
||||
foreach ( $block_types as $block_type ) {
|
||||
if ( ! property_exists( $block_type, 'block_hooks' ) || ! is_array( $block_type->block_hooks ) ) {
|
||||
if ( ! ( $block_type instanceof WP_Block_Type ) || ! is_array( $block_type->block_hooks ) ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( $block_type->block_hooks as $anchor_block_type => $position ) {
|
||||
|
||||
Reference in New Issue
Block a user