Widgetizing application layouts
As mentioned earlier, we have the option of creating template files inside a theme or a plugin. Here, we are going to create the templates inside the plugins
folder to improve flexibility. So, let's begin the process by creating another plugin named WPWA Theme Manager
. Create a folder named wpwa-theme
and define the main plugin file as class-wpwa-theme.php
with the usual plugin definitions. Next, we can update the constructor code as follows to register the widgetized area for the home page:
class WPWA_Theme { public function __construct() { $this-> register_widget_areas(); } public function register_widget_areas() { register_sidebar(array('name' => __('Home Widgets','wpwa'),'id' => 'home-widgets','description' => __('Home Widget Area', 'wpwa'),'before_widget' => '<div id="one" class="home_list">','after_widget' => '</div>','before_title' => '<h2>','after_title' => '</h2>')); } }
Surprisingly,...