-
Notifications
You must be signed in to change notification settings - Fork 14
Add sanitize_callback to validate palette checkbox input #290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
| 'default' => false, | ||
| 'sanitize_callback' => function( $input ) { | ||
| // Accept only true, 'on', or 1 | ||
| if ( $input === 'on' || $input === true || $input === 1 || $input === '1' ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for raising this fix @aditigodse10
I found an issue, that when you try to save the settings with the checkbox unchecked, the Invalid value for Most Used Palette setting. error is shown on top of the page. This is because $input is null when it is unchecked. Can you fix that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sure, will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aditigodse10 checking in to see if you'll be able to updated based on the code review feedback above?
|
@peterwilsoncc will probably need your help in getting this finished off/reviewed/merged |
This PR adds a sanitize_callback to the
tenup_isc_most_read_paletteoption to validate input before saving.✅ Accepts only true, 'on', 1, or '1'
❌ Rejects all invalid values
🛡️ Shows an admin error using
add_settings_error()when input is incorrectThis ensures secure, expected handling of the checkbox setting and follows WordPress sanitization best practices.