public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
/**
 * Includes a template part, similar to the WP get template part, but looks
 * in the correct directories for WPInventory templates
 *
 * @param string $slug
 * @param null|string $name
 *
 * @uses WPIMTemplates::get
 * @author Alpha Channel Group
 * @since 0.1
 **/
function wpinventory_get_template_part($slug, $name = NULL, $echo = TRUE, $args = NULL)
{
    // Execute code for this part
    do_action('wpim_pre_get_template_part_' . $slug, $slug, $name);
    // Setup possible parts
    $templates = array($slug . '.php');
    if (isset($name)) {
        array_unshift($templates, $slug . '-' . $name . '.php');
    }
    // Allow template parts to be filtered
    $templates = apply_filters('wpim_get_template_part_templates', $templates, $slug, $name);
    $found = FALSE;
    // loop through templates, return first one found.
    foreach ($templates as $template) {
        $file = WPIMTemplate::get($template);
        $file = apply_filters('wpim_get_template_part_path', $file, $template, $slug, $name);
        $file = apply_filters('wpim_get_template_part_path_' . $template, $file, $slug, $name);
        if (file_exists($file)) {
            $found = TRUE;
            ob_start();
            do_action('wpim_before_get_template_part', $template, $file, $template, $slug, $name);
            include $file;
            do_action('wpim_after_get_template_part', $template, $file, $slug, $name);
            $html = ob_get_clean();
            echo apply_filters('wpim_get_template_part_content', $html, $template, $file, $slug, $name);
            break;
        }
    }
    if (!$found) {
        echo '<!-- Could not find template ' . $slug . ' ' . $name . '-->';
    }
    do_action('wpim_post_get_template_part_' . $slug, $slug, $name);
}