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

/**
 * Renders the `gtm/post-excerpt` 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 post excerpt for the current post.
 */
function gtm_render_block_post_excerpt( $attr, $content, $block ) {

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

	$post_ID = $block->context['postId'];

	if ( $attr['enableExcerptLength'] && ! empty( $attr['excerptLength'] ) ) {
		GTM_Excerpt::set( intval( $attr['excerptLength'] ) );
	}

	$excerpt = $attr['enableAutoExcerpt'] ? gtm_get_automatic_excerpt() : get_the_excerpt();

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

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

/**
 * Registers the `gtm/post-excerpt` block on the server.
 */
function gtm_register_block_post_excerpt() {
	gtm_register_block_type( 'post-excerpt', [
		'render_callback' => 'gtm_render_block_post_excerpt',
	] );
}

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

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

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

	gtm_css_compileCssVar( $block_style, "post-excerpt-max-width", $attributes['excerptMaxWidth'] );

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