Undefined index.., Undefined offset.. warnings with WP_DEBUG
-
Here my contribution to your helpful plugin.
With
define('WP_DEBUG', true);
inwp-config.php
some PHP warnings can be observed in a WordPress 3.4.2 and 3.5.1 admin backend, especially in combination with WPML plugin and its language switcher widget.1. Warning on top of page
/wp-admin/widgets.php
:Notice: Undefined index: icl_lang_sel_widget in ..wp-content/plugins/widget-logic/widget_logic.php on line 116
Line 116, old:
if (!$wp_registered_widget_controls[$id])
Line 116, quick fix:
if (!isset($wp_registered_widget_controls[$id]))
2. Warning when clicking the dropdown “open” button at WPML language switcher widget:
Notice: Undefined offset: 0 in ..wp-content/plugins/widget-logic/widget_logic.php on line 233
Line 233, old:
$number=$params[0]['number']; if ($number==-1) {$number="__i__"; $value="";} $id_disp=$id;
Line 233, quick fix:
if (!empty($params)) { $number=$params[0]['number']; if ($number==-1) {$number="__i__"; $value="";} } $id_disp=$id;
Warnings like these are pretty annoying during development where
WP_DEBUG
is required as they also break unrelated ajax-responses within admin-backend.Note: WPML plugin seems to be available for free for plugin-authors with compatibility issues, more here: https://wpml.org/documentation/theme-compatibility/go-global-program/
- The topic ‘Undefined index.., Undefined offset.. warnings with WP_DEBUG’ is closed to new replies.