Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 27
0.00% covered (danger)
0.00%
0 / 1
CRAP
n/a
0 / 0
Automattic\Jetpack\Jetpack_Mu_Wpcom\Wpcom_Legacy_FSE\render_site_title_block
0.00% covered (danger)
0.00%
0 / 27
0.00% covered (danger)
0.00%
0 / 1
90
1<?php
2/**
3 * Render site title block.
4 *
5 * @package automattic/jetpack-mu-wpcom
6 */
7
8namespace Automattic\Jetpack\Jetpack_Mu_Wpcom\Wpcom_Legacy_FSE;
9
10use Automattic\Jetpack\Jetpack_Mu_Wpcom\Common;
11
12/**
13 * Renders the site title and allows for editing in the full site editor.
14 *
15 * @param array $attributes Block attributes.
16 * @return string
17 */
18function render_site_title_block( $attributes ) {
19    Common\wpcom_record_tracks_event( 'wpcom_legacy_fse_render_block', array( 'block_name' => 'a8c/site-title' ) );
20
21    ob_start();
22
23    $styles = '';
24
25    $class = 'site-title wp-block-a8c-site-title';
26    if ( isset( $attributes['className'] ) ) {
27        $class .= ' ' . $attributes['className'];
28    }
29
30    $align = ' alignwide';
31    if ( isset( $attributes['align'] ) ) {
32        $align = empty( $attributes['align'] ) ? '' : ' align' . $attributes['align'];
33    }
34    $class .= $align;
35
36    if ( isset( $attributes['textAlign'] ) ) {
37        $class .= ' has-text-align-' . $attributes['textAlign'];
38    } else {
39        $class .= ' has-text-align-center';
40    }
41
42    if ( isset( $attributes['textColor'] ) ) {
43        $class .= ' has-text-color';
44        $class .= ' has-' . $attributes['textColor'] . '-color';
45    } elseif ( isset( $attributes['customTextColor'] ) ) {
46        $class  .= ' has-text-color';
47        $styles .= ' color: ' . $attributes['customTextColor'] . ';';
48    }
49
50    if ( isset( $attributes['fontSize'] ) ) {
51        $class .= ' has-' . $attributes['fontSize'] . '-font-size';
52    } elseif ( isset( $attributes['customFontSize'] ) ) {
53        $styles .= ' font-size: ' . $attributes['customFontSize'] . 'px;';
54    } else {
55        $class .= ' has-normal-font-size';
56    }
57
58    ?>
59    <h1 class="<?php echo esc_attr( $class ); ?>" style="<?php echo esc_attr( $styles ); ?>">
60        <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a>
61    </h1>
62    <!-- a8c:site-title -->
63    <?php
64    return ob_get_clean();
65}
66