Timber\Timber::get_sidebar_from_php PHP Method

get_sidebar_from_php() public static method

Get sidebar from PHP
public static get_sidebar_from_php ( string $sidebar = '', array $data ) : string
$sidebar string
$data array
return string
    public static function get_sidebar_from_php($sidebar = '', $data)
    {
        $caller = LocationManager::get_calling_script_dir(1);
        $uris = LocationManager::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) {
            Helper::error_log('error loading your sidebar, check to make sure the file exists');
        }
        $ret = ob_get_contents();
        ob_end_clean();
        return $ret;
    }