Wal-Mart.com USA, LLC
Wal-Mart.com USA, LLC

Using PHP5 object constructors in WP Widget API

29 September 2009, 10:15 am

Someone mentioned to me that they couldn’t use PHP5-style object constructors when using the WP Widget API. I looked into it, and it turns out it does work. Example: 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 } The key is using parent::__construct() instead of $this->WP_Widget(). ... Read More »

More Topics from "News"


Featured Video


Wal-Mart.com USA, LLC
Wal-Mart.com USA, LLC