This widget prints Hello Widget and works with many versions of WordPress including 5.8.4, but with 5.9.1, 5.9.3 or 6.0.1 (all with classic-widgets 0.3 installed) it appears the widget()
method never even gets called. There are no traces of neither the method output nor the error_log()s. What would be required to port the widget over to never WordPress versions? It should be possible, right? WP_Widget does not mention anything about the API being deprecated, or even had any changes at all for quite a while.
<?php
class HelloWidget extends WP_Widget {
public function __construct() {
error_log("entering __construct()");
parent::__construct( 'hello-widget', __('Hello Widget'));
add_action(
'widgets_init',
function() {
register_widget('HelloWidget');
}
);
error_log("end of __construct()");
}
public function widget( $args, $instance ) {
error_log("entering widget()");
echo "Hello Widget";
error_log("end of widget()");
}
public function form( $instance ) {
error_log("form()");
}
public function update( $new_instance, $old_instance ) {
error_log("update()");
// edit: (solution to question)
// Here is the main error. The default update() method of the parent
// class should be used, unless adding a complete implementation.
}
}
$hello_widget = new HelloWidget();
Release Notes for Josephine mentions improvements to the block editor, but could be more clear on how the upgrade breaks things. Gutenberg is on my radar, but it would be preferable to not block upgrades on needing to rewrite this (in reality slightly more complex) plugin completely.
I've searched around, but all one seem to be able to find is someone having a similar problem without a solution on the support forums.