current_theme_supports( ‘woocommerce’ )
in block themes: is it still needed?
#46426
Replies: 2 comments
-
Thanks @Aljullu, for kicking off the discussion!
I agree with the option 2.
I'm not sure that this point is a "real issue". Mostly because of the growing prevalence of block themes, plugin developers are likely already updated their codebases to ensure compatibility with these themes. For this reason, this issue may not be as significant as it seems. |
Beta Was this translation helpful? Give feedback.
-
A quick follow-up on this discussion, given that it has been open for more than 7 weeks: I'll add it to the next Store Editing snaps just to make sure it gets some visibility in the community. If before the next cooldown we hadn't received any feedback against option 2, I will create a cooldown issue to work on it. |
Beta Was this translation helpful? Give feedback.
-
With classic themes, there was the concept that a theme might "support WooCommerce" or might not. Usually that meant that the theme included templates specific to WooCommerce and was tested/supported by the authors to work with WooCommerce. That was represented by adding this code snippet to the theme:
add_theme_support( 'woocommerce' )
, which would cause calls tocurrent_theme_supports( ‘woocommerce’)
to returntrue
.With block themes, however, we wanted to take a different approach: all block themes should work out-of-the-box with WooCommerce, without theme authors needing to do anything specific. Of course, theme authors can still override the block templates and provide specific styles for WooCommerce blocks, but WooCommerce should work in the same way in those themes as in any other block theme.
That's why we have been recently wondering if
current_theme_supports( ‘woocommerce’)
should be limited to classic themes and whether it should be assumed to be true when the active theme is a block theme.As for the implementation, we envision two ways to implement it:
current_theme_supports( 'woocommerce' )
returnstrue
.current_theme_supports( 'woocommerce' )
in the WooCommerce codebase and replacing them withwc_current_theme_supports_woocommerce_or_fse()
when appropriate.We are starting this discussion publicly to hear from folks in the community, in case you have any preference. We know some themes and plugins are reading the value of
current_theme_supports( 'woocommerce' )
so we acknowledge we need to be wary if we change how it works.That's why I personally lean towards option 2, as I consider it to be a “safer approach” because it doesn't modify what's returned by
current_theme_supports( 'woocommerce' )
. However, it means that if a 3rd-party plugin is currently relying oncurrent_theme_supports( 'woocommerce' )
to detect if a theme supports WC, it will keep missing block themes. In those cases, the plugin authors would need to audit their codebase and switch towc_current_theme_supports_woocommerce_or_fse()
when appropriate.Both approaches have pros and cons, so we are interested in hearing if the community has any preferences on this!
Beta Was this translation helpful? Give feedback.
All reactions