Adding “old” widgets to sidebar triggers PHP warning
-
Widgets registered using
wp_register_sidebar_widget()triggers a PHP warning when they are added to a sidebar.The cause is in inc/widgets.php, in the
graphene_dynamic_sidebar_paramsfunction.It expects
$paramsto have 2 elements however in these widgets,$paramsonly has 1 elements so PHP complains about accessing the element at index 1.
This is easily fixable by moving the line$widget_number = $params[1]['number'];inside the if condition. Since you pass a function to wp_register_sidebar_widget(), the condition isn’t triggered for older widgets.Here’s a basic implementation of a older widget for testing: https://developer.wordpress.org/reference/functions/wp_register_sidebar_widget/
The topic ‘Adding “old” widgets to sidebar triggers PHP warning’ is closed to new replies.
