PluginProbe
WooCommerce / 11.1.0-rc.2
WooCommerce v11.1.0-rc.2
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / src / Blocks / TemplateOptions.php
TemplateOptions.php
43 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 declare( strict_types = 1 );
3
4 namespace Automattic\WooCommerce\Blocks;
5
6 use Automattic\WooCommerce\Blocks\Options;
7
8 /**
9 * TemplateOptions class.
10 *
11 * @internal
12 */
13 class TemplateOptions {
14
15 /**
16 * Initialization method.
17 */
18 public function init() {
19 add_action( 'after_switch_theme', array( $this, 'check_should_use_blockified_product_grid_templates' ), 10, 2 );
20 }
21
22 /**
23 * Checks the old and current themes and determines if the "wc_blocks_use_blockified_product_grid_block_as_template"
24 * option need to be updated accordingly.
25 *
26 * @param string $old_name Old theme name.
27 * @param \WP_Theme $old_theme Instance of the old theme.
28 * @return void
29 */
30 public function check_should_use_blockified_product_grid_templates( $old_name, $old_theme ) {
31 if ( ! $old_theme->is_block_theme() && wp_is_block_theme() ) {
32 $option_name = Options::WC_BLOCK_USE_BLOCKIFIED_PRODUCT_GRID_BLOCK_AS_TEMPLATE;
33 // We previously stored "yes" or "no" values. This will convert them to true or false.
34 $option_value = wc_string_to_bool( get_option( $option_name ) );
35
36 // We don't need to do anything if the option is already set to true.
37 if ( ! $option_value ) {
38 update_option( $option_name, true );
39 }
40 }
41 }
42 }
43