HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/insiders/wp-load/wp-content/plugins/gutenmate/block-library/template-title.php
<?php

/**
 * Renders the `gtm/template-title` block on the server.
 *
 * @param array    $attributes Block attributes.
 * @param string   $content    Block default content.
 * @param WP_Block $block      Block instance.
 * @return string Returns the title for the current template.
 */
function gtm_render_block_template_title( $attr, $content, $block ) {

	if ( ! isset( $block->context['gtmTemplateTitle'] ) ) {
		return '';
	}

	$template_title   = $block->context['gtmTemplateTitle'];
	$template_tagline = $block->context['gtmTemplateTagline'] ?? null;

	$inner_html = sprintf( '<%1$s class="wp-block-gtm-template-title__title"><span>%2$s</span></%1$s>', esc_html( $attr['titleTag'] ), esc_html( $template_title ) );

	if ( ! empty( $template_tagline ) ) {
		$inner_html .= sprintf( '<%1$s class="wp-block-gtm-template-title__tagline"><span>%2$s</span></%1$s>', esc_html( $attr['taglineTag'] ), esc_html( $template_tagline ) );

	}

	$wrapper_attributes = get_block_wrapper_attributes( ['class' => ''] );

	return sprintf(
		'<div %1$s>%2$s</div>',
		$wrapper_attributes,
		$inner_html
	);
}

/**
 * Registers the `gtm/template-title` block on the server.
 */
function gtm_register_block_template_title() {
	gtm_register_block_type( 'template-title', [
		'render_callback' => 'gtm_render_block_template_title',
	] );
}

add_action( 'init', 'gtm_register_block_template_title', 20 );

add_filter( 'gtm.BlockStyleCompiler.gtm/template-title', 'gtm_compile_block_css_template_title', 10, 3 );
function gtm_compile_block_css_template_title( $output, $attributes, $blockName ) {
	$block_style = ['classes' => [], 'style' => []];

	$block_style['classes'][] = 'gtm-block';

	gtm_css_compileCssVar( $block_style, "template-title-max-width", $attributes['maxWidth'] );

	// Main headline
	gtm_css_compileCssVar( $block_style, "template-title-title-color", gtm_css_parseColorValue( $attributes['titleColor'] ) );
	gtm_css_compileCssVar( $block_style, "template-title-title-typography", gtm_css_parseTypographyProps( $attributes['titleTypography'] ) );

	// Tagline
	gtm_css_compileCssVar( $block_style, "template-title-tagline-color", gtm_css_parseColorValue( $attributes['taglineColor'] ) );
	gtm_css_compileCssVar( $block_style, "template-title-tagline-spacing", gtm_css_parseSpacingValue( $attributes['taglineSpacing'] ) );
	gtm_css_compileCssVar( $block_style, "template-title-tagline-typography", gtm_css_parseTypographyProps( $attributes['taglineTypography'] ) );

	// Apply to output
	$block_style['style'] = ['{{BLOCK}}' => $block_style['style']];

	return [
		'classes' => array_merge( $output['classes'], $block_style['classes'] ),
		'style'   => array_replace_recursive( $output['style'], $block_style['style'] ),
	];
}