render_block_core_social_link()WP 1.0

Renders the core/social-link block on server.

Хуков нет.

Возвращает

Строку. Rendered HTML of the referenced block.

Использование

render_block_core_social_link( $attributes, $content, $block );
$attributes(Array) (обязательный)
The block attributes.
$content(String) (обязательный)
InnerBlocks content of the Block.
$block(WP_Block) (обязательный)
Block object.

Код render_block_core_social_link() WP 6.0.2

function render_block_core_social_link( $attributes, $content, $block ) {
	$open_in_new_tab = isset( $block->context['openInNewTab'] ) ? $block->context['openInNewTab'] : false;

	$service     = ( isset( $attributes['service'] ) ) ? $attributes['service'] : 'Icon';
	$url         = ( isset( $attributes['url'] ) ) ? $attributes['url'] : false;
	$label       = ( isset( $attributes['label'] ) ) ? $attributes['label'] : block_core_social_link_get_name( $service );
	$show_labels = array_key_exists( 'showLabels', $block->context ) ? $block->context['showLabels'] : false;

	// Don't render a link if there is no URL set.
	if ( ! $url ) {
		return '';
	}

	$rel_target_attributes = '';
	if ( $open_in_new_tab ) {
		$rel_target_attributes = 'rel="noopener nofollow" target="_blank"';
	}

	$icon               = block_core_social_link_get_icon( $service );
	$wrapper_attributes = get_block_wrapper_attributes(
		array(
			'class' => 'wp-social-link wp-social-link-' . $service,
			'style' => block_core_social_link_get_color_styles( $block->context ),
		)
	);

	$link  = '<li ' . $wrapper_attributes . '>';
	$link .= '<a href="' . esc_url( $url ) . '" ' . $rel_target_attributes . ' class="wp-block-social-link-anchor">';
	$link .= $icon;
	$link .= '<span class="wp-block-social-link-label' . ( $show_labels ? '' : ' screen-reader-text' ) . '">';
	$link .= esc_html( $label );
	$link .= '</span></a></li>';

	return $link;
}