I'm making a school project where I need to make a WordPress widget. It can change my state of employment and display it. I can't seem to find where the problem lies. The value isn't saved, nor does it change when I hit "save" in the widget menu.
public function __construct()
{
$widget_ops = array(
'classname' => 'my_widget',
'desciption' => 'state of employment widget',
);
parent::__construct('my_widget', 'My Widget', $widget_ops);
}
public function widget( $args, $instance )
{
?>
<p>My state of employment is :
<?php
if ($isEmployed ) {
echo "Employed";
} else if ( !$isEmployed ) {
echo "Unemployed";
}
?><p>
<?php
}
public function form( $instance )
{
?>
<div style="max-height: 120px; overflow: auto;">
<ul>
<li><input type="radio" name="Employment" value="Employed" <?php checked($isEmployed ) ?> > Employed</li>
<li><input type="radio" name="Employment" value="Unemployed" <?php checked(!$isEmployed ) ?> > Unemployed</li>
</ul>
</div>
<?php
}
// save options
public function update( $new_instance, $old_instance )
{
$reply = $_POST["Employment"];
if ($reply = "Employed") {
$isEmployed = true;
} elseif ($reply = "Unemployed"){
$isEmployed = false;
}
}
}
?>