Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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,204 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' );
    }