|
9 | 9 |
|
10 | 10 | global $taxonomy, $term; |
11 | 11 |
|
| 12 | +if ( isset( $GLOBALS['sm_podcast_data'] ) && is_array( $GLOBALS['sm_podcast_data'] ) ) { |
| 13 | + $settings = $GLOBALS['sm_podcast_data']; |
| 14 | +} else { |
| 15 | + $settings = array(); |
| 16 | +} |
| 17 | + |
| 18 | +// Option ID => escape function. |
| 19 | +$default_settings = array( |
| 20 | + 'podcasts_per_page' => 'intval', |
| 21 | + 'title' => 'esc_html', |
| 22 | + 'website_link' => 'esc_url', |
| 23 | + 'description' => 'esc_html', |
| 24 | + 'language' => 'esc_html', |
| 25 | + 'copyright' => 'esc_html', |
| 26 | + 'itunes_subtitle' => 'esc_html', |
| 27 | + 'itunes_author' => 'esc_html', |
| 28 | + 'enable_podcast_html_description' => '', |
| 29 | + 'itunes_summary' => '', |
| 30 | + 'itunes_owner_name' => 'esc_html', |
| 31 | + 'itunes_owner_email' => 'esc_html', |
| 32 | + 'itunes_cover_image' => 'esc_url', |
| 33 | + 'itunes_sub_category' => '', |
| 34 | + 'podcast_sermon_image_series' => '', |
| 35 | + 'podtrac' => '', |
| 36 | + 'use_published_date' => '', |
| 37 | +); |
| 38 | + |
| 39 | +// If there is no default. |
| 40 | +$wordpress_settings = array( |
| 41 | + 'podcasts_per_page' => 10, |
| 42 | + 'title' => get_wp_title_rss(), |
| 43 | + 'website_link' => get_bloginfo_rss( 'url' ), |
| 44 | + 'description' => get_bloginfo_rss( 'description' ), |
| 45 | + 'language' => get_bloginfo_rss( 'language' ), |
| 46 | +); |
| 47 | + |
| 48 | +foreach ( $default_settings as $id => $escape_function ) { |
| 49 | + // Get SM podcast setting if there is no custom. |
| 50 | + if ( ! isset( $settings[ $id ] ) ) { |
| 51 | + $settings[ $id ] = SermonManager::getOption( $id ); |
| 52 | + } |
| 53 | + |
| 54 | + // Escape the data. |
| 55 | + if ( $escape_function ) { |
| 56 | + $settings[ $id ] = call_user_func( $escape_function, $settings[ $id ] ); |
| 57 | + } |
| 58 | + |
| 59 | + // Get the WordPress or custom default if there is no custom setting or SM setting. |
| 60 | + if ( ! $settings[ $id ] ) { |
| 61 | + $settings[ $id ] = ''; |
| 62 | + |
| 63 | + if ( isset( $wordpress_settings[ $id ] ) ) { |
| 64 | + $settings[ $id ] = $wordpress_settings[ $id ]; |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + // No need to escape again here, since the data will either come from WordPress podcast functions or be pre-escaped |
| 69 | + // in this script (or be blank). |
| 70 | +} |
| 71 | + |
12 | 72 | /** |
13 | 73 | * Create the query for sermons. |
14 | 74 | */ |
15 | 75 | $args = array( |
16 | 76 | 'post_type' => 'wpfc_sermon', |
17 | | - 'posts_per_page' => intval( \SermonManager::getOption( 'podcasts_per_page' ) ) ?: 10, |
| 77 | + 'posts_per_page' => $settings['podcasts_per_page'], |
18 | 78 | 'meta_key' => 'sermon_date', |
19 | 79 | 'meta_value_num' => time(), |
20 | 80 | 'meta_compare' => '<=', |
|
109 | 169 | '7' => 'Spirituality', |
110 | 170 | ); |
111 | 171 |
|
112 | | -$title = esc_html( \SermonManager::getOption( 'title' ) ) ?: get_wp_title_rss(); |
113 | | -$link = esc_url( \SermonManager::getOption( 'website_link' ) ) ?: get_bloginfo_rss( 'url' ); |
114 | | -$description = esc_html( \SermonManager::getOption( 'description' ) ) ?: get_bloginfo_rss( 'description' ); |
115 | | -$language = esc_html( \SermonManager::getOption( 'language' ) ) ?: get_bloginfo_rss( 'language' ); |
| 172 | +$title = $settings['title']; |
| 173 | +$link = $settings['website_link']; |
| 174 | +$description = $settings['description']; |
| 175 | +$language = $settings['language']; |
116 | 176 | $last_sermon_date = ! empty( $sermon_podcast_query->posts ) ? get_post_meta( $sermon_podcast_query->posts[0]->ID, 'sermon_date', true ) ?: null : null; |
117 | | -$copyright = html_entity_decode( esc_html( \SermonManager::getOption( 'copyright' ) ), ENT_COMPAT, 'UTF-8' ); |
118 | | -$subtitle = esc_html( \SermonManager::getOption( 'itunes_subtitle' ) ); |
119 | | -$author = esc_html( \SermonManager::getOption( 'itunes_author' ) ); |
120 | | -$summary = str_replace( ' ', '', \SermonManager::getOption( 'enable_podcast_html_description' ) ? stripslashes( wpautop( wp_filter_kses( \SermonManager::getOption( 'itunes_summary' ) ) ) ) : stripslashes( wp_filter_nohtml_kses( \SermonManager::getOption( 'itunes_summary' ) ) ) ); |
121 | | -$owner_name = esc_html( \SermonManager::getOption( 'itunes_owner_name' ) ); |
122 | | -$owner_email = esc_html( \SermonManager::getOption( 'itunes_owner_email' ) ); |
123 | | -$cover_image_url = esc_url( \SermonManager::getOption( 'itunes_cover_image' ) ); |
124 | | -$subcategory = esc_attr( ! empty( $categories[ \SermonManager::getOption( 'itunes_sub_category' ) ] ) ? $categories[ \SermonManager::getOption( 'itunes_sub_category' ) ] : 'Christianity' ); |
| 177 | +$copyright = html_entity_decode( $settings['copyright'], ENT_COMPAT, 'UTF-8' ); |
| 178 | +$subtitle = $settings['itunes_subtitle']; |
| 179 | +$author = $settings['itunes_author']; |
| 180 | +$summary = str_replace( ' ', '', $settings['enable_podcast_html_description'] ? stripslashes( wpautop( wp_filter_kses( $settings['itunes_summary'] ) ) ) : stripslashes( wp_filter_nohtml_kses( $settings['itunes_summary'] ) ) ); |
| 181 | +$owner_name = $settings['itunes_owner_name']; |
| 182 | +$owner_email = $settings['itunes_owner_email']; |
| 183 | +$cover_image_url = $settings['itunes_cover_image']; |
| 184 | +$subcategory = esc_attr( ! empty( $categories[ $settings['itunes_sub_category'] ] ) ? $categories[ $settings['itunes_sub_category'] ] : 'Christianity' ); |
125 | 185 |
|
126 | 186 | ?> |
127 | 187 | <rss version="2.0" |
|
150 | 210 | <itunes:email><?php echo $owner_email; ?></itunes:email> |
151 | 211 | </itunes:owner> |
152 | 212 | <itunes:explicit>no</itunes:explicit> |
153 | | - <?php if ( \SermonManager::getOption( 'itunes_cover_image' ) ) : ?> |
| 213 | + <?php if ( $cover_image_url ) : ?> |
154 | 214 | <itunes:image href="<?php echo $cover_image_url; ?>"/> |
155 | 215 | <?php endif; ?> |
156 | 216 |
|
|
175 | 235 | $speaker = $speakers_terms ? $speakers_terms[0]->name : ''; |
176 | 236 | $series = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_series', '', ', ', '' ) ); |
177 | 237 | $topics = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_topics', '', ', ', '' ) ); |
178 | | - $post_image = get_sermon_image_url( SermonManager::getOption( 'podcast_sermon_image_series' ) ); |
| 238 | + $post_image = get_sermon_image_url( $settings['podcast_sermon_image_series'] ); |
179 | 239 | $post_image = str_ireplace( 'https://', 'http://', ! empty( $post_image ) ? $post_image : '' ); |
180 | 240 | $audio_duration = get_post_meta( $post->ID, '_wpfc_sermon_duration', true ) ?: '0:00'; |
181 | 241 | $audio_file_size = get_post_meta( $post->ID, '_wpfc_sermon_size', 'true' ) ?: 0; |
182 | 242 | $description = strip_shortcodes( get_post_meta( $post->ID, 'sermon_description', true ) ); |
183 | | - $description = str_replace( ' ', '', \SermonManager::getOption( 'enable_podcast_html_description' ) ? stripslashes( wpautop( wp_filter_kses( $description ) ) ) : stripslashes( wp_filter_nohtml_kses( $description ) ) ); |
| 243 | + $description = str_replace( ' ', '', $settings['enable_podcast_html_description'] ? stripslashes( wpautop( wp_filter_kses( $description ) ) ) : stripslashes( wp_filter_nohtml_kses( $description ) ) ); |
184 | 244 | $date_preached = SM_Dates::get( 'D, d M Y H:i:s +0000', null, false, false ); |
185 | 245 | $date_published = get_the_date( 'D, d M Y H:i:s +0000', $post->ID ); |
186 | 246 |
|
|
189 | 249 | $audio = site_url( $audio ); |
190 | 250 | } |
191 | 251 |
|
192 | | - if ( \SermonManager::getOption( 'podtrac' ) ) { |
| 252 | + if ( $settings['podtrac'] ) { |
193 | 253 | $audio = 'http://dts.podtrac.com/redirect.mp3/' . esc_url( preg_replace( '#^https?://#', '', $audio ) ); |
194 | 254 | } else { |
195 | 255 | // As per RSS 2.0 spec, the enclosure URL must be HTTP only: |
|
205 | 265 | <comments><?php comments_link_feed(); ?></comments> |
206 | 266 | <?php endif; ?> |
207 | 267 |
|
208 | | - <pubDate><?php echo SermonManager::getOption( 'use_published_date' ) ? $date_published : $date_preached; ?></pubDate> |
| 268 | + <pubDate><?php echo $settings['use_published_date'] ? $date_published : $date_preached; ?></pubDate> |
209 | 269 | <dc:creator><![CDATA[<?php echo esc_html( $speaker ); ?>]]></dc:creator> |
210 | 270 | <?php the_category_rss( 'rss2' ); ?> |
211 | 271 |
|
|
220 | 280 | <itunes:image href="<?php echo esc_url( $post_image ); ?>"/> |
221 | 281 | <?php endif; ?> |
222 | 282 |
|
| 283 | + <!--suppress CheckEmptyScriptTag --> |
223 | 284 | <enclosure url="<?php echo esc_url( $audio ); ?>" |
224 | 285 | length="<?php echo esc_attr( $audio_file_size ); ?>" |
225 | 286 | type="audio/mpeg"/> |
|
0 commit comments