PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 11.0.2
Jetpack – WP Security, Backup, Speed, & Growth v11.0.2
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / modules / google-fonts.php
google-fonts.php
108 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Module Name: Google Fonts (Beta)
4 * Module Description: A selection of Google fonts for block enabled themes. This feature is still being developed.
5 * Sort Order: 1
6 * Recommendation Order: 2
7 * First Introduced: 10.8.0
8 * Requires Connection: No
9 * Auto Activate: No
10 * Module Tags: Fonts, Recommended
11 * Feature: Writing
12 * Additional Search Queries: fonts, webfonts, typography
13 *
14 * @package automattic/jetpack
15 */
16
17 /**
18 * Curated list of Google Fonts
19 * See https://wp.me/p9Jlb4-22P
20 */
21 const JETPACK_GOOGLE_FONTS_LIST = array(
22 'Arvo',
23 'Bodoni Moda',
24 'Cabin',
25 'Chivo',
26 'Courier Prime',
27 'DM Sans',
28 'Domine',
29 'EB Garamond',
30 'Fira Sans',
31 'IBM Plex Sans',
32 'IBM Plex Mono',
33 'Inter',
34 'Josefin Sans',
35 'Jost',
36 'Libre Baskerville',
37 'Libre Franklin',
38 'Literata',
39 'Lora',
40 'Merriweather',
41 'Montserrat',
42 'Newsreader',
43 'Nunito',
44 'Open Sans',
45 'Overpass',
46 'Playfair Display',
47 'Poppins',
48 'Raleway',
49 'Roboto',
50 'Roboto Slab',
51 'Rubik',
52 'Source Sans Pro',
53 'Source Serif Pro',
54 'Space Mono',
55 'Texturina',
56 'Work Sans',
57 );
58
59 /**
60 * Register a curated selection of Google Fonts.
61 *
62 * @return void
63 */
64 function jetpack_add_google_fonts_provider() {
65 if ( ! function_exists( 'wp_register_webfont_provider' ) || ! function_exists( 'wp_register_webfonts' ) ) {
66 return;
67 }
68
69 wp_register_webfont_provider( 'jetpack-google-fonts', '\Automattic\Jetpack\Fonts\Google_Fonts_Provider' );
70
71 /**
72 * Curated list of Google Fonts.
73 *
74 * @module google-fonts
75 *
76 * @since 10.8
77 *
78 * @param array $fonts_to_register Array of Google Font names to register.
79 */
80 $fonts_to_register = apply_filters( 'jetpack_google_fonts_list', JETPACK_GOOGLE_FONTS_LIST );
81
82 foreach ( $fonts_to_register as $font_family ) {
83 wp_register_webfonts(
84 array(
85 array(
86 'font-family' => $font_family,
87 'font-weight' => '100 900',
88 'font-style' => 'normal',
89 'font-display' => 'fallback',
90 'provider' => 'jetpack-google-fonts',
91 ),
92 array(
93 'font-family' => $font_family,
94 'font-weight' => '100 900',
95 'font-style' => 'italic',
96 'font-display' => 'fallback',
97 'provider' => 'jetpack-google-fonts',
98 ),
99 )
100 );
101 }
102 }
103 add_action( 'after_setup_theme', 'jetpack_add_google_fonts_provider' );
104
105 add_filter( 'wp_resource_hints', '\Automattic\Jetpack\Fonts\Utils::font_source_resource_hint', 10, 2 );
106 add_filter( 'pre_render_block', '\Automattic\Jetpack\Fonts\Introspectors\Blocks::enqueue_block_fonts', 10, 2 );
107 add_action( 'init', '\Automattic\Jetpack\Fonts\Introspectors\Global_Styles::enqueue_global_styles_fonts' );
108