I'm getting two errors with wp-debug

In the settings panel of my plugin I have a check-box to set defaults upon reactivation of the plugin. I'm get two errors in the settings panel with WP_Debug set to true.

Notice: Undefined index: chkbox1 in /home/hdomains39/public_html/hyper.domains/wp-content/plugins/wptld/wptld.php on line 84

Notice: Undefined variable: checked in /home/hdomains39/public_html/hyper.domains/wp-content/plugins/wptld/wptld.php on line 85

Here are the two lines of code.

line -84  if($options['chkbox1']) { $checked = ' checked="checked" '; }
line -85	  echo "<input ".$checked." id='setting_chk1_wptld' name='wptld_options[chkbox1]' type='checkbox' />";

I have played around with it to find a fix but I thought I would turn to the pros. :slight_smile:

  • Vinod Dalvi

    Hi Fla0,

    I hope you are well today and thanks for posting on the forum.

    These are simple PHP notices and most of the time it doesn't affect functionality of site so it is nothing to worry about!

    These are displaying because you have set the wp debug to true so just set it to false.

    This will hide the warning messages and you will be able to use your site normally.

    You can also fix these notices by making sure the variables are declared before using it and using the following code replacing your shared code respectively.

    if(isset($options['chkbox1']) && $options['chkbox1']) { $checked = ' checked="checked" '; }
    echo "<input ".@$checked." id='setting_chk1_wptld' name='wptld_options[chkbox1]' type='checkbox' />";

    Best Regards,
    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.