render_block_core_social_link

Advertisement

Summery Summery

Renders the core/social-link block on server.

Syntax Syntax

render_block_core_social_link( array $attributes )

Parameters Parameters

$attributes

(Required) The block attributes.

Return Return

(string) Rendered HTML of the referenced block.

Source Source

File: wp-includes/blocks/social-link.php

function render_block_core_social_link( $attributes ) {
	$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 );
	$class_name = isset( $attributes['className'] ) ? ' ' . $attributes['className'] : false;

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

	$icon = block_core_social_link_get_icon( $service );
	return '<li class="wp-social-link wp-social-link-' . esc_attr( $service ) . esc_attr( $class_name ) . '"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( $label ) . '"> ' . $icon . '</a></li>';
}

Advertisement

Advertisement

Leave a Reply