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-extensions/block-printing.php
<?php
defined( 'GTM_BLOCK_SUPPORT_PRINTING_KEY' ) || define( 'GTM_BLOCK_SUPPORT_PRINTING_KEY', 'gtmBlockPrinting' );

/**
 * Registers the align block attribute for block types that support it.
 *
 * @param WP_Block_Type $block_type Block Type.
 */
function gtm_register_block_printing_support( $block_type ) {

	if (  ! $block_type->attributes ) {
		$block_type->attributes = [];
	}

	if (  ! array_key_exists( 'gtmPrinting', $block_type->attributes ) ) {
		$block_type->attributes['gtmPrinting'] = [
			'type'    => 'string',
			'enum'    => ["", "hide", "exclusive"],
			'default' => "",
		];
	}
}

// Register the block support.
WP_Block_Supports::get_instance()->register(
	GTM_BLOCK_SUPPORT_PRINTING_KEY,
	[
		'register_attribute' => 'gtm_register_block_printing_support',
	]
);

/**
 * Render block style
 */

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

	if (  ! empty( $attributes['gtmPrinting'] ) ) {
		if ( $attributes['gtmPrinting'] == 'hide' ) {
			$block_style['classes'][] = 'gtm-no-print';
		} else if ( $attributes['gtmPrinting'] == 'exclusive' ) {
			$block_style['classes'][] = 'gtm-exclusive-print';
		}
	}

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