Skip to content

Commit

Permalink
Add classes and styles to the front end rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Copons committed Nov 1, 2019
1 parent a8207d3 commit c785ac7
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions packages/block-library/src/site-description/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,51 @@
*
* @return string The render.
*/
function render_block_core_site_description() {
return sprintf( '<p>%s</p>', get_bloginfo( 'description' ) );
function render_block_core_site_description( $attributes ) {
$styles = '';

$class = 'wp-block-site-description';
if ( isset( $attributes['className'] ) ) {
$class .= ' ' . $attributes['className'];
}

if ( isset( $attributes['align'] ) ) {
$class .= ' align' . $attributes['align'];
}

if ( isset( $attributes['textAlign'] ) ) {
$class .= ' has-text-align-' . $attributes['textAlign'];
}

if ( isset( $attributes['textColor'] ) ) {
$class .= ' has-text-color';
$class .= ' has-' . $attributes['textColor'] . '-color';
} elseif ( isset( $attributes['customTextColor'] ) ) {
$class .= ' has-text-color';
$styles .= ' color: ' . $attributes['customTextColor'] . ';';
}

if ( isset( $attributes['backgroundColor'] ) ) {
$class .= ' has-background';
$class .= ' has-' . $attributes['backgroundColor'] . '-background-color';
} elseif ( isset( $attributes['customBackgroundColor'] ) ) {
$class .= ' has-background';
$styles .= ' background-color: ' . $attributes['customBackgroundColor'] . ';';
}

if ( isset( $attributes['fontSize'] ) ) {
$class .= ' has-' . $attributes['fontSize'] . '-font-size';
} elseif ( isset( $attributes['customFontSize'] ) ) {
$styles .= ' font-size: ' . $attributes['customFontSize'] . 'px;';
}

ob_start();
?>
<p class="<?php echo esc_attr( $class ); ?>" style="<?php echo esc_attr( $styles ); ?>">
<?php bloginfo( 'description' ); ?>
</p>
<?php
return ob_get_clean();
}

/**
Expand Down

0 comments on commit c785ac7

Please sign in to comment.