浏览代码

Blockbase: Ensure Blockbase migration script is only run once (#6711)

Co-authored-by: Jason Crist <jcrist@pbking.com>
Jeremy Yip 2 年之前
父节点
当前提交
bbe195f936
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      blockbase/inc/fonts/custom-font-migration.php

+ 8 - 1
blockbase/inc/fonts/custom-font-migration.php

@@ -3,6 +3,10 @@
 add_action( 'init', 'migrate_blockbase_custom_fonts', 99 );
 
 function migrate_blockbase_custom_fonts() {
+	// The data has already been transformed
+	if ( get_theme_mod( 'blockbase_legacy_font_settings' ) ) {
+		return;
+	}
 
 	$heading_font_slug = null;
 	$body_font_slug    = null;
@@ -18,7 +22,9 @@ function migrate_blockbase_custom_fonts() {
 	if ( isset( $font_families['custom'] ) && is_array( $font_families['custom'] ) ) {
 		$font_families = $font_families['custom'];
 	} else {
-		$font_families = $font_families['theme'];
+		// No Customizer font settings found. Mark as transformed and hide the Customizer UI for fonts.
+		set_theme_mod( 'blockbase_legacy_font_settings', true );
+		return;
 	}
 
 	// Look first for fonts customized via Customizer, then for fonts configured in the child theme.json "the old way"
@@ -85,6 +91,7 @@ function migrate_blockbase_custom_fonts() {
 	}
 
 	update_global_styles( $new_settings, $new_styles );
+	set_theme_mod( 'blockbase_legacy_font_settings', true );
 }
 
 /**