Skip to content

Instantly share code, notes, and snippets.

@jfeliweb
Created June 9, 2017 20:45
Show Gist options
  • Select an option

  • Save jfeliweb/a50bc66b6f5af3ed391e25b790bf030f to your computer and use it in GitHub Desktop.

Select an option

Save jfeliweb/a50bc66b6f5af3ed391e25b790bf030f to your computer and use it in GitHub Desktop.
PHP7 is slated for release later this year. One of the changes is that PHP4 style constructors are deprecated. In order to prepare WordPress to support PHP7, these constructors have been deprecated in WordPress core. This is a quick guide to all you need to know about this change.
// Deprecating PHP4 style constructors in WordPress 4.3
class My_Widget extends WP_Widget {
function __construct() {
$widget_ops = array( 'classname' => 'css-class', 'description' => 'Description' );
parent::__construct( 'css-class', 'Title', $widget_ops );
}
// Rest of your widget subclass goes here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment