LLMS_Block_Library::modify_editor_settings( array $settings, WP_Block_Editor_Context $context )

Loads custom fonts for the llms/certificate-title block.


Parameters Parameters

$settings

(array) (Required) Editor settings.

$context

(WP_Block_Editor_Context) (Required) Current block editor context.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/class-llms-block-library.php

	public function modify_editor_settings( $settings, $context ) {

		// Only load fonts when in post editor context for a certificate post type.
		if ( ! empty( $context->post ) && in_array( $context->post->post_type, array( 'llms_certificate', 'llms_my_certificate' ), true ) ) {

			$theme_fonts = $settings['__experimentalFeatures']['typography']['fontFamilies']['theme'] ?? array();

			$fonts        = llms_get_certificate_fonts();
			$custom_fonts = array_map(
				function( $slug, $font_data ) {
					unset( $font_data['href'] );
					$font_data['slug'] = $slug;
					return $font_data;
				},
				array_keys( $fonts ),
				$fonts
			);

			_wp_array_set(
				$settings,
				array(
					'__experimentalFeatures',
					'blocks',
					'llms/certificate-title',
					'typography',
					'fontFamilies',
					'custom',
				),
				array_merge( $theme_fonts, array_filter( $custom_fonts ) )
			);

		}

		return $settings;

	}


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.