wp/wp-includes/blocks/comment-edit-link.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
     5  * @package WordPress
     5  * @package WordPress
     6  */
     6  */
     7 
     7 
     8 /**
     8 /**
     9  * Renders the `core/comment-edit-link` block on the server.
     9  * Renders the `core/comment-edit-link` block on the server.
       
    10  *
       
    11  * @since 6.0.0
    10  *
    12  *
    11  * @param array    $attributes Block attributes.
    13  * @param array    $attributes Block attributes.
    12  * @param string   $content    Block default content.
    14  * @param string   $content    Block default content.
    13  * @param WP_Block $block      Block instance.
    15  * @param WP_Block $block      Block instance.
    14  *
    16  *
    25 
    27 
    26 	if ( ! empty( $attributes['linkTarget'] ) ) {
    28 	if ( ! empty( $attributes['linkTarget'] ) ) {
    27 		$link_atts .= sprintf( 'target="%s"', esc_attr( $attributes['linkTarget'] ) );
    29 		$link_atts .= sprintf( 'target="%s"', esc_attr( $attributes['linkTarget'] ) );
    28 	}
    30 	}
    29 
    31 
    30 	$classes = '';
    32 	$classes = array();
    31 	if ( isset( $attributes['textAlign'] ) ) {
    33 	if ( isset( $attributes['textAlign'] ) ) {
    32 		$classes .= 'has-text-align-' . $attributes['textAlign'];
    34 		$classes[] = 'has-text-align-' . $attributes['textAlign'];
       
    35 	}
       
    36 	if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
       
    37 		$classes[] = 'has-link-color';
    33 	}
    38 	}
    34 
    39 
    35 	$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
    40 	$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
    36 
    41 
    37 	return sprintf(
    42 	return sprintf(
    38 		'<div %1$s><a href="%2$s" %3$s>%4$s</a></div>',
    43 		'<div %1$s><a href="%2$s" %3$s>%4$s</a></div>',
    39 		$wrapper_attributes,
    44 		$wrapper_attributes,
    40 		esc_url( $edit_comment_link ),
    45 		esc_url( $edit_comment_link ),
    43 	);
    48 	);
    44 }
    49 }
    45 
    50 
    46 /**
    51 /**
    47  * Registers the `core/comment-edit-link` block on the server.
    52  * Registers the `core/comment-edit-link` block on the server.
       
    53  *
       
    54  * @since 6.0.0
    48  */
    55  */
    49 function register_block_core_comment_edit_link() {
    56 function register_block_core_comment_edit_link() {
    50 	register_block_type_from_metadata(
    57 	register_block_type_from_metadata(
    51 		__DIR__ . '/comment-edit-link',
    58 		__DIR__ . '/comment-edit-link',
    52 		array(
    59 		array(