[wp-hackers] Saving Radio Options in Plugin Menu

Otto otto at ottodestruct.com
Sat Nov 23 11:19:56 UTC 2013


No matter how you slice it, this is wrong:

 printf(
'<input id="%s" type="radio" name="ams_options[%s]"
value="voteThumbs">voteThumbs', 'ams_choose_comment_buttons', checked(
'voteThumbs' == $buttonStyle ));

You appear to be using the "checked" function to output something that
determines the name, and are also giving all the input boxes the same ID,
which definitely won't work.

Also, yes, they are user input and must be validated/sanitized.


-Otto


On Sat, Nov 23, 2013 at 5:07 AM, BenderisGreat <greglancaster71 at gmail.com>wrote:

> Here is the code, when I select an option, nothing saved.  var_dump on
> $buttonStyle gives me a boolean false.   Feel like I am missing something
> here.  How exactly should the input be saved?  Do I need to validate or
> sanitize the input of a radio button?  Seems that I wouldnt need to since
> its not really user input.
>
>         public function ams_choose_comment_buttons_setting() //checkbox
> input
>         {
>         $buttonStyle = get_option('ams_choose_comment_buttons');
>         var_dump($buttonStyle);
>
>         printf(
> '<input id="%s" type="radio" name="ams_options[%s]"
> value="voteThumbs">voteThumbs', 'ams_choose_comment_buttons', checked(
> 'voteThumbs' == $buttonStyle ));
> printf(
> '<input id="%s" type="radio" name="ams_options[%s]"
> value="voteTextLinks">voteTextLinks', 'ams_choose_comment_buttons',
> checked(
> 'voteTextLinks' == $buttonStyle ));
> printf(
> '<input id="%s" type="radio" name="ams_options[%s]"
> value="voteThumbCount">voteThumbCount', 'ams_choose_comment_buttons',
> checked( "voteThumbCount" == $buttonStyle ));
> printf(
> '<input id="%s" type="radio" name="ams_options[%s]"
> value="voteChevrons">voteChevrons', 'ams_choose_comment_buttons', checked(
> "voteChevrons" == $buttonStyle ));
> printf(
> '<input id="%s" type="radio" name="ams_options[%s]"
> value="votePlusMinus">votePlusMinus', 'ams_choose_comment_buttons',
> checked(
> "votePlusMinus" == $buttonStyle ));
> printf(
> '<input id="%s" type="radio" name="ams_options[%s]"
> value="voteLikeDislike">voteLikeDislike', 'ams_choose_comment_buttons',
> checked( "voteLikeDislike" == $buttonStyle ));
>
>
>
>         }
>
>
>
>
> --
> View this message in context:
> http://wordpress-hackers.1065353.n5.nabble.com/Saving-Radio-Options-in-Plugin-Menu-tp42904.html
> Sent from the Wordpress Hackers mailing list archive at Nabble.com.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list