$_POST['pod_format_new_slug']) : ''; $format = wp_insert_term($_POST['pod_format_new_name'], 'podcast_format', $args); $format = get_term($format['term_id'], 'podcast_format'); $pod_explicits = unserialize(get_option('pod_formats')); $pod_explicits[$format->slug] = $_POST['pod_format_new_explicit']; update_option('pod_formats', serialize($pod_explicits)); } // Update formats if ( isset($_POST['term_ids']) ) { foreach ( $term_ids as $term_id ) { $term_id = (int) $term_id; $format = get_term($term_id, 'podcast_format'); if ( isset($_POST["delete_pod_format_$term_id"]) ) wp_delete_term($term_id, 'podcast_format'); // Update taxonomy $args = array( 'name' => $_POST["pod_format_name_$term_id"], 'slug' => $_POST["pod_format_slug_$term_id"] ); wp_update_term($term_id, 'podcast_format', $args); // Update explicit $pod_explicits[$format->slug] = $_POST["pod_format_explicit_$term_id"]; update_option('pod_formats', serialize($pod_explicits)); } } // Clear used variables unset($term_ids); } // iTunes category options $pod_itunes_cats = array( 'Arts', 'Arts||Design', 'Arts||Fashion & Beauty', 'Arts||Food', 'Arts||Literature', 'Arts||Performing Arts', 'Arts||Visual Arts', 'Business', 'Business||Business News', 'Business||Careers', 'Business||Investing', 'Business||Management & Marketing', 'Business||Shopping', 'Comedy', 'Education', 'Education||Education Technology', 'Education||Higher Education', 'Education||K-12', 'Education||Language Courses', 'Education||Training', 'Games & Hobbies', 'Games & Hobbies||Automotive', 'Games & Hobbies||Aviation', 'Games & Hobbies||Hobbies', 'Games & Hobbies||Other Games', 'Games & Hobbies||Video Games', 'Government & Organizations', 'Government & Organizations||Local', 'Government & Organizations||National', 'Government & Organizations||Non-Profit', 'Government & Organizations||Regional', 'Health', 'Health||Alternative Health', 'Health||Fitness & Nutrition', 'Health||Self-Help', 'Health||Sexuality', 'Kids & Family', 'Music', 'News & Politics', 'Religion & Spirituality', 'Religion & Spirituality||Buddhism', 'Religion & Spirituality||Christianity', 'Religion & Spirituality||Hinduism', 'Religion & Spirituality||Islam', 'Religion & Spirituality||Judaism', 'Religion & Spirituality||Other', 'Religion & Spirituality||Spirituality', 'Science & Medicine', 'Science & Medicine||Medicine', 'Science & Medicine||Natural Sciences', 'Science & Medicine||Social Sciences', 'Society & Culture', 'Society & Culture||History', 'Society & Culture||Personal Journals', 'Society & Culture||Philosophy', 'Society & Culture||Places & Travel', 'Sports & Recreation', 'Sports & Recreation||Amateur', 'Sports & Recreation||College & High School', 'Sports & Recreation||Outdoor', 'Sports & Recreation||Professional', 'Technology', 'Technology||Gadgets', 'Technology||Tech News', 'Technology||Podcasting', 'Technology||Software How-To', 'TV & Film' ); $pod_formats = get_terms('podcast_format', 'get=all'); ?>

Podcasting Options

using_permalinks()) echo "/feed/podcast/"; else echo "/?feed=podcast"; ?>


If your podcast's title is different than your blog's title, change the title here.

If your podcast's tagline is different than your blog's tagline, change the tagline here.
iTunes Specifics

A detailed description of your podcast. iTunes allows up to 4,000 characters and the tagline will be used if no summary is entered.

The default author of your podcast.

An image which represents your podcast. iTunes uses this image on your podcast directory page and a smaller version in searches. iTunes prefers square .jpg images that are at least 300 x 300 pixels, but any jpg or png will work.


Up to 12 comma-separated words which iTunes uses for search placement.

