0 ) { $url = get_permalink( $pages_settings['category'] ); if ( '' !== get_option( 'permalink_structure' ) ) { $url = user_trailingslashit( trailingslashit( $url ) . $term->slug ); } else { $url = add_query_arg( 'aiopod_category', $term->slug, $url ); } } return apply_filters( 'aiopod_category_page_url', $url, $term ); } /** * Get the tracking (download) URL for an episode file. * * Three formats are available, chosen by the Episode File URL Format setting: * * extension /{episode-base}/{episode-slug}/file/episode.{ext} (default) * no_extension /{episode-base}/{episode-slug}/file/ * query /?aiopod_episode={episode-slug}&aiopod_download=1 * * The default reads best and tells a podcast app what it is fetching before it fetches it. Some * servers, however, answer any address ending in a media extension themselves — treating it as a * file on disk — and never pass the request to WordPress, which leaves apps unable to play the * episode. The other two formats exist for those servers: `no_extension` keeps the pretty address, * and `query` avoids the rewrite rules altogether. * * WordPress plain permalinks have no pretty address to build on, so they always use the query * format. Any value other than `extension` or `query` builds the no-extension address. * * @since 1.0.0 * @param WP_Post $post Episode post object. * @return string Tracking URL for the episode file. */ function aiopod_get_episode_file_url( $post ) { $performance_settings = aiopod_get_option( 'aiopod_performance_settings' ); // Absent on installs that saved this section before the setting existed $format = ! empty( $performance_settings['episode_file_url_format'] ) ? $performance_settings['episode_file_url_format'] : 'extension'; if ( 'query' === $format || '' === get_option( 'permalink_structure' ) ) { $url = add_query_arg( array( 'aiopod_episode' => $post->post_name, 'aiopod_download' => '1', ), home_url( '/' ) ); return apply_filters( 'aiopod_episode_file_url', $url, $post ); } $permalink = untrailingslashit( get_permalink( $post ) ); $ext = ''; if ( 'extension' === $format ) { // Derive the file extension from the stored episode_file meta. $file_url = get_post_meta( $post->ID, 'episode_file', true ); if ( ! empty( $file_url ) ) { $parsed = parse_url( $file_url ); $path = isset( $parsed['path'] ) ? $parsed['path'] : ''; $ext = strtolower( pathinfo( $path, PATHINFO_EXTENSION ) ); // Accept only safe, alphanumeric extensions. if ( ! preg_match( '/^[a-z0-9]{1,10}$/', $ext ) ) { $ext = ''; } } } if ( ! empty( $ext ) ) { $url = $permalink . '/file/episode.' . $ext; } else { $url = $permalink . '/file/'; } return apply_filters( 'aiopod_episode_file_url', $url, $post ); } /** * Get the participant page URL. * * @since 1.0.0 * @param object $term The term object. * @return string Participant page URL. */ function aiopod_get_participant_page_url( $term ) { $pages_settings = aiopod_get_option( 'aiopod_pages_settings' ); $url = '/'; if ( $pages_settings['participant'] > 0 ) { $url = get_permalink( $pages_settings['participant'] ); if ( '' !== get_option( 'permalink_structure' ) ) { $url = user_trailingslashit( trailingslashit( $url ) . $term->slug ); } else { $url = add_query_arg( 'aiopod_participant', $term->slug, $url ); } } return apply_filters( 'aiopod_participant_page_url', $url, $term ); } /** * Get the RSS feed URL for a podcast. * * @since 1.0.0 * @param WP_Post $post Podcast post object. * @return string RSS feed URL. */ function aiopod_get_rss_feed_url( $post ) { // Bail out early when post_name is empty (post not yet saved). if ( empty( $post->post_name ) ) { return apply_filters( 'aiopod_rss_feed_url', '', $post ); } if ( '' !== get_option( 'permalink_structure' ) ) { $permalink = untrailingslashit( get_permalink( $post ) ); $url = $permalink . '/feed/'; } else { $url = add_query_arg( array( 'aiopod_podcast' => $post->post_name, 'aiopod_feed' => 'podcast' ), home_url( '/' ) ); } return apply_filters( 'aiopod_rss_feed_url', $url, $post ); } /** * Get the tag page URL. * * @since 1.0.0 * @param object $term The term object. * @return string Tag page URL. */ function aiopod_get_tag_page_url( $term ) { $pages_settings = aiopod_get_option( 'aiopod_pages_settings' ); $url = '/'; if ( $pages_settings['tag'] > 0 ) { $url = get_permalink( $pages_settings['tag'] ); if ( '' !== get_option( 'permalink_structure' ) ) { $url = user_trailingslashit( trailingslashit( $url ) . $term->slug ); } else { $url = add_query_arg( 'aiopod_tag', $term->slug, $url ); } } return apply_filters( 'aiopod_tag_page_url', $url, $term ); } /** * Get the address that serves an episode's transcript in a given format. * * Always a query-string address, whatever the permalink settings: a new rewrite rule would not * reach existing sites until their rules were flushed, and some servers answer any address ending * in a file extension themselves rather than passing it to WordPress. The feed's `type` attribute * tells podcast apps what the file is, so no extension is needed. * * @since 1.0.5 * @param WP_Post $post Episode post object. * @param string $language The transcript row's language, or '' for the row in the podcast's language. * @param string $format Format key from aiopod_get_transcript_formats(). * @return string Transcript URL. */ function aiopod_get_transcript_url( $post, $language, $format ) { $url = add_query_arg( array( 'aiopod_episode' => $post->post_name, 'aiopod_transcript' => '' !== $language ? $language : 'default', 'aiopod_format' => $format ), home_url( '/' ) ); /** * The address that serves an episode's transcript. * * @since 1.0.5 * @param string $url Transcript URL. * @param WP_Post $post Episode post object. * @param string $language The transcript row's language, or '' for the podcast's language. * @param string $format Format key: vtt, srt, json, html or txt. */ return apply_filters( 'aiopod_transcript_url', $url, $post, $language, $format ); }