Skip to content

Commit b988a44

Browse files
add upgrade path
1 parent 072b878 commit b988a44

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/css-file-generator.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ public function __construct() {
394394
// Register the setting stackable_use_css_files
395395
add_action( 'admin_init', array( $this, 'register_use_css_files_setting' ) );
396396
add_action( 'rest_api_init', array( $this, 'register_use_css_files_setting' ) );
397+
398+
add_action( 'stackable_early_version_upgraded', 'register_use_css_files_setting_upgraded', 10, 2 );
397399
}
398400

399401
/**
@@ -413,6 +415,15 @@ public function register_use_css_files_setting() {
413415
);
414416
}
415417

418+
/**
419+
* When upgrading from a lower version, disable use CSS files.
420+
*/
421+
public function register_use_css_files_setting_upgraded( $old_version, $new_version ) {
422+
if ( ! empty( $old_version ) && version_compare( $old_version, "3.19.0", "<" ) ) {
423+
update_option( 'stackable_use_css_files', '', 'no' );
424+
}
425+
}
426+
416427
/**
417428
* Register REST API routes.
418429
*/

src/init.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function register_frontend_assets() {
117117
}
118118

119119
// Enqueue the global CSS file in the frontend.
120-
if ( ! is_admin() && ! empty( get_option( 'stackable_use_css_files', true ) ) ) {
120+
if ( ! is_admin() && get_option( 'stackable_use_css_files', '1' ) === '1' ) {
121121
// The enqueue_global_css_file method now has built-in fallback to inline styles
122122
// if CSS file generation fails
123123
Stackable_Global_Design_System_CSS_Generator::enqueue_global_css_file();
@@ -241,7 +241,7 @@ public function load_frontend_scripts_conditionally( $block_content, $block ) {
241241
// Register inline frontend styles for theme.json block style inheritance
242242
public function enqueue_inline_block_style_inheritance() {
243243
// Use the new CSS generator class with built-in fallback to inline styles
244-
if ( ! is_admin() && ! empty( get_option( 'stackable_use_css_files', true ) ) ) {
244+
if ( ! is_admin() && get_option( 'stackable_use_css_files', '1' ) === '1' ) {
245245
Stackable_Block_Style_Inheritance_CSS_Generator::enqueue_block_inheritance_css_file();
246246
} else {
247247
Stackable_Block_Style_Inheritance_CSS_Generator::enqueue_block_inheritance_css_inline();

0 commit comments

Comments
 (0)