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_template_directory() . '/mobile.php')) {
         $mobile_themes = true;
     }
     //checks to see if mobile-phone theme is available
     $mobile_phone_themes = false;
     if (file_exists(get_stylesheet_directory() . '/mobile-phone.php') or file_exists(get_template_directory() . '/mobile-phone.php')) {
         $mobile_phone_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()->isTablet()) {
         /*
          * theme/tpl/layout/file.php -  theme/tpl/index.php
          */
         $templates = array('tpl/mobile/mobile.php');
         if (self::$base_tpl) {
             //twitter bootstrap themes
             array_unshift($templates, sprintf('tpl/mobile/tpl-mobile-%s.php', self::$base_tpl));
         }
     } elseif ($mobile_phone_themes and mod_mobile::detect()->isPhone()) {
         /*
          * theme/tpl/layout/file.php -  theme/tpl/index.php
          */
         $templates = array('tpl/mobile/phone.php');
         if (self::$base_tpl) {
             //twitter bootstrap themes
             array_unshift($templates, sprintf('tpl/mobile/tpl-phone-%s.php', self::$base_tpl));
         }
     } else {
         /*
          * theme/tpl/layout/file.php -  theme/tpl/index.php
          */
         $templates = array('tpl/themes/tpl-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));
         }
     }
     //return locate_template($templates,true);
     self::locate_tpl($templates, null, true);
     // return self::locate_tpl($templates);
 }