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/directions.php
<?php

/**
 * Renders the `gtm/directions` 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 directions.
 */
function gtm_render_block_directions( $attr, $content, $block ) {
	if ( get_option( 'gtm_seo_enable_post_rich_snippets', true ) ) {
		$content = gtm_str_replace_first( '<div ', '<div itemscope itemtype="https://schema.org/HowTo" ', $content );
		$content = str_replace( '"wp-block-gtm-directions__title"', '"wp-block-gtm-directions__title" itemprop="name"', $content );
	}

	return $content;
}

/**
 * Registers the `gtm/directions` block on the server.
 */
function gtm_register_block_directions() {
	gtm_register_block_type( 'directions', [
		'render_callback' => 'gtm_render_block_directions',
	] );
}

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

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

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

	gtm_css_compileCssVar( $block_style, "directions-gap", gtm_css_parseSpacingValue( $attributes['gap'] ) );

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

	// Content
	gtm_css_compileCssVar( $block_style, "directions-content-typography", gtm_css_parseTypographyProps( $attributes['contentTypography'] ) );
	gtm_css_compileCssVar( $block_style, "directions-content-color", gtm_css_parseColorValue( $attributes['contentColor'] ) );

	// 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'] ),
	];
}