Create URL blank test in podcast code

Issue #53 resolved
Allen Cox created an issue

CHANGE:

// add itunes specific info to each item
function wpfc_podcast_add_item(){
global $post;
$audio = get_post_meta($post->ID, 'sermon_audio', 'true');
$speaker = strip_tags( get_the_term_list( $post->ID, 'wpfc_preacher', '', ' & ', '' ) );
$series = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_series', '', ', ', '' ) );
// Sermon Topics
$topic_list = wp_get_post_terms( get_the_ID() , 'wpfc_sermon_topics' );
$topics = false;
if( $topic_list && count( $topic_list ) > 0 ) {
$c = 0;
foreach( $topic_list as $t ) {
if( $c == 0 ) {
$topics = esc_html( $t->name );
++$c;
} else {
$topics .= ', ' . esc_html( $t->name );
}
}
}

$post_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
$post_image = ( $post_image ) ? $post_image['0'] : null;
$enclosure = get_post_meta($post->ID, 'enclosure', 'true');

$audio_duration = get_post_meta($post->ID, '_wpfc_sermon_duration', 'true');
if ($audio_duration == '' ) $audio_duration = '0:00'; //zero if undefined
?>
<itunes:author><?php echo $speaker ?></itunes:author>
<itunes:subtitle><?php echo $series ?></itunes:subtitle>
<itunes:summary><?php strip_tags( wpfc_sermon_meta('sermon_description') ); ?></itunes:summary>
<?php if ( $post_image ) : ?>
<itunes:image href="<?php echo $post_image; ?>" />
<?php endif; ?>
<?php if ( $enclosure == '' ) : ?>
<enclosure url="<?php echo $audio; ?>" length="0" type="audio/mpeg"/>
<?php endif; ?>
<itunes:duration><?php echo esc_html( $audio_duration ); ?></itunes:duration>
<?php if( $topics ) { ?>
<itunes:keywords><?php echo esc_html( $topics ); ?></itunes:keywords><?php }
}
}

TO...

// add itunes specific info to each item
function wpfc_podcast_add_item(){
global $post;
$audio = get_post_meta($post->ID, 'sermon_audio', 'true');
$speaker = strip_tags( get_the_term_list( $post->ID, 'wpfc_preacher', '', ' & ', '' ) );
$series = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_series', '', ', ', '' ) );
// Sermon Topics
$topic_list = wp_get_post_terms( get_the_ID() , 'wpfc_sermon_topics' );
$topics = false;
if( $topic_list && count( $topic_list ) > 0 ) {
$c = 0;
foreach( $topic_list as $t ) {
if( $c == 0 ) {
$topics = esc_html( $t->name );
++$c;
} else {
$topics .= ', ' . esc_html( $t->name );
}
}
}

$post_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
$post_image = ( $post_image ) ? $post_image['0'] : null;
$enclosure = get_post_meta($post->ID, 'enclosure', 'true');

$audio_duration = get_post_meta($post->ID, '_wpfc_sermon_duration', 'true');
if ($audio_duration == '' ) $audio_duration = '0:00'; //zero if undefined
if ($audio ) {
?>
<itunes:author><?php echo $speaker ?></itunes:author>
<itunes:subtitle><?php echo $series ?></itunes:subtitle>
<itunes:summary><?php strip_tags( wpfc_sermon_meta('sermon_description') ); ?></itunes:summary>
<?php if ( $post_image ) : ?>
<itunes:image href="<?php echo $post_image; ?>" />
<?php endif; ?>
<?php if ( $enclosure == '' ) : ?>
<enclosure url="<?php echo $audio; ?>" length="0" type="audio/mpeg"/>
<?php endif; ?>
<itunes:duration><?php echo esc_html( $audio_duration ); ?></itunes:duration>
<?php if( $topics ) { ?>
<itunes:keywords><?php echo esc_html( $topics ); ?></itunes:keywords><?php }
}
}

IN podcast-functions.php

Providing an empty URL for the .MP3 file breaks validation! I added this to filter out posts from the feed that do not have a proper URL for the audio file. After I added this MOD everything Validated perfectly!!

Comments (5)

  1. Allen Cox reporter

    notice this bold part in the new section of code

    $audio_duration = get_post_meta($post->ID, '_wpfc_sermon_duration', 'true'); if ($audio_duration == '' ) $audio_duration = '0:00'; //zero if undefined if ($audio ) { ?>

  2. Log in to comment