Skip to content

Instantly share code, notes, and snippets.

@circlecube
Created September 17, 2015 17:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save circlecube/79e24f51639912dd9dfd to your computer and use it in GitHub Desktop.
Save circlecube/79e24f51639912dd9dfd to your computer and use it in GitHub Desktop.
How to fix "The called constructor method for WP_Widget is deprecated since version 4.3.0!"
...
class My_Widget extends WP_Widget {
function __construct() {
parent::__construct(
'my-widget', // Base ID
'My Widget', // Name
array( 'description' => 'My Widget description.' ) // Args
);
}
function widget($args, $instance) {
...
...
class My_Widget extends WP_Widget {
function My_Widget() {
$widget_ops = array('classname' => 'my-widget', 'description' => 'My Widget description.');
$control_ops = array('id_base' => 'my-widget');
$this->WP_Widget('my-widget', 'My Widget', $widget_ops, $control_ops);
}
function widget($args, $instance) {
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment