wc_set_hooked_blocks_version_on_theme_switch()
If the user switches from a classic to a block theme and they haven't already got a woocommerce_hooked_blocks_version, set the version of the hooked blocks in the database, or as "no" to disable all block hooks then set as the latest WC version.
No Hooks.
Returns
null. Nothing (null).
Usage
wc_set_hooked_blocks_version_on_theme_switch( $old_name, $old_theme );
- $old_name(string) (required)
- Old theme name.
- $old_theme(WP_Theme) (required)
- Instance of the old theme.
Changelog
| Since 9.2.0 | Introduced. |
wc_set_hooked_blocks_version_on_theme_switch() wc set hooked blocks version on theme switch code WC 10.5.0
function wc_set_hooked_blocks_version_on_theme_switch( $old_name, $old_theme ) {
$option_name = 'woocommerce_hooked_blocks_version';
$option_value = get_option( $option_name, false );
// Sites with the option value set to "no" have already been migrated, and block hooks have been disabled. Checking explicitly for false to avoid setting the option again.
if ( ! $old_theme->is_block_theme() && ( wp_is_block_theme() || current_theme_supports( 'block-template-parts' ) ) && false === $option_value ) {
add_option( $option_name, WC()->stable_version() );
}
}