Integrating a template loader into the user manager
In Chapter 2, Implementing Membership Roles, Permissions, and Features, we used direct file inclusions to load the necessary templates. In Chapter 4, The Building Blocks of Web Applications, we improved the loading of templates by introducing a common templates loader. Now we can integrate the template loader into the user manager component to keep the code consistent. First, we'll look at the template-loading code used in the class-wpwa-user-manager.php
file:
include dirname(__FILE__) . '/templates/info.php'; include dirname(__FILE__) . '/templates/login.php'; include dirname(__FILE__) . '/templates/register.php';
Now let's look at the modified code for template loading in the user manager component:
$tmp = new WPWA_Template_Loader(); $tmp->render("info", array("message"=>$message)); $tmp = new WPWA_Template_Loader(); $tmp->render("login", array("errors"=>$errors)); $tmp = new WPWA_Template_Loader(); $tmp->render("register...