Automattic\WooCommerce\Internal\Font

FontFamily::get_font_family_by_name()public staticWC 1.0

Gets a font family by name.

Method of the class: FontFamily{}

No Hooks.

Return

\WP_Post|null. The font family post or null if not found.

Usage

$result = FontFamily::get_font_family_by_name( $name );
$name(string) (required)
The font family slug.

FontFamily::get_font_family_by_name() code WC 9.3.3

public static function get_font_family_by_name( $name ) {
	$query = new \WP_Query(
		array(
			'post_type'              => self::POST_TYPE,
			'posts_per_page'         => 1,
			'title'                  => $name,
			'update_post_meta_cache' => false,
			'update_post_term_cache' => false,
		)
	);

	if ( ! empty( $query->get_posts() ) ) {
		return $query->get_posts()[0];
	}
	return null;
}