How to read if a checkbox is checked in PHP?
Wordpress have the checked()
function.
Reference: https://developer.wordpress.org/reference/functions/checked/
checked( mixed $checked, mixed $current = true, bool $echo = true )
Description Compares the first two arguments and if identical marks as checked
Parameters $checked (mixed) (Required) One of the values to compare
$current (mixed) (Optional) (true) The other value to compare if not just true Default value: true
$echo (bool) (Optional) Whether to echo or just return the string Default value: true
Return #Return (string) html attribute or empty string