Changeset 57686 for trunk/src/wp-includes/fonts.php
- Timestamp:
- 02/21/2024 07:24:14 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/fonts.php
r57558 r57686 54 54 55 55 /** 56 * Registers a new Font Collection in the Font Library. 57 * 58 * @since 6.5.0 59 * 60 * @param string $slug Font collection slug. May only contain alphanumeric characters, dashes, 56 * Registers a new font collection in the font library. 57 * 58 * See {@link https://schemas.wp.org/trunk/font-collection.json} for the schema 59 * the font collection data must adhere to. 60 * 61 * @since 6.5.0 62 * 63 * @param string $slug Font collection slug. May only contain alphanumeric characters, dashes, 61 64 * and underscores. See sanitize_title(). 62 * @param array|string $data_or_file { 63 * Font collection data array or a path/URL to a JSON file containing the font collection. 64 * 65 * @link https://schemas.wp.org/trunk/font-collection.json 66 * 67 * @type string $name Required. Name of the font collection shown in the Font Library. 68 * @type string $description Optional. A short descriptive summary of the font collection. Default empty. 69 * @type array $font_families Required. Array of font family definitions that are in the collection. 70 * @type array $categories Optional. Array of categories, each with a name and slug, that are used by the 71 * fonts in the collection. Default empty. 65 * @param array $args { 66 * Font collection data. 67 * 68 * @type string $name Required. Name of the font collection shown in the Font Library. 69 * @type string $description Optional. A short descriptive summary of the font collection. Default empty. 70 * @type array|string $font_families Required. Array of font family definitions that are in the collection, 71 * or a string containing the path or URL to a JSON file containing the font collection. 72 * @type array $categories Optional. Array of categories, each with a name and slug, that are used by the 73 * fonts in the collection. Default empty. 72 74 * } 73 75 * @return WP_Font_Collection|WP_Error A font collection if it was registered 74 76 * successfully, or WP_Error object on failure. 75 77 */ 76 function wp_register_font_collection( $slug, $data_or_file) {77 return WP_Font_Library::get_instance()->register_font_collection( $slug, $ data_or_file);78 function wp_register_font_collection( string $slug, array $args ) { 79 return WP_Font_Library::get_instance()->register_font_collection( $slug, $args ); 78 80 } 79 81 … … 86 88 * @return bool True if the font collection was unregistered successfully, else false. 87 89 */ 88 function wp_unregister_font_collection( $slug ) {90 function wp_unregister_font_collection( string $slug ) { 89 91 return WP_Font_Library::get_instance()->unregister_font_collection( $slug ); 90 92 } … … 197 199 */ 198 200 function _wp_register_default_font_collections() { 199 wp_register_font_collection( 'google-fonts', 'https://s.w.org/images/fonts/17.7/collections/google-fonts-with-preview.json' ); 200 } 201 wp_register_font_collection( 202 'google-fonts', 203 array( 204 'name' => _x( 'Google Fonts', 'font collection name' ), 205 'description' => __( 'Install from Google Fonts. Fonts are copied to and served from your site.' ), 206 'font_families' => 'https://s.w.org/images/fonts/17.7/collections/google-fonts-with-preview.json', 207 'categories' => array( 208 array( 209 'name' => _x( 'Sans Serif', 'font category' ), 210 'slug' => 'sans-serif', 211 ), 212 array( 213 'name' => _x( 'Display', 'font category' ), 214 'slug' => 'display', 215 ), 216 array( 217 'name' => _x( 'Serif', 'font category' ), 218 'slug' => 'serif', 219 ), 220 array( 221 'name' => _x( 'Handwriting', 'font category' ), 222 'slug' => 'handwriting', 223 ), 224 array( 225 'name' => _x( 'Monospace', 'font category' ), 226 'slug' => 'monospace', 227 ), 228 ), 229 ) 230 ); 231 }
Note: See TracChangeset
for help on using the changeset viewer.