| 1 |
<?php |
| 2 |
/** |
| 3 |
* Deprecated functions provided here to give extenders time to change |
| 4 |
* their plugins/themes before this API is introduced into Core. |
| 5 |
* |
| 6 |
* BACKPORT NOTE: Do not backport these deprecated functions to Core. |
| 7 |
* |
| 8 |
* @package WordPress |
| 9 |
* @subpackage Fonts API |
| 10 |
* @since X.X.X |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! function_exists( 'wp_webfonts' ) ) { |
| 14 |
/** |
| 15 |
* Initialize $wp_webfonts if it has not been set. |
| 16 |
* |
| 17 |
* @since X.X.X |
| 18 |
* @deprecated GB 15.1 Use wp_fonts() instead. |
| 19 |
* |
| 20 |
* @global WP_Webfonts $wp_webfonts |
| 21 |
* |
| 22 |
* @return WP_Webfonts WP_Webfonts instance. |
| 23 |
*/ |
| 24 |
function wp_webfonts() { |
| 25 |
_deprecated_function( __FUNCTION__, 'GB 15.1', 'wp_fonts()' ); |
| 26 |
|
| 27 |
global $wp_webfonts; |
| 28 |
|
| 29 |
if ( ! ( $wp_webfonts instanceof WP_Webfonts ) ) { |
| 30 |
$wp_webfonts = new WP_Webfonts( wp_fonts() ); |
| 31 |
} |
| 32 |
|
| 33 |
return $wp_webfonts; |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
if ( ! function_exists( 'wp_register_webfonts' ) ) { |
| 38 |
/** |
| 39 |
* Registers one or more font-families and each of their variations. |
| 40 |
* |
| 41 |
* @since X.X.X |
| 42 |
* @deprecated GB 15.1 Use wp_register_fonts() instead. |
| 43 |
* |
| 44 |
* @param array[] $webfonts { |
| 45 |
* Web fonts to be registered, grouped by each font-family. |
| 46 |
* |
| 47 |
* @type string $font-family => array[] $variations { |
| 48 |
* An array of web font variations for this font-family. |
| 49 |
* Each variation has the following structure. |
| 50 |
* |
| 51 |
* @type array $variation { |
| 52 |
* @type string $provider The provider ID. Default 'local'. |
| 53 |
* @type string $font-style The font-style property. Default 'normal'. |
| 54 |
* @type string $font-weight The font-weight property. Default '400'. |
| 55 |
* @type string $font-display The font-display property. Default 'fallback'. |
| 56 |
* } |
| 57 |
* } |
| 58 |
* } |
| 59 |
* @return string[] Array of registered font family handles. |
| 60 |
*/ |
| 61 |
function wp_register_webfonts( array $webfonts ) { |
| 62 |
_deprecated_function( __FUNCTION__, 'GB 15.1', 'wp_register_fonts()' ); |
| 63 |
|
| 64 |
$webfonts = Gutenberg_Fonts_API_BC_Layer::migrate_deprecated_structure( $webfonts ); |
| 65 |
|
| 66 |
return wp_register_fonts( $webfonts ); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
if ( ! function_exists( 'wp_register_webfont' ) ) { |
| 71 |
/** |
| 72 |
* Registers a single webfont. |
| 73 |
* |
| 74 |
* Example of how to register Source Serif Pro font with font-weight range of 200-900: |
| 75 |
* |
| 76 |
* If the font file is contained within the theme: |
| 77 |
* |
| 78 |
* <code> |
| 79 |
* wp_register_webfont( |
| 80 |
* array( |
| 81 |
* 'provider' => 'local', |
| 82 |
* 'font-family' => 'Source Serif Pro', |
| 83 |
* 'font-weight' => '200 900', |
| 84 |
* 'font-style' => 'normal', |
| 85 |
* 'src' => get_theme_file_uri( 'assets/fonts/source-serif-pro/SourceSerif4Variable-Roman.ttf.woff2' ), |
| 86 |
* ) |
| 87 |
* ); |
| 88 |
* </code> |
| 89 |
* |
| 90 |
* @since 6.0.0 |
| 91 |
* @deprecated 14.9.1 Use wp_register_fonts(). |
| 92 |
* |
| 93 |
* @param array $webfont Webfont to be registered. |
| 94 |
* @return string|false The font family slug if successfully registered, else false. |
| 95 |
*/ |
| 96 |
function wp_register_webfont( array $webfont ) { |
| 97 |
_deprecated_function( __FUNCTION__, '14.9.1', 'wp_register_fonts()' ); |
| 98 |
|
| 99 |
return wp_fonts()->register_webfont( $webfont, '', '', false ); |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
if ( ! function_exists( 'wp_enqueue_webfonts' ) ) { |
| 104 |
/** |
| 105 |
* Enqueues one or more font family and all of its variations. |
| 106 |
* |
| 107 |
* @since X.X.X |
| 108 |
* @since GB 15.1 Use wp_enqueue_fonts() ihstead. |
| 109 |
* |
| 110 |
* @param string[] $font_families Font family(ies) to enqueue. |
| 111 |
*/ |
| 112 |
function wp_enqueue_webfonts( array $font_families ) { |
| 113 |
_deprecated_function( __FUNCTION__, 'GB 15.1', 'wp_enqueue_fonts()' ); |
| 114 |
|
| 115 |
wp_enqueue_fonts( $font_families ); |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
if ( ! function_exists( 'wp_enqueue_webfont' ) ) { |
| 120 |
/** |
| 121 |
* Enqueue a single font family that has been registered beforehand. |
| 122 |
* |
| 123 |
* Example of how to enqueue Source Serif Pro font: |
| 124 |
* |
| 125 |
* <code> |
| 126 |
* wp_enqueue_webfont( 'Source Serif Pro' ); |
| 127 |
* </code> |
| 128 |
* |
| 129 |
* Font families should be enqueued from the `init` hook or later. |
| 130 |
* |
| 131 |
* @since 6.0.0 |
| 132 |
* @deprecated GB 14.9.1 Use wp_enqueue_fonts() instead. |
| 133 |
* |
| 134 |
* @param string $font_family_name The font family name to be enqueued. |
| 135 |
* @return bool True if successfully enqueued, else false. |
| 136 |
*/ |
| 137 |
function wp_enqueue_webfont( $font_family_name ) { |
| 138 |
_deprecated_function( __FUNCTION__, 'GB 14.9.1', 'wp_enqueue_fonts()' ); |
| 139 |
|
| 140 |
wp_enqueue_fonts( array( $font_family_name ) ); |
| 141 |
return true; |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
if ( ! function_exists( 'wp_enqueue_webfont_variations' ) ) { |
| 146 |
/** |
| 147 |
* Enqueues a specific set of web font variations. |
| 148 |
* |
| 149 |
* @since X.X.X |
| 150 |
* @deprecated GB 15.1 Use wp_enqueue_font_variations() instead. |
| 151 |
* |
| 152 |
* @param string|string[] $variation_handles Variation handle (string) or handles (array of strings). |
| 153 |
*/ |
| 154 |
function wp_enqueue_webfont_variations( $variation_handles ) { |
| 155 |
_deprecated_function( __FUNCTION__, 'GB 15.1', 'wp_enqueue_font_variations()' ); |
| 156 |
|
| 157 |
wp_enqueue_font_variations( $variation_handles ); |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
if ( ! function_exists( 'wp_deregister_webfont_variation' ) ) { |
| 162 |
/** |
| 163 |
* Deregisters a font variation. |
| 164 |
* |
| 165 |
* @since GB 14.9.1 |
| 166 |
* @deprecated GB 15.1 Use wp_deregister_font_variation() instead. |
| 167 |
* |
| 168 |
* @param string $font_family_handle The font family for this variation. |
| 169 |
* @param string $variation_handle The variation's handle to remove. |
| 170 |
*/ |
| 171 |
function wp_deregister_webfont_variation( $font_family_handle, $variation_handle ) { |
| 172 |
_deprecated_function( __FUNCTION__, 'GB 15.1', 'wp_deregister_font_variation()' ); |
| 173 |
|
| 174 |
wp_deregister_font_variation( $font_family_handle, $variation_handle ); |
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
if ( ! function_exists( 'wp_get_webfont_providers' ) ) { |
| 179 |
/** |
| 180 |
* Gets all registered providers. |
| 181 |
* |
| 182 |
* Return an array of providers, each keyed by their unique |
| 183 |
* ID (i.e. the `$id` property in the provider's object) with |
| 184 |
* an instance of the provider (object): |
| 185 |
* ID => provider instance |
| 186 |
* |
| 187 |
* Each provider contains the business logic for how to |
| 188 |
* process its specific font service (i.e. local or remote) |
| 189 |
* and how to generate the `@font-face` styles for its service. |
| 190 |
* |
| 191 |
* @since X.X.X |
| 192 |
* @deprecated GB 14.9.1 Use wp_fonts()->get_providers(). |
| 193 |
* |
| 194 |
* @return string[] All registered providers, each keyed by their unique ID. |
| 195 |
*/ |
| 196 |
function wp_get_webfont_providers() { |
| 197 |
_deprecated_function( __FUNCTION__, '14.9.1', 'wp_fonts()->get_providers()' ); |
| 198 |
|
| 199 |
$providers = array(); |
| 200 |
foreach ( wp_fonts()->get_providers() as $id => $config ) { |
| 201 |
$providers[ $id ] = $config['class']; |
| 202 |
} |
| 203 |
|
| 204 |
return $providers; |
| 205 |
} |
| 206 |
} |
| 207 |
|
| 208 |
if ( ! function_exists( 'wp_register_webfont_provider' ) ) { |
| 209 |
/** |
| 210 |
* Registers a custom font service provider. |
| 211 |
* |
| 212 |
* A webfont provider contains the business logic for how to |
| 213 |
* interact with a remote font service and how to generate |
| 214 |
* the `@font-face` styles for that remote service. |
| 215 |
* |
| 216 |
* How to register a custom font service provider: |
| 217 |
* 1. Load its class file into memory before registration. |
| 218 |
* 2. Pass the class' name to this function. |
| 219 |
* |
| 220 |
* For example, for a class named `My_Custom_Font_Service_Provider`: |
| 221 |
* ``` |
| 222 |
* wp_register_webfont_provider( My_Custom_Font_Service_Provider::class ); |
| 223 |
* ``` |
| 224 |
* |
| 225 |
* @since X.X.X |
| 226 |
* @deprecated GB 15.1 Use wp_register_font_provider() instead. |
| 227 |
* |
| 228 |
* @param string $name The provider's name. |
| 229 |
* @param string $classname The provider's class name. |
| 230 |
* The class should be a child of `WP_Webfonts_Provider`. |
| 231 |
* See {@see WP_Webfonts_Provider}. |
| 232 |
* |
| 233 |
* @return bool True if successfully registered, else false. |
| 234 |
*/ |
| 235 |
function wp_register_webfont_provider( $name, $classname ) { |
| 236 |
_deprecated_function( __FUNCTION__, 'GB 15.1', 'wp_register_font_provider' ); |
| 237 |
|
| 238 |
return wp_register_font_provider( $name, $classname ); |
| 239 |
} |
| 240 |
} |
| 241 |
|
| 242 |
if ( ! function_exists( 'wp_print_webfonts' ) ) { |
| 243 |
/** |
| 244 |
* Invokes each provider to process and print its styles. |
| 245 |
* |
| 246 |
* @since GB 14.9.1 |
| 247 |
* @deprecated GB 15.1 Use wp_print_fonts() instead. |
| 248 |
* |
| 249 |
* @param string|string[]|false $handles Optional. Items to be processed: queue (false), |
| 250 |
* single item (string), or multiple items (array of strings). |
| 251 |
* Default false. |
| 252 |
* @return array|string[] Array of web font handles that have been processed. |
| 253 |
* An empty array if none were processed. |
| 254 |
*/ |
| 255 |
function wp_print_webfonts( $handles = false ) { |
| 256 |
_deprecated_function( __FUNCTION__, 'GB 15.1', 'wp_print_fonts' ); |
| 257 |
|
| 258 |
return wp_print_fonts( $handles ); |
| 259 |
} |
| 260 |
} |
| 261 |
|