Example #1
0
 /**
  * Get sidebar from PHP
  *
  * @param string  $sidebar
  * @param array   $data
  * @return string
  */
 public static function get_sidebar_from_php($sidebar = '', $data)
 {
     $caller = self::get_calling_script_dir();
     $loader = new TimberLoader();
     $uris = $loader->get_locations($caller);
     ob_start();
     $found = false;
     foreach ($uris as $uri) {
         if (file_exists(trailingslashit($uri) . $sidebar)) {
             include trailingslashit($uri) . $sidebar;
             $found = true;
             break;
         }
     }
     if (!$found) {
         TimberHelper::error_log('error loading your sidebar, check to make sure the file exists');
     }
     $ret = ob_get_contents();
     ob_end_clean();
     return $ret;
 }