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/about-author.php
<?php

/**
 * Renders the `gtm/about-author` 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 featured image for the current post.
 */
function gtm_render_block_about_author( $attr, $content, $block ) {
	if ( ! isset( $block->context['postId'] ) ) {
		return '';
	}

	$wrapper_attributes = get_block_wrapper_attributes( ['class' => ''] );
	$inner_html         = '';
	$post_ID            = $block->context['postId'];
	$author_id          = get_post_field( 'post_author', $post_ID );
	$author_url         = get_author_posts_url( $author_id );
	$author_name        = get_the_author_meta( 'display_name', $author_id );
	$tooltip            = sprintf( esc_html__( "View %s's page", 'gutenmate' ), $author_name );
	$author_link_attr   = ' href="' . esc_url( $author_url ) . '"';
	$author_link_attr .= sprintf( ' data-tippy-content="%1$s" aria-label="%1$s"', $tooltip );

	if ( ! empty( $attr['enableAvatar'] ) ) {
		$avatar_alt = sprintf( esc_attr__( "Avatar of %s", 'gutenmate' ), get_the_author_meta( 'display_name', $author_id ) );

		$inner_html .= '<a class="wp-block-gtm-about-author__avatar-container"';
		$inner_html .= $author_link_attr;
		$inner_html .= '>';
		$inner_html .= get_avatar( $author_id, $attr['avatarSize'], '', $avatar_alt );
		$inner_html .= '</a>';
	}

	$inner_html .= '<div class="wp-block-gtm-about-author__info-container">';

	if ( ! empty( $attr['tagline'] ) ) {
		$inner_html .= '<div class="wp-block-gtm-about-author__tagline"><span>';
		$inner_html .= wp_kses_post( $attr['tagline'] );
		$inner_html .= '</span></div>';
	}

	$inner_html .= '<a class="wp-block-gtm-about-author__name"';
	$inner_html .= $author_link_attr;
	$inner_html .= '><span>';
	$inner_html .= wp_kses_post( $author_name );
	$inner_html .= '</span></a>';

	if ( ! empty( $attr['enableBio'] ) ) {
		$inner_html .= '<div class="wp-block-gtm-about-author__bio">';
		$inner_html .= wp_kses_post( get_the_author_meta( 'description', $author_id ) );
		$inner_html .= '</div>';
	}

	if ( ! empty( $attr['enableSocial'] ) ) {
		$socials_html = gtm_author_social_networks( $author_id );

		if ( $socials_html ) {
			$inner_html .= '<div class="wp-block-gtm-about-author__social-networks">';
			$inner_html .= $socials_html;
			$inner_html .= '</div>';
		}
	}

	$inner_html .= '</div>';

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

/**
 * Registers the `gtm/about-author` block on the server.
 */
function gtm_register_block_about_author() {
	gtm_register_block_type( 'about-author', [
		'render_callback' => 'gtm_render_block_about_author',
	] );
}

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

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

	$block_style['classes'][] = 'gtm-block';
	$block_style['classes'][] = "gtm-has-stacked-layout-{$attributes['layoutStacked']}";
	$block_style['classes'][] = "gtm-has-social-display-{$attributes['socialDisplay']}";

	/* Avatar */

	gtm_css_compileCssVar( $block_style, "about-author-avatar-radius", gtm_css_parseBorderRadiusValue( $attributes['avatarRadius'] ) );

	gtm_css_compileCssVar( $block_style, "about-author-avatar-shadow", gtm_css_parseShadowValue( $attributes['avatarShadow'] ) );

	gtm_css_compileCssVar( $block_style, "about-author-avatar-spacing", gtm_css_parseSpacingValue( $attributes['avatarSpacing'] ) );

	/* Tagline */

	gtm_css_compileCssVar( $block_style, "about-author-tagline-typography", gtm_css_parseTypographyProps( $attributes['taglineTypography'] ) );

	gtm_css_compileCssVar( $block_style, "about-author-tagline-spacing", gtm_css_parseSpacingValue( $attributes['taglineSpacing'] ) );

	gtm_css_compileCssVar( $block_style, "about-author-tagline-color", gtm_css_parseColorValue( $attributes['taglineColor'] ) );

	/* Author name */

	gtm_css_compileCssVar( $block_style, "about-author-name-typography", gtm_css_parseTypographyProps( $attributes['nameTypography'] ) );

	gtm_css_compileCssVar( $block_style, "about-author-name-color", gtm_css_parseColorValue( $attributes['nameColor'] ) );

	/* Bio */

	if ( $attributes['enableBio'] ) {
		gtm_css_compileCssVar( $block_style, "about-author-bio-typography", gtm_css_parseTypographyProps( $attributes['bioTypography'] ) );

		gtm_css_compileCssVar( $block_style, "about-author-bio-spacing", gtm_css_parseSpacingValue( $attributes['bioSpacing'] ) );

		gtm_css_compileCssVar( $block_style, "about-author-bio-color", gtm_css_parseColorValue( $attributes['bioColor'] ) );
	}

	/* Social */

	if ( $attributes['enableSocial'] ) {
		gtm_css_compileCssVar( $block_style, "about-author-social-spacing", gtm_css_parseSpacingValue( $attributes['socialSpacing'] ) );

		gtm_css_compileCssVar( $block_style, "about-author-social-link-spacing", gtm_css_parseSpacingValue( $attributes['socialLinkSpacing'] ) );

		if ( $attributes['socialDisplay'] === 'icon' ) {
			gtm_css_compileCssVar( $block_style, "about-author-social-link-size", $attributes['socialLinkSize'] );
		} else {
			gtm_css_compileCssVar( $block_style, "about-author-social-link-padding", gtm_css_parseResponsiveBoxProps( $attributes['socialLinkPadding'] ) );
		}

		gtm_css_compileCssVar( $block_style, "about-author-social-link-radius", gtm_css_parseBorderRadiusValue( $attributes['socialLinkRadius'] ) );

		gtm_css_compileCssVar( $block_style, "about-author-social-link-typography", gtm_css_parseTypographyProps( $attributes['socialLinkTypography'] ) );

		gtm_css_compileCssVar( $block_style, "about-author-social-link-color", gtm_css_parseColorValue( $attributes['socialLinkColor'] ) );

		gtm_css_compileCssVar( $block_style, "about-author-social-link-bg", gtm_css_parseColorValue( $attributes['socialLinkBg'] ) );

		gtm_css_compileCssVar( $block_style, "about-author-social-link-hover-color", gtm_css_parseColorValue( $attributes['socialLinkHoverColor'] ) );

		gtm_css_compileCssVar( $block_style, "about-author-social-link-hover-bg", gtm_css_parseColorValue( $attributes['socialLinkHoverBg'] ) );
	}

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