Created
June 9, 2017 20:45
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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