I've created a custom element for the WPBakery plugin. I have mapped out a simple checkbox for this element:
array(
'type' => 'checkbox',
'heading' => esc_html__( 'Add box shadow?', 'js_composer' ),
'param_name' => 'add_boxShadow',
'value' => array('Yes' => 'true'),
'std' => false,
'description' => esc_html__('Ticking this will add a shadow below the row.'),
'group' => __( 'Custom', 'my-text-domain' ),
)
And I have initialised it like so:
$output = "";
extract(
shortcode_atts(
array(
'add_boxShadow' => false,
// 'add_boxShadow' => '', have also tried this
),
$atts
)
);
And outputting like this:
<?php
$shadowBottom = "";
($add_boxShadow = true ? $shadowBottom = "shadow__bottom" : "");
$output .= '<div class="wrapper'.$shadowBottom.' "> test </div>';
return $output;
?>
With the above, I'm having the following issues:
A
var_dump($add_boxShadow)
returnsbool(false) bool(false)
. My guess that's because when the var is initialised, the $add_boxShadow is set to false ('add_boxShadow' => false
). However, I've done this so that the checkbox is unticked my default.In the WPBakery page builder, this is how the field looks:
Which is good, it's unchecked by default which is what I want. However, if I then tick the checkbox, save and update the page, when I go back to that blocks setting, the checkbox is still unticked. Almost as if it's always being rendered false?