| 1 |
<?php |
| 2 |
$prefix = 'bBlocksSectionHeading'; |
| 3 |
$id = wp_unique_id( "$prefix-" ); |
| 4 |
$planClass = BBlocks\Inc\Utils::isPro() ? 'pro' : 'free'; |
| 5 |
|
| 6 |
use BBlocks\Inc\GetCSS as GetCSS; |
| 7 |
|
| 8 |
// Generate Styles |
| 9 |
if( !function_exists( 'bBlocksSectionHeadingStyle' ) ) { |
| 10 |
function bBlocksSectionHeadingStyle($attributes, $id, $prefix){ |
| 11 |
extract( $attributes ); |
| 12 |
|
| 13 |
$headingSl = "#$id .$prefix"; |
| 14 |
|
| 15 |
$sectionHeadingStyle = new BBlocksStyleGenerator(); |
| 16 |
$sectionHeadingStyle::addStyle( "$headingSl", [ |
| 17 |
'text-align' => $textAlign |
| 18 |
] ); |
| 19 |
$sectionHeadingStyle::addStyle( "$headingSl .sectionHeadingTitle", [ |
| 20 |
'color' => $titleColor, |
| 21 |
'margin' => GetCSS::getSpaceCSS( $titleMargin ) |
| 22 |
] ); |
| 23 |
$sectionHeadingStyle::addStyle( "$headingSl .sectionHeadingSeparator", [ |
| 24 |
GetCSS::getSeparatorCSS( $separator ) => '', |
| 25 |
'margin' => GetCSS::getSpaceCSS( $sepMargin ) |
| 26 |
] ); |
| 27 |
$sectionHeadingStyle::addStyle( "$headingSl .sectionHeadingDescription", [ |
| 28 |
'color' => $descColor, |
| 29 |
'margin' => GetCSS::getSpaceCSS( $descMargin ) |
| 30 |
] ); |
| 31 |
|
| 32 |
return GetCSS::getTypoCSS( '', $titleTypo )['googleFontLink'] . |
| 33 |
GetCSS::getTypoCSS( '', $descTypo )['googleFontLink'] . |
| 34 |
GetCSS::getTypoCSS( "$headingSl .sectionHeadingTitle", $titleTypo )['styles'] . |
| 35 |
GetCSS::getTypoCSS( "$headingSl .sectionHeadingDescription", $descTypo )['styles'] . |
| 36 |
$sectionHeadingStyle::renderStyle(); |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
extract( $attributes ); |
| 41 |
?> |
| 42 |
<div |
| 43 |
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_block_wrapper_attributes() is properly escaped ?> |
| 44 |
<?php echo get_block_wrapper_attributes( [ 'class' => $planClass ] ); ?> |
| 45 |
id='<?php echo esc_attr( $id ); ?>' |
| 46 |
> |
| 47 |
<style> |
| 48 |
<?php echo esc_html( bBlocksSectionHeadingStyle( $attributes, $id, $prefix ) ); ?> |
| 49 |
</style> |
| 50 |
|
| 51 |
<div class='bBlocksSectionHeading'> |
| 52 |
<h2 class='sectionHeadingTitle'><?php echo wp_kses_post( $title ); ?></h2> |
| 53 |
<?php echo $isSep ? "<span class='sectionHeadingSeparator'></span>" : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static markup, no user input. ?> |
| 54 |
<?php echo $isDesc ? "<p class='sectionHeadingDescription'>". wp_kses_post( $desc ) ."</p>" : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static wrapper tags with wp_kses_post-escaped content. ?> |
| 55 |
</div> |
| 56 |
</div> |