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. What are PHP4 style constructors? Prior to the introduction of __construct in PHP5, classes were constructed by using a method with the same name as the class. For example: class Yo { function yo(){ // code that constructs our class } } PHP5 added __construct, but it also continued to allow the PHP4 style constructors, but with some evolving (and occasionally confusing) rules related to the presence of __construct, the ordering of the methods, and if a class is within a namespace. What is WordPress Doing r32990 introduced a change so that all classes use the PHP5 style constructors, while still retaining the PHP4 style constructors for backwards compatibility. For WordPress classes (not external libraries), a deprecated_constructor warning that follows the same rules as deprecated_function will also be displayed. This is designed to help ease the transition to PHP7. What should you do? If you
Share This