ソースを参照

Allow Jetpack to register fonts that Blockbase has not. (#6777)

Jason Crist 2 年 前
コミット
5be05d36a2
1 ファイル変更14 行追加4 行削除
  1. 14 4
      blockbase/inc/fonts/custom-fonts.php

+ 14 - 4
blockbase/inc/fonts/custom-fonts.php

@@ -207,10 +207,20 @@ function enqueue_block_fonts( $content, $parsed_block ) {
 
 /**
  * Jetpack may attempt to register fonts for the Google Font Provider.
- * If that happens on a child theme then ONLY Jetpack fonts are registered.
- * This 'filter' filters out all of the fonts Jetpack should register
- * so that we depend exclusively on those provided by Blockbase.
+ * This filters out all of the fonts Blockbase has already registered.
  */
 function blockbase_filter_jetpack_google_fonts_list( $list_to_filter ) {
-	return array();
+	$font_families = array();
+	$filtered_list = array();
+	$fonts         = collect_fonts_from_blockbase();
+	foreach ( $fonts as $font ) {
+		$font_families[] = $font['name'];
+	}
+	foreach ( $list_to_filter as $jetpack_font_family ) {
+		if ( ! in_array( $jetpack_font_family, $font_families, true ) ) {
+			$filtered_list[] = $jetpack_font_family;
+		}
+	}
+	return $filtered_list;
 }
+