浏览代码

Merge pull request #3715 from Automattic/fix/bcb-warnings

BCB: Fix PHP warnings
Ben Dwyer 4 年之前
父节点
当前提交
0d466f03f1
共有 1 个文件被更改,包括 14 次插入9 次删除
  1. 14 9
      blank-canvas-blocks/functions.php

+ 14 - 9
blank-canvas-blocks/functions.php

@@ -58,20 +58,25 @@ add_action( 'wp_enqueue_scripts', 'blank_canvas_blocks_scripts' );
  */
 
 function blank_canvas_blocks_fonts_url() {
-	$fonts_url = '';
+	if ( ! class_exists( 'WP_Theme_JSON_Resolver' ) ) {
+		return '';
+	}
+
+	$theme_data = WP_Theme_JSON_Resolver::get_merged_data()->get_settings();
+	if ( empty( $theme_data ) || empty( $theme_data['defaults'] ) || empty( $theme_data['defaults']['custom'] ) ) {
+		return '';
+	}
 
-	$theme_data  = WP_Theme_JSON_Resolver::get_merged_data()->get_settings();
 	$custom_data = $theme_data['defaults']['custom'];
 	if ( array_key_exists( 'fontsToLoadFromGoogle', $custom_data ) ) {
-		$font_families = $theme_data['defaults']['custom']['fontsToLoadFromGoogle'];
-
-		$font_families[] = 'display=swap';
-
-		// Make a single request for the theme fonts.
-		$fonts_url = 'https://fonts.googleapis.com/css2?' . implode( '&', $font_families );
+		return '';
 	}
 
-	return esc_url_raw( $fonts_url );
+	$font_families   = $theme_data['defaults']['custom']['fontsToLoadFromGoogle'];
+	$font_families[] = 'display=swap';
+
+	// Make a single request for the theme fonts.
+	return esc_url_raw( 'https://fonts.googleapis.com/css2?' . implode( '&', $font_families ) );
 }
 
 /**