Context: This is my first widget and I am following along with an online tutorial. I am expecting the front-end of the widget to echo some content upon checking a check-box in the back-end form, but rather I am not seeing any content displayed.
Reference Material:
I have attempted to follow along with these two-part tutorials http://www.wpexplorer.com/create-widget-plugin-wordpress/ and http://www.wpexplorer.com/how-to-create-a-widget-plugin-for-wordpress-part-2/ .
My complete widget file is located here http://pastebin.com/nVTzxiTQ
screenshots:
Back-end looks like this after saving
Front-end looks like this after saving
Question: Why isn't the act of checking the check-box in the back-end UI resulting in the rendering of the string 'Checkbox is checked' on the front-end, as I expect it to?
$checkbox
variable isundefined
in yourwidget()
function. As you did -$text = $instance['text']; $textarea = $instance['textarea'];
do the same for$checkbox = $instance['checkbox']
too. – Shazzad Jan 15 '14 at 22:32$checkbox
variable was the cause of the problem. After defining it as suggested, the widget worked as I exepected. Thank you. – Daniel Dropik Jan 15 '14 at 23:36