Notifies readers your podcast contains explicit material. Select clean if your podcast removed any explicit content. Note: iTunes requires all explicit podcast to mark themself as one. Failure to do so can result in removal from the iTunes podcast directory.

Your podcast's owner's name. The owner name will not be publically displayed and is used only by iTunes in the event they need to contact your podcast.

Your podcast's owner's e-mail address. The owner e-mail address will not be publically displayed and is used only by iTunes in the event they need to contact your podcast.

1 ) { ?>
Formats slug ) { if ( $term_count > 0 ) $term_ids .= ','; $term_count++; $term_ids .= $pod_format->term_id; ?>
Format Feed slug/"; else echo "/?feed=podcast&format=$pod_format->slug"; ?>" readonly="readonly" />
Format Name Format Slug Explicit
Add a New Format

The display name of your new new format.

If you leave this field blank, a slug will automatically be generated for you.

The explicit setting for this format. If you leave this field blank, your global podcast explicit setting will be used.

'; } // Podcasting post form function podcasting_edit_form() { global $wpdb, $post; if ($post->ID) $enclosures = $wpdb->get_results("SELECT meta_id, meta_value FROM {$wpdb->postmeta} WHERE post_id = {$post->ID} AND meta_key = 'enclosure' ORDER BY meta_id", ARRAY_A); $pod_formats = get_terms('podcast_format', 'get=all'); ?>

Podcasting

0 ) $enclosure_ids .= ','; $enclosure_count++; $enclosure_ids .= $enclosure['meta_id']; $enclosure_value = explode("\n", $enclosure['meta_value']); $enclosure_itunes = unserialize($enclosure_value[3]); $podcast_player = ( 'mp3' == substr(trim($enclosure_value[0]), -3) ) ? true : false; ?>
File
Format KeywordsUp to 12 comma-separated words which iTunes uses for search placement.
AuthorAuthor name if different than default. LengthLength of the podcast in HH:MM:SS format. ExplicitExplicit setting if different than default.

Add a new file:

