Browse Source

Minor changes so the migrator can run sans-Gutenberg

Jason Crist 3 years ago
parent
commit
f11c2e3d39
2 changed files with 15 additions and 10 deletions
  1. 10 2
      blockbase/inc/fonts/custom-font-migration.php
  2. 5 8
      blockbase/inc/fonts/custom-fonts.php

+ 10 - 2
blockbase/inc/fonts/custom-font-migration.php

@@ -10,7 +10,12 @@ function migrate_blockbase_custom_fonts() {
 
 	// Here we must use gutenberg_get_global_* because it introduces clean_cached_data() which we
 	// need to leverage as we are modifying the values of global styles settings and styles on page load.
-	$font_families = gutenberg_get_global_settings( array( 'typography', 'fontFamilies' ) );
+	if ( function_exists( 'gutenberg_get_global_settings' ) ) {
+		$font_families = gutenberg_get_global_settings( array( 'typography', 'fontFamilies' ) );
+	} else {
+		$font_families = wp_get_global_settings( array( 'typography', 'fontFamilies' ) );
+	}
+
 	if ( isset( $font_families['custom'] ) && is_array( $font_families['custom'] ) ) {
 		$font_families = $font_families['custom'];
 	} else {
@@ -117,7 +122,10 @@ function update_global_styles( $new_settings, $new_styles ) {
 	delete_transient( 'global_styles_' . get_stylesheet() );
 	delete_transient( 'gutenberg_global_styles' );
 	delete_transient( 'gutenberg_global_styles_' . get_stylesheet() );
-	WP_Theme_JSON_Resolver_Gutenberg::clean_cached_data();
+
+	if ( class_exists( 'WP_Theme_JSON_Resolver_Gutenberg' ) ) {
+		WP_Theme_JSON_Resolver_Gutenberg::clean_cached_data();
+	}
 }
 
 /**

+ 5 - 8
blockbase/inc/fonts/custom-fonts.php

@@ -1,13 +1,10 @@
 <?php
 
-// If Gutenberg is enabled there was the potential to customize fonts via the Customizer.
-// Migrate those settings (semantic fonts) to explicit font values in Global Styles
-if ( class_exists( 'WP_Theme_JSON_Resolver_Gutenberg' ) ) {
-	// Font Migration
-	require get_template_directory() . '/inc/fonts/custom-font-migration.php';
-	// Font settings deprecation message
-	require get_template_directory() . '/inc/customizer/wp-customize-fonts.php';
-}
+// Font settings deprecation message
+require get_template_directory() . '/inc/customizer/wp-customize-fonts.php';
+
+// Font Migration
+require get_template_directory() . '/inc/fonts/custom-font-migration.php';
 
 /**
  * Get the CSS containing font_face values for a given slug