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

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

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

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

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

	$inner_html = '';

	$post_date_iso = get_the_date( 'c', $post_ID );

	if ( ! empty( $attr['enableLine1'] ) ) {
		$date = get_the_date( ! empty( $attr['line1format'] ) ? $attr['line1format'] : '', $post_ID );
		$inner_html .= '<div class="wp-block-gtm-post-date-box__line-1" >';
		$inner_html .= $date;
		$inner_html .= '</div>';
	}

	$date = get_the_date( ! empty( $attr['line2format'] ) ? $attr['line2format'] : '', $post_ID );
	$inner_html .= '<div class="wp-block-gtm-post-date-box__line-2" >';
	$inner_html .= $date;
	$inner_html .= '</div>';

	if ( ! empty( $attr['enableLine3'] ) ) {
		$date = get_the_date( ! empty( $attr['line3format'] ) ? $attr['line3format'] : '', $post_ID );
		$inner_html .= '<div class="wp-block-gtm-post-date-box__line-3" >';
		$inner_html .= $date;
		$inner_html .= '</div>';
	}

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

/**
 * Registers the `gtm/post-date` block on the server.
 */
function gtm_register_block_post_date_box() {
	gtm_register_block_type( 'post-date-box', [
		'render_callback' => 'gtm_render_block_post_date_box',
	] );
}

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

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

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

	if ( ! empty( $attributes['enableLine1'] ) ) {
		gtm_css_compileCssVar( $block_style, "post-date-box-line-1-typography", gtm_css_parseTypographyProps( $attributes['line1typography'] ) );
		gtm_css_compileCssVar( $block_style, "post-date-box-line-1-padding", gtm_css_parseResponsiveBoxProps( $attributes['line1padding'] ) );
		gtm_css_compileCssVar( $block_style, "post-date-box-line-1-spacing", gtm_css_parseSpacingValue( $attributes['line1spacing'] ) );
		gtm_css_compileCssVar( $block_style, "post-date-box-line-1-radius", gtm_css_parseBorderRadiusValue( $attributes['line1radius'] ) );
		gtm_css_compileCssVar( $block_style, "post-date-box-line-1-color", gtm_css_parseColorValue( $attributes['line1color'] ) );
		gtm_css_compileCssVar( $block_style, "post-date-box-line-1-bg", gtm_css_parseColorValue( $attributes['line1bg'] ) );
	}

	gtm_css_compileCssVar( $block_style, "post-date-box-line-2-typography", gtm_css_parseTypographyProps( $attributes['line2typography'] ) );
	gtm_css_compileCssVar( $block_style, "post-date-box-line-2-padding", gtm_css_parseResponsiveBoxProps( $attributes['line2padding'] ) );
	gtm_css_compileCssVar( $block_style, "post-date-box-line-2-radius", gtm_css_parseBorderRadiusValue( $attributes['line2radius'] ) );
	gtm_css_compileCssVar( $block_style, "post-date-box-line-2-color", gtm_css_parseColorValue( $attributes['line2color'] ) );
	gtm_css_compileCssVar( $block_style, "post-date-box-line-2-bg", gtm_css_parseColorValue( $attributes['line2bg'] ) );

	if ( ! empty( $attributes['enableLine3'] ) ) {
		gtm_css_compileCssVar( $block_style, "post-date-box-line-3-typography", gtm_css_parseTypographyProps( $attributes['line3typography'] ) );
		gtm_css_compileCssVar( $block_style, "post-date-box-line-3-padding", gtm_css_parseResponsiveBoxProps( $attributes['line3padding'] ) );
		gtm_css_compileCssVar( $block_style, "post-date-box-line-3-spacing", gtm_css_parseSpacingValue( $attributes['line3spacing'] ) );
		gtm_css_compileCssVar( $block_style, "post-date-box-line-3-radius", gtm_css_parseBorderRadiusValue( $attributes['line3radius'] ) );
		gtm_css_compileCssVar( $block_style, "post-date-box-line-3-color", gtm_css_parseColorValue( $attributes['line3color'] ) );
		gtm_css_compileCssVar( $block_style, "post-date-box-line-3-bg", gtm_css_parseColorValue( $attributes['line3bg'] ) );
	}

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