function run($default_template)
 {
     //set template paths
     $Path = apply_filters("WXP.get_paths_object", new Path());
     do_action("WXP.set_template_paths", $Path);
     //template paths can now be accessed via WXP::get_template_paths
     WXP::setPaths($Path);
     //allow override of global View object
     $View = apply_filters("WXP.get_global_view", View::getInstance());
     //make View observable
     $View = new Observer("View", $View);
     //set global View object variable for easy access
     $View->add("wxp_global_view", $View);
     //set default render path
     $View->set_render_path($default_template)->add("wxp_default_render_path", $default_template)->add("wxp_allow_plugin_template_override", true);
     //do dom routing action
     $router = apply_filters("WXP.get_dom_router", DomRouter::getInstance());
     //make router observable;
     $router = new Observer("DomRouter", $router);
     do_action("WXP.set_dom_routes", $router);
     $router->route();
     //now include view.php; which will render the global view
     return apply_filters("WXP.view_render_page", WXP::DS(get_template_directory() . "/view.php"));
 }
function view_var($var)
{
    return \WXP\View::getInstance()->get($var);
}
 /**
  * fires actions bound to body class routes
  */
 function route()
 {
     do_action("WXP.DomRoute.before");
     $body_class = get_body_class();
     //add 'common' to the body class array
     array_unshift($body_class, 'common');
     //apply filters to body classes
     $body_class = apply_filters("WXP.DomRoute.body_classes", $body_class);
     //return false if no routes set
     if (empty($this->routes)) {
         return false;
     }
     foreach ($this->routes as $route_hook => $actions) {
         //if $action has the class key that means an action
         //was bound to multiple classes and wont be fired unless
         //all of those classes are present
         if (isset($actions["class"])) {
             $found = true;
             foreach ($actions["class"] as $cls) {
                 $found = in_array($cls, $body_class);
                 if (!$found) {
                     break;
                 }
             }
             //if all classes are not found skip to next route
             if (!$found) {
                 continue;
             }
             //else if all classes are found set $actions with the value
             $actions = (array) $actions['action'];
         } else {
             if (!in_array($route_hook, $body_class)) {
                 continue;
             }
         }
         //fire actions if not in $called_callbacks array
         foreach ($actions as $action) {
             if (is_string($action) && isset($this->called_callbacks[$action])) {
                 //if value is set to true, that means the
                 //callback has been called already
                 //skip to next action
                 if ($this->called_callbacks[$action] === true) {
                     continue;
                 }
                 //else the callback has not been fired yet
                 //set value to true to prevent it from being fired
                 //again in another route
                 $this->called_callbacks[$action] = true;
             }
             //finally fire the callback/action
             WXP::call_target($action, array(View::getInstance()), true);
         }
     }
     do_action("WXP.DomRoute.after");
 }
 /**
  * Sets the properties of #layout_nav template. Checks defined theme options.
  * note: a binded variable can only be overridden by another binded variable to the same template
  * 
  * <b>$menu !!</b>  - binds the name of the #menu to #layout_nav view, blank by default
  * 
  * <b>$brand !!</b> - binds the name of the #brand template to #layout_nav, blank by default
  * 
  * <b>$menu_drawer_template</b> - the #menu-drawer View object if responsive menu is supported, blank otherwise, used in #layout_nav
  * 
  * <b>$responsive_menu_trigger</b> - the name of the #responsive_menu_trigger template if supported, _kill(ed) otherwise, used in #layout_nav 
  * 
  * <b>$layout_nav_brand_block_class</b> - the brand block class, set to bootstrap grid values by default
  * 
  * <b>$layout_nav_menu_block_class</b> - the menu block class, set to bootstrap grid values by default
  * 
  */
 function set_layout_nav()
 {
     //set block classes
     //the brand block
     $this->View->add("layout_nav_brand_block_class", "col-12 col-md-4")->add("layout_nav_menu_block_class", "col-12 col-md-8");
     //bind blank values for menu and brand to the #layout_nav
     //to avoid name clashes
     $this->View->bind("#layout_nav", array("menu" => "", "brand" => ""));
     //if primary-menu is not defined _kill the #menu template
     $this->View->bind("#layout_nav", array("menu" => "_kill"));
     //if theme doesn't support responsive drawer nav
     if (!$this->Options->get("wxp_responsive_menu_support")) {
         //set menu drawer to empty string
         $this->View->add("menu_drawer_template", "")->add("responsive_menu_trigger", "_kill");
     } else {
         //if theme does support responsive navigation
         //pass responsive drawer menu template to #layout_nav view
         $menu_drawer = new View("#menu");
         $menu_drawer->set_render_path("#menu", "drawer");
         $this->View->add("menu_drawer_template", $menu_drawer);
     }
 }