Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress How to Build a WordPress Plugin Building WordPress Widgets, and Shortcodes How to Create WordPress Widgets

Ashley Shaw
PLUS
Ashley Shaw
Courses Plus Student 15,793 Points

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP

I get this error: Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Wptreehouse_Badges_Widget has a deprecated constructor in /xxx/wp-content/plugins/wptreehouse-badges/wptreehouse-badges.php on line 92

3 Answers

Dude, did you get an answer to your question chap ????

Sipann A.
Sipann A.
30,234 Points

Hi,

I did not get the error, but checked the php documentation and found this : http://php.net/manual/en/migration70.deprecated.php It seems that same names should not be an issue since our class does implement a __construct() method :

function wptreehouse_badges_widget() {
        // Instantiate the parent object
        parent::__construct( false, 'Official Treehouse Badges Widget' );
    }

(providing you kept that part).

Or I may be wrong. Just glad to know that I'm not completely alone in this class.

Glenré Charl Labuschagné
Glenré Charl Labuschagné
23,202 Points

Hi all,

Just sharing the below worked fine for me:

class Wptreehouse_Badges_Widget extends WP_Widget {
    function __construct() {
        // Instantiate the parent object
        parent::__construct( false, 'Official Treehouse Badges Widget' );
    }