Wordpress - WordPress Settings and Configuration
You want to save a user preference 'font_size' only if it is a positive integer. Which code snippet correctly updates the setting safely?
$size = intval($_POST['font_size']);
if ($size > 0) {
update_option('font_size', $size);
} uses intval to convert input to integer and checks if it is positive before saving.update_option, preventing invalid data.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions