wppaste
WordPress

WP_Font_Library

Since
6.5.0
Source
wp-includes/fonts/class-wp-font-library.php:17
Font Library class.

Compatibility

WordPress
since 6.5.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 2

$collectionsarrayprivate
Font collections.
$instanceWP_Font_Library|nullprivate static
Container for the main instance of the class.

Methods · 6

Source code

class WP_Font_Library { 	/**	 * Font collections.	 *	 * @since 6.5.0	 * @var array	 */	private $collections = array(); 	/**	 * Container for the main instance of the class.	 *	 * @since 6.5.0	 * @var WP_Font_Library|null	 */	private static $instance = null; 	/**	 * Register a new font collection.	 *	 * @since 6.5.0	 *	 * @param string $slug Font collection slug. May only contain alphanumeric characters, dashes,	 *                     and underscores. See sanitize_title().	 * @param array  $args Font collection data. See wp_register_font_collection() for information on accepted arguments.	 * @return WP_Font_Collection|WP_Error A font collection if it was registered successfully,	 *                                     or WP_Error object on failure.	 */	public function register_font_collection( string $slug, array $args ) {		$new_collection = new WP_Font_Collection( $slug, $args ); 		if ( $this->is_collection_registered( $new_collection->slug ) ) {			$error_message = sprintf(				/* translators: %s: Font collection slug. */				__( 'Font collection with slug: "%s" is already registered.' ),				$new_collection->slug			);			_doing_it_wrong(				__METHOD__,				$error_message,				'6.5.0'			);			return new WP_Error( 'font_collection_registration_error', $error_message );		}		$this->collections[ $new_collection->slug ] = $new_collection;		return $new_collection;	} 	/**	 * Unregisters a previously registered font collection.	 *	 * @since 6.5.0	 *	 * @param string $slug Font collection slug.	 * @return bool True if the font collection was unregistered successfully and false otherwise.	 */	public function unregister_font_collection( string $slug ) {		if ( ! $this->is_collection_registered( $slug ) ) {			_doing_it_wrong(				__METHOD__,				/* translators: %s: Font collection slug. */				sprintf( __( 'Font collection "%s" not found.' ), $slug ),				'6.5.0'			);			return false;		}		unset( $this->collections[ $slug ] );		return true;	} 	/**	 * Checks if a font collection is registered.	 *	 * @since 6.5.0	 *	 * @param string $slug Font collection slug.	 * @return bool True if the font collection is registered and false otherwise.	 */	private function is_collection_registered( string $slug ) {

Changelog

Introduced in 6.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/fonts/class-wp-font-library.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.