Upgrading WordPress Corpo theme to PHP 8.1

I recently had to upgrade this site to PHP 8.x. The Corpo theme I use is pretty old (the link to the developers website doesn’t work anymore). When upgrading I got this:

Fatal error: Uncaught ArgumentCountError: Too few arguments to function WP_Widget::__construct(), 0 passed in /some-path/janscholtyssek.dk/httpd.www/wp-includes/class-wp-widget-factory.php on line 61 and at least 2 expected in /some-path/janscholtyssek.dk/httpd.www/wp-includes/class-wp-widget.php:162 
Stack trace:
#0 /some-path/janscholtyssek.dk/httpd.www/wp-includes/class-wp-widget-factory.php(61): WP_Widget->__construct()
#1 /some-path/janscholtyssek.dk/httpd.www/wp-includes/widgets.php(115): WP_Widget_Factory->register('corpo_contact_w...')
#2 /some-path/janscholtyssek.dk/httpd.www/wp-content/themes/corpo/functions.php(233): register_widget('corpo_contact_w...') #3 /some-path/janscholtyssek.dk/httpd.www/wp-includes/class-wp-hook.php(307): corpo_widgets_init('')
#4 /some-path/janscholtyssek.dk/httpd.www/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
#5 /some-path/janscholtyssek.dk/httpd.www/wp-includes/plugin.php(476): WP_Hook->do_action(Array)
#6 /some-path/janscholtyssek.dk/httpd.www/wp-includes/widgets.php(1854): do_action('widgets_init')
#7 /some-path/janscholtyssek.dk/httpd.www/wp-includes/class-wp-hook.php(307): wp_widgets_init('')
#8 /some-path/janscholtyssek.dk/httpd.www/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
#9 /some-path/janscholtyssek.dk/httpd.www/wp-includes/plugin.php(476): WP_Hook->do_action(Array)
#10 /some-path/janscholtyssek.dk/httpd.www/wp-settings.php(598): do_action('init')
#11 /some-path/janscholtyssek.dk/httpd.www/wp-config.php(97): require_once('/customers/1/1/...')
#12 /some-path/janscholtyssek.dk/httpd.www/wp-load.php(50): require_once('/customers/1/1/...')
#13 /some-path/janscholtyssek.dk/httpd.www/wp-blog-header.php(13): require_once('/customers/1/1/...')
#14 /some-path/janscholtyssek.dk/httpd.www/index.php(17): require('/customers/1/1/...')
#15 {main} thrown in /some-path/janscholtyssek.dk/httpd.www/wp-includes/class-wp-widget.php on line 162

 

The solution was to edit the files in /some-path/janscholtyssek.dk/httpd.www/wp-content/themes/corpo/functions/widgets and replacing the named constructor, e.g.

function corpo_contact_widget() {
...
$this->WP_Widget( 'corpo_contact_widget', __('Corpo: Contact widget', 'corpo'), $widget_ops, $control_ops );
}

with this:

function __construct() {
...
parent::__construct( 'corpo_contact_widget', __('Corpo: Contact widget', 'corpo'), $widget_ops, $control_ops );
}

Comments are closed.