Creating widgets

Having defined the widget area, we can create some dynamic widgets to populate the home page content. Registering widgets is similar to the process used for registering widgetized areas. Let's create a function for including and registering widgets into the application:

    public function register_widgets() {       $base_path = WPWAF_PLUGIN_DIR;       include $base_path . 'widgets/class-wpwaf-home-list-widget.php';       register_widget('WPWAF_Home_List_Widget');     } 

We will create all three widgets required for the home page using the class-wpwaf-home-list-widget.php file inside the widgets folder of our plugins folder. First, we have to include the widgets file inside the register_widgets function. Second, we have to register each and every ...

Get Wordpress Web Application Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.