Example #1
0
 public static function tpl_include($template)
 {
     //checks to see if mobile theme is available
     $mobile_themes = false;
     if (file_exists(get_stylesheet_directory() . '/mobile.php') or file_exists(get_stylesheet_directory() . '/tbs-mobile.php')) {
         $mobile_themes = true;
     }
     if (cwp::theme_settings('offline') == 1 and !current_user_can('manage_options')) {
         self::$main_tpl = get_stylesheet_directory() . '/offline.php';
     } else {
         self::$main_tpl = $template;
     }
     self::$base_tpl = substr(basename(self::$main_tpl), 0, -4);
     if ('index' == self::$base_tpl) {
         self::$base_tpl = false;
     }
     /**
      *  check to seee if a mobile templaate exists in stylesheet dir and load
      *  to disable mobile themes create a child theme without a mobile template
      */
     if ($mobile_themes and mod_mobile::detect()->isPhone()) {
         /*
          * theme/tpl/layout/file.php -  theme/tpl/index.php
          */
         $templates = array('tpl/mobile/tbs-mobile.php', 'tpl/mobile/mobile.php');
         if (self::$base_tpl) {
             //twitter bootstrap themes
             array_unshift($templates, sprintf('tpl/mobile/tpl-tbs-mobile-%s.php', self::$base_tpl));
             //foundation themes - may remove foundation entirely
             array_unshift($templates, sprintf('tpl/mobile/tpl-mobile-%s.php', self::$base_tpl));
         }
     } else {
         /*
          * theme/tpl/layout/file.php -  theme/tpl/index.php
          */
         $templates = array('tpl/layout/tbs-index.php', 'tpl/themes/index.php', 'tpl/layout/tpl-index.php', 'tpl/layout/index.php');
         if (self::$base_tpl) {
             //foundation themes  - may remove foundation entirely
             //array_unshift($templates, sprintf('tpl/sample/tpl-%s.php', self::$base_tpl));
             array_unshift($templates, sprintf('tpl/layout/tpl-%s.php', self::$base_tpl));
             array_unshift($templates, sprintf('tpl/themes/tpl-%s.php', self::$base_tpl));
             //array_unshift($templates, sprintf('tpl/custom/tpl-%s.php', self::$base_tpl));
             //twitter bootstrap themes
             //array_unshift($templates, sprintf('tpl/sample/tpl-tbs-%s.php', self::$base_tpl));
             array_unshift($templates, sprintf('tpl/layout/tpl-tbs-%s.php', self::$base_tpl));
             array_unshift($templates, sprintf('tpl/themes/tpl-tbs-%s.php', self::$base_tpl));
             // array_unshift($templates, sprintf('tpl/custom/tpl-tbs-%s.php', self::$base_tpl));
         }
     }
     return locate_template($templates);
     //self::locate_tpl($template_names, $slug, $load, $require_once)
     // return self::locate_tpl($templates);
 }