Crashes in PHP 8; here’s the fix
-
This plugin is incompatible with PHP 8. To fix it, make these changes to the
widgets.phpfile:First, replace this:
function WIC_Widget_Divider() {
$widget_ops = array('description' => __( 'New row of widgets', 'widget-in-columns' ) );
$this->WP_Widget( "wic-divider", __( 'Divider', 'widget-in-columns' ), $widget_ops, null );
}With this:
public function __construct() {
$widget_ops = array(
'description' => __( 'New row of widgets', 'widget-in-columns' ),
);
parent::__construct(
'wic-divider',
__( 'Divider', 'widget-in-columns' ),
$widget_ops
);
}Next, replace this:
function WIC_Widget_Spacer() {
$widget_ops = array('description' => __( 'Adds a blank column', 'widget-in-columns' ) );
$this->WP_Widget( "wic-spacer", __( 'Spacer', 'widget-in-columns' ), $widget_ops, null );
}With this:
public function __construct() {
$widget_ops = array(
'description' => __( 'Adds a blank column', 'widget-in-columns' ),
);
parent::__construct(
'wic-spacer',
__( 'Spacer', 'widget-in-columns' ),
$widget_ops
);
}Optionally, replace this:
echo "<div class='{$instance[type]}'></div>";With this:
$type = isset( $instance['type'] ) ? esc_attr( $instance['type'] ) : 'divider';
echo "<div class='{$type}'></div>";That’s it!
You must be logged in to reply to this topic.