16 $site_title = get_bloginfo( 'name' ); |
18 $site_title = get_bloginfo( 'name' ); |
17 if ( ! $site_title ) { |
19 if ( ! $site_title ) { |
18 return; |
20 return; |
19 } |
21 } |
20 |
22 |
21 $tag_name = 'h1'; |
23 $tag_name = 'h1'; |
22 $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; |
24 $classes = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; |
23 |
25 if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { |
24 $aria_current = is_home() || ( is_front_page() && 'page' === get_option( 'show_on_front' ) ) ? ' aria-current="page"' : ''; |
26 $classes .= ' has-link-color'; |
|
27 } |
25 |
28 |
26 if ( isset( $attributes['level'] ) ) { |
29 if ( isset( $attributes['level'] ) ) { |
27 $tag_name = 0 === $attributes['level'] ? 'p' : 'h' . (int) $attributes['level']; |
30 $tag_name = 0 === $attributes['level'] ? 'p' : 'h' . (int) $attributes['level']; |
28 } |
31 } |
29 |
32 |
30 if ( $attributes['isLink'] ) { |
33 if ( $attributes['isLink'] ) { |
31 $link_attrs = array( |
34 $aria_current = is_home() || ( is_front_page() && 'page' === get_option( 'show_on_front' ) ) ? ' aria-current="page"' : ''; |
32 'href="' . esc_url( get_bloginfo( 'url' ) ) . '"', |
35 $link_target = ! empty( $attributes['linkTarget'] ) ? $attributes['linkTarget'] : '_self'; |
33 'rel="' . esc_attr( 'home' ) . '"', |
36 |
|
37 $site_title = sprintf( |
|
38 '<a href="%1$s" target="%2$s" rel="home"%3$s>%4$s</a>', |
|
39 esc_url( home_url() ), |
|
40 esc_attr( $link_target ), |
34 $aria_current, |
41 $aria_current, |
|
42 esc_html( $site_title ) |
35 ); |
43 ); |
36 if ( '_blank' === $attributes['linkTarget'] ) { |
|
37 $link_attrs[] = 'target="_blank"'; |
|
38 } |
|
39 $site_title = sprintf( '<a %1$s>%2$s</a>', implode( ' ', $link_attrs ), esc_html( $site_title ) ); |
|
40 } |
44 } |
41 $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); |
45 $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => trim( $classes ) ) ); |
42 |
46 |
43 return sprintf( |
47 return sprintf( |
44 '<%1$s %2$s>%3$s</%1$s>', |
48 '<%1$s %2$s>%3$s</%1$s>', |
45 $tag_name, |
49 $tag_name, |
46 $wrapper_attributes, |
50 $wrapper_attributes, |