@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly. |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if ( ! defined ( 'ABSPATH' ) ) { |
|
| 4 | 4 | exit; |
| 5 | 5 | } |
| 6 | 6 | |
@@ -26,19 +26,19 @@ discard block |
||
| 26 | 26 | $instance++; |
| 27 | 27 | |
| 28 | 28 | // Get all podcast post types |
| 29 | - $podcast_post_types = ssp_post_types( true ); |
|
| 29 | + $podcast_post_types = ssp_post_types ( true ); |
|
| 30 | 30 | |
| 31 | 31 | // Get list of episode IDs for display from `episodes` parameter |
| 32 | - if ( ! empty( $params['episodes'] ) ) { |
|
| 32 | + if ( ! empty( $params[ 'episodes' ] ) ) { |
|
| 33 | 33 | // 'episodes' is explicitly ordered, unless you specify otherwise. |
| 34 | - if ( empty( $params['orderby'] ) ) { |
|
| 35 | - $params['orderby'] = 'post__in'; |
|
| 34 | + if ( empty( $params[ 'orderby' ] ) ) { |
|
| 35 | + $params[ 'orderby' ] = 'post__in'; |
|
| 36 | 36 | } |
| 37 | - $params['include'] = $params['episodes']; |
|
| 37 | + $params[ 'include' ] = $params[ 'episodes' ]; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // Parse shortcode attributes |
| 41 | - $atts = shortcode_atts( array( |
|
| 41 | + $atts = shortcode_atts ( array( |
|
| 42 | 42 | 'type' => 'audio', |
| 43 | 43 | 'series' => '', |
| 44 | 44 | 'order' => 'ASC', |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | ), $params, 'podcast_playlist' ); |
| 53 | 53 | |
| 54 | 54 | // Included posts must be passed as an array |
| 55 | - if( $atts['include'] ) { |
|
| 56 | - $atts['include'] = explode( ',', $atts['include'] ); |
|
| 55 | + if ( $atts[ 'include' ] ) { |
|
| 56 | + $atts[ 'include' ] = explode ( ',', $atts[ 'include' ] ); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // Excluded posts must be passed as an array |
| 60 | - if( $atts['exclude'] ) { |
|
| 61 | - $atts['exclude'] = explode( ',', $atts['exclude'] ); |
|
| 60 | + if ( $atts[ 'exclude' ] ) { |
|
| 61 | + $atts[ 'exclude' ] = explode ( ',', $atts[ 'exclude' ] ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // Set up query rguments for fetching podcast episodes |
@@ -66,33 +66,33 @@ discard block |
||
| 66 | 66 | 'post_status' => 'publish', |
| 67 | 67 | 'post_type' => $podcast_post_types, |
| 68 | 68 | 'posts_per_page' => -1, |
| 69 | - 'order' => $atts['order'], |
|
| 70 | - 'orderby' => $atts['orderby'], |
|
| 69 | + 'order' => $atts[ 'order' ], |
|
| 70 | + 'orderby' => $atts[ 'orderby' ], |
|
| 71 | 71 | 'ignore_sticky_posts' => true, |
| 72 | - 'post__in' => $atts['include'], |
|
| 73 | - 'post__not_in' => $atts['exclude'], |
|
| 72 | + 'post__in' => $atts[ 'include' ], |
|
| 73 | + 'post__not_in' => $atts[ 'exclude' ], |
|
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | 76 | // Limit query to episodes in defined series only |
| 77 | - if ( $atts['series'] ) { |
|
| 77 | + if ( $atts[ 'series' ] ) { |
|
| 78 | 78 | |
| 79 | - $query_args['tax_query'] = array( |
|
| 79 | + $query_args[ 'tax_query' ] = array( |
|
| 80 | 80 | array( |
| 81 | 81 | 'taxonomy' => 'series', |
| 82 | 82 | 'field' => 'slug', |
| 83 | - 'terms' => $atts['series'], |
|
| 83 | + 'terms' => $atts[ 'series' ], |
|
| 84 | 84 | ), |
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Allow dynamic filtering of query args |
| 90 | - $query_args = apply_filters( 'ssp_podcast_playlist_query_args', $query_args ); |
|
| 90 | + $query_args = apply_filters ( 'ssp_podcast_playlist_query_args', $query_args ); |
|
| 91 | 91 | |
| 92 | 92 | // Fetch all episodes for display |
| 93 | - $episodes = get_posts( $query_args ); |
|
| 93 | + $episodes = get_posts ( $query_args ); |
|
| 94 | 94 | |
| 95 | - if( empty ( $episodes ) ) { |
|
| 95 | + if ( empty ( $episodes ) ) { |
|
| 96 | 96 | return; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -102,30 +102,30 @@ discard block |
||
| 102 | 102 | $default_height = 360; |
| 103 | 103 | |
| 104 | 104 | $theme_width = empty( $content_width ) ? $default_width : ( $content_width - $outer ); |
| 105 | - $theme_height = empty( $content_width ) ? $default_height : round( ( $default_height * $theme_width ) / $default_width ); |
|
| 105 | + $theme_height = empty( $content_width ) ? $default_height : round ( ( $default_height * $theme_width ) / $default_width ); |
|
| 106 | 106 | |
| 107 | 107 | $data = array( |
| 108 | - 'type' => $atts['type'], |
|
| 108 | + 'type' => $atts[ 'type' ], |
|
| 109 | 109 | // don't pass strings to JSON, will be truthy in JS |
| 110 | - 'tracklist' => wp_validate_boolean( $atts['tracklist'] ), |
|
| 111 | - 'tracknumbers' => wp_validate_boolean( $atts['tracknumbers'] ), |
|
| 112 | - 'images' => wp_validate_boolean( $atts['images'] ), |
|
| 110 | + 'tracklist' => wp_validate_boolean ( $atts[ 'tracklist' ] ), |
|
| 111 | + 'tracknumbers' => wp_validate_boolean ( $atts[ 'tracknumbers' ] ), |
|
| 112 | + 'images' => wp_validate_boolean ( $atts[ 'images' ] ), |
|
| 113 | 113 | 'artists' => false, |
| 114 | 114 | ); |
| 115 | 115 | |
| 116 | 116 | $tracks = array(); |
| 117 | 117 | foreach ( $episodes as $episode ) { |
| 118 | 118 | |
| 119 | - $url = $ss_podcasting->get_enclosure( $episode->ID ); |
|
| 120 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 121 | - $url = $ss_podcasting->get_episode_download_link( $episode->ID ); |
|
| 122 | - $url = str_replace( 'podcast-download', 'podcast-player', $url ); |
|
| 119 | + $url = $ss_podcasting->get_enclosure ( $episode->ID ); |
|
| 120 | + if ( get_option ( 'permalink_structure' ) ) { |
|
| 121 | + $url = $ss_podcasting->get_episode_download_link ( $episode->ID ); |
|
| 122 | + $url = str_replace ( 'podcast-download', 'podcast-player', $url ); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // Get episode file type |
| 126 | - $ftype = wp_check_filetype( $url, wp_get_mime_types() ); |
|
| 126 | + $ftype = wp_check_filetype ( $url, wp_get_mime_types () ); |
|
| 127 | 127 | |
| 128 | - if( $episode->post_excerpt ) { |
|
| 128 | + if ( $episode->post_excerpt ) { |
|
| 129 | 129 | $episode_excerpt = $episode->post_excerpt; |
| 130 | 130 | } else { |
| 131 | 131 | $episode_excerpt = $episode->post_title; |
@@ -134,19 +134,19 @@ discard block |
||
| 134 | 134 | // Setup episode data for media player |
| 135 | 135 | $track = array( |
| 136 | 136 | 'src' => $url, |
| 137 | - 'type' => $ftype['type'], |
|
| 137 | + 'type' => $ftype[ 'type' ], |
|
| 138 | 138 | 'caption' => $episode->post_title, |
| 139 | 139 | 'title' => $episode_excerpt, |
| 140 | 140 | 'description' => $episode->post_content, |
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | 143 | // We don't need the ID3 meta data here, but still need to set an empty array |
| 144 | - $track['meta'] = array(); |
|
| 144 | + $track[ 'meta' ] = array(); |
|
| 145 | 145 | |
| 146 | 146 | // Set video dimensions for player |
| 147 | - if ( 'video' === $atts['type'] ) { |
|
| 148 | - $track['dimensions'] = array( |
|
| 149 | - 'original' => compact( $default_width, $default_height ), |
|
| 147 | + if ( 'video' === $atts[ 'type' ] ) { |
|
| 148 | + $track[ 'dimensions' ] = array( |
|
| 149 | + 'original' => compact ( $default_width, $default_height ), |
|
| 150 | 150 | 'resized' => array( |
| 151 | 151 | 'width' => $theme_width, |
| 152 | 152 | 'height' => $theme_height |
@@ -155,27 +155,27 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // Get episode image |
| 158 | - if ( $atts['images'] ) { |
|
| 159 | - $thumb_id = get_post_thumbnail_id( $episode->ID ); |
|
| 158 | + if ( $atts[ 'images' ] ) { |
|
| 159 | + $thumb_id = get_post_thumbnail_id ( $episode->ID ); |
|
| 160 | 160 | if ( ! empty( $thumb_id ) ) { |
| 161 | - list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'full' ); |
|
| 162 | - $track['image'] = compact( 'src', 'width', 'height' ); |
|
| 163 | - list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'thumbnail' ); |
|
| 164 | - $track['thumb'] = compact( 'src', 'width', 'height' ); |
|
| 161 | + list( $src, $width, $height ) = wp_get_attachment_image_src ( $thumb_id, 'full' ); |
|
| 162 | + $track[ 'image' ] = compact ( 'src', 'width', 'height' ); |
|
| 163 | + list( $src, $width, $height ) = wp_get_attachment_image_src ( $thumb_id, 'thumbnail' ); |
|
| 164 | + $track[ 'thumb' ] = compact ( 'src', 'width', 'height' ); |
|
| 165 | 165 | } else { |
| 166 | - $track['image'] = ''; |
|
| 167 | - $track['thumb'] = ''; |
|
| 166 | + $track[ 'image' ] = ''; |
|
| 167 | + $track[ 'thumb' ] = ''; |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $tracks[] = $track; |
|
| 171 | + $tracks[ ] = $track; |
|
| 172 | 172 | } |
| 173 | - $data['tracks'] = $tracks; |
|
| 173 | + $data[ 'tracks' ] = $tracks; |
|
| 174 | 174 | |
| 175 | - $safe_type = esc_attr( $atts['type'] ); |
|
| 176 | - $safe_style = esc_attr( $atts['style'] ); |
|
| 175 | + $safe_type = esc_attr ( $atts[ 'type' ] ); |
|
| 176 | + $safe_style = esc_attr ( $atts[ 'style' ] ); |
|
| 177 | 177 | |
| 178 | - ob_start(); |
|
| 178 | + ob_start (); |
|
| 179 | 179 | |
| 180 | 180 | if ( 1 === $instance ) { |
| 181 | 181 | /** |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | * @param string $type Type of playlist. Possible values are 'audio' or 'video'. |
| 187 | 187 | * @param string $style The 'theme' for the playlist. Core provides 'light' and 'dark'. |
| 188 | 188 | */ |
| 189 | - do_action( 'wp_playlist_scripts', $atts['type'], $atts['style'] ); |
|
| 189 | + do_action ( 'wp_playlist_scripts', $atts[ 'type' ], $atts[ 'style' ] ); |
|
| 190 | 190 | } ?> |
| 191 | 191 | <div class="wp-playlist wp-<?php echo $safe_type ?>-playlist wp-playlist-<?php echo $safe_style ?>"> |
| 192 | - <?php if ( 'audio' === $atts['type'] ): ?> |
|
| 192 | + <?php if ( 'audio' === $atts[ 'type' ] ): ?> |
|
| 193 | 193 | <div class="wp-playlist-current-item"></div> |
| 194 | 194 | <?php endif ?> |
| 195 | 195 | <<?php echo $safe_type ?> controls="controls" preload="none" width="<?php |
@@ -202,21 +202,21 @@ discard block |
||
| 202 | 202 | <noscript> |
| 203 | 203 | <ol><?php |
| 204 | 204 | foreach ( $episodes as $episode ) { |
| 205 | - $url = $ss_podcasting->get_enclosure( $episode->ID ); |
|
| 206 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 207 | - $url = $ss_podcasting->get_episode_download_link( $episode->ID ); |
|
| 208 | - $url = str_replace( 'podcast-download', 'podcast-player', $url ); |
|
| 205 | + $url = $ss_podcasting->get_enclosure ( $episode->ID ); |
|
| 206 | + if ( get_option ( 'permalink_structure' ) ) { |
|
| 207 | + $url = $ss_podcasting->get_episode_download_link ( $episode->ID ); |
|
| 208 | + $url = str_replace ( 'podcast-download', 'podcast-player', $url ); |
|
| 209 | 209 | } |
| 210 | - printf( '<li>%s</li>', $url ); |
|
| 210 | + printf ( '<li>%s</li>', $url ); |
|
| 211 | 211 | } |
| 212 | 212 | ?></ol> |
| 213 | 213 | </noscript> |
| 214 | - <script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode( $data ) ?></script> |
|
| 214 | + <script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode ( $data ) ?></script> |
|
| 215 | 215 | </div> |
| 216 | 216 | <?php |
| 217 | - return ob_get_clean(); |
|
| 217 | + return ob_get_clean (); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | -$GLOBALS['ssp_shortcodes']['podcast_playlist'] = new SSP_Shortcode_Podcast_Playlist(); |
|
| 223 | 222 | \ No newline at end of file |
| 223 | +$GLOBALS[ 'ssp_shortcodes' ][ 'podcast_playlist' ] = new SSP_Shortcode_Podcast_Playlist (); |
|
| 224 | 224 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly. |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined ( 'ABSPATH' ) ) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | public function __construct() { |
| 27 | 27 | // Widget variable settings |
| 28 | 28 | $this->widget_cssclass = 'widget_podcast_playlist'; |
| 29 | - $this->widget_description = __( 'Display a playlist of episodes.', 'seriously-simple-podcasting' ); |
|
| 29 | + $this->widget_description = __ ( 'Display a playlist of episodes.', 'seriously-simple-podcasting' ); |
|
| 30 | 30 | $this->widget_idbase = 'ss_podcast'; |
| 31 | - $this->widget_title = __( 'Podcast: Playlist', 'seriously-simple-podcasting' ); |
|
| 31 | + $this->widget_title = __ ( 'Podcast: Playlist', 'seriously-simple-podcasting' ); |
|
| 32 | 32 | |
| 33 | 33 | // Widget settings |
| 34 | 34 | $widget_ops = array( |
@@ -37,109 +37,109 @@ discard block |
||
| 37 | 37 | 'customize_selective_refresh' => true, |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | - parent::__construct('podcast-playlist', $this->widget_title, $widget_ops); |
|
| 40 | + parent::__construct ( 'podcast-playlist', $this->widget_title, $widget_ops ); |
|
| 41 | 41 | |
| 42 | 42 | $this->alt_option_name = 'widget_podcast_playlist'; |
| 43 | 43 | |
| 44 | - add_action( 'save_post', array( $this, 'flush_widget_cache' ) ); |
|
| 45 | - add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) ); |
|
| 46 | - add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) ); |
|
| 44 | + add_action ( 'save_post', array( $this, 'flush_widget_cache' ) ); |
|
| 45 | + add_action ( 'deleted_post', array( $this, 'flush_widget_cache' ) ); |
|
| 46 | + add_action ( 'switch_theme', array( $this, 'flush_widget_cache' ) ); |
|
| 47 | 47 | |
| 48 | 48 | } // End __construct() |
| 49 | 49 | |
| 50 | - public function widget($args, $instance) { |
|
| 50 | + public function widget( $args, $instance ) { |
|
| 51 | 51 | $cache = array(); |
| 52 | - if ( ! $this->is_preview() ) { |
|
| 53 | - $cache = wp_cache_get( 'widget_podcast_playlist', 'widget' ); |
|
| 52 | + if ( ! $this->is_preview () ) { |
|
| 53 | + $cache = wp_cache_get ( 'widget_podcast_playlist', 'widget' ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if ( ! is_array( $cache ) ) { |
|
| 56 | + if ( ! is_array ( $cache ) ) { |
|
| 57 | 57 | $cache = array(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if ( ! isset( $args['widget_id'] ) ) { |
|
| 61 | - $args['widget_id'] = $this->id; |
|
| 60 | + if ( ! isset( $args[ 'widget_id' ] ) ) { |
|
| 61 | + $args[ 'widget_id' ] = $this->id; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if ( isset( $cache[ $args['widget_id'] ] ) ) { |
|
| 65 | - echo $cache[ $args['widget_id'] ]; |
|
| 64 | + if ( isset( $cache[ $args[ 'widget_id' ] ] ) ) { |
|
| 65 | + echo $cache[ $args[ 'widget_id' ] ]; |
|
| 66 | 66 | return; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - ob_start(); |
|
| 69 | + ob_start (); |
|
| 70 | 70 | |
| 71 | - $episodes = ( $instance['episodes'] ) ? $instance['episodes'] : ''; |
|
| 72 | - $series_slug = ( $instance['series_slug'] ) ? $instance['series_slug'] : ''; |
|
| 71 | + $episodes = ( $instance[ 'episodes' ] ) ? $instance[ 'episodes' ] : ''; |
|
| 72 | + $series_slug = ( $instance[ 'series_slug' ] ) ? $instance[ 'series_slug' ] : ''; |
|
| 73 | 73 | |
| 74 | 74 | $shortcode = '[podcast_playlist'; |
| 75 | 75 | |
| 76 | - if( $episodes ) { |
|
| 77 | - $shortcode .= ' episodes=' . $episodes; |
|
| 76 | + if ( $episodes ) { |
|
| 77 | + $shortcode .= ' episodes='.$episodes; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if( $series_slug ) { |
|
| 81 | - $shortcode .= ' series=' . $series_slug; |
|
| 80 | + if ( $series_slug ) { |
|
| 81 | + $shortcode .= ' series='.$series_slug; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $shortcode .= ']'; |
| 85 | 85 | |
| 86 | - $title = $instance['title']; |
|
| 86 | + $title = $instance[ 'title' ]; |
|
| 87 | 87 | |
| 88 | 88 | /** This filter is documented in wp-includes/default-widgets.php */ |
| 89 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
| 89 | + $title = apply_filters ( 'widget_title', $title, $instance, $this->id_base ); |
|
| 90 | 90 | |
| 91 | - echo $args['before_widget']; |
|
| 91 | + echo $args[ 'before_widget' ]; |
|
| 92 | 92 | |
| 93 | 93 | if ( $title ) { |
| 94 | - echo $args['before_title'] . $title . $args['after_title']; |
|
| 94 | + echo $args[ 'before_title' ].$title.$args[ 'after_title' ]; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - echo do_shortcode( $shortcode ); |
|
| 97 | + echo do_shortcode ( $shortcode ); |
|
| 98 | 98 | |
| 99 | - echo $args['after_widget']; |
|
| 99 | + echo $args[ 'after_widget' ]; |
|
| 100 | 100 | |
| 101 | - if ( ! $this->is_preview() ) { |
|
| 102 | - $cache[ $args['widget_id'] ] = ob_get_flush(); |
|
| 103 | - wp_cache_set( 'widget_podcast_series', $cache, 'widget' ); |
|
| 101 | + if ( ! $this->is_preview () ) { |
|
| 102 | + $cache[ $args[ 'widget_id' ] ] = ob_get_flush (); |
|
| 103 | + wp_cache_set ( 'widget_podcast_series', $cache, 'widget' ); |
|
| 104 | 104 | } else { |
| 105 | - ob_end_flush(); |
|
| 105 | + ob_end_flush (); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | public function update( $new_instance, $old_instance ) { |
| 110 | 110 | $instance = $old_instance; |
| 111 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
| 112 | - $instance['episodes'] = isset( $new_instance['episodes'] ) ? $new_instance['episodes'] : ''; |
|
| 113 | - $instance['series_slug'] = isset( $new_instance['series_slug'] ) ? $new_instance['series_slug'] : ''; |
|
| 114 | - $this->flush_widget_cache(); |
|
| 111 | + $instance[ 'title' ] = strip_tags ( $new_instance[ 'title' ] ); |
|
| 112 | + $instance[ 'episodes' ] = isset( $new_instance[ 'episodes' ] ) ? $new_instance[ 'episodes' ] : ''; |
|
| 113 | + $instance[ 'series_slug' ] = isset( $new_instance[ 'series_slug' ] ) ? $new_instance[ 'series_slug' ] : ''; |
|
| 114 | + $this->flush_widget_cache (); |
|
| 115 | 115 | |
| 116 | 116 | return $instance; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | public function flush_widget_cache() { |
| 120 | - wp_cache_delete('widget_podcast_playlist', 'widget'); |
|
| 120 | + wp_cache_delete ( 'widget_podcast_playlist', 'widget' ); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | public function form( $instance ) { |
| 124 | - $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; |
|
| 125 | - $episodes = isset( $instance['episodes'] ) ? esc_attr( $instance['episodes'] ) : ''; |
|
| 126 | - $series_slug = isset( $instance['series_slug'] ) ? $instance['series_slug'] : ''; |
|
| 124 | + $title = isset( $instance[ 'title' ] ) ? esc_attr ( $instance[ 'title' ] ) : ''; |
|
| 125 | + $episodes = isset( $instance[ 'episodes' ] ) ? esc_attr ( $instance[ 'episodes' ] ) : ''; |
|
| 126 | + $series_slug = isset( $instance[ 'series_slug' ] ) ? $instance[ 'series_slug' ] : ''; |
|
| 127 | 127 | |
| 128 | 128 | // Get all podcast series |
| 129 | - $series = get_terms( 'series' ); |
|
| 129 | + $series = get_terms ( 'series' ); |
|
| 130 | 130 | ?> |
| 131 | - <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title (optional):', 'seriously-simple-podcasting' ); ?></label> |
|
| 132 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" placeholder="<?php _e( 'Widget title', 'seriously-simple-podcasting' ); ?>" value="<?php echo $title; ?>" /></p> |
|
| 131 | + <p><label for="<?php echo $this->get_field_id ( 'title' ); ?>"><?php _e ( 'Title (optional):', 'seriously-simple-podcasting' ); ?></label> |
|
| 132 | + <input class="widefat" id="<?php echo $this->get_field_id ( 'title' ); ?>" name="<?php echo $this->get_field_name ( 'title' ); ?>" type="text" placeholder="<?php _e ( 'Widget title', 'seriously-simple-podcasting' ); ?>" value="<?php echo $title; ?>" /></p> |
|
| 133 | 133 | |
| 134 | - <p><label for="<?php echo $this->get_field_id( 'episodes' ); ?>"><?php _e( 'Episodes (comma-separated IDs):', 'seriously-simple-podcasting' ); ?></label> |
|
| 135 | - <input class="widefat" id="<?php echo $this->get_field_id( 'episodes' ); ?>" name="<?php echo $this->get_field_name( 'episodes' ); ?>" type="text" placeholder="<?php _e( 'Display all episodes', 'seriously-simple-podcasting' ); ?>" value="<?php echo $episodes; ?>" /></p> |
|
| 134 | + <p><label for="<?php echo $this->get_field_id ( 'episodes' ); ?>"><?php _e ( 'Episodes (comma-separated IDs):', 'seriously-simple-podcasting' ); ?></label> |
|
| 135 | + <input class="widefat" id="<?php echo $this->get_field_id ( 'episodes' ); ?>" name="<?php echo $this->get_field_name ( 'episodes' ); ?>" type="text" placeholder="<?php _e ( 'Display all episodes', 'seriously-simple-podcasting' ); ?>" value="<?php echo $episodes; ?>" /></p> |
|
| 136 | 136 | |
| 137 | - <p><label for="<?php echo $this->get_field_id( 'series_slug' ); ?>"><?php _e( 'Series:', 'seriously-simple-podcasting' ); ?></label> |
|
| 138 | - <select id="<?php echo $this->get_field_id( 'series_slug' ); ?>" name="<?php echo $this->get_field_name( 'series_slug' ); ?>"> |
|
| 139 | - <option value=""><?php _e( 'Use episodes specified above', 'seriously-simple-podcasting' ); ?></option> |
|
| 137 | + <p><label for="<?php echo $this->get_field_id ( 'series_slug' ); ?>"><?php _e ( 'Series:', 'seriously-simple-podcasting' ); ?></label> |
|
| 138 | + <select id="<?php echo $this->get_field_id ( 'series_slug' ); ?>" name="<?php echo $this->get_field_name ( 'series_slug' ); ?>"> |
|
| 139 | + <option value=""><?php _e ( 'Use episodes specified above', 'seriously-simple-podcasting' ); ?></option> |
|
| 140 | 140 | <?php |
| 141 | 141 | foreach ( $series as $s ) { |
| 142 | - echo '<option value="' . esc_attr( $s->slug ) . '" ' . selected( $series_slug, $s->slug, false ) . '>' . $s->name . '</option>' . "\n"; |
|
| 142 | + echo '<option value="'.esc_attr ( $s->slug ).'" '.selected ( $series_slug, $s->slug, false ).'>'.$s->name.'</option>'."\n"; |
|
| 143 | 143 | } |
| 144 | 144 | ?> |
| 145 | 145 | </select> |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly. |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined ( 'ABSPATH' ) ) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -33,57 +33,57 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $this->version = $version; |
| 35 | 35 | |
| 36 | - $this->dir = dirname( $file ); |
|
| 36 | + $this->dir = dirname ( $file ); |
|
| 37 | 37 | $this->file = $file; |
| 38 | - $this->assets_dir = trailingslashit( $this->dir ) . 'assets'; |
|
| 39 | - $this->assets_url = esc_url( trailingslashit( plugins_url( '/assets/', $file ) ) ); |
|
| 40 | - $this->template_path = trailingslashit( $this->dir ) . 'templates/'; |
|
| 41 | - $this->template_url = esc_url( trailingslashit( plugins_url( '/templates/', $file ) ) ); |
|
| 42 | - $this->home_url = trailingslashit( home_url() ); |
|
| 43 | - $this->site_url = trailingslashit( site_url() ); |
|
| 38 | + $this->assets_dir = trailingslashit ( $this->dir ).'assets'; |
|
| 39 | + $this->assets_url = esc_url ( trailingslashit ( plugins_url ( '/assets/', $file ) ) ); |
|
| 40 | + $this->template_path = trailingslashit ( $this->dir ).'templates/'; |
|
| 41 | + $this->template_url = esc_url ( trailingslashit ( plugins_url ( '/templates/', $file ) ) ); |
|
| 42 | + $this->home_url = trailingslashit ( home_url () ); |
|
| 43 | + $this->site_url = trailingslashit ( site_url () ); |
|
| 44 | 44 | $this->token = 'podcast'; |
| 45 | 45 | |
| 46 | 46 | // Add meta data to start of podcast content |
| 47 | - $locations = get_option( 'ss_podcasting_player_locations', array() ); |
|
| 47 | + $locations = get_option ( 'ss_podcasting_player_locations', array() ); |
|
| 48 | 48 | |
| 49 | - if ( in_array( 'content', (array) $locations ) ) { |
|
| 50 | - add_filter( 'the_content', array( $this, 'content_meta_data' ), 10, 1 ); |
|
| 49 | + if ( in_array ( 'content', (array) $locations ) ) { |
|
| 50 | + add_filter ( 'the_content', array( $this, 'content_meta_data' ), 10, 1 ); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if ( in_array( 'excerpt', (array) $locations ) ) { |
|
| 54 | - add_filter( 'the_excerpt', array( $this, 'get_excerpt_meta_data' ), 10, 1 ); |
|
| 53 | + if ( in_array ( 'excerpt', (array) $locations ) ) { |
|
| 54 | + add_filter ( 'the_excerpt', array( $this, 'get_excerpt_meta_data' ), 10, 1 ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if ( in_array( 'excerpt_embed', (array) $locations ) ) { |
|
| 58 | - add_filter( 'the_excerpt_embed', array( $this, 'get_embed_meta_data' ), 10, 1 ); |
|
| 57 | + if ( in_array ( 'excerpt_embed', (array) $locations ) ) { |
|
| 58 | + add_filter ( 'the_excerpt_embed', array( $this, 'get_embed_meta_data' ), 10, 1 ); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Add SSP label and version to generator tags |
| 62 | - add_action( 'get_the_generator_html', array( $this, 'generator_tag' ), 10, 2 ); |
|
| 63 | - add_action( 'get_the_generator_xhtml', array( $this, 'generator_tag' ), 10, 2 ); |
|
| 62 | + add_action ( 'get_the_generator_html', array( $this, 'generator_tag' ), 10, 2 ); |
|
| 63 | + add_action ( 'get_the_generator_xhtml', array( $this, 'generator_tag' ), 10, 2 ); |
|
| 64 | 64 | |
| 65 | 65 | // Add RSS meta tag to site header |
| 66 | - add_action( 'wp_head' , array( $this, 'rss_meta_tag' ) ); |
|
| 66 | + add_action ( 'wp_head', array( $this, 'rss_meta_tag' ) ); |
|
| 67 | 67 | |
| 68 | 68 | // Add podcast episode to main query loop if setting is activated |
| 69 | - add_action( 'pre_get_posts' , array( $this, 'add_to_home_query' ) ); |
|
| 69 | + add_action ( 'pre_get_posts', array( $this, 'add_to_home_query' ) ); |
|
| 70 | 70 | |
| 71 | 71 | // Make sure to fetch all relevant post types when viewing series archive |
| 72 | - add_action( 'pre_get_posts' , array( $this, 'add_all_post_types' ) ); |
|
| 72 | + add_action ( 'pre_get_posts', array( $this, 'add_all_post_types' ) ); |
|
| 73 | 73 | |
| 74 | 74 | // Download podcast episode |
| 75 | - add_action( 'wp', array( $this, 'download_file' ), 1 ); |
|
| 75 | + add_action ( 'wp', array( $this, 'download_file' ), 1 ); |
|
| 76 | 76 | |
| 77 | 77 | // Register widgets |
| 78 | - add_action( 'widgets_init', array( $this, 'register_widgets' ), 1 ); |
|
| 78 | + add_action ( 'widgets_init', array( $this, 'register_widgets' ), 1 ); |
|
| 79 | 79 | |
| 80 | 80 | // Add shortcodes |
| 81 | - add_action( 'init', array( $this, 'register_shortcodes' ), 1 ); |
|
| 81 | + add_action ( 'init', array( $this, 'register_shortcodes' ), 1 ); |
|
| 82 | 82 | |
| 83 | - add_filter( 'feed_content_type', array( $this, 'feed_content_type' ), 10, 2 ); |
|
| 83 | + add_filter ( 'feed_content_type', array( $this, 'feed_content_type' ), 10, 2 ); |
|
| 84 | 84 | |
| 85 | 85 | // Handle localisation |
| 86 | - add_action( 'plugins_loaded', array( $this, 'load_localisation' ) ); |
|
| 86 | + add_action ( 'plugins_loaded', array( $this, 'load_localisation' ) ); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -94,36 +94,36 @@ discard block |
||
| 94 | 94 | public function get_episode_download_link( $episode_id, $referrer = '' ) { |
| 95 | 95 | |
| 96 | 96 | // Get file URL |
| 97 | - $file = $this->get_enclosure( $episode_id ); |
|
| 97 | + $file = $this->get_enclosure ( $episode_id ); |
|
| 98 | 98 | |
| 99 | 99 | if ( ! $file ) { |
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Get download link based on permalink structure |
| 104 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 105 | - $episode = get_post( $episode_id ); |
|
| 104 | + if ( get_option ( 'permalink_structure' ) ) { |
|
| 105 | + $episode = get_post ( $episode_id ); |
|
| 106 | 106 | |
| 107 | 107 | // Get file extension - default to MP3 to prevent empty extension strings |
| 108 | - $ext = pathinfo( $file, PATHINFO_EXTENSION ); |
|
| 109 | - if( ! $ext ) { |
|
| 108 | + $ext = pathinfo ( $file, PATHINFO_EXTENSION ); |
|
| 109 | + if ( ! $ext ) { |
|
| 110 | 110 | $ext = 'mp3'; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $link = $this->home_url . 'podcast-download/' . $episode_id . '/' . $episode->post_name . '.' . $ext; |
|
| 113 | + $link = $this->home_url.'podcast-download/'.$episode_id.'/'.$episode->post_name.'.'.$ext; |
|
| 114 | 114 | } else { |
| 115 | - $link = add_query_arg( array( 'podcast_episode' => $episode_id ), $this->home_url ); |
|
| 115 | + $link = add_query_arg ( array( 'podcast_episode' => $episode_id ), $this->home_url ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Allow for dyamic referrer |
| 119 | - $referrer = apply_filters( 'ssp_download_referrer', $referrer, $episode_id ); |
|
| 119 | + $referrer = apply_filters ( 'ssp_download_referrer', $referrer, $episode_id ); |
|
| 120 | 120 | |
| 121 | 121 | // Add referrer flag if supplied |
| 122 | 122 | if ( $referrer ) { |
| 123 | - $link = add_query_arg( array( 'ref' => $referrer ), $link ); |
|
| 123 | + $link = add_query_arg ( array( 'ref' => $referrer ), $link ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - return apply_filters( 'ssp_episode_download_link', esc_url( $link ), $episode_id, $file ); |
|
| 126 | + return apply_filters ( 'ssp_episode_download_link', esc_url ( $link ), $episode_id, $file ); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function get_episode_type( $episode_id = 0 ) { |
| 135 | 135 | |
| 136 | - if( ! $episode_id ) { |
|
| 136 | + if ( ! $episode_id ) { |
|
| 137 | 137 | return false; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $type = get_post_meta( $episode_id , 'episode_type' , true ); |
|
| 140 | + $type = get_post_meta ( $episode_id, 'episode_type', true ); |
|
| 141 | 141 | |
| 142 | - if( ! $type ) { |
|
| 142 | + if ( ! $type ) { |
|
| 143 | 143 | $type = 'audio'; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -155,39 +155,39 @@ discard block |
||
| 155 | 155 | global $post, $wp_current_filter, $episode_context; |
| 156 | 156 | |
| 157 | 157 | // Don't output unformatted data on excerpts |
| 158 | - if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) { |
|
| 158 | + if ( in_array ( 'get_the_excerpt', (array) $wp_current_filter ) ) { |
|
| 159 | 159 | return $content; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | // Don't output episode meta in shortcode or widget |
| 163 | - if ( isset( $episode_context ) && in_array( $episode_context, array( 'shortcode', 'widget' ) ) ) { |
|
| 163 | + if ( isset( $episode_context ) && in_array ( $episode_context, array( 'shortcode', 'widget' ) ) ) { |
|
| 164 | 164 | return $content; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if( post_password_required( $post->ID ) ) { |
|
| 167 | + if ( post_password_required ( $post->ID ) ) { |
|
| 168 | 168 | return $content; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $podcast_post_types = ssp_post_types( true ); |
|
| 171 | + $podcast_post_types = ssp_post_types ( true ); |
|
| 172 | 172 | |
| 173 | - $player_visibility = get_option( 'ss_podcasting_player_content_visibility' ); |
|
| 173 | + $player_visibility = get_option ( 'ss_podcasting_player_content_visibility' ); |
|
| 174 | 174 | |
| 175 | - switch( $player_visibility ) { |
|
| 175 | + switch ( $player_visibility ) { |
|
| 176 | 176 | case 'all': $player_visibility_bool = true; break; |
| 177 | - case 'membersonly': $player_visibility_bool = is_user_logged_in(); break; |
|
| 177 | + case 'membersonly': $player_visibility_bool = is_user_logged_in (); break; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if ( $player_visibility_bool && in_array( $post->post_type, $podcast_post_types ) && ! is_feed() && ! isset( $_GET['feed'] ) ) { |
|
| 180 | + if ( $player_visibility_bool && in_array ( $post->post_type, $podcast_post_types ) && ! is_feed () && ! isset( $_GET[ 'feed' ] ) ) { |
|
| 181 | 181 | |
| 182 | 182 | // Get episode meta data |
| 183 | - $meta = $this->episode_meta( $post->ID, 'content' ); |
|
| 183 | + $meta = $this->episode_meta ( $post->ID, 'content' ); |
|
| 184 | 184 | |
| 185 | 185 | // Get specified player position |
| 186 | - $player_position = get_option( 'ss_podcasting_player_content_location', 'above' ); |
|
| 186 | + $player_position = get_option ( 'ss_podcasting_player_content_location', 'above' ); |
|
| 187 | 187 | |
| 188 | - switch( $player_position ) { |
|
| 189 | - case 'above': $content = $meta . $content; break; |
|
| 190 | - case 'below': $content = $content . $meta; break; |
|
| 188 | + switch ( $player_position ) { |
|
| 189 | + case 'above': $content = $meta.$content; break; |
|
| 190 | + case 'below': $content = $content.$meta; break; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @return string Modified excerpt |
| 202 | 202 | */ |
| 203 | 203 | public function get_excerpt_meta_data( $excerpt = '' ) { |
| 204 | - return $this->excerpt_meta_data( $excerpt, 'excerpt' ); |
|
| 204 | + return $this->excerpt_meta_data ( $excerpt, 'excerpt' ); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * @return string Modified excerpt |
| 211 | 211 | */ |
| 212 | 212 | public function get_embed_meta_data( $excerpt = '' ) { |
| 213 | - return $this->excerpt_meta_data( $excerpt, 'embed' ); |
|
| 213 | + return $this->excerpt_meta_data ( $excerpt, 'embed' ); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -221,17 +221,17 @@ discard block |
||
| 221 | 221 | public function excerpt_meta_data( $excerpt = '', $content = 'excerpt' ) { |
| 222 | 222 | global $post; |
| 223 | 223 | |
| 224 | - if( post_password_required( $post->ID ) ) { |
|
| 224 | + if ( post_password_required ( $post->ID ) ) { |
|
| 225 | 225 | return $excerpt; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - $podcast_post_types = ssp_post_types( true ); |
|
| 228 | + $podcast_post_types = ssp_post_types ( true ); |
|
| 229 | 229 | |
| 230 | - if ( ( in_array( $post->post_type, $podcast_post_types ) ) && ! is_feed() ) { |
|
| 230 | + if ( ( in_array ( $post->post_type, $podcast_post_types ) ) && ! is_feed () ) { |
|
| 231 | 231 | |
| 232 | - $meta = $this->episode_meta( $post->ID, $content ); |
|
| 232 | + $meta = $this->episode_meta ( $post->ID, $content ); |
|
| 233 | 233 | |
| 234 | - $excerpt = $meta . $excerpt; |
|
| 234 | + $excerpt = $meta.$excerpt; |
|
| 235 | 235 | |
| 236 | 236 | } |
| 237 | 237 | |
@@ -252,34 +252,34 @@ discard block |
||
| 252 | 252 | return $meta; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - $file = $this->get_enclosure( $episode_id ); |
|
| 255 | + $file = $this->get_enclosure ( $episode_id ); |
|
| 256 | 256 | |
| 257 | 257 | if ( $file ) { |
| 258 | 258 | |
| 259 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 260 | - $file = $this->get_episode_download_link( $episode_id ); |
|
| 259 | + if ( get_option ( 'permalink_structure' ) ) { |
|
| 260 | + $file = $this->get_episode_download_link ( $episode_id ); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | // Hide audio player in `ss_podcast` shortcode by default |
| 264 | 264 | $show_player = true; |
| 265 | - if( 'shortcode' == $context ) { |
|
| 265 | + if ( 'shortcode' == $context ) { |
|
| 266 | 266 | $show_player = false; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // Allow media player to be dynamically hidden/displayed |
| 270 | - $show_player = apply_filters( 'ssp_show_media_player', $show_player, $context ); |
|
| 270 | + $show_player = apply_filters ( 'ssp_show_media_player', $show_player, $context ); |
|
| 271 | 271 | |
| 272 | 272 | // Show audio player if requested |
| 273 | - if( $show_player ) { |
|
| 274 | - $meta .= '<div class="podcast_player">' . $this->media_player( $file, $episode_id ) . '</div>'; |
|
| 273 | + if ( $show_player ) { |
|
| 274 | + $meta .= '<div class="podcast_player">'.$this->media_player ( $file, $episode_id ).'</div>'; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - if ( apply_filters( 'ssp_show_episode_details', true, $episode_id, $context ) ) { |
|
| 278 | - $meta .= $this->episode_meta_details( $episode_id, $context ); |
|
| 277 | + if ( apply_filters ( 'ssp_show_episode_details', true, $episode_id, $context ) ) { |
|
| 278 | + $meta .= $this->episode_meta_details ( $episode_id, $context ); |
|
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - $meta = apply_filters( 'ssp_episode_meta', $meta, $episode_id, $context ); |
|
| 282 | + $meta = apply_filters ( 'ssp_episode_meta', $meta, $episode_id, $context ); |
|
| 283 | 283 | |
| 284 | 284 | return $meta; |
| 285 | 285 | } |
@@ -290,36 +290,36 @@ discard block |
||
| 290 | 290 | * @param string $context Context for display |
| 291 | 291 | * @return string Episode meta details |
| 292 | 292 | */ |
| 293 | - public function episode_meta_details ( $episode_id = 0, $context = 'content' ) { |
|
| 293 | + public function episode_meta_details( $episode_id = 0, $context = 'content' ) { |
|
| 294 | 294 | |
| 295 | 295 | if ( ! $episode_id ) { |
| 296 | 296 | return; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - $file = $this->get_enclosure( $episode_id ); |
|
| 299 | + $file = $this->get_enclosure ( $episode_id ); |
|
| 300 | 300 | |
| 301 | 301 | if ( ! $file ) { |
| 302 | 302 | return; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - $link = $this->get_episode_download_link( $episode_id, 'download' ); |
|
| 306 | - $duration = get_post_meta( $episode_id , 'duration' , true ); |
|
| 307 | - $size = get_post_meta( $episode_id , 'filesize' , true ); |
|
| 305 | + $link = $this->get_episode_download_link ( $episode_id, 'download' ); |
|
| 306 | + $duration = get_post_meta ( $episode_id, 'duration', true ); |
|
| 307 | + $size = get_post_meta ( $episode_id, 'filesize', true ); |
|
| 308 | 308 | if ( ! $size ) { |
| 309 | - $size_data = $this->get_file_size( $file ); |
|
| 310 | - $size = $size_data['formatted']; |
|
| 309 | + $size_data = $this->get_file_size ( $file ); |
|
| 310 | + $size = $size_data[ 'formatted' ]; |
|
| 311 | 311 | if ( $size ) { |
| 312 | - if ( isset( $size_data['formatted'] ) ) { |
|
| 313 | - update_post_meta( $episode_id, 'filesize', $size_data['formatted'] ); |
|
| 312 | + if ( isset( $size_data[ 'formatted' ] ) ) { |
|
| 313 | + update_post_meta ( $episode_id, 'filesize', $size_data[ 'formatted' ] ); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if ( isset( $size_data['raw'] ) ) { |
|
| 317 | - update_post_meta( $episode_id, 'filesize_raw', $size_data['raw'] ); |
|
| 316 | + if ( isset( $size_data[ 'raw' ] ) ) { |
|
| 317 | + update_post_meta ( $episode_id, 'filesize_raw', $size_data[ 'raw' ] ); |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - $date_recorded = get_post_meta( $episode_id, 'date_recorded', true ); |
|
| 322 | + $date_recorded = get_post_meta ( $episode_id, 'date_recorded', true ); |
|
| 323 | 323 | |
| 324 | 324 | // Build up meta data array with default values |
| 325 | 325 | $meta = array( |
@@ -330,62 +330,62 @@ discard block |
||
| 330 | 330 | 'date_recorded' => '', |
| 331 | 331 | ); |
| 332 | 332 | |
| 333 | - if( $link ) { |
|
| 334 | - $meta['link'] = $link; |
|
| 333 | + if ( $link ) { |
|
| 334 | + $meta[ 'link' ] = $link; |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - if( $link && apply_filters( 'ssp_show_new_window_link', true, $context ) ) { |
|
| 338 | - $meta['new_window'] = true; |
|
| 337 | + if ( $link && apply_filters ( 'ssp_show_new_window_link', true, $context ) ) { |
|
| 338 | + $meta[ 'new_window' ] = true; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - if( $link ) { |
|
| 342 | - $meta['duration'] = $duration; |
|
| 341 | + if ( $link ) { |
|
| 342 | + $meta[ 'duration' ] = $duration; |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - if( $size ) { |
|
| 346 | - $meta['size'] = $size; |
|
| 345 | + if ( $size ) { |
|
| 346 | + $meta[ 'size' ] = $size; |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - if( $date_recorded ) { |
|
| 350 | - $meta['date_recorded'] = $date_recorded; |
|
| 349 | + if ( $date_recorded ) { |
|
| 350 | + $meta[ 'date_recorded' ] = $date_recorded; |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | // Allow dynamic filtering of meta data - to remove, add or reorder meta items |
| 354 | - $meta = apply_filters( 'ssp_episode_meta_details', $meta, $episode_id, $context ); |
|
| 354 | + $meta = apply_filters ( 'ssp_episode_meta_details', $meta, $episode_id, $context ); |
|
| 355 | 355 | |
| 356 | 356 | $meta_display = ''; |
| 357 | - $meta_sep = apply_filters( 'ssp_episode_meta_separator', ' | ' ); |
|
| 357 | + $meta_sep = apply_filters ( 'ssp_episode_meta_separator', ' | ' ); |
|
| 358 | 358 | foreach ( $meta as $key => $data ) { |
| 359 | 359 | |
| 360 | - if( ! $data ) { |
|
| 360 | + if ( ! $data ) { |
|
| 361 | 361 | continue; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - if( $meta_display ) { |
|
| 364 | + if ( $meta_display ) { |
|
| 365 | 365 | $meta_display .= $meta_sep; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - switch( $key ) { |
|
| 368 | + switch ( $key ) { |
|
| 369 | 369 | |
| 370 | 370 | case 'link': |
| 371 | - $meta_display .= '<a href="' . esc_url( $data ) . '" title="' . get_the_title() . ' " class="podcast-meta-download" download>' . __( 'Download file' , 'seriously-simple-podcasting' ) . '</a>'; |
|
| 371 | + $meta_display .= '<a href="'.esc_url ( $data ).'" title="'.get_the_title ().' " class="podcast-meta-download" download>'.__ ( 'Download file', 'seriously-simple-podcasting' ).'</a>'; |
|
| 372 | 372 | break; |
| 373 | 373 | |
| 374 | 374 | case 'new_window': |
| 375 | - $play_link = add_query_arg( 'ref', 'new_window', $link ); |
|
| 376 | - $meta_display .= '<a href="' . esc_url( $play_link ) . '" target="_blank" title="' . get_the_title() . ' " class="podcast-meta-new-window">' . __( 'Play in new window' , 'seriously-simple-podcasting' ) . '</a>'; |
|
| 375 | + $play_link = add_query_arg ( 'ref', 'new_window', $link ); |
|
| 376 | + $meta_display .= '<a href="'.esc_url ( $play_link ).'" target="_blank" title="'.get_the_title ().' " class="podcast-meta-new-window">'.__ ( 'Play in new window', 'seriously-simple-podcasting' ).'</a>'; |
|
| 377 | 377 | break; |
| 378 | 378 | |
| 379 | 379 | case 'duration': |
| 380 | - $meta_display .= '<span class="podcast-meta-duration">' . __( 'Duration' , 'seriously-simple-podcasting' ) . ': ' . $data . '</span>'; |
|
| 380 | + $meta_display .= '<span class="podcast-meta-duration">'.__ ( 'Duration', 'seriously-simple-podcasting' ).': '.$data.'</span>'; |
|
| 381 | 381 | break; |
| 382 | 382 | |
| 383 | 383 | case 'size': |
| 384 | - $meta_display .= '<span class="podcast-meta-size">' . __( 'Size' , 'seriously-simple-podcasting' ) . ': ' . $data . '</span>'; |
|
| 384 | + $meta_display .= '<span class="podcast-meta-size">'.__ ( 'Size', 'seriously-simple-podcasting' ).': '.$data.'</span>'; |
|
| 385 | 385 | break; |
| 386 | 386 | |
| 387 | 387 | case 'date_recorded': |
| 388 | - $meta_display .= '<span class="podcast-meta-date">' . __( 'Recorded on' , 'seriously-simple-podcasting' ) . ' ' . date_i18n( get_option( 'date_format' ), strtotime( $data ) ) . '</span>'; |
|
| 388 | + $meta_display .= '<span class="podcast-meta-date">'.__ ( 'Recorded on', 'seriously-simple-podcasting' ).' '.date_i18n ( get_option ( 'date_format' ), strtotime ( $data ) ).'</span>'; |
|
| 389 | 389 | break; |
| 390 | 390 | |
| 391 | 391 | // Allow for custom items to be added, but only allow a small amount of HTML tags |
@@ -401,13 +401,13 @@ discard block |
||
| 401 | 401 | 'target' => array(), |
| 402 | 402 | ), |
| 403 | 403 | ); |
| 404 | - $meta_display .= wp_kses( $data, $allowed_tags ); |
|
| 404 | + $meta_display .= wp_kses ( $data, $allowed_tags ); |
|
| 405 | 405 | break; |
| 406 | 406 | |
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - $meta_display = '<div class="podcast_meta"><aside>' . $meta_display . '</aside></div>'; |
|
| 410 | + $meta_display = '<div class="podcast_meta"><aside>'.$meta_display.'</aside></div>'; |
|
| 411 | 411 | |
| 412 | 412 | return $meta_display; |
| 413 | 413 | |
@@ -419,43 +419,43 @@ discard block |
||
| 419 | 419 | */ |
| 420 | 420 | public function add_to_home_query( $query ) { |
| 421 | 421 | |
| 422 | - if ( is_admin() ) { |
|
| 422 | + if ( is_admin () ) { |
|
| 423 | 423 | return; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - $include_in_main_query = get_option('ss_podcasting_include_in_main_query'); |
|
| 426 | + $include_in_main_query = get_option ( 'ss_podcasting_include_in_main_query' ); |
|
| 427 | 427 | if ( $include_in_main_query && $include_in_main_query == 'on' ) { |
| 428 | - if ( $query->is_home() && $query->is_main_query() ) { |
|
| 429 | - $query->set( 'post_type', array( 'post', 'podcast' ) ); |
|
| 428 | + if ( $query->is_home () && $query->is_main_query () ) { |
|
| 429 | + $query->set ( 'post_type', array( 'post', 'podcast' ) ); |
|
| 430 | 430 | } |
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - public function add_all_post_types ( $query ) { |
|
| 434 | + public function add_all_post_types( $query ) { |
|
| 435 | 435 | |
| 436 | - if ( is_admin() ) { |
|
| 436 | + if ( is_admin () ) { |
|
| 437 | 437 | return; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - if ( ! $query->is_main_query() ) { |
|
| 440 | + if ( ! $query->is_main_query () ) { |
|
| 441 | 441 | return; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if ( is_post_type_archive( 'podcast' ) || is_tax( 'series' ) ) { |
|
| 444 | + if ( is_post_type_archive ( 'podcast' ) || is_tax ( 'series' ) ) { |
|
| 445 | 445 | |
| 446 | - $podcast_post_types = ssp_post_types( false ); |
|
| 446 | + $podcast_post_types = ssp_post_types ( false ); |
|
| 447 | 447 | |
| 448 | 448 | if ( empty( $podcast_post_types ) ) { |
| 449 | 449 | return; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - $episode_ids = ssp_episode_ids(); |
|
| 452 | + $episode_ids = ssp_episode_ids (); |
|
| 453 | 453 | if ( ! empty( $episode_ids ) ) { |
| 454 | 454 | |
| 455 | - $query->set( 'post__in', $episode_ids ); |
|
| 455 | + $query->set ( 'post__in', $episode_ids ); |
|
| 456 | 456 | |
| 457 | - $podcast_post_types[] = 'podcast'; |
|
| 458 | - $query->set( 'post_type', $podcast_post_types ); |
|
| 457 | + $podcast_post_types[ ] = 'podcast'; |
|
| 458 | + $query->set ( 'post_type', $podcast_post_types ); |
|
| 459 | 459 | |
| 460 | 460 | } |
| 461 | 461 | |
@@ -473,29 +473,29 @@ discard block |
||
| 473 | 473 | if ( $file ) { |
| 474 | 474 | |
| 475 | 475 | // Include media functions if necessary |
| 476 | - if ( ! function_exists( 'wp_read_audio_metadata' ) ) { |
|
| 477 | - require_once( ABSPATH . 'wp-admin/includes/media.php' ); |
|
| 476 | + if ( ! function_exists ( 'wp_read_audio_metadata' ) ) { |
|
| 477 | + require_once( ABSPATH.'wp-admin/includes/media.php' ); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | // translate file URL to local file path if possible |
| 481 | - $file = $this->get_local_file_path( $file ); |
|
| 481 | + $file = $this->get_local_file_path ( $file ); |
|
| 482 | 482 | |
| 483 | 483 | // Get file data (for local file) |
| 484 | - $data = wp_read_audio_metadata( $file ); |
|
| 484 | + $data = wp_read_audio_metadata ( $file ); |
|
| 485 | 485 | |
| 486 | 486 | $raw = $formatted = ''; |
| 487 | 487 | |
| 488 | 488 | if ( $data ) { |
| 489 | - $raw = $data['filesize']; |
|
| 490 | - $formatted = $this->format_bytes( $raw ); |
|
| 489 | + $raw = $data[ 'filesize' ]; |
|
| 490 | + $formatted = $this->format_bytes ( $raw ); |
|
| 491 | 491 | } else { |
| 492 | 492 | |
| 493 | 493 | // get file data (for remote file) |
| 494 | - $data = wp_remote_head( $file, array( 'timeout' => 10, 'redirection' => 5 ) ); |
|
| 494 | + $data = wp_remote_head ( $file, array( 'timeout' => 10, 'redirection' => 5 ) ); |
|
| 495 | 495 | |
| 496 | - if ( ! is_wp_error( $data ) && is_array( $data ) && isset( $data['headers']['content-length'] ) ) { |
|
| 497 | - $raw = $data['headers']['content-length']; |
|
| 498 | - $formatted = $this->format_bytes( $raw ); |
|
| 496 | + if ( ! is_wp_error ( $data ) && is_array ( $data ) && isset( $data[ 'headers' ][ 'content-length' ] ) ) { |
|
| 497 | + $raw = $data[ 'headers' ][ 'content-length' ]; |
|
| 498 | + $formatted = $this->format_bytes ( $raw ); |
|
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | 'formatted' => $formatted |
| 507 | 507 | ); |
| 508 | 508 | |
| 509 | - return apply_filters( 'ssp_file_size', $size, $file ); |
|
| 509 | + return apply_filters ( 'ssp_file_size', $size, $file ); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | } |
@@ -524,30 +524,30 @@ discard block |
||
| 524 | 524 | if ( $file ) { |
| 525 | 525 | |
| 526 | 526 | // Include media functions if necessary |
| 527 | - if ( ! function_exists( 'wp_read_audio_metadata' ) ) { |
|
| 528 | - require_once( ABSPATH . 'wp-admin/includes/media.php' ); |
|
| 527 | + if ( ! function_exists ( 'wp_read_audio_metadata' ) ) { |
|
| 528 | + require_once( ABSPATH.'wp-admin/includes/media.php' ); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | // translate file URL to local file path if possible |
| 532 | - $file = $this->get_local_file_path( $file ); |
|
| 532 | + $file = $this->get_local_file_path ( $file ); |
|
| 533 | 533 | |
| 534 | 534 | // Get file data (will only work for local files) |
| 535 | - $data = wp_read_audio_metadata( $file ); |
|
| 535 | + $data = wp_read_audio_metadata ( $file ); |
|
| 536 | 536 | |
| 537 | 537 | $duration = false; |
| 538 | 538 | |
| 539 | 539 | if ( $data ) { |
| 540 | - if ( isset( $data['length_formatted'] ) && strlen( $data['length_formatted'] ) > 0 ) { |
|
| 541 | - $duration = $data['length_formatted']; |
|
| 540 | + if ( isset( $data[ 'length_formatted' ] ) && strlen ( $data[ 'length_formatted' ] ) > 0 ) { |
|
| 541 | + $duration = $data[ 'length_formatted' ]; |
|
| 542 | 542 | } else { |
| 543 | - if ( isset( $data['length'] ) && strlen( $data['length'] ) > 0 ) { |
|
| 544 | - $duration = gmdate( 'H:i:s', $data['length'] ); |
|
| 543 | + if ( isset( $data[ 'length' ] ) && strlen ( $data[ 'length' ] ) > 0 ) { |
|
| 544 | + $duration = gmdate ( 'H:i:s', $data[ 'length' ] ); |
|
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | if ( $data ) { |
| 550 | - return apply_filters( 'ssp_file_duration', $duration, $file ); |
|
| 550 | + return apply_filters ( 'ssp_file_duration', $duration, $file ); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | } |
@@ -561,15 +561,15 @@ discard block |
||
| 561 | 561 | * @param integer $precision Level of precision for formatting |
| 562 | 562 | * @return mixed Formatted file size on success, false on failure |
| 563 | 563 | */ |
| 564 | - protected function format_bytes( $size , $precision = 2 ) { |
|
| 564 | + protected function format_bytes( $size, $precision = 2 ) { |
|
| 565 | 565 | |
| 566 | 566 | if ( $size ) { |
| 567 | 567 | |
| 568 | - $base = log ( $size ) / log( 1024 ); |
|
| 569 | - $suffixes = array( '' , 'k' , 'M' , 'G' , 'T' ); |
|
| 570 | - $formatted_size = round( pow( 1024 , $base - floor( $base ) ) , $precision ) . $suffixes[ floor( $base ) ]; |
|
| 568 | + $base = log ( $size ) / log ( 1024 ); |
|
| 569 | + $suffixes = array( '', 'k', 'M', 'G', 'T' ); |
|
| 570 | + $formatted_size = round ( pow ( 1024, $base - floor ( $base ) ), $precision ).$suffixes[ floor ( $base ) ]; |
|
| 571 | 571 | |
| 572 | - return apply_filters( 'ssp_file_size_formatted', $formatted_size, $size ); |
|
| 572 | + return apply_filters ( 'ssp_file_size_formatted', $formatted_size, $size ); |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | return false; |
@@ -585,10 +585,10 @@ discard block |
||
| 585 | 585 | |
| 586 | 586 | // Let's hash the URL to ensure that we don't get |
| 587 | 587 | // any illegal chars that might break the cache. |
| 588 | - $key = md5( $url ); |
|
| 588 | + $key = md5 ( $url ); |
|
| 589 | 589 | |
| 590 | 590 | // Do we have anything in the cache for this URL? |
| 591 | - $attachment_id = wp_cache_get( $key, 'attachment_id' ); |
|
| 591 | + $attachment_id = wp_cache_get ( $key, 'attachment_id' ); |
|
| 592 | 592 | |
| 593 | 593 | if ( $attachment_id === false ) { |
| 594 | 594 | |
@@ -605,39 +605,39 @@ discard block |
||
| 605 | 605 | |
| 606 | 606 | |
| 607 | 607 | // Function introduced in 4.0, let's try this first. |
| 608 | - if ( function_exists( 'attachment_url_to_postid' ) ) { |
|
| 609 | - $attachment_id = absint( attachment_url_to_postid( $url ) ); |
|
| 608 | + if ( function_exists ( 'attachment_url_to_postid' ) ) { |
|
| 609 | + $attachment_id = absint ( attachment_url_to_postid ( $url ) ); |
|
| 610 | 610 | if ( 0 !== $attachment_id ) { |
| 611 | - wp_cache_set( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
| 611 | + wp_cache_set ( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
| 612 | 612 | return $attachment_id; |
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | // Then this. |
| 617 | - if ( preg_match( '#\.[a-zA-Z0-9]+$#', $url ) ) { |
|
| 618 | - $sql = $wpdb->prepare( |
|
| 617 | + if ( preg_match ( '#\.[a-zA-Z0-9]+$#', $url ) ) { |
|
| 618 | + $sql = $wpdb->prepare ( |
|
| 619 | 619 | "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND guid = %s", |
| 620 | - esc_url_raw( $url ) |
|
| 620 | + esc_url_raw ( $url ) |
|
| 621 | 621 | ); |
| 622 | - $attachment_id = absint( $wpdb->get_var( $sql ) ); |
|
| 622 | + $attachment_id = absint ( $wpdb->get_var ( $sql ) ); |
|
| 623 | 623 | if ( 0 !== $attachment_id ) { |
| 624 | - wp_cache_set( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
| 624 | + wp_cache_set ( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
| 625 | 625 | return $attachment_id; |
| 626 | 626 | } |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | // And then try this |
| 630 | - $upload_dir_paths = wp_upload_dir(); |
|
| 631 | - if ( false !== strpos( $url, $upload_dir_paths['baseurl'] ) ) { |
|
| 630 | + $upload_dir_paths = wp_upload_dir (); |
|
| 631 | + if ( false !== strpos ( $url, $upload_dir_paths[ 'baseurl' ] ) ) { |
|
| 632 | 632 | // Ensure that we have file extension that matches iTunes. |
| 633 | - $url = preg_replace( '/(?=\.(m4a|mp3|mov|mp4)$)/i', '', $url ); |
|
| 633 | + $url = preg_replace ( '/(?=\.(m4a|mp3|mov|mp4)$)/i', '', $url ); |
|
| 634 | 634 | // Remove the upload path base directory from the attachment URL |
| 635 | - $url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $url ); |
|
| 635 | + $url = str_replace ( $upload_dir_paths[ 'baseurl' ].'/', '', $url ); |
|
| 636 | 636 | // Finally, run a custom database query to get the attachment ID from the modified attachment URL |
| 637 | - $sql = $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = 'attachment'", $url ); |
|
| 638 | - $attachment_id = absint( $wpdb->get_var( $sql ) ); |
|
| 637 | + $sql = $wpdb->prepare ( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = 'attachment'", $url ); |
|
| 638 | + $attachment_id = absint ( $wpdb->get_var ( $sql ) ); |
|
| 639 | 639 | if ( 0 !== $attachment_id ) { |
| 640 | - wp_cache_set( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
| 640 | + wp_cache_set ( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
| 641 | 641 | return $attachment_id; |
| 642 | 642 | } |
| 643 | 643 | } |
@@ -655,20 +655,20 @@ discard block |
||
| 655 | 655 | public function get_attachment_mimetype( $attachment = '' ) { |
| 656 | 656 | |
| 657 | 657 | // Let's hash the URL to ensure that we don't get any illegal chars that might break the cache. |
| 658 | - $key = md5( $attachment ); |
|
| 658 | + $key = md5 ( $attachment ); |
|
| 659 | 659 | |
| 660 | 660 | if ( $attachment ) { |
| 661 | 661 | // Do we have anything in the cache for this? |
| 662 | - $mime = wp_cache_get( $key, 'mime-type' ); |
|
| 662 | + $mime = wp_cache_get ( $key, 'mime-type' ); |
|
| 663 | 663 | if ( $mime === false ) { |
| 664 | 664 | |
| 665 | 665 | // Get the ID |
| 666 | - $id = $this->get_attachment_id_from_url( $attachment ); |
|
| 666 | + $id = $this->get_attachment_id_from_url ( $attachment ); |
|
| 667 | 667 | |
| 668 | 668 | // Get the MIME type |
| 669 | - $mime = get_post_mime_type( $id ); |
|
| 669 | + $mime = get_post_mime_type ( $id ); |
|
| 670 | 670 | // Set the cache |
| 671 | - wp_cache_set( $key, $mime, 'mime-type', DAY_IN_SECONDS ); |
|
| 671 | + wp_cache_set ( $key, $mime, 'mime-type', DAY_IN_SECONDS ); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | return $mime; |
@@ -685,8 +685,8 @@ discard block |
||
| 685 | 685 | * @return string Audio player HTML on success, false on failure |
| 686 | 686 | */ |
| 687 | 687 | public function audio_player( $src = '', $episode_id = 0 ) { |
| 688 | - $player = $this->media_player( $src, $episode_id ); |
|
| 689 | - return apply_filters( 'ssp_audio_player', $player, $src, $episode_id ); |
|
| 688 | + $player = $this->media_player ( $src, $episode_id ); |
|
| 689 | + return apply_filters ( 'ssp_audio_player', $player, $src, $episode_id ); |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | /** |
@@ -695,40 +695,40 @@ discard block |
||
| 695 | 695 | * @param integer $episode_id Episode ID for audio file |
| 696 | 696 | * @return string Media player HTML on success, empty string on failure |
| 697 | 697 | */ |
| 698 | - public function media_player ( $src = '', $episode_id = 0 ) { |
|
| 698 | + public function media_player( $src = '', $episode_id = 0 ) { |
|
| 699 | 699 | $player = ''; |
| 700 | 700 | |
| 701 | 701 | if ( $src ) { |
| 702 | 702 | |
| 703 | 703 | // Get episode type and default to audio |
| 704 | - $type = $this->get_episode_type( $episode_id ); |
|
| 705 | - if( ! $type ) { |
|
| 704 | + $type = $this->get_episode_type ( $episode_id ); |
|
| 705 | + if ( ! $type ) { |
|
| 706 | 706 | $type = 'audio'; |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | // Switch to podcast player URL |
| 710 | - $src = str_replace( 'podcast-download', 'podcast-player', $src ); |
|
| 710 | + $src = str_replace ( 'podcast-download', 'podcast-player', $src ); |
|
| 711 | 711 | |
| 712 | 712 | // Set up paramters for media player |
| 713 | 713 | $params = array( 'src' => $src, 'preload' => 'none' ); |
| 714 | 714 | |
| 715 | 715 | // Use built-in WordPress media player |
| 716 | - switch( $type ) { |
|
| 717 | - case 'audio': $player = wp_audio_shortcode( $params ); break; |
|
| 716 | + switch ( $type ) { |
|
| 717 | + case 'audio': $player = wp_audio_shortcode ( $params ); break; |
|
| 718 | 718 | case 'video': |
| 719 | 719 | // Use featured image as video poster |
| 720 | - if( $episode_id && has_post_thumbnail( $episode_id ) ) { |
|
| 721 | - $poster = wp_get_attachment_url( get_post_thumbnail_id( $episode_id ) ); |
|
| 722 | - if( $poster ) { |
|
| 723 | - $params['poster'] = $poster; |
|
| 720 | + if ( $episode_id && has_post_thumbnail ( $episode_id ) ) { |
|
| 721 | + $poster = wp_get_attachment_url ( get_post_thumbnail_id ( $episode_id ) ); |
|
| 722 | + if ( $poster ) { |
|
| 723 | + $params[ 'poster' ] = $poster; |
|
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | - $player = wp_video_shortcode( $params ); |
|
| 726 | + $player = wp_video_shortcode ( $params ); |
|
| 727 | 727 | break; |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | // Allow filtering so that alternative players can be used |
| 731 | - $player = apply_filters( 'ssp_media_player', $player, $src, $episode_id ); |
|
| 731 | + $player = apply_filters ( 'ssp_media_player', $player, $src, $episode_id ); |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | return $player; |
@@ -743,17 +743,17 @@ discard block |
||
| 743 | 743 | public function get_image( $id = 0, $size = 'full' ) { |
| 744 | 744 | $image = ''; |
| 745 | 745 | |
| 746 | - if ( has_post_thumbnail( $id ) ) { |
|
| 746 | + if ( has_post_thumbnail ( $id ) ) { |
|
| 747 | 747 | // If not a string or an array, and not an integer, default to 200x9999. |
| 748 | - if ( is_int( $size ) || ( 0 < intval( $size ) ) ) { |
|
| 749 | - $size = array( intval( $size ), intval( $size ) ); |
|
| 750 | - } elseif ( ! is_string( $size ) && ! is_array( $size ) ) { |
|
| 748 | + if ( is_int ( $size ) || ( 0 < intval ( $size ) ) ) { |
|
| 749 | + $size = array( intval ( $size ), intval ( $size ) ); |
|
| 750 | + } elseif ( ! is_string ( $size ) && ! is_array ( $size ) ) { |
|
| 751 | 751 | $size = array( 200, 9999 ); |
| 752 | 752 | } |
| 753 | - $image = get_the_post_thumbnail( intval( $id ), $size ); |
|
| 753 | + $image = get_the_post_thumbnail ( intval ( $id ), $size ); |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | - return apply_filters( 'ssp_episode_image', $image, $id ); |
|
| 756 | + return apply_filters ( 'ssp_episode_image', $image, $id ); |
|
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | /** |
@@ -768,29 +768,29 @@ discard block |
||
| 768 | 768 | 'series' => '' |
| 769 | 769 | ); |
| 770 | 770 | |
| 771 | - $args = apply_filters( 'ssp_get_podcast_args', wp_parse_args( $args, $defaults ) ); |
|
| 771 | + $args = apply_filters ( 'ssp_get_podcast_args', wp_parse_args ( $args, $defaults ) ); |
|
| 772 | 772 | |
| 773 | 773 | $query = array(); |
| 774 | 774 | |
| 775 | - if ( 'episodes' == $args['content'] ) { |
|
| 775 | + if ( 'episodes' == $args[ 'content' ] ) { |
|
| 776 | 776 | |
| 777 | 777 | // Get selected series |
| 778 | 778 | $podcast_series = ''; |
| 779 | - if ( isset( $args['series'] ) && $args['series'] ) { |
|
| 780 | - $podcast_series = $args['series']; |
|
| 779 | + if ( isset( $args[ 'series' ] ) && $args[ 'series' ] ) { |
|
| 780 | + $podcast_series = $args[ 'series' ]; |
|
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | // Get query args |
| 784 | - $query_args = apply_filters( 'ssp_get_podcast_query_args', ssp_episodes( -1, $podcast_series, true, '' ) ); |
|
| 784 | + $query_args = apply_filters ( 'ssp_get_podcast_query_args', ssp_episodes ( -1, $podcast_series, true, '' ) ); |
|
| 785 | 785 | |
| 786 | 786 | // The Query |
| 787 | - $query = get_posts( $query_args ); |
|
| 787 | + $query = get_posts ( $query_args ); |
|
| 788 | 788 | |
| 789 | 789 | // The Display |
| 790 | - if ( ! is_wp_error( $query ) && is_array( $query ) && count( $query ) > 0 ) { |
|
| 790 | + if ( ! is_wp_error ( $query ) && is_array ( $query ) && count ( $query ) > 0 ) { |
|
| 791 | 791 | foreach ( $query as $k => $v ) { |
| 792 | 792 | // Get the URL |
| 793 | - $query[$k]->url = get_permalink( $v->ID ); |
|
| 793 | + $query[ $k ]->url = get_permalink ( $v->ID ); |
|
| 794 | 794 | } |
| 795 | 795 | } else { |
| 796 | 796 | $query = false; |
@@ -798,27 +798,27 @@ discard block |
||
| 798 | 798 | |
| 799 | 799 | } else { |
| 800 | 800 | |
| 801 | - $terms = get_terms( 'series' ); |
|
| 801 | + $terms = get_terms ( 'series' ); |
|
| 802 | 802 | |
| 803 | - if ( count( $terms ) > 0) { |
|
| 803 | + if ( count ( $terms ) > 0 ) { |
|
| 804 | 804 | |
| 805 | 805 | foreach ( $terms as $term ) { |
| 806 | - $query[ $term->term_id ] = new stdClass(); |
|
| 806 | + $query[ $term->term_id ] = new stdClass (); |
|
| 807 | 807 | $query[ $term->term_id ]->title = $term->name; |
| 808 | - $query[ $term->term_id ]->url = get_term_link( $term ); |
|
| 808 | + $query[ $term->term_id ]->url = get_term_link ( $term ); |
|
| 809 | 809 | |
| 810 | - $query_args = apply_filters( 'ssp_get_podcast_series_query_args', ssp_episodes( -1, $term->slug, true, '' ) ); |
|
| 810 | + $query_args = apply_filters ( 'ssp_get_podcast_series_query_args', ssp_episodes ( -1, $term->slug, true, '' ) ); |
|
| 811 | 811 | |
| 812 | - $posts = get_posts( $query_args ); |
|
| 812 | + $posts = get_posts ( $query_args ); |
|
| 813 | 813 | |
| 814 | - $count = count( $posts ); |
|
| 814 | + $count = count ( $posts ); |
|
| 815 | 815 | $query[ $term->term_id ]->count = $count; |
| 816 | 816 | } |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | - $query['content'] = $args['content']; |
|
| 821 | + $query[ 'content' ] = $args[ 'content' ]; |
|
| 822 | 822 | |
| 823 | 823 | return $query; |
| 824 | 824 | } |
@@ -831,7 +831,7 @@ discard block |
||
| 831 | 831 | public function get_enclosure( $episode_id = 0 ) { |
| 832 | 832 | |
| 833 | 833 | if ( $episode_id ) { |
| 834 | - return apply_filters( 'ssp_episode_enclosure', get_post_meta( $episode_id, 'audio_file', true ), $episode_id ); |
|
| 834 | + return apply_filters ( 'ssp_episode_enclosure', get_post_meta ( $episode_id, 'audio_file', true ), $episode_id ); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | return ''; |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | |
| 850 | 850 | if ( $file != '' ) { |
| 851 | 851 | |
| 852 | - $post_types = ssp_post_types( true ); |
|
| 852 | + $post_types = ssp_post_types ( true ); |
|
| 853 | 853 | |
| 854 | 854 | $args = array( |
| 855 | 855 | 'post_type' => $post_types, |
@@ -859,17 +859,17 @@ discard block |
||
| 859 | 859 | 'meta_value' => $file |
| 860 | 860 | ); |
| 861 | 861 | |
| 862 | - $qry = new WP_Query( $args ); |
|
| 862 | + $qry = new WP_Query ( $args ); |
|
| 863 | 863 | |
| 864 | - if ( $qry->have_posts() ) { |
|
| 865 | - while ( $qry->have_posts() ) { $qry->the_post(); |
|
| 864 | + if ( $qry->have_posts () ) { |
|
| 865 | + while ( $qry->have_posts () ) { $qry->the_post (); |
|
| 866 | 866 | $episode = $post; |
| 867 | 867 | break; |
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | - return apply_filters( 'ssp_episode_from_file', $episode, $file ); |
|
| 872 | + return apply_filters ( 'ssp_episode_from_file', $episode, $file ); |
|
| 873 | 873 | |
| 874 | 874 | } |
| 875 | 875 | |
@@ -879,33 +879,33 @@ discard block |
||
| 879 | 879 | */ |
| 880 | 880 | public function download_file() { |
| 881 | 881 | |
| 882 | - if ( is_podcast_download() ) { |
|
| 882 | + if ( is_podcast_download () ) { |
|
| 883 | 883 | global $wp_query; |
| 884 | 884 | |
| 885 | 885 | // Get requested episode ID |
| 886 | - $episode_id = intval( $wp_query->query_vars['podcast_episode'] ); |
|
| 886 | + $episode_id = intval ( $wp_query->query_vars[ 'podcast_episode' ] ); |
|
| 887 | 887 | |
| 888 | 888 | if ( isset( $episode_id ) && $episode_id ) { |
| 889 | 889 | |
| 890 | 890 | // Get episode post object |
| 891 | - $episode = get_post( $episode_id ); |
|
| 891 | + $episode = get_post ( $episode_id ); |
|
| 892 | 892 | |
| 893 | 893 | // Make sure we have a valid episode post object |
| 894 | - if ( ! $episode || ! is_object( $episode ) || is_wp_error( $episode ) || ! isset( $episode->ID ) ) { |
|
| 894 | + if ( ! $episode || ! is_object ( $episode ) || is_wp_error ( $episode ) || ! isset( $episode->ID ) ) { |
|
| 895 | 895 | return; |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | 898 | // Do we have newlines? |
| 899 | 899 | $parts = false; |
| 900 | - if( is_string( $episode ) ) { |
|
| 901 | - $parts = explode( "\n", $episode ); |
|
| 900 | + if ( is_string ( $episode ) ) { |
|
| 901 | + $parts = explode ( "\n", $episode ); |
|
| 902 | 902 | } |
| 903 | 903 | |
| 904 | - if ( $parts && is_array( $parts ) && count( $parts ) > 1 ) { |
|
| 905 | - $file = $parts[0]; |
|
| 904 | + if ( $parts && is_array ( $parts ) && count ( $parts ) > 1 ) { |
|
| 905 | + $file = $parts[ 0 ]; |
|
| 906 | 906 | } else { |
| 907 | 907 | // Get audio file for download |
| 908 | - $file = $this->get_enclosure( $episode_id ); |
|
| 908 | + $file = $this->get_enclosure ( $episode_id ); |
|
| 909 | 909 | } |
| 910 | 910 | |
| 911 | 911 | // Exit if no file is found |
@@ -915,77 +915,77 @@ discard block |
||
| 915 | 915 | |
| 916 | 916 | // Get file referrer |
| 917 | 917 | $referrer = ''; |
| 918 | - if( isset( $wp_query->query_vars['podcast_ref'] ) && $wp_query->query_vars['podcast_ref'] ) { |
|
| 919 | - $referrer = $wp_query->query_vars['podcast_ref']; |
|
| 918 | + if ( isset( $wp_query->query_vars[ 'podcast_ref' ] ) && $wp_query->query_vars[ 'podcast_ref' ] ) { |
|
| 919 | + $referrer = $wp_query->query_vars[ 'podcast_ref' ]; |
|
| 920 | 920 | } else { |
| 921 | - if( isset( $_GET['ref'] ) ) { |
|
| 922 | - $referrer = esc_attr( $_GET['ref'] ); |
|
| 921 | + if ( isset( $_GET[ 'ref' ] ) ) { |
|
| 922 | + $referrer = esc_attr ( $_GET[ 'ref' ] ); |
|
| 923 | 923 | } |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | // Allow other actions - functions hooked on here must not output any data |
| 927 | - do_action( 'ssp_file_download', $file, $episode, $referrer ); |
|
| 927 | + do_action ( 'ssp_file_download', $file, $episode, $referrer ); |
|
| 928 | 928 | |
| 929 | 929 | // Set necessary headers |
| 930 | - header( "Pragma: no-cache" ); |
|
| 931 | - header( "Expires: 0" ); |
|
| 932 | - header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); |
|
| 933 | - header( "Robots: none" ); |
|
| 930 | + header ( "Pragma: no-cache" ); |
|
| 931 | + header ( "Expires: 0" ); |
|
| 932 | + header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); |
|
| 933 | + header ( "Robots: none" ); |
|
| 934 | 934 | |
| 935 | 935 | // Check file referrer |
| 936 | - if( 'download' == $referrer ) { |
|
| 936 | + if ( 'download' == $referrer ) { |
|
| 937 | 937 | |
| 938 | 938 | // Set size of file |
| 939 | 939 | // Do we have anything in Cache/DB? |
| 940 | - $size = wp_cache_get( $episode_id, 'filesize_raw' ); |
|
| 940 | + $size = wp_cache_get ( $episode_id, 'filesize_raw' ); |
|
| 941 | 941 | |
| 942 | 942 | // Nothing in the cache, let's see if we can figure it out. |
| 943 | 943 | if ( false === $size ) { |
| 944 | 944 | |
| 945 | 945 | // Do we have anything in post_meta? |
| 946 | - $size = get_post_meta( $episode_id, 'filesize_raw', true ); |
|
| 946 | + $size = get_post_meta ( $episode_id, 'filesize_raw', true ); |
|
| 947 | 947 | |
| 948 | 948 | if ( empty( $size ) ) { |
| 949 | 949 | |
| 950 | 950 | // Let's see if we can figure out the path... |
| 951 | - $attachment_id = $this->get_attachment_id_from_url( $file ); |
|
| 951 | + $attachment_id = $this->get_attachment_id_from_url ( $file ); |
|
| 952 | 952 | |
| 953 | - if ( ! empty( $attachment_id ) ) { |
|
| 954 | - $size = filesize( get_attached_file( $attachment_id ) ); |
|
| 955 | - update_post_meta( $episode_id, 'filesize_raw', $size ); |
|
| 953 | + if ( ! empty( $attachment_id ) ) { |
|
| 954 | + $size = filesize ( get_attached_file ( $attachment_id ) ); |
|
| 955 | + update_post_meta ( $episode_id, 'filesize_raw', $size ); |
|
| 956 | 956 | } |
| 957 | 957 | |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | // Update the cache |
| 961 | - wp_cache_set( $episode_id, $size, 'filesize_raw' ); |
|
| 961 | + wp_cache_set ( $episode_id, $size, 'filesize_raw' ); |
|
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | // Send Content-Length header |
| 965 | 965 | if ( ! empty( $size ) ) { |
| 966 | - header( "Content-Length: " . $size ); |
|
| 966 | + header ( "Content-Length: ".$size ); |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | // Force file download |
| 970 | - header( "Content-Type: application/force-download" ); |
|
| 970 | + header ( "Content-Type: application/force-download" ); |
|
| 971 | 971 | |
| 972 | 972 | // Set other relevant headers |
| 973 | - header( "Content-Description: File Transfer" ); |
|
| 974 | - header( "Content-Disposition: attachment; filename=\"" . basename( $file ) . "\";" ); |
|
| 975 | - header( "Content-Transfer-Encoding: binary" ); |
|
| 973 | + header ( "Content-Description: File Transfer" ); |
|
| 974 | + header ( "Content-Disposition: attachment; filename=\"".basename ( $file )."\";" ); |
|
| 975 | + header ( "Content-Transfer-Encoding: binary" ); |
|
| 976 | 976 | |
| 977 | 977 | // Encode spaces in file names until this is fixed in core (https://core.trac.wordpress.org/ticket/36998) |
| 978 | - $file = str_replace( ' ', '%20', $file ); |
|
| 978 | + $file = str_replace ( ' ', '%20', $file ); |
|
| 979 | 979 | |
| 980 | 980 | // Use ssp_readfile_chunked() if allowed on the server or simply access file directly |
| 981 | - @ssp_readfile_chunked( $file ) or header( 'Location: ' . $file ); |
|
| 981 | + @ssp_readfile_chunked ( $file ) or header ( 'Location: '.$file ); |
|
| 982 | 982 | } else { |
| 983 | 983 | |
| 984 | 984 | // Encode spaces in file names until this is fixed in core (https://core.trac.wordpress.org/ticket/36998) |
| 985 | - $file = str_replace( ' ', '%20', $file ); |
|
| 985 | + $file = str_replace ( ' ', '%20', $file ); |
|
| 986 | 986 | |
| 987 | 987 | // For all other referrers redirect to the raw file |
| 988 | - wp_redirect( $file, 302 ); |
|
| 988 | + wp_redirect ( $file, 302 ); |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | // Exit to prevent other processes running later on |
@@ -1002,16 +1002,16 @@ discard block |
||
| 1002 | 1002 | public function generator_tag( $gen, $type ) { |
| 1003 | 1003 | |
| 1004 | 1004 | // Allow generator tags to be hidden if necessary |
| 1005 | - if ( apply_filters( 'ssp_show_generator_tag', true, $type ) ) { |
|
| 1005 | + if ( apply_filters ( 'ssp_show_generator_tag', true, $type ) ) { |
|
| 1006 | 1006 | |
| 1007 | - $generator = 'Seriously Simple Podcasting ' . esc_attr( $this->version ); |
|
| 1007 | + $generator = 'Seriously Simple Podcasting '.esc_attr ( $this->version ); |
|
| 1008 | 1008 | |
| 1009 | 1009 | switch ( $type ) { |
| 1010 | 1010 | case 'html': |
| 1011 | - $gen .= "\n" . '<meta name="generator" content="' . $generator . '">'; |
|
| 1011 | + $gen .= "\n".'<meta name="generator" content="'.$generator.'">'; |
|
| 1012 | 1012 | break; |
| 1013 | 1013 | case 'xhtml': |
| 1014 | - $gen .= "\n" . '<meta name="generator" content="' . $generator . '" />'; |
|
| 1014 | + $gen .= "\n".'<meta name="generator" content="'.$generator.'" />'; |
|
| 1015 | 1015 | break; |
| 1016 | 1016 | } |
| 1017 | 1017 | |
@@ -1027,53 +1027,53 @@ discard block |
||
| 1027 | 1027 | public function rss_meta_tag() { |
| 1028 | 1028 | |
| 1029 | 1029 | // Get feed slug |
| 1030 | - $feed_slug = apply_filters( 'ssp_feed_slug', $this->token ); |
|
| 1030 | + $feed_slug = apply_filters ( 'ssp_feed_slug', $this->token ); |
|
| 1031 | 1031 | |
| 1032 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 1033 | - $feed_url = $this->home_url . 'feed/' . $feed_slug; |
|
| 1032 | + if ( get_option ( 'permalink_structure' ) ) { |
|
| 1033 | + $feed_url = $this->home_url.'feed/'.$feed_slug; |
|
| 1034 | 1034 | } else { |
| 1035 | - $feed_url = $this->home_url . '?feed=' . $feed_slug; |
|
| 1035 | + $feed_url = $this->home_url.'?feed='.$feed_slug; |
|
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | - $custom_feed_url = get_option( 'ss_podcasting_feed_url' ); |
|
| 1038 | + $custom_feed_url = get_option ( 'ss_podcasting_feed_url' ); |
|
| 1039 | 1039 | if ( $custom_feed_url ) { |
| 1040 | 1040 | $feed_url = $custom_feed_url; |
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | - $feed_url = apply_filters( 'ssp_feed_url', $feed_url ); |
|
| 1043 | + $feed_url = apply_filters ( 'ssp_feed_url', $feed_url ); |
|
| 1044 | 1044 | |
| 1045 | 1045 | $html = ''; |
| 1046 | 1046 | |
| 1047 | - if( apply_filters( 'ssp_show_global_feed_tag', true ) ) { |
|
| 1048 | - $html = '<link rel="alternate" type="application/rss+xml" title="' . __( 'Podcast RSS feed', 'seriously-simple-podcasting' ) . '" href="' . esc_url( $feed_url ) . '" />'; |
|
| 1047 | + if ( apply_filters ( 'ssp_show_global_feed_tag', true ) ) { |
|
| 1048 | + $html = '<link rel="alternate" type="application/rss+xml" title="'.__ ( 'Podcast RSS feed', 'seriously-simple-podcasting' ).'" href="'.esc_url ( $feed_url ).'" />'; |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | // Check if this is a series taxonomy archive and display series-specific RSS feed tag |
| 1052 | - $current_obj = get_queried_object(); |
|
| 1053 | - if( isset( $current_obj->taxonomy ) && 'series' == $current_obj->taxonomy && isset( $current_obj->slug ) && $current_obj->slug ) { |
|
| 1052 | + $current_obj = get_queried_object (); |
|
| 1053 | + if ( isset( $current_obj->taxonomy ) && 'series' == $current_obj->taxonomy && isset( $current_obj->slug ) && $current_obj->slug ) { |
|
| 1054 | 1054 | |
| 1055 | - if( apply_filters( 'ssp_show_series_feed_tag', true, $current_obj->slug ) ) { |
|
| 1055 | + if ( apply_filters ( 'ssp_show_series_feed_tag', true, $current_obj->slug ) ) { |
|
| 1056 | 1056 | |
| 1057 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 1058 | - $series_feed_url = $feed_url . '/' . $current_obj->slug; |
|
| 1057 | + if ( get_option ( 'permalink_structure' ) ) { |
|
| 1058 | + $series_feed_url = $feed_url.'/'.$current_obj->slug; |
|
| 1059 | 1059 | } else { |
| 1060 | - $series_feed_url = $feed_url . '&podcast_series=' . $current_obj->slug; |
|
| 1060 | + $series_feed_url = $feed_url.'&podcast_series='.$current_obj->slug; |
|
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | - $html .= "\n" . '<link rel="alternate" type="application/rss+xml" title="' . sprintf( __( '%s RSS feed', 'seriously-simple-podcasting' ), $current_obj->name ) . '" href="' . esc_url( $series_feed_url ) . '" />'; |
|
| 1063 | + $html .= "\n".'<link rel="alternate" type="application/rss+xml" title="'.sprintf ( __ ( '%s RSS feed', 'seriously-simple-podcasting' ), $current_obj->name ).'" href="'.esc_url ( $series_feed_url ).'" />'; |
|
| 1064 | 1064 | |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | - echo "\n" . apply_filters( 'ssp_rss_meta_tag', $html ) . "\n\n"; |
|
| 1069 | + echo "\n".apply_filters ( 'ssp_rss_meta_tag', $html )."\n\n"; |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | /** |
| 1073 | 1073 | * Register plugin widgets |
| 1074 | 1074 | * @return void |
| 1075 | 1075 | */ |
| 1076 | - public function register_widgets () { |
|
| 1076 | + public function register_widgets() { |
|
| 1077 | 1077 | |
| 1078 | 1078 | $widgets = array( |
| 1079 | 1079 | 'recent-episodes' => 'Recent_Episodes', |
@@ -1083,8 +1083,8 @@ discard block |
||
| 1083 | 1083 | ); |
| 1084 | 1084 | |
| 1085 | 1085 | foreach ( $widgets as $id => $name ) { |
| 1086 | - require_once( $this->dir . '/includes/widgets/class-ssp-widget-' . $id . '.php' ); |
|
| 1087 | - register_widget( 'SSP_Widget_' . $name ); |
|
| 1086 | + require_once( $this->dir.'/includes/widgets/class-ssp-widget-'.$id.'.php' ); |
|
| 1087 | + register_widget ( 'SSP_Widget_'.$name ); |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | } |
@@ -1093,7 +1093,7 @@ discard block |
||
| 1093 | 1093 | * Register plugin shortcodes |
| 1094 | 1094 | * @return void |
| 1095 | 1095 | */ |
| 1096 | - public function register_shortcodes () { |
|
| 1096 | + public function register_shortcodes() { |
|
| 1097 | 1097 | |
| 1098 | 1098 | $shortcodes = array( |
| 1099 | 1099 | 'podcast_episode', |
@@ -1102,8 +1102,8 @@ discard block |
||
| 1102 | 1102 | ); |
| 1103 | 1103 | |
| 1104 | 1104 | foreach ( $shortcodes as $shortcode ) { |
| 1105 | - require_once( $this->dir . '/includes/shortcodes/class-ssp-shortcode-' . $shortcode . '.php' ); |
|
| 1106 | - add_shortcode( $shortcode, array( $GLOBALS['ssp_shortcodes'][ $shortcode ], 'shortcode' ) ); |
|
| 1105 | + require_once( $this->dir.'/includes/shortcodes/class-ssp-shortcode-'.$shortcode.'.php' ); |
|
| 1106 | + add_shortcode ( $shortcode, array( $GLOBALS[ 'ssp_shortcodes' ][ $shortcode ], 'shortcode' ) ); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | 1109 | } |
@@ -1114,64 +1114,64 @@ discard block |
||
| 1114 | 1114 | * @param array $content_items Orderd array of content items to display |
| 1115 | 1115 | * @return string HTML of episode with specified content items |
| 1116 | 1116 | */ |
| 1117 | - public function podcast_episode ( $episode_id = 0, $content_items = array( 'title', 'player', 'details' ), $context = '' ) { |
|
| 1117 | + public function podcast_episode( $episode_id = 0, $content_items = array( 'title', 'player', 'details' ), $context = '' ) { |
|
| 1118 | 1118 | global $post, $episode_context; |
| 1119 | 1119 | |
| 1120 | - if ( ! $episode_id || ! is_array( $content_items ) || empty( $content_items ) ) { |
|
| 1120 | + if ( ! $episode_id || ! is_array ( $content_items ) || empty( $content_items ) ) { |
|
| 1121 | 1121 | return; |
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | 1124 | // Get episode object |
| 1125 | - $episode = get_post( $episode_id ); |
|
| 1125 | + $episode = get_post ( $episode_id ); |
|
| 1126 | 1126 | |
| 1127 | - if ( ! $episode || is_wp_error( $episode ) ) { |
|
| 1127 | + if ( ! $episode || is_wp_error ( $episode ) ) { |
|
| 1128 | 1128 | return; |
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | - $html = '<div class="podcast-episode episode-' . esc_attr( $episode_id ) . '">' . "\n"; |
|
| 1131 | + $html = '<div class="podcast-episode episode-'.esc_attr ( $episode_id ).'">'."\n"; |
|
| 1132 | 1132 | |
| 1133 | 1133 | // Setup post data for episode post object |
| 1134 | 1134 | $post = $episode; |
| 1135 | - setup_postdata( $post ); |
|
| 1135 | + setup_postdata ( $post ); |
|
| 1136 | 1136 | |
| 1137 | 1137 | $episode_context = $context; |
| 1138 | 1138 | |
| 1139 | 1139 | // Display specified content items in the order supplied |
| 1140 | 1140 | foreach ( $content_items as $item ) { |
| 1141 | 1141 | |
| 1142 | - switch( $item ) { |
|
| 1142 | + switch ( $item ) { |
|
| 1143 | 1143 | |
| 1144 | 1144 | case 'title': |
| 1145 | - $html .= '<h3 class="episode-title">' . get_the_title() . '</h3>' . "\n"; |
|
| 1145 | + $html .= '<h3 class="episode-title">'.get_the_title ().'</h3>'."\n"; |
|
| 1146 | 1146 | break; |
| 1147 | 1147 | |
| 1148 | 1148 | case 'excerpt': |
| 1149 | - $html .= '<p class="episode-excerpt">' . get_the_excerpt() . '</p>' . "\n"; |
|
| 1149 | + $html .= '<p class="episode-excerpt">'.get_the_excerpt ().'</p>'."\n"; |
|
| 1150 | 1150 | break; |
| 1151 | 1151 | |
| 1152 | 1152 | case 'content': |
| 1153 | - $html .= '<div class="episode-content">' . apply_filters( 'the_content', get_the_content() ) . '</div>' . "\n"; |
|
| 1153 | + $html .= '<div class="episode-content">'.apply_filters ( 'the_content', get_the_content () ).'</div>'."\n"; |
|
| 1154 | 1154 | break; |
| 1155 | 1155 | |
| 1156 | 1156 | case 'player': |
| 1157 | - $file = $this->get_enclosure( $episode_id ); |
|
| 1158 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 1159 | - $file = $this->get_episode_download_link( $episode_id ); |
|
| 1157 | + $file = $this->get_enclosure ( $episode_id ); |
|
| 1158 | + if ( get_option ( 'permalink_structure' ) ) { |
|
| 1159 | + $file = $this->get_episode_download_link ( $episode_id ); |
|
| 1160 | 1160 | } |
| 1161 | - $html .= '<div class="podcast_player">' . $this->media_player( $file, $episode_id ) . '</div>' . "\n"; |
|
| 1161 | + $html .= '<div class="podcast_player">'.$this->media_player ( $file, $episode_id ).'</div>'."\n"; |
|
| 1162 | 1162 | break; |
| 1163 | 1163 | |
| 1164 | 1164 | case 'details': |
| 1165 | - $html .= $this->episode_meta_details( $episode_id, $episode_context ); |
|
| 1165 | + $html .= $this->episode_meta_details ( $episode_id, $episode_context ); |
|
| 1166 | 1166 | break; |
| 1167 | 1167 | |
| 1168 | 1168 | } |
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | // Reset post data after fetching episode details |
| 1172 | - wp_reset_postdata(); |
|
| 1172 | + wp_reset_postdata (); |
|
| 1173 | 1173 | |
| 1174 | - $html .= '</div>' . "\n"; |
|
| 1174 | + $html .= '</div>'."\n"; |
|
| 1175 | 1175 | |
| 1176 | 1176 | return $html; |
| 1177 | 1177 | } |
@@ -1186,26 +1186,26 @@ discard block |
||
| 1186 | 1186 | function get_local_file_path( $file ) { |
| 1187 | 1187 | |
| 1188 | 1188 | // Identify file by root path and not URL (required for getID3 class) |
| 1189 | - $site_root = trailingslashit( ABSPATH ); |
|
| 1189 | + $site_root = trailingslashit ( ABSPATH ); |
|
| 1190 | 1190 | |
| 1191 | 1191 | // Remove common dirs from the ends of site_url and site_root, so that file can be outside of the WordPress installation |
| 1192 | - $root_chunks = explode( '/', $site_root ); |
|
| 1193 | - $url_chunks = explode( '/', $this->site_url ); |
|
| 1192 | + $root_chunks = explode ( '/', $site_root ); |
|
| 1193 | + $url_chunks = explode ( '/', $this->site_url ); |
|
| 1194 | 1194 | |
| 1195 | - end( $root_chunks ); |
|
| 1196 | - end( $url_chunks ); |
|
| 1195 | + end ( $root_chunks ); |
|
| 1196 | + end ( $url_chunks ); |
|
| 1197 | 1197 | |
| 1198 | - while ( ! is_null( key( $root_chunks ) ) && ! is_null( key( $url_chunks ) ) && ( current( $root_chunks ) == current( $url_chunks ) ) ) { |
|
| 1199 | - array_pop( $root_chunks ); |
|
| 1200 | - array_pop( $url_chunks ); |
|
| 1201 | - end( $root_chunks ); |
|
| 1202 | - end( $url_chunks ); |
|
| 1198 | + while ( ! is_null ( key ( $root_chunks ) ) && ! is_null ( key ( $url_chunks ) ) && ( current ( $root_chunks ) == current ( $url_chunks ) ) ) { |
|
| 1199 | + array_pop ( $root_chunks ); |
|
| 1200 | + array_pop ( $url_chunks ); |
|
| 1201 | + end ( $root_chunks ); |
|
| 1202 | + end ( $url_chunks ); |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | - $site_root = implode('/', $root_chunks); |
|
| 1206 | - $site_url = implode('/', $url_chunks); |
|
| 1205 | + $site_root = implode ( '/', $root_chunks ); |
|
| 1206 | + $site_url = implode ( '/', $url_chunks ); |
|
| 1207 | 1207 | |
| 1208 | - $file = str_replace( $site_url, $site_root, $file ); |
|
| 1208 | + $file = str_replace ( $site_url, $site_root, $file ); |
|
| 1209 | 1209 | |
| 1210 | 1210 | return $file; |
| 1211 | 1211 | } |
@@ -1217,16 +1217,16 @@ discard block |
||
| 1217 | 1217 | * @param string $type Type of feed |
| 1218 | 1218 | * @return string Updated content type |
| 1219 | 1219 | */ |
| 1220 | - public function feed_content_type ( $content_type = '', $type = '' ) { |
|
| 1220 | + public function feed_content_type( $content_type = '', $type = '' ) { |
|
| 1221 | 1221 | |
| 1222 | - if( 'podcast' == $type ) { |
|
| 1222 | + if ( 'podcast' == $type ) { |
|
| 1223 | 1223 | $content_type = 'text/xml'; |
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | return $content_type; |
| 1227 | 1227 | } |
| 1228 | 1228 | |
| 1229 | - public function load_localisation () { |
|
| 1230 | - load_plugin_textdomain( 'seriously-simple-podcasting', false, basename( dirname( $this->file ) ) . '/languages/' ); |
|
| 1229 | + public function load_localisation() { |
|
| 1230 | + load_plugin_textdomain ( 'seriously-simple-podcasting', false, basename ( dirname ( $this->file ) ).'/languages/' ); |
|
| 1231 | 1231 | } |
| 1232 | 1232 | } |