Skip to content

Commit

Permalink
Add PodTrac Support (#29)
Browse files Browse the repository at this point in the history
* Update options.php

* Update podcast-functions.php

* Update readme.txt

* Update podcast-feed.php

* Update sermons.php

* Update podcast-functions.php

* Update readme.txt

* Update sermons.php

* Update podcast-feed.php
  • Loading branch information
reykroona authored and Nikola Miljković committed Apr 18, 2017
1 parent da69741 commit 0f91ca1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
14 changes: 14 additions & 0 deletions includes/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,20 @@ function wpfc_sermon_options_render_form() {
</td>
</tr>

<tr>
<th scope="row"><?php _e( 'PodTrac Tracking', 'podtrac' ); ?></th>
<td>
<label><input name="wpfc_options[podtrac]" type="checkbox"
value="1" <?php if ( isset( $options['podtrac'] ) ) {
checked( '1', $options['podtrac'] );
} ?> /> <?php _e( 'Enables PodTrac tracking.', 'sermon-manager' ); ?>
</label><br/>
</td>
<td class="info">
<p><?php _e( 'For more info on PodTrac or to sign up for an account, visit <a href=http://podtrac.com>podtrac.com</a>', 'sermon-manager' ); ?></p>
</td>
</tr>

</table>

<br/>
Expand Down
11 changes: 9 additions & 2 deletions includes/podcast-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,15 @@
<?php if ( $post_image ) : ?>
<itunes:image href="<?php echo $post_image; ?>"/>
<?php endif; ?>
<enclosure url="<?php echo esc_url( $audio_file ); ?>" length="<?php echo $audio_file_size; ?>"
type="audio/mpeg"/>
<?php if ( isset( $settings['podtrac'] ) ) { ?>
<?php
$nohttpaudio = $audio;
$nohttpaudio = preg_replace('#^https?://#', '', $nohttpaudio);
?>
<enclosure url="http://dts.podtrac.com/redirect.mp3/<?php echo $nohttpaudio; ?>" length="<?php echo $audio_file_size; ?>" type="audios/mpeg" />
<?php } else { ?>
<enclosure url="<?php echo esc_url( $audio_file ); ?>" length="<?php echo $audio_file_size; ?>" type="audio/mpeg"/>
<?php } ?>
<guid><?php echo esc_url( get_post_meta( $post->ID, 'sermon_audio', true ) ) ?></guid>
<pubDate><?php echo $Sermon_Date ?></pubDate>
<itunes:duration><?php echo esc_html( $audio_duration ); ?></itunes:duration>
Expand Down
11 changes: 9 additions & 2 deletions includes/podcast-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function wpfc_podcast_add_head() {
function wpfc_podcast_add_item() {

global $post;

$settings = get_option( 'wpfc_options' );
$audio = str_ireplace( 'https://', 'http://', get_post_meta( $post->ID, 'sermon_audio', 'true' ) );
$speaker = strip_tags( get_the_term_list( $post->ID, 'wpfc_preacher', '', ' &amp; ', '' ) );
$series = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_series', '', ', ', '' ) );
Expand Down Expand Up @@ -80,7 +80,14 @@ function wpfc_podcast_add_item() {
<itunes:image href="<?php echo $post_image; ?>"/>
<?php endif; ?>
<?php if ( $audio !== '' ) : ?>
<enclosure url="<?php echo $audio; ?>" length="0" type="audio/mpeg"/>
<?php if ( isset( $settings['podtrac'] ) ) {
$nohttpaudio = $audio;
$nohttpaudio = preg_replace('#^https?://#', '', $nohttpaudio);
?>
<enclosure url="http://dts.podtrac.com/redirect.mp3/<?php echo $nohttpaudio; ?>" length="0" type="audio/mpeg"/>
<?php } else { ?>
<enclosure url="<?php echo $audio; ?>" length="0" type="audio/mpeg"/>
<?php } ?>
<?php endif; ?>
<itunes:duration><?php echo esc_html( $audio_duration ); ?></itunes:duration>
<?php if ( $topics ) { ?>
Expand Down

0 comments on commit 0f91ca1

Please sign in to comment.