LLMS_User_Certificate::get_custom_fonts( array|null $blocks = null )

Retrieves a list of the fonts used by the certificate.


Description Description

See also See also


Top ↑

Parameters Parameters

$blocks

(array|null) (Optional) A list of parsed block arrays or null. If none supplied the certificate's content is parsed and used instead.

Default value: null


Top ↑

Return Return

(array[]) Array of fonts by the certificate. Each array is a font definition with the font's id added to the array.


Top ↑

Source Source

File: includes/models/model.llms.user.certificate.php

	public function get_custom_fonts( $blocks = null ) {

		$fonts = array();

		$blocks = is_null( $blocks ) ? parse_blocks( $this->get( 'content', true ) ) : $blocks;
		foreach ( $blocks as $block ) {

			if ( ! empty( $block['attrs']['fontFamily'] ) ) {
				$fonts[] = $block['attrs']['fontFamily'];
			}

			if ( ! empty( $block['innerBlocks'] ) ) {
				$fonts = array_merge( $fonts, wp_list_pluck( $this->get_custom_fonts( $block['innerBlocks'] ), 'id' ) );
			}
		}

		$valid_fonts = llms_get_certificate_fonts();

		return array_filter(
			array_map(
				function( $font ) use ( $valid_fonts ) {
					if ( 'default' === $font ) {
						return null;
					}
					$ret = $valid_fonts[ $font ] ?? null;
					if ( $ret ) {
						$ret['id'] = $font;
					}
					return $ret;
				},
				array_unique( $fonts )
			)
		);

	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.