| 1 |
<?php |
| 2 |
$prefix = 'bBlocksShapeDivider'; |
| 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( 'bBlocksShapeDividerStyle' ) ) { |
| 10 |
function bBlocksShapeDividerStyle( $attributes, $id, $prefix){ |
| 11 |
extract( $attributes ); |
| 12 |
|
| 13 |
$mainSl = "#$id"; |
| 14 |
|
| 15 |
$transform = 'top' === $shapePosition ? '0deg' : '180deg'; |
| 16 |
|
| 17 |
$shapeDividerStyle = new BBlocksStyleGenerator(); |
| 18 |
$shapeDividerStyle::addStyle( "$mainSl", [ |
| 19 |
'min-height' => $height['desktop'], |
| 20 |
GetCSS::getBackgroundCSS( $background ) => '', |
| 21 |
'padding' => implode(' ', $padding) |
| 22 |
] ); |
| 23 |
$shapeDividerStyle::addStyle( "$mainSl svg", [ |
| 24 |
'width' => "calc($shapeWidth% + 1.3px)", |
| 25 |
'height' => $shapeHeight['desktop'], |
| 26 |
'fill' => $shapeColor, |
| 27 |
'top' => 'top' === $shapePosition ? '0' : 'auto', |
| 28 |
'bottom' => 'bottom' === $shapePosition ? '0' : 'auto', |
| 29 |
'transform' => "rotate( $transform )" |
| 30 |
] ); |
| 31 |
|
| 32 |
return $shapeDividerStyle::renderStyle(); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
if( !function_exists( 'bBlocksShapePath' ) ){ |
| 37 |
function bBlocksShapePath( $shape ){ |
| 38 |
$path = ''; |
| 39 |
|
| 40 |
if( 'curve' === $shape ){ |
| 41 |
$path = "<path d='M0,0V7.23C0,65.52,268.63,112.77,600,112.77S1200,65.52,1200,7.23V0Z' />"; |
| 42 |
} |
| 43 |
else if( 'tilt' === $shape ){ |
| 44 |
$path = "<path d='M1200 120L0 16.48 0 0 1200 0 1200 120z' />"; |
| 45 |
} |
| 46 |
else if( 'curve-acymmetrical' === $shape ){ |
| 47 |
$path = "<path d='M0,0V6c0,21.6,291,111.46,741,110.26,445.39,3.6,459-88.3,459-110.26V0Z' />"; |
| 48 |
} |
| 49 |
else if( 'waves' === $shape ){ |
| 50 |
$path = "<path d='M321.39,56.44c58-10.79,114.16-30.13,172-41.86,82.39-16.72,168.19-17.73,250.45-.39C823.78,31,906.67,72,985.66,92.83c70.05,18.48,146.53,26.09,214.34,3V0H0V27.35A600.21,600.21,0,0,0,321.39,56.44Z' />"; |
| 51 |
} |
| 52 |
else if( 'waves-opacity' === $shape ){ |
| 53 |
$path = "<path d='M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.84,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z' opacity='.25' /> |
| 54 |
<path d='M0,0V15.81C13,36.92,27.64,56.86,47.69,72.05,99.41,111.27,165,111,224.58,91.58c31.15-10.15,60.09-26.07,89.67-39.8,40.92-19,84.73-46,130.83-49.67,36.26-2.85,70.9,9.42,98.6,31.56,31.77,25.39,62.32,62,103.63,73,40.44,10.79,81.35-6.69,119.13-24.28s75.16-39,116.92-43.05c59.73-5.85,113.28,22.88,168.9,38.84,30.2,8.66,59,6.17,87.09-7.5,22.43-10.89,48-26.93,60.65-49.24V0Z' opacity='.5' /> |
| 55 |
<path d='M0,0V5.63C149.93,59,314.09,71.32,475.83,42.57c43-7.64,84.23-20.12,127.61-26.46,59-8.63,112.48,12.24,165.56,35.4C827.93,77.22,886,95.24,951.2,90c86.53-7,172.46-45.71,248.8-84.81V0Z' />"; |
| 56 |
}else{ |
| 57 |
$path = "<path d='M0,0V7.23C0,65.52,268.63,112.77,600,112.77S1200,65.52,1200,7.23V0Z' />"; |
| 58 |
} |
| 59 |
|
| 60 |
return $path; |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
extract( $attributes ); |
| 65 |
?> |
| 66 |
<div |
| 67 |
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- get_block_wrapper_attributes() is properly escaped ?> |
| 68 |
<?php echo get_block_wrapper_attributes( [ 'class' => "$planClass align$align" ] ); ?> |
| 69 |
id='<?php echo esc_attr( $id ); ?>' |
| 70 |
> |
| 71 |
<style> |
| 72 |
<?php echo esc_html( bBlocksShapeDividerStyle( $attributes, $id, $prefix ) ); ?> |
| 73 |
</style> |
| 74 |
|
| 75 |
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 120' preserveAspectRatio='none'> |
| 76 |
<?php echo wp_kses( bBlocksShapePath( $shape ), ['path' => [ 'd' => [], 'opacity' => [] ] ] ); ?> |
| 77 |
</svg> |
| 78 |
<div class='shapeContent'> |
| 79 |
<?php echo wp_kses( $content, wp_parse_args( wp_kses_allowed_html('post'), ['style'=>[]] ) ); ?> |
| 80 |
</div> |
| 81 |
</div> |