function pugpig_get_theme_manifest()
{
    $theme_name = get_option("pugpig_opt_theme_switch");
    if (!isset($theme_name) || $theme_name == '') {
        $theme_name = get_template();
    }
    $theme_dir = get_theme_root();
    $theme_url = get_theme_root_uri();
    if (!is_dir($theme_dir . "/{$theme_name}") && $theme_name != '') {
        echo "ERROR: Invalid theme name: {$theme_name}";
        exit;
    }
    $theme_path = pugpig_strip_domain($theme_url . "/" . $theme_name);
    $theme_dir = $theme_dir . "/" . $theme_name . "/";
    $output = pugpig_theme_manifest_string($theme_path, $theme_dir, $theme_name);
    if (is_child_theme()) {
        $output .= "\n# Child Theme Assets\n";
        $theme_name = get_stylesheet();
        $theme_dir = get_theme_root();
        if (!is_dir($theme_dir . "/{$theme_name}") && $theme_name != '') {
            echo "ERROR: Invalid child theme name: {$theme_name}";
            exit;
        }
        $theme_path = pugpig_strip_domain($theme_url . "/" . $theme_name);
        $theme_dir = $theme_dir . "/" . $theme_name . "/";
        $output .= pugpig_theme_manifest_string($theme_path, $theme_dir, $theme_name);
    }
    return $output;
}
function pugpig_ad_extra_manifest_items($output, $post)
{
    if ($post->post_type != PUGPIG_AD_BUNDLE_POST_TYPE) {
        return $output;
    }
    // Exlude the entry HTML from the manifest
    $theme_path = pugpig_ad_bundle_get_unzip_url($post->ID);
    $theme_dir = pugpig_ad_bundle_get_unzip_dir($post->ID);
    $index = pugpig_ad_bundle_index_file($post);
    // Try to extract again if we've failed
    if (!is_dir($theme_dir)) {
        $attach_id = get_post_meta($post->ID, 'ad_bundle_zip_file', true);
        if (!empty($attach_id)) {
            pugpig_ad_bundle_process($attach_id);
        }
    }
    $exclusions = array(trim($index, "/"));
    $manifest_items = pugpig_theme_manifest_string($theme_path, $theme_dir, '', $exclusions);
    return $output . $manifest_items;
}