PHP Warning: Undefined array key “value” in lib-widget-fields.php
-
Title: PHP Warning: Undefined array key “value” in
lib-widget-fields.php(checkbox widget field)Plugin version: 8.8.7
Environment:
- PHP 8.3 (CloudLinux Alt-PHP)
- WordPress (latest)
Description:
The
checkbox()method inincludes/widgets/lib-widget-fields.php(line 85) reads$field['value']directly without checking whether the key exists:php
protected static function checkbox( $id, $name, $value, $label, $options, $field ) { ?> <input type="checkbox" ... value="<?php echo esc_attr( $field['value'] ); ?>" <?php checked( $value, $field['value'] ); ?> />However, several built-in widgets define checkbox-type fields without setting a
'value'key, e.g.:includes/widgets/popular-listings.phpincludes/widgets/submit-listing.phpincludes/widgets/login-form.phpincludes/widgets/featured-listing.phpincludes/widgets/all-locations.php
Whenever one of these widgets is rendered in the WordPress admin (widget editor / Customizer), it throws:
PHP Warning: Undefined array key "value" in .../includes/widgets/lib-widget-fields.php on line 85This occurred 40 times in our error log over roughly a week of normal admin usage.
The page I need help with: [log in to see the link]
You must be logged in to reply to this topic.