Editor: Replace property_exists calls in block related functions with instanceof
Replace calls to `property_exists` with `instanceof WP_Block_Type` in block related functions. This change not only improves type safety but also enhances performance. Follow on from [56678] and [56677]. Props gziolo, aristath, aaronrobertshaw, spacedmonkey. Fixes #59453 Built from https://develop.svn.wordpress.org/trunk@56742 git-svn-id: http://core.svn.wordpress.org/trunk@56254 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
829bbf3605
commit
e74a3bfdb0
|
@ -152,7 +152,7 @@ function wp_apply_border_support( $block_type, $block_attributes ) {
|
||||||
*/
|
*/
|
||||||
function wp_has_border_feature_support( $block_type, $feature, $default_value = false ) {
|
function wp_has_border_feature_support( $block_type, $feature, $default_value = false ) {
|
||||||
// Check if all border support features have been opted into via `"__experimentalBorder": true`.
|
// Check if all border support features have been opted into via `"__experimentalBorder": true`.
|
||||||
if ( property_exists( $block_type, 'supports' ) ) {
|
if ( $block_type instanceof WP_Block_Type ) {
|
||||||
$block_type_supports_border = isset( $block_type->supports['__experimentalBorder'] )
|
$block_type_supports_border = isset( $block_type->supports['__experimentalBorder'] )
|
||||||
? $block_type->supports['__experimentalBorder']
|
? $block_type->supports['__experimentalBorder']
|
||||||
: $default_value;
|
: $default_value;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
function wp_register_colors_support( $block_type ) {
|
function wp_register_colors_support( $block_type ) {
|
||||||
$color_support = false;
|
$color_support = false;
|
||||||
if ( property_exists( $block_type, 'supports' ) ) {
|
if ( $block_type instanceof WP_Block_Type ) {
|
||||||
$color_support = isset( $block_type->supports['color'] ) ? $block_type->supports['color'] : false;
|
$color_support = isset( $block_type->supports['color'] ) ? $block_type->supports['color'] : false;
|
||||||
}
|
}
|
||||||
$has_text_colors_support = true === $color_support ||
|
$has_text_colors_support = true === $color_support ||
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* @param WP_Block_Type $block_type Block Type.
|
* @param WP_Block_Type $block_type Block Type.
|
||||||
*/
|
*/
|
||||||
function wp_register_typography_support( $block_type ) {
|
function wp_register_typography_support( $block_type ) {
|
||||||
if ( ! property_exists( $block_type, 'supports' ) ) {
|
if ( ! ( $block_type instanceof WP_Block_Type ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ function wp_register_typography_support( $block_type ) {
|
||||||
* @return array Typography CSS classes and inline styles.
|
* @return array Typography CSS classes and inline styles.
|
||||||
*/
|
*/
|
||||||
function wp_apply_typography_support( $block_type, $block_attributes ) {
|
function wp_apply_typography_support( $block_type, $block_attributes ) {
|
||||||
if ( ! property_exists( $block_type, 'supports' ) ) {
|
if ( ! ( $block_type instanceof WP_Block_Type ) ) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ class WP_Block_Supports {
|
||||||
$block_registry = WP_Block_Type_Registry::get_instance();
|
$block_registry = WP_Block_Type_Registry::get_instance();
|
||||||
$registered_block_types = $block_registry->get_all_registered();
|
$registered_block_types = $block_registry->get_all_registered();
|
||||||
foreach ( $registered_block_types as $block_type ) {
|
foreach ( $registered_block_types as $block_type ) {
|
||||||
if ( ! property_exists( $block_type, 'supports' ) ) {
|
if ( ! ( $block_type instanceof WP_Block_Type ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( ! $block_type->attributes ) {
|
if ( ! $block_type->attributes ) {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.4-beta1-56741';
|
$wp_version = '6.4-beta1-56742';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue