Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 35
0.00% covered (danger)
0.00%
0 / 1
CRAP
n/a
0 / 0
Automattic\Jetpack\Jetpack_Mu_Wpcom\Wpcom_Legacy_FSE\render_site_description_block
0.00% covered (danger)
0.00%
0 / 35
0.00% covered (danger)
0.00%
0 / 1
132
1<?php
2/**
3 * Render site description file.
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 description (tagline) block.
14 *
15 * @param array $attributes Block attributes.
16 * @return string
17 */
18function render_site_description_block( $attributes ) {
19    Common\wpcom_record_tracks_event( 'wpcom_legacy_fse_render_block', array( 'block_name' => 'a8c/site-description' ) );
20
21    ob_start();
22
23    $styles = '';
24
25    $class = 'site-description wp-block-a8c-site-description';
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['backgroundColor'] ) ) {
51        $class .= ' has-background';
52        $class .= ' has-' . $attributes['backgroundColor'] . '-background-color';
53    } elseif ( isset( $attributes['customBackgroundColor'] ) ) {
54        $class  .= ' has-background';
55        $styles .= ' background-color: ' . $attributes['customBackgroundColor'] . ';';
56    }
57
58    if ( isset( $attributes['fontSize'] ) ) {
59        $class .= ' has-' . $attributes['fontSize'] . '-font-size';
60    } elseif ( isset( $attributes['customFontSize'] ) ) {
61        $styles .= ' font-size: ' . $attributes['customFontSize'] . 'px;';
62    } else {
63        $class .= ' has-small-font-size';
64    }
65
66    ?>
67    <p class="<?php echo esc_attr( $class ); ?>" style="<?php echo esc_attr( $styles ); ?>">
68        <?php bloginfo( 'description' ); ?>
69    </p>
70    <?php
71    return ob_get_clean();
72}