function powerpress_admin_categoryfeeds()
{
    $General = powerpress_get_settings('powerpress_general');
    ?>
<h2><?php 
    echo __('Category Podcasting', 'powerpress');
    ?>
</h2>
<p>
	<?php 
    echo __('Category Podcasting adds custom podcast settings to specific blog category feeds, allowing you to organize episodes by topic.', 'powerpress');
    ?>
</p>
<p>
	<?php 
    echo sprintf(__('If you are looking to organize episodes by file or format, please use %s.', 'powerpress'), '<a href="' . admin_url('admin.php?page=powerpress/powerpressadmin_customfeeds.php') . '" title="' . __('Custom Podcast Channels') . '">' . __('Custom Podcast Channels') . '</a>');
    ?>
</p><style type="text/css">
.column-url {
	width: 40%;
}
.column-name {
	width: 30%;
}
.column-feed-slug {
	width: 15%;
}
.column-episode-count {
	width: 15%;
}
.category-list {
	width: 100%;
}
</style>
<div id="col-container">

<div id="col-right">
<table class="widefat fixed" cellspacing="0">
	<thead>
	<tr>
<?php 
    print_column_headers('powerpressadmin_categoryfeeds');
    ?>
	</tr>
	</thead>

	<tfoot>
	<tr>
<?php 
    print_column_headers('powerpressadmin_categoryfeeds', false);
    ?>
	</tr>
	</tfoot>
	<tbody>
<?php 
    $Feeds = array();
    if (isset($General['custom_cat_feeds'])) {
        $Feeds = $General['custom_cat_feeds'];
    }
    $count = 0;
    while (list($null, $cat_ID) = each($Feeds)) {
        if (empty($cat_ID)) {
            continue;
        }
        $category = get_category_to_edit($cat_ID);
        if (is_wp_error($category)) {
            // $cat_ID does not existing
            continue;
        }
        //var_dump($category);
        $columns = powerpress_admin_customfeeds_columns();
        $hidden = array();
        if ($count % 2 == 0) {
            echo '<tr valign="middle" class="alternate">';
        } else {
            echo '<tr valign="middle">';
        }
        $edit_link = admin_url('admin.php?page=powerpress/powerpressadmin_categoryfeeds.php&amp;action=powerpress-editcategoryfeed&amp;cat=') . $cat_ID;
        $feed_title = $category->name;
        $url = get_category_feed_link($cat_ID);
        $short_url = str_replace('http://', '', $url);
        $short_url = str_replace('www.', '', $short_url);
        if (strlen($short_url) > 35) {
            $short_url = substr($short_url, 0, 32) . '...';
        }
        foreach ($columns as $column_name => $column_display_name) {
            $class = "class=\"column-{$column_name}\"";
            //$short_url = '';
            switch ($column_name) {
                case 'feed-slug':
                    echo "<td {$class}>{$category->slug}";
                    echo "</td>";
                    break;
                case 'name':
                    echo '<td ' . $class . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit "%s"', 'powerpress'), $feed_title)) . '">' . esc_html($feed_title) . '</a></strong><br />';
                    $actions = array();
                    $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit', 'powerpress') . '</a>';
                    $actions['remove'] = "<a class='submitdelete' href='" . admin_url() . wp_nonce_url("admin.php?page=powerpress/powerpressadmin_categoryfeeds.php&amp;action=powerpress-delete-category-feed&amp;cat={$cat_ID}", 'powerpress-delete-category-feed-' . $cat_ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf(__("You are about to remove podcast settings for category feed '%s'\n  'Cancel' to stop, 'OK' to delete.", 'powerpress'), esc_html($feed_title))) . "') ) { return true;}return false;\">" . __('Remove', 'powerpress') . "</a>";
                    $action_count = count($actions);
                    $i = 0;
                    echo '<div class="row-actions">';
                    foreach ($actions as $action => $linkaction) {
                        ++$i;
                        $i == $action_count ? $sep = '' : ($sep = ' | ');
                        echo '<span class="' . $action . '">' . $linkaction . $sep . '</span>';
                    }
                    echo '</div>';
                    echo '</td>';
                    break;
                case 'url':
                    echo "<td {$class}><a href='{$url}' title='" . esc_attr(sprintf(__('Visit %s', 'powerpress'), $feed_title)) . "' target=\"_blank\">{$short_url}</a>";
                    echo '<div class="row-actions">';
                    if (defined('POWERPRESS_FEEDVALIDATOR_URL')) {
                        echo '<span class="' . $action . '"><a href="' . POWERPRESS_FEEDVALIDATOR_URL . urlencode(str_replace('&amp;', '&', $url)) . '" target="_blank">' . __('Validate Feed', 'powerpress') . '</a></span>';
                    }
                    echo '</div>';
                    echo "</td>";
                    break;
                case 'episode-count':
                    echo "<td {$class}>{$episode_total}";
                    echo "</td>";
                    break;
                default:
                    break;
            }
        }
        echo "\n    </tr>\n";
        $count++;
    }
    ?>
	</tbody>
</table>
</div> <!-- col-right -->

<div id="col-left">
<div class="col-wrap">
<div class="form-wrap">
<h3><?php 
    echo __('Add Podcast Settings to existing Category Feed', 'powerpress');
    ?>
</h3>
<input type="hidden" name="action" value="powerpress-addcategoryfeed" />
<input type="hidden" name="taxonomy" value="category" />
<?php 
    //wp_original_referer_field(true, 'previous');
    wp_nonce_field('powerpress-add-taxonomy-feed');
    ?>

<div class="form-field form-required">
	<label for="feed_name"><?php 
    echo __('Category', 'powerpress');
    ?>
</label>
<?php 
    wp_dropdown_categories(array('class' => 'category-list', 'show_option_none' => __('Select Category', 'powerpress'), 'orderby' => 'name', 'hide_empty' => 0, 'hierarchical' => 1, 'name' => 'term', 'id' => 'term_id'));
    ?>
	
    
</div>

<p class="submit"><input type="submit" class="button" name="submit" value="<?php 
    echo __('Add Podcast Settings to Category Feed', 'powerpress');
    ?>
" /></p>

</div>
</div>

</div> <!-- col-left -->

</div> <!-- col-container -->

<h3><?php 
    echo __('Example Usage', 'powerpress');
    ?>
</h3>
<p>
	<?php 
    echo __('Example 1: You have a podcast that covers two topics that sometimes share same posts and sometimes do not. Use your main podcast feed as a combined feed of both topics 	and use category feeds to distribute topic specific episodes.', 'powerpress');
    ?>
</p>
<p>
	<?php 
    echo __('Example 2: You want to use categories to keep episodes separate from each other. Each category can be used to distribute separate podcasts with the main podcast feed combining all categories to provide a network feed.', 'powerpress');
    ?>
</p>

<?php 
}
function powerpress_admin_customfeeds()
{
    $General = powerpress_get_settings('powerpress_general');
    ?>
<h2><?php 
    echo __('Custom Podcast Channels', 'powerpress');
    ?>
</h2>
<p>
	<?php 
    echo __('Custom podcast Channels allow you to associate multiple media files and/or formats to one blog post.', 'powerpress');
    ?>
</p>
<p>
	<?php 
    echo sprintf(__('If you are looking to organize episodes by topic, please use %s.', 'powerpress'), '<a href="' . admin_url('admin.php?page=powerpress/powerpressadmin_categoryfeeds.php') . '" title="' . __('Category Podcast Feeds', 'powerpress') . '">' . __('Category Podcast Feeds', 'powerpress') . '</a>');
    ?>
</p>

<style type="text/css">

.column-url {
	width: 40%;
}
.column-name {
	width: 30%;
}
.column-feed-slug {
	width: 15%;
}
.column-episode-count {
	width: 15%;
}
</style>
<div id="col-container">

<div id="col-right">
<table class="widefat fixed" cellspacing="0">
	<thead>
	<tr>
<?php 
    print_column_headers('powerpressadmin_customfeeds');
    ?>
	</tr>
	</thead>

	<tfoot>
	<tr>
<?php 
    print_column_headers('powerpressadmin_customfeeds', false);
    ?>
	</tr>
	</tfoot>
	<tbody>
<?php 
    $Feeds = array('podcast' => __('Podcast', 'powerpress'));
    if (isset($General['custom_feeds']['podcast'])) {
        $Feeds = $General['custom_feeds'];
    } else {
        if (is_array($General['custom_feeds'])) {
            $Feeds += $General['custom_feeds'];
        }
    }
    asort($Feeds, SORT_STRING);
    // Sort feeds
    $count = 0;
    while (list($feed_slug, $feed_title) = each($Feeds)) {
        $feed_slug = esc_attr($feed_slug);
        // Precaution
        $episode_total = powerpress_admin_episodes_per_feed($feed_slug);
        $columns = powerpress_admin_customfeeds_columns();
        $hidden = array();
        if ($feed_slug == 'podcast') {
            $feed_title = __('Podcast', 'powerpress');
        }
        if ($count % 2 == 0) {
            echo '<tr valign="middle" class="alternate">';
        } else {
            echo '<tr valign="middle">';
        }
        foreach ($columns as $column_name => $column_display_name) {
            $class = "class=\"column-{$column_name}\"";
            $edit_link = admin_url('admin.php?page=powerpress/powerpressadmin_customfeeds.php&amp;action=powerpress-editfeed&amp;feed_slug=') . $feed_slug;
            $url = get_feed_link($feed_slug);
            $short_url = str_replace('http://', '', $url);
            $short_url = str_replace('www.', '', $short_url);
            //if ('/' == substr($short_url, -1))
            //	$short_url = substr($short_url, 0, -1);
            if (strlen($short_url) > 35) {
                $short_url = substr($short_url, 0, 32) . '...';
            }
            //$short_url = '';
            switch ($column_name) {
                case 'feed-slug':
                    echo "<td {$class}>{$feed_slug}";
                    echo "</td>";
                    break;
                case 'name':
                    echo '<td ' . $class . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit "%s"', 'powerpress'), $feed_title)) . '">' . esc_html($feed_title) . '</a></strong>' . ($feed_slug == 'podcast' ? ' (' . __('default channel', 'powerpress') . ')' : '') . '<br />';
                    $actions = array();
                    $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit', 'powerpress') . '</a>';
                    $actions['delete'] = "<a class='submitdelete' href='" . admin_url() . wp_nonce_url("admin.php?page=powerpress/powerpressadmin_customfeeds.php&amp;action=powerpress-delete-feed&amp;feed_slug={$feed_slug}", 'powerpress-delete-feed-' . $feed_slug) . "' onclick=\"if ( confirm('" . esc_js(sprintf(__("You are about to delete feed '%s'\n  'Cancel' to stop, 'OK' to delete.", 'powerpress'), esc_attr($feed_title))) . "') ) { return true;}return false;\">" . __('Delete', 'powerpress') . "</a>";
                    if (!isset($General['custom_feeds'][$feed_slug])) {
                        unset($actions['delete']);
                    }
                    $action_count = count($actions);
                    $i = 0;
                    echo '<div class="row-actions">';
                    foreach ($actions as $action => $linkaction) {
                        ++$i;
                        $i == $action_count ? $sep = '' : ($sep = ' | ');
                        echo '<span class="' . $action . '">' . $linkaction . $sep . '</span>';
                    }
                    echo '</div>';
                    echo '</td>';
                    break;
                case 'url':
                    echo "<td {$class}><a href='{$url}' title='" . esc_attr(sprintf(__('Visit %s', 'powerpress'), $feed_title)) . "' target=\"_blank\">" . esc_html($short_url) . "</a>";
                    echo '<div class="row-actions">';
                    if (defined('POWERPRESS_FEEDVALIDATOR_URL')) {
                        echo '<span class="' . $action . '"><a href="' . POWERPRESS_FEEDVALIDATOR_URL . urlencode($url) . '" target="_blank">' . __('Validate Feed', 'powerpress') . '</a></span>';
                    }
                    echo '</div>';
                    echo "</td>";
                    break;
                case 'episode-count':
                    echo "<td {$class}>{$episode_total}";
                    echo "</td>";
                    break;
                default:
                    break;
            }
        }
        echo "\n    </tr>\n";
        $count++;
    }
    ?>
	</tbody>
</table>
<?php 
    if (!isset($General['custom_feeds'][$feed_slug])) {
        ?>
<p><?php 
        echo sprintf(__('Note: The default channel "Podcast" is currently using global PowerPress settings. Click %s to customize the default "Podcast" channel.', 'powerpress'), '<a href="' . admin_url('admin.php?page=powerpress/powerpressadmin_customfeeds.php&amp;action=powerpress-editfeed&amp;feed_slug=podcast') . '">' . __('Edit', 'powerpress') . '</a>');
        ?>
</p>
<?php 
    }
    ?>
</div> <!-- col-right -->

<div id="col-left">
<div class="col-wrap">
<div class="form-wrap">
<h3><?php 
    echo __('Add Podcast Channel', 'powerpress');
    ?>
</h3>
<div id="ajax-response"></div>
<input type="hidden" name="action" value="powerpress-addfeed" />
<?php 
    //wp_original_referer_field(true, 'previous');
    //wp_nonce_field('powerpress-add-feed');
    ?>

<div class="form-field form-required">
	<label for="feed_name"><?php 
    echo __('Feed Name', 'powerpress');
    ?>
</label>
	<input name="feed_name" id="feed_name" type="text" value="" size="40" />
    <p><?php 
    echo __('The name is used for use within the administration area only.', 'powerpress');
    ?>
</p>
</div>

<div class="form-field">
	<label for="feed_slug"><?php 
    echo __('Feed Slug', 'powerpress');
    ?>
</label>
	<input name="feed_slug" id="feed_slug" type="text" value="" size="40" />
    <p><?php 
    echo __('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'powerpress');
    ?>
</p>
</div>

<p class="submit"><input type="submit" class="button" name="submit" value="<?php 
    echo __('Add Podcast Channel', 'powerpress');
    ?>
" /></p>

</div>
</div>

</div> <!-- col-left -->

</div> <!-- col-container -->

<h3><?php 
    echo __('Example Usage', 'powerpress');
    ?>
</h3>
<p>
	<?php 
    echo __('Example 1: You want to distribute both an mp3 and an ogg version of your podcast. Use the default podcast channel for your mp3 media and create a custom channel for your ogg media.', 'powerpress');
    ?>
</p>
<p>
	<?php 
    echo __('Example 2: You have a video podcast with multiple file formats. Use the default podcast channel for the main media that you want to appear on your blog (e.g. m4v). Create additional channels for the remaining formats (e.g. wmv, mov, mpeg).', 'powerpress');
    ?>
</p>
<p>
	<?php 
    echo __('Example 3: You create two versions of your podcast, a 20 minute summary and a full 2 hour episode. Use the default channel for your 20 minute summary episodes and create a new custom channel for your full length episodes.', 'powerpress');
    ?>
</p>

<?php 
}