File URL
$_POST['pod_format_' . $enclosure_id], 'keywords' => $_POST['pod_keywords_' . $enclosure_id], 'author' => $_POST['pod_author_' . $enclosure_id], 'length' => $_POST['pod_length_' . $enclosure_id], 'explicit' => $_POST['pod_explicit_' . $enclosure_id] )); // Update format wp_set_object_terms($enclosure_id, $_POST['pod_format_' . $enclosure_id], 'podcast_format', false); // Update enclsoure $enclosure = explode("\n", $enclosures[$i]); $enclosure[3] = $itunes; update_post_meta($postID, 'enclosure', implode("\n", $enclosure), $enclosures[$i]); $i++; // Delete enclosure if (isset($_POST['delete_pod_' . $enclosure_id])) { // Remove format wp_delete_object_term_relationships($enclosure_id, 'podcast_format'); // Remove enclosure delete_meta($enclosure_id); // Fake a save $_POST['save'] = 'Update'; } } // Add new enclosures if ( (isset($_POST['pod_new_file'])) && ('' != $_POST['pod_new_file']) ) { $content = $_POST['pod_new_file']; $enclosed = get_enclosed($postID); do_enclose($content, $postID); // Add relationship if new enclosure if ( !in_array($content, $enclosed) ) { $enclosure_id = $wpdb->get_var("SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = {$postID} AND meta_key = 'enclosure' ORDER BY meta_id DESC"); // Find the enclosure we just added wp_set_object_terms($enclosure_id, 'default-format', 'podcast_format', false); } } return $postID; } // podcasting_save_form() // Cleanup a deleted post function podcasting_delete_form($postID) { $enclosure_ids = explode(',', $_POST['enclosure_ids']); foreach ($enclosure_ids as $enclosure_id) { $enclosure_id = (int) $enclosure_id; wp_delete_object_term_relationships($enclosure_id, 'podcast_format'); } return $postID; } /* ------------------------------------- WORK -------------------------------------- */ // Create a custom feed function do_feed_podcast() { global $wp_query; $wp_query->get_posts(); load_template(ABSPATH . 'wp-rss2.php'); } // Pretty permalinks for the custom feed function podcasting_rewrite_rules($wp_rewrite) { // Rewrite rules are manually entered as there is no hook for adding addition feed queries $feed_rules = array( 'podcast/(.+)/?$' => 'index.php?feed=podcast&format=' . $wp_rewrite->preg_index(1), 'feed/podcast/(.+)/?$' => 'index.php?feed=podcast&format=' . $wp_rewrite->preg_index(1), 'search/(.+)/podcast/(.+)/?$' => 'index.php?s=' . $wp_rewrite->preg_index(1) . '&feed=podcast&format=' . $wp_rewrite->preg_index(2), 'search/(.+)/feed/podcast/(.+)/?$' => 'index.php?s=' . $wp_rewrite->preg_index(1) . '&feed=podcast&format=' . $wp_rewrite->preg_index(2), 'category/(.+?)/podcast/(.+)/?$' => 'index.php?category_name=' . $wp_rewrite->preg_index(1) . '&feed=podcast&format=' . $wp_rewrite->preg_index(2), 'category/(.+?)/feed/podcast/(.+)/?$' => 'index.php?category_name=' . $wp_rewrite->preg_index(1) . '&feed=podcast&format=' . $wp_rewrite->preg_index(2), 'tag/(.+?)/podcast/(.+)/?$' => 'index.php?tag=' . $wp_rewrite->preg_index(1) . '&feed=podcast&format=' . $wp_rewrite->preg_index(2), 'tag/(.+?)/feed/podcast/(.+)/?$' => 'index.php?tag=' . $wp_rewrite->preg_index(1) . '&feed=podcast&format=' . $wp_rewrite->preg_index(2), 'author/([^/]+)/podcast/(.+)/?$' => 'index.php?author_name=' . $wp_rewrite->preg_index(1) . '&feed=podcast&format=' . $wp_rewrite->preg_index(2), 'author/([^/]+)/feed/podcast/(.+)/?$' => 'index.php?author_name=' . $wp_rewrite->preg_index(1) . '&feed=podcast&format=' . $wp_rewrite->preg_index(2), '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/podcast/(.+)/?$' => 'index.php?year=' . $wp_rewrite->preg_index(1) . '&monthnum=' . $wp_rewrite->preg_index(2) . '&day=' . $wp_rewrite->preg_index(3) . '&feed=podcast&format=' . $wp_rewrite->preg_index(4), '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/podcast/(.+)/?$' => 'index.php?year=' . $wp_rewrite->preg_index(1) . '&monthnum=' . $wp_rewrite->preg_index(2) . '&day=' . $wp_rewrite->preg_index(3) . '&feed=podcast&format=' . $wp_rewrite->preg_index(4), '([0-9]{4})/([0-9]{1,2})/podcast/(.+)/?$' => 'index.php?year=' . $wp_rewrite->preg_index(1) . '&monthnum=' . $wp_rewrite->preg_index(2) . '&feed=podcast&format=' . $wp_rewrite->preg_index(3), '([0-9]{4})/([0-9]{1,2})/feed/podcast/(.+)/?$' => 'index.php?year=' . $wp_rewrite->preg_index(1) . '&monthnum=' . $wp_rewrite->preg_index(2) . '&feed=podcast&format=' . $wp_rewrite->preg_index(3), '([0-9]{4})/podcast/(.+)/?$' => 'index.php?year=' . $wp_rewrite->preg_index(1) . '&feed=podcast&format=' . $wp_rewrite->preg_index(2), '([0-9]{4})/feed/podcast/(.+)/?$' => 'index.php?year=' . $wp_rewrite->preg_index(1) . '&feed=podcast&format=' . $wp_rewrite->preg_index(2), '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/podcast/(.+)/?$' => 'index.php?year=' . $wp_rewrite->preg_index(1) . '&monthnum=' . $wp_rewrite->preg_index(2) . '&day=' . $wp_rewrite->preg_index(3) . '&name=' . $wp_rewrite->preg_index(4) . '&feed=podcast&format=' . $wp_rewrite->preg_index(5), '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/podcast/(.+)/?$' => 'index.php?year=' . $wp_rewrite->preg_index(1) . '&monthnum=' . $wp_rewrite->preg_index(2) . '&day=' . $wp_rewrite->preg_index(3) . '&name=' . $wp_rewrite->preg_index(4) . '&feed=podcast&format=' . $wp_rewrite->preg_index(5) ); $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; } // podcasting_rewrite_rules() // Adds variable to select format for podcasting function podcasting_query_vars($vars) { $vars[] = 'format'; return $vars; } // Add the join needed for enclosures only function podcasting_feed_join($join) { global $wpdb; if ( 'podcast' == get_query_var('feed') ) { $join .= " INNER JOIN {$wpdb->postmeta} pod_meta ON {$wpdb->posts}.ID = pod_meta.post_id"; $join .= " INNER JOIN {$wpdb->term_relationships} pod_rel ON (pod_meta.meta_id = pod_rel.object_id)"; $join .= " INNER JOIN {$wpdb->term_taxonomy} pod_tax ON (pod_rel.term_taxonomy_id = pod_tax.term_taxonomy_id)"; $join .= " INNER JOIN {$wpdb->terms} pod_terms ON (pod_tax.term_id = pod_terms.term_id)"; } return $join; } // Add the where needed for enclosures only function podcasting_feed_where($where) { global $wpdb; if ( 'podcast' == get_query_var('feed') ) { $podcast_format = ( '' == get_query_var('format') ) ? 'default-format' : get_query_var('format'); $where .= " AND pod_meta.meta_key = 'enclosure'"; $where .= " AND pod_terms.slug = '{$podcast_format}'"; } return $where; } // Add the groupby needed for enclosures only function podcasting_feed_groupby($groupby) { global $wpdb; if ( 'podcast' == get_query_var('feed') ) $groupby = "{$wpdb->posts}.ID"; return $groupby; } // Add the feed autodiscovery links to section function podcasting_add_feed_discovery() { global $wp_rewrite; $podcast_url = ($wp_rewrite->using_permalinks()) ? '/feed/podcast/' : '/?feed=podcast'; $podcast_url = get_option('home') . $podcast_url; echo ' ' . "\n"; // Formats $pod_formats = get_terms('podcast_format', 'get=all'); foreach ($pod_formats as $pod_format) { if ( 'default-format' != $pod_format->slug ) { $podcast_format_url = ($wp_rewrite->using_permalinks()) ? $podcast_url . "$pod_format->slug/" : $podcast_url . "&format=$pod_format->slug"; echo ' name)" . '" href="' . $podcast_format_url . '" />' . "\n"; } } } // Add the iTunes xml information function podcasting_add_itunes_xml() { if ( 'podcast' == get_query_var('feed') ) { echo 'xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"'; } } // Change the podcast title function podcasting_blogname_filter($title) { if ( 'podcast' == get_query_var('feed') ) { $podcast_format = get_term_by('slug', get_query_var('format'), 'podcast_format'); $title = stripslashes(get_option('pod_title')); if ( 'default-format' != get_query_var('format') && '' != get_query_var('format') && !empty($podcast_format) ) $title .= " ($podcast_format->name)"; } return $title; } // Change the podcast tagline function podcasting_blogdescription_filter($tagline) { if ( 'podcast' == get_query_var('feed') ) $tagline = stripslashes(get_option('pod_tagline')); return $tagline; } // Add the special iTunes information to channel function podcasting_add_itunes_feed() { if ( 'podcast' == get_query_var('feed') ) { // iTunes summary if ( '' != get_option('pod_itunes_summary') ) echo '' . htmlentities(stripslashes(get_option('pod_itunes_summary'))) . '' . "\n "; // iTunes subtitle if ( '' != get_option('pod_tagline') ) echo '' . htmlentities(stripslashes(get_option('pod_tagline'))) . '' . "\n "; // iTunes author if ( '' != get_option('pod_itunes_author') ) echo '' . htmlentities(stripslashes(get_option('pod_itunes_author'))) . '' . "\n "; // iTunes image if ( '' != get_option('pod_itunes_image') ) echo '' . "\n "; // iTunes categories for ($i = 1; $i <= 3; $i++) { $pod_cat_option = 'pod_itunes_cat' . $i; if ( '' != get_option($pod_cat_option) ) { $pod_category = explode('||', htmlspecialchars(stripslashes(get_option($pod_cat_option)))); if ( $pod_category[1] ) { echo '' . "\n "; echo '' . "\n "; echo '' . "\n "; } else echo '' . "\n "; } } // iTunes keywords if ( '' != get_option('pod_itunes_keywords') ) echo '' . htmlentities(stripslashes(get_option('pod_itunes_keywords'))) . '' . "\n "; // iTunes keywords if ( '' != get_option('pod_itunes_explicit') ) echo '' . get_option('pod_itunes_explicit') . '' . "\n "; else echo 'no' . "\n "; // iTunes owner information if ( ( '' != get_option('pod_itunes_ownername') ) || ( '' != get_option('pod_itunes_owneremail') ) ) { echo '' . "\n "; if ( '' != get_option('pod_itunes_ownername') ) echo ' ' . htmlentities(stripslashes(get_option('pod_itunes_ownername'))) . '' . "\n "; if ( '' != get_option('pod_itunes_owneremail') ) echo ' ' . htmlentities(stripslashes(get_option('pod_itunes_owneremail'))) . '' . "\n "; echo '' . "\n "; } } } // podcasting_add_itunes_feed() // Only enclosures of the current format function podcasting_remove_enclosures($enclosure) { if ( 'podcast' == get_query_var('feed') ) { $podcast_format = ( '' == get_query_var('format') ) ? 'default-format' : get_query_var('format'); $enclosures = get_post_custom_values('enclosure'); $podcast_urlformats = array(); // Check if the enclosure should be displayed foreach ($enclosures as $enclose) { $enclose = explode("\n", $enclose); $enclosure_itunes = unserialize($enclose[3]); $enclosure_url = explode('"', $enclosure); if ( ( $enclosure_url[1] == trim(htmlspecialchars($enclose[0])) ) && ( $enclosure_itunes['format'] == $podcast_format ) ) return $enclosure; } } } // Add the special iTunes information to item function podcasting_add_itunes_item() { if ( 'podcast' == get_query_var('feed') ) { $podcast_format = ( '' == get_query_var('format') ) ? 'default-format' : get_query_var('format'); $enclosures = get_post_custom_values('enclosure'); foreach ($enclosures as $enclosure) { $enclosure_itunes = explode("\n", $enclosure); $enclosure_itunes = unserialize($enclosure_itunes[3]); if ($enclosure_itunes['format'] == $podcast_format) break; } // iTunes summary ob_start(); the_content(); $itunes_summary = ob_get_contents(); ob_end_clean(); echo '' . htmlentities(strip_tags(stripslashes($itunes_summary))) . '' . "\n"; // iTunes subtitle ob_start(); the_excerpt_rss(); $itunes_subtitle = ob_get_contents(); ob_end_clean(); echo '' . htmlentities(strip_tags(stripslashes($itunes_subtitle))) . '' . "\n"; // iTunes author if ( '' != $enclosure_itunes['author'] ) echo '' . htmlentities(stripslashes($enclosure_itunes['author'])) . '' . "\n"; // iTunes duration if ( '' != $enclosure_itunes['length'] ) echo '' . htmlentities(stripslashes($enclosure_itunes['length'])) . '' . "\n"; // iTunes keywords if ( '' != $enclosure_itunes['keywords'] ) echo '' . htmlentities(stripslashes($enclosure_itunes['keywords'])) . '' . "\n"; // iTunes explicit if ( '' != $enclosure_itunes['explicit'] ) echo '' . $enclosure_itunes['explicit'] . '' . "\n"; } } // podcasting_add_itunes_item() // Add the podcasting player javascript function podcasting_add_player_javascript() { echo '