File: /var/www/html/insiders/wp-load/wp-content/plugins/breadly/block-library/icon.php
<?php
function gtm_render_block_icon( $attr, $content, $block ) {
$icon = 'gtm-basic-icon-ice-cream';
if ( ! empty( $attr['icon'] ) ) {
$icon = $attr['icon'];
}
$wrapper_attributes = get_block_wrapper_attributes( ['class' => implode( ' ', ['gtm-icon', $icon] )] );
return sprintf(
'<i %1$s></i>',
$wrapper_attributes
);
}
/**
* Registers the `gtm/icon` block on the server.
*/
function gtm_register_block_icon() {
gtm_register_block_type( 'icon', [
'render_callback' => 'gtm_render_block_icon',
] );
}
add_action( 'init', 'gtm_register_block_icon', 20 );
add_filter( 'gtm.BlockStyleCompiler.gtm/icon', 'gtm_compile_block_css_icon', 10, 3 );
function gtm_compile_block_css_icon( $output, $attributes, $blockName ) {
$block_style = ['classes' => [], 'style' => []];
$block_style['classes'][] = 'gtm-block';
gtm_css_compileCssVar( $block_style, "icon-icon-size", $attributes['iconSize'] );
/* Colors */
gtm_css_compileCssVar( $block_style, "icon-color", gtm_css_parseColorValue( $attributes['color'] ) );
gtm_css_compileCssVar( $block_style, "icon-bg", gtm_css_parseColorValue( $attributes['bg'] ) );
gtm_css_compileCssVar( $block_style, "icon-hover-color", gtm_css_parseColorValue( $attributes['hoverColor'] ) );
gtm_css_compileCssVar( $block_style, "icon-hover-bg", gtm_css_parseColorValue( $attributes['hoverBg'] ) );
// 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'] ),
];
}