-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use instanceOf over property_exists. #54835
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -649,7 +649,7 @@ private static function get_global_styles_presets( $sources ) { | |
private static function get_selector( $block_name ) { | ||
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_name ); | ||
|
||
if ( $block_type && property_exists( $block_type, 'supports' ) ) { | ||
if ( $block_type && $block_type instanceof WP_Block_Type ) { | ||
// Backwards compatibility with `supports.color.__experimentalDuotone` | ||
// is provided via the `block_type_metadata_settings` filter. If | ||
// `supports.filter.duotone` has not been set and the experimental | ||
|
@@ -747,7 +747,7 @@ private static function enqueue_global_styles_preset( $filter_id, $duotone_selec | |
*/ | ||
public static function register_duotone_support( $block_type ) { | ||
$has_duotone_support = false; | ||
if ( property_exists( $block_type, 'supports' ) ) { | ||
if ( $block_type instanceof WP_Block_Type ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line doesn't seem to appear at all in WP Core There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So is there a missing backport on this PR. Should we consider it done. It's very unfortunate that the code between core and Gutenberg for block supports have diverged this much. We should either do:
It's probably something to do post release though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So to confirm, no further action on this and it can be marked as backported?
Can I check whether you intended to write |
||
// Previous `color.__experimentalDuotone` support flag is migrated | ||
// to `filter.duotone` via `block_type_metadata_settings` filter. | ||
$has_duotone_support = $block_type->supports['filter']['duotone'] ?? null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code does not match in WP Core
https://github.com/WordPress/wordpress-develop/blob/e83f5a1a602b86dbecbf8ee58d6b8761d53b6197/src/wp-includes/class-wp-duotone.php#L956-L958
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with the previous code difference, I think the core version needed to be backported to Gutenberg. @spacedmonkey might have further context on why it wasn't.