In the Public Function Update
this code is sitting →
`public function update($new_instance, $old_instance) $instance['description_box'] = $new_instance['description_box'];
In the public function widget, this code is sitting →
public function widget($args, $instance) { $description_box = $instance[ 'description_box' ] ? 'true' : 'false';
In the public function→
public function form( $instance ) {
This code is sitting →
<p> <input class="checkbox" type="checkbox" <?php checked( $instance[ 'description_box' ], 'on' ); ?> id="<?php echo $this->get_field_id( 'description_box' ); ?>" name="<?php echo $this->get_field_name( 'description_box' ); ?>" /> <label for="<?php echo $this->get_field_id( 'description_box' ); ?>">Check whether to display description or not</label> </p>
Now what i want is when the condition is true i.e. the box is checked then execute some code.
If ($description_box is true) {
<p>some text</p>
}
How to correctly write this using this →https://codex.wordpress.org/Function_Reference/checked
Update →
I tried using this →
<?php if($description_box==0){ ?>
<p><</p>
<?php } ?>
But the problem is if the widget is in 2 different sidebars, in one checkbox ticked and in another not, but the result is same in both i.e. it either displays <p></p>
or not based on the either $description_box
is set to 0/1 or true/false in the php
if condition
. whats the remedy?
<p></p>
or not at the same time, but the truth is that in one widget-sidebar arrangement we have opted to check the check box, and in another we didn't. Did you get my Point now?$description_check_box
variable, before you compare it? This is the behaviour you'd see if that variable wasn't set.