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/breadly/block-library/sliding-panel.php
<?php

/**
 * Registers the `gtm/sliding-panel` block on the server.
 */
function gtm_register_block_sliding_panel() {
	gtm_register_block_type( 'sliding-panel',
		[
			'render_callback' => 'gtm_render_block_sliding_panel',
		]
	);
}

function gtm_render_block_sliding_panel( $attr, $content, $block ) {
	return gtm_translate_aria_label( $content, esc_attr__( 'Close', 'gutenmate' ) );
}

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

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

	$block_style['classes'][] = 'gtm-block';
	$block_style['classes'][] = "gtm-has-sliding-panel-position-{$attributes['position']}";

	if ( $attributes['enableThinScrollbar'] ) {
		$block_style['classes'][] = 'gtm-has-thin-scrollbar';
	}

	if ( $attributes['enableCloseButton'] ) {
		$block_style['classes'][] = 'gtm-has-close-button';
		$block_style['classes'][] = "gtm-has-sliding-panel-close-position-{$attributes['closeButtonPosition']}";
	}

	if ( ! in_array( $attributes['position'], ['full'] ) ) {
		gtm_css_compileCssVar( $block_style, "sliding-panel-width", $attributes['width'] );
	}

	if ( ! in_array( $attributes['position'], ['full', 'center'] ) ) {
		gtm_css_compileCssVar( $block_style, "sliding-panel-offset-x", $attributes['offsetX'] );
		gtm_css_compileCssVar( $block_style, "sliding-panel-offset-y", $attributes['offsetY'] );
	}

	if ( $attributes['enableCloseButton'] ) {
		gtm_css_compileCssVar( $block_style, "sliding-panel-close-offset-x", $attributes['closeButtonOffsetX'] );
		gtm_css_compileCssVar( $block_style, "sliding-panel-close-offset-y", $attributes['closeButtonOffsetY'] );
		gtm_css_compileCssVar( $block_style, "sliding-panel-close-size", $attributes['closeButtonIconSize'] );
		gtm_css_compileCssVar( $block_style, "sliding-panel-close-width", $attributes['closeButtonWidth'] );
		gtm_css_compileCssVar( $block_style, "sliding-panel-close-radius", gtm_css_parseBorderRadiusValue( $attributes['closeButtonRadius'] ) );
		gtm_css_compileCssVar( $block_style, "sliding-panel-close-color", gtm_css_parseColorValue( $attributes['closeButtonColor'] ) );
		gtm_css_compileCssVar( $block_style, "sliding-panel-close-bg", gtm_css_parseColorValue( $attributes['closeButtonBg'] ) );
	}

	if ( $attributes['enableThinScrollbar'] ) {
		gtm_css_compileCssVar( $block_style, "sliding-panel-scroll-color", gtm_css_parseColorValue( $attributes['thinScrollbarColor'] ) );
		gtm_css_compileCssVar( $block_style, "sliding-panel-scroll-space", $attributes['thinScrollbarSpace'] );
	}

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