rebase on oct-10-2023
This commit is contained in:
@@ -47,7 +47,7 @@ function render_block_core_social_link( $attributes, $content, $block ) {
|
||||
$icon = block_core_social_link_get_icon( $service );
|
||||
$wrapper_attributes = get_block_wrapper_attributes(
|
||||
array(
|
||||
'class' => 'wp-social-link wp-social-link-' . $service,
|
||||
'class' => 'wp-social-link wp-social-link-' . $service . block_core_social_link_get_color_classes( $block->context ),
|
||||
'style' => block_core_social_link_get_color_styles( $block->context ),
|
||||
)
|
||||
);
|
||||
@@ -59,15 +59,15 @@ function render_block_core_social_link( $attributes, $content, $block ) {
|
||||
$link .= esc_html( $label );
|
||||
$link .= '</span></a></li>';
|
||||
|
||||
$w = new WP_HTML_Tag_Processor( $link );
|
||||
$w->next_tag( 'a' );
|
||||
$processor = new WP_HTML_Tag_Processor( $link );
|
||||
$processor->next_tag( 'a' );
|
||||
if ( $open_in_new_tab ) {
|
||||
$w->set_attribute( 'rel', esc_attr( $rel ) . ' noopener nofollow' );
|
||||
$w->set_attribute( 'target', '_blank' );
|
||||
$processor->set_attribute( 'rel', esc_attr( $rel ) . ' noopener nofollow' );
|
||||
$processor->set_attribute( 'target', '_blank' );
|
||||
} elseif ( '' !== $rel ) {
|
||||
$w->set_attribute( 'rel', esc_attr( $rel ) );
|
||||
$processor->set_attribute( 'rel', esc_attr( $rel ) );
|
||||
}
|
||||
return $w;
|
||||
return $processor->get_updated_html();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +144,7 @@ function block_core_social_link_services( $service = '', $field = '' ) {
|
||||
),
|
||||
'chain' => array(
|
||||
'name' => 'Link',
|
||||
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.647,16.706a1.134,1.134,0,0,0-.343-.833l-2.549-2.549a1.134,1.134,0,0,0-.833-.343,1.168,1.168,0,0,0-.883.392l.233.226q.2.189.264.264a2.922,2.922,0,0,1,.184.233.986.986,0,0,1,.159.312,1.242,1.242,0,0,1,.043.337,1.172,1.172,0,0,1-1.176,1.176,1.237,1.237,0,0,1-.337-.043,1,1,0,0,1-.312-.159,2.76,2.76,0,0,1-.233-.184q-.073-.068-.264-.264l-.226-.233a1.19,1.19,0,0,0-.4.895,1.134,1.134,0,0,0,.343.833L15.837,19.3a1.13,1.13,0,0,0,.833.331,1.18,1.18,0,0,0,.833-.318l1.8-1.789a1.12,1.12,0,0,0,.343-.821Zm-8.615-8.64a1.134,1.134,0,0,0-.343-.833L8.163,4.7a1.134,1.134,0,0,0-.833-.343,1.184,1.184,0,0,0-.833.331L4.7,6.473a1.12,1.12,0,0,0-.343.821,1.134,1.134,0,0,0,.343.833l2.549,2.549a1.13,1.13,0,0,0,.833.331,1.184,1.184,0,0,0,.883-.38L8.728,10.4q-.2-.189-.264-.264A2.922,2.922,0,0,1,8.28,9.9a.986.986,0,0,1-.159-.312,1.242,1.242,0,0,1-.043-.337A1.172,1.172,0,0,1,9.254,8.079a1.237,1.237,0,0,1,.337.043,1,1,0,0,1,.312.159,2.761,2.761,0,0,1,.233.184q.073.068.264.264l.226.233a1.19,1.19,0,0,0,.4-.895ZM22,16.706a3.343,3.343,0,0,1-1.042,2.488l-1.8,1.789a3.536,3.536,0,0,1-4.988-.025l-2.525-2.537a3.384,3.384,0,0,1-1.017-2.488,3.448,3.448,0,0,1,1.078-2.561l-1.078-1.078a3.434,3.434,0,0,1-2.549,1.078,3.4,3.4,0,0,1-2.5-1.029L3.029,9.794A3.4,3.4,0,0,1,2,7.294,3.343,3.343,0,0,1,3.042,4.806l1.8-1.789A3.384,3.384,0,0,1,7.331,2a3.357,3.357,0,0,1,2.5,1.042l2.525,2.537a3.384,3.384,0,0,1,1.017,2.488,3.448,3.448,0,0,1-1.078,2.561l1.078,1.078a3.551,3.551,0,0,1,5.049-.049l2.549,2.549A3.4,3.4,0,0,1,22,16.706Z"></path></svg>',
|
||||
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M15.6,7.2H14v1.5h1.6c2,0,3.7,1.7,3.7,3.7s-1.7,3.7-3.7,3.7H14v1.5h1.6c2.8,0,5.2-2.3,5.2-5.2,0-2.9-2.3-5.2-5.2-5.2zM4.7,12.4c0-2,1.7-3.7,3.7-3.7H10V7.2H8.4c-2.9,0-5.2,2.3-5.2,5.2,0,2.9,2.3,5.2,5.2,5.2H10v-1.5H8.4c-2,0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z"></path></svg>',
|
||||
),
|
||||
'codepen' => array(
|
||||
'name' => 'CodePen',
|
||||
@@ -208,7 +208,7 @@ function block_core_social_link_services( $service = '', $field = '' ) {
|
||||
),
|
||||
'mail' => array(
|
||||
'name' => 'Mail',
|
||||
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M20,4H4C2.895,4,2,4.895,2,6v12c0,1.105,0.895,2,2,2h16c1.105,0,2-0.895,2-2V6C22,4.895,21.105,4,20,4z M20,8.236l-8,4.882 L4,8.236V6h16V8.236z"></path></svg>',
|
||||
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19,5H5c-1.1,0-2,.9-2,2v10c0,1.1.9,2,2,2h14c1.1,0,2-.9,2-2V7c0-1.1-.9-2-2-2zm.5,12c0,.3-.2.5-.5.5H5c-.3,0-.5-.2-.5-.5V9.8l7.5,5.6,7.5-5.6V17zm0-9.1L12,13.6,4.5,7.9V7c0-.3.2-.5.5-.5h14c.3,0,.5.2.5.5v.9z"></path></svg>',
|
||||
),
|
||||
'mastodon' => array(
|
||||
'name' => 'Mastodon',
|
||||
@@ -337,3 +337,24 @@ function block_core_social_link_get_color_styles( $context ) {
|
||||
|
||||
return implode( '', $styles );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns CSS classes for icon and icon background colors.
|
||||
*
|
||||
* @param array $context Block context passed to Social Sharing Link.
|
||||
*
|
||||
* @return string CSS classes for link's icon and background colors.
|
||||
*/
|
||||
function block_core_social_link_get_color_classes( $context ) {
|
||||
$classes = array();
|
||||
|
||||
if ( array_key_exists( 'iconColor', $context ) ) {
|
||||
$classes[] = 'has-' . $context['iconColor'] . '-color';
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'iconBackgroundColor', $context ) ) {
|
||||
$classes[] = 'has-' . $context['iconBackgroundColor'] . '-background-color';
|
||||
}
|
||||
|
||||
return ' ' . implode( ' ', $classes );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user