PluginProbe
Gutenberg / 13.7.2
Gutenberg v13.7.2
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / experimental / class-wp-webfonts-provider.php

class-wp-webfonts-provider.php in Gutenberg 13.7.2, at lib/experimental/class-wp-webfonts-provider.php

73 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Webfonts API: Provider abstract class.
4 *
5 * Individual webfonts providers should extend this class and implement.
6 *
7 * @package WordPress
8 * @subpackage WebFonts
9 * @since 6.0.0
10 */
11
12 if ( class_exists( 'WP_Webfonts_Provider' ) ) {
13 return;
14 }
15
16 /**
17 * Abstract class for Webfonts API providers.
18 *
19 * The starting point to building a webfont service provider.
20 *
21 * What is a Provider?
22 *
23 * A provider contains the know-how (business logic) for how to
24 * process its specific font service (i.e. local or remote)
25 * and how to generate the `@font-face` styles for its service.
26 *
27 * It receives a collection of webfonts from the Controller
28 * {@see WP_Webfonts_Provider::set_setfonts()}, and when requested
29 * {@see WP_Webfonts_Provider::get_css()}, it transforms them
30 * into styles (in a performant way for the provider service
31 * it manages).
32 *
33 * @since 6.0.0
34 */
35 abstract class WP_Webfonts_Provider {
36
37 /**
38 * Webfonts to be processed.
39 *
40 * @since 6.0.0
41 *
42 * @var array[]
43 */
44 protected $webfonts = array();
45
46 /**
47 * Sets this provider's webfonts property.
48 *
49 * The API's Controller passes this provider's webfonts
50 * for processing here in the provider.
51 *
52 * @since 6.0.0
53 *
54 * @param array[] $webfonts Registered webfonts.
55 */
56 public function set_webfonts( array $webfonts ) {
57 $this->webfonts = $webfonts;
58 }
59
60 /**
61 * Gets the `@font-face` CSS for the provider's webfonts.
62 *
63 * This method is where the provider does it processing to build the
64 * needed `@font-face` CSS for all of its webfonts. Specifics of how
65 * this processing is done is contained in each provider.
66 *
67 * @since 6.0.0
68 *
69 * @return string The `@font-face` CSS.
70 */
71 abstract public function get_css();
72 }
73