Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audit/KAD-4008 #646

Merged
merged 10 commits into from
Jan 20, 2025
11 changes: 6 additions & 5 deletions includes/blocks/class-kadence-blocks-infobox-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,20 +344,21 @@ public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
$css->add_property( 'border-color', $css->render_color( $media_style['border'] ) );
}
if ( isset( $media_style['borderRadius'] ) && ! empty( $media_style['borderRadius'] ) ) {
$css->add_property( 'border-radius', $media_style['borderRadius'] . 'px' );
$css->add_property( 'border-radius', $media_style['borderRadius'] . ( isset( $media_style['borderRadiusUnit'] ) ? $media_style['borderRadiusUnit'] : 'px' ) );
}
if ( isset( $media_style['borderWidth'] ) && is_array( $media_style['borderWidth'] ) ) {
$border_width_unit = isset( $media_style['borderWidthUnit'] ) ? $media_style['borderWidthUnit'] : 'px';
if ( isset( $media_style['borderWidth'][0] ) && is_numeric( $media_style['borderWidth'][0] ) ) {
$css->add_property( 'border-top-width', $media_style['borderWidth'][0] . 'px' );
$css->add_property( 'border-top-width', $media_style['borderWidth'][0] . $border_width_unit );
}
if ( isset( $media_style['borderWidth'][1] ) && is_numeric( $media_style['borderWidth'][1] ) ) {
$css->add_property( 'border-right-width', $media_style['borderWidth'][1] . 'px' );
$css->add_property( 'border-right-width', $media_style['borderWidth'][1] . $border_width_unit );
}
if ( isset( $media_style['borderWidth'][2] ) && is_numeric( $media_style['borderWidth'][2] ) ) {
$css->add_property( 'border-bottom-width', $media_style['borderWidth'][2] . 'px' );
$css->add_property( 'border-bottom-width', $media_style['borderWidth'][2] . $border_width_unit );
}
if ( isset( $media_style['borderWidth'][3] ) && is_numeric( $media_style['borderWidth'][3] ) ) {
$css->add_property( 'border-left-width', $media_style['borderWidth'][3] . 'px' );
$css->add_property( 'border-left-width', $media_style['borderWidth'][3] . $border_width_unit );
}
}
$padding_unit = isset( $media_style['paddingUnit'] ) ? $media_style['paddingUnit'] : 'px';
Expand Down
2 changes: 2 additions & 0 deletions src/blocks/infobox/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@
"border": "",
"hoverBorder": "",
"borderRadius": 0,
"borderRadiusUnit": "px",
"borderWidth": [0, 0, 0, 0],
"borderWidthUnit": "px",
"padding": [10, 10, 10, 10],
"paddingUnit": "px",
"margin": [0, 15, 0, 15],
Expand Down
45 changes: 34 additions & 11 deletions src/blocks/infobox/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2949,7 +2949,7 @@ function KadenceInfoBox(props) {
value={mediaIcon[0].width}
defaultValue={2}
onChange={(value) => saveMediaIcon({ width: value })}
step={0.5}
step={0.1}
min={0.5}
max={4}
reset={true}
Expand All @@ -2962,19 +2962,39 @@ function KadenceInfoBox(props) {
onChange={(value) => saveMediaStyle({ borderWidth: value })}
onControl={(value) => setMediaBorderControl(value)}
min={0}
max={40}
max={
mediaStyle[0].borderWidthUnit === 'px' ||
typeof mediaStyle[0].borderWidthUnit === 'undefined'
? 40
: 12
}
step={1}
reset={() => saveMediaStyle({ borderWidth: [0, 0, 0, 0] })}
reset={() =>
saveMediaStyle({ borderWidth: [0, 0, 0, 0], borderWidthUnit: 'px' })
}
showUnit={true}
unit={mediaStyle[0].borderWidthUnit ?? 'px'}
onUnit={(value) => saveMediaStyle({ borderWidthUnit: value })}
/>
<RangeControl
label={__('Icon Border Radius (px)', 'kadence-blocks')}
label={__('Icon Border Radius', 'kadence-blocks')}
value={mediaStyle[0].borderRadius}
defaultValue={0}
onChange={(value) => saveMediaStyle({ borderRadius: value })}
step={1}
min={0}
max={200}
reset={true}
max={
mediaStyle[0].borderRadiusUnit === 'px' ||
typeof mediaStyle[0].borderRadiusUnit === 'undefined'
? 200
: 12
}
reset={() =>
saveMediaStyle({ borderRadius: 0, borderRadiusUnit: 'px' })
}
showUnit={true}
unit={mediaStyle[0].borderRadiusUnit ?? 'px'}
onUnit={(value) => saveMediaStyle({ borderRadiusUnit: value })}
/>
<SelectControl
label={__('Icon Hover Animation', 'kadence-blocks')}
Expand Down Expand Up @@ -4116,16 +4136,19 @@ function KadenceInfoBox(props) {
style={{
borderColor: KadenceColorOutput(mediaStyle[0].border),
backgroundColor: KadenceColorOutput(mediaStyle[0].background),
borderRadius: mediaStyle[0].borderRadius + 'px',
borderRadius: mediaStyle[0].borderRadius + (mediaStyle[0].borderRadiusUnit ?? 'px'),
borderWidth: mediaStyle[0].borderWidth
? mediaStyle[0].borderWidth[0] +
'px ' +
(mediaStyle[0].borderWidthUnit ?? 'px') +
' ' +
mediaStyle[0].borderWidth[1] +
'px ' +
(mediaStyle[0].borderWidthUnit ?? 'px') +
' ' +
mediaStyle[0].borderWidth[2] +
'px ' +
(mediaStyle[0].borderWidthUnit ?? 'px') +
' ' +
mediaStyle[0].borderWidth[3] +
'px'
(mediaStyle[0].borderWidthUnit ?? 'px')
: '',
padding: mediaStyle[0].padding
? mediaStyle[0].padding[0] +
Expand Down
Loading