1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<?php /** * Class GoogleFonts. * * Registers Google fonts for admin screens. * * @since 2.0 * * @package AmpProject\AmpWP */
namespace AmpProject\AmpWP\Admin;
use AmpProject\AmpWP\Infrastructure\Conditional; use AmpProject\AmpWP\Infrastructure\Delayed; use AmpProject\AmpWP\Infrastructure\Registerable; use AmpProject\AmpWP\Infrastructure\Service; use WP_Styles;
/** * Enqueue Google Fonts stylesheet. * * @since 2.0 * @internal */ final class GoogleFonts implements Conditional, Delayed, Service, Registerable {
/** * Check whether the conditional object is currently needed. * * @return bool Whether the conditional object is needed. */ public static function is_needed() { return is_admin() && ! wp_doing_ajax(); }
/** * Get the action to use for registering the service. * * @return string Registration action to use. */ public static function get_registration_action() { return 'plugins_loaded'; }
/** * Provides the asset handle. * * @return string */ public function get_handle() { return 'amp-admin-google-fonts'; }
/** * Runs on instantiation. */ public function register() { add_action( 'wp_default_styles', [ $this, 'register_style' ] ); }
/** * Registers the google font style. * * @param WP_Styles $wp_styles WP_Styles instance. */ public function register_style( WP_Styles $wp_styles ) { // PHPCS ignore reason: WP will strip multiple `family` args from the Google fonts URL while adding the version string, // so we need to avoid specifying a version at all. $wp_styles->add( // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion $this->get_handle(), 'https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&family=Poppins:wght@400;700&display=swap', [], null ); } }
|