@@ -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,55 +33,55 @@ 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 | // Add shortcodes |
| 78 | - add_shortcode( 'ss_podcast', 'ss_podcast_shortcode' ); |
|
| 79 | - add_shortcode( 'podcast_episode', array( $this, 'podcast_episode_shortcode' ) ); |
|
| 78 | + add_shortcode ( 'ss_podcast', 'ss_podcast_shortcode' ); |
|
| 79 | + add_shortcode ( 'podcast_episode', array( $this, 'podcast_episode_shortcode' ) ); |
|
| 80 | 80 | |
| 81 | 81 | // Register widgets |
| 82 | - add_action( 'widgets_init', array( $this, 'register_widgets' ), 1 ); |
|
| 82 | + add_action ( 'widgets_init', array( $this, 'register_widgets' ), 1 ); |
|
| 83 | 83 | |
| 84 | - add_filter( 'feed_content_type', array( $this, 'feed_content_type' ), 10, 2 ); |
|
| 84 | + add_filter ( 'feed_content_type', array( $this, 'feed_content_type' ), 10, 2 ); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -92,36 +92,36 @@ discard block |
||
| 92 | 92 | public function get_episode_download_link( $episode_id, $referrer = '' ) { |
| 93 | 93 | |
| 94 | 94 | // Get file URL |
| 95 | - $file = $this->get_enclosure( $episode_id ); |
|
| 95 | + $file = $this->get_enclosure ( $episode_id ); |
|
| 96 | 96 | |
| 97 | 97 | if ( ! $file ) { |
| 98 | 98 | return; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Get download link based on permalink structure |
| 102 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 103 | - $episode = get_post( $episode_id ); |
|
| 102 | + if ( get_option ( 'permalink_structure' ) ) { |
|
| 103 | + $episode = get_post ( $episode_id ); |
|
| 104 | 104 | |
| 105 | 105 | // Get file extension - default to MP3 to prevent empty extension strings |
| 106 | - $ext = pathinfo( $file, PATHINFO_EXTENSION ); |
|
| 107 | - if( ! $ext ) { |
|
| 106 | + $ext = pathinfo ( $file, PATHINFO_EXTENSION ); |
|
| 107 | + if ( ! $ext ) { |
|
| 108 | 108 | $ext = 'mp3'; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - $link = $this->home_url . 'podcast-download/' . $episode_id . '/' . $episode->post_name . '.' . $ext; |
|
| 111 | + $link = $this->home_url.'podcast-download/'.$episode_id.'/'.$episode->post_name.'.'.$ext; |
|
| 112 | 112 | } else { |
| 113 | - $link = add_query_arg( array( 'podcast_episode' => $episode_id ), $this->home_url ); |
|
| 113 | + $link = add_query_arg ( array( 'podcast_episode' => $episode_id ), $this->home_url ); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // Allow for dyamic referrer |
| 117 | - $referrer = apply_filters( 'ssp_download_referrer', $referrer, $episode_id ); |
|
| 117 | + $referrer = apply_filters ( 'ssp_download_referrer', $referrer, $episode_id ); |
|
| 118 | 118 | |
| 119 | 119 | // Add referrer flag if supplied |
| 120 | 120 | if ( $referrer ) { |
| 121 | - $link = add_query_arg( array( 'ref' => $referrer ), $link ); |
|
| 121 | + $link = add_query_arg ( array( 'ref' => $referrer ), $link ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - return apply_filters( 'ssp_episode_download_link', esc_url( $link ), $episode_id, $file ); |
|
| 124 | + return apply_filters ( 'ssp_episode_download_link', esc_url ( $link ), $episode_id, $file ); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -131,13 +131,13 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function get_episode_type( $episode_id = 0 ) { |
| 133 | 133 | |
| 134 | - if( ! $episode_id ) { |
|
| 134 | + if ( ! $episode_id ) { |
|
| 135 | 135 | return false; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - $type = get_post_meta( $episode_id , 'episode_type' , true ); |
|
| 138 | + $type = get_post_meta ( $episode_id, 'episode_type', true ); |
|
| 139 | 139 | |
| 140 | - if( ! $type ) { |
|
| 140 | + if ( ! $type ) { |
|
| 141 | 141 | $type = 'audio'; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -153,32 +153,32 @@ discard block |
||
| 153 | 153 | global $post, $wp_current_filter, $episode_context; |
| 154 | 154 | |
| 155 | 155 | // Don't output unformatted data on excerpts |
| 156 | - if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) { |
|
| 156 | + if ( in_array ( 'get_the_excerpt', (array) $wp_current_filter ) ) { |
|
| 157 | 157 | return $content; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Don't output episode meta in shortcode or widget |
| 161 | - if ( isset( $episode_context ) && in_array( $episode_context, array( 'shortcode', 'widget' ) ) ) { |
|
| 161 | + if ( isset( $episode_context ) && in_array ( $episode_context, array( 'shortcode', 'widget' ) ) ) { |
|
| 162 | 162 | return $content; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if( post_password_required( $post->ID ) ) { |
|
| 165 | + if ( post_password_required ( $post->ID ) ) { |
|
| 166 | 166 | return $content; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $podcast_post_types = ssp_post_types( true ); |
|
| 169 | + $podcast_post_types = ssp_post_types ( true ); |
|
| 170 | 170 | |
| 171 | - if ( in_array( $post->post_type, $podcast_post_types ) && ! is_feed() && ! isset( $_GET['feed'] ) ) { |
|
| 171 | + if ( in_array ( $post->post_type, $podcast_post_types ) && ! is_feed () && ! isset( $_GET[ 'feed' ] ) ) { |
|
| 172 | 172 | |
| 173 | 173 | // Get episode meta data |
| 174 | - $meta = $this->episode_meta( $post->ID, 'content' ); |
|
| 174 | + $meta = $this->episode_meta ( $post->ID, 'content' ); |
|
| 175 | 175 | |
| 176 | 176 | // Get specified player position |
| 177 | - $player_position = get_option( 'ss_podcasting_player_content_location', 'above' ); |
|
| 177 | + $player_position = get_option ( 'ss_podcasting_player_content_location', 'above' ); |
|
| 178 | 178 | |
| 179 | - switch( $player_position ) { |
|
| 180 | - case 'above': $content = $meta . $content; break; |
|
| 181 | - case 'below': $content = $content . $meta; break; |
|
| 179 | + switch ( $player_position ) { |
|
| 180 | + case 'above': $content = $meta.$content; break; |
|
| 181 | + case 'below': $content = $content.$meta; break; |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @return string Modified excerpt |
| 193 | 193 | */ |
| 194 | 194 | public function get_excerpt_meta_data( $excerpt = '' ) { |
| 195 | - return $this->excerpt_meta_data( $excerpt, 'excerpt' ); |
|
| 195 | + return $this->excerpt_meta_data ( $excerpt, 'excerpt' ); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @return string Modified excerpt |
| 202 | 202 | */ |
| 203 | 203 | public function get_embed_meta_data( $excerpt = '' ) { |
| 204 | - return $this->excerpt_meta_data( $excerpt, 'embed' ); |
|
| 204 | + return $this->excerpt_meta_data ( $excerpt, 'embed' ); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -212,17 +212,17 @@ discard block |
||
| 212 | 212 | public function excerpt_meta_data( $excerpt = '', $content = 'excerpt' ) { |
| 213 | 213 | global $post; |
| 214 | 214 | |
| 215 | - if( post_password_required( $post->ID ) ) { |
|
| 215 | + if ( post_password_required ( $post->ID ) ) { |
|
| 216 | 216 | return $excerpt; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - $podcast_post_types = ssp_post_types( true ); |
|
| 219 | + $podcast_post_types = ssp_post_types ( true ); |
|
| 220 | 220 | |
| 221 | - if ( ( in_array( $post->post_type, $podcast_post_types ) ) && ! is_feed() ) { |
|
| 221 | + if ( ( in_array ( $post->post_type, $podcast_post_types ) ) && ! is_feed () ) { |
|
| 222 | 222 | |
| 223 | - $meta = $this->episode_meta( $post->ID, $content ); |
|
| 223 | + $meta = $this->episode_meta ( $post->ID, $content ); |
|
| 224 | 224 | |
| 225 | - $excerpt = $meta . $excerpt; |
|
| 225 | + $excerpt = $meta.$excerpt; |
|
| 226 | 226 | |
| 227 | 227 | } |
| 228 | 228 | |
@@ -243,34 +243,34 @@ discard block |
||
| 243 | 243 | return $meta; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $file = $this->get_enclosure( $episode_id ); |
|
| 246 | + $file = $this->get_enclosure ( $episode_id ); |
|
| 247 | 247 | |
| 248 | 248 | if ( $file ) { |
| 249 | 249 | |
| 250 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 251 | - $file = $this->get_episode_download_link( $episode_id ); |
|
| 250 | + if ( get_option ( 'permalink_structure' ) ) { |
|
| 251 | + $file = $this->get_episode_download_link ( $episode_id ); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | // Hide audio player in `ss_podcast` shortcode by default |
| 255 | 255 | $show_player = true; |
| 256 | - if( 'shortcode' == $context ) { |
|
| 256 | + if ( 'shortcode' == $context ) { |
|
| 257 | 257 | $show_player = false; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | // Allow media player to be dynamically hidden/displayed |
| 261 | - $show_player = apply_filters( 'ssp_show_media_player', $show_player, $context ); |
|
| 261 | + $show_player = apply_filters ( 'ssp_show_media_player', $show_player, $context ); |
|
| 262 | 262 | |
| 263 | 263 | // Show audio player if requested |
| 264 | - if( $show_player ) { |
|
| 265 | - $meta .= '<div class="podcast_player">' . $this->media_player( $file, $episode_id ) . '</div>'; |
|
| 264 | + if ( $show_player ) { |
|
| 265 | + $meta .= '<div class="podcast_player">'.$this->media_player ( $file, $episode_id ).'</div>'; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if ( apply_filters( 'ssp_show_episode_details', true, $episode_id, $context ) ) { |
|
| 269 | - $meta .= $this->episode_meta_details( $episode_id, $context ); |
|
| 268 | + if ( apply_filters ( 'ssp_show_episode_details', true, $episode_id, $context ) ) { |
|
| 269 | + $meta .= $this->episode_meta_details ( $episode_id, $context ); |
|
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - $meta = apply_filters( 'ssp_episode_meta', $meta, $episode_id, $context ); |
|
| 273 | + $meta = apply_filters ( 'ssp_episode_meta', $meta, $episode_id, $context ); |
|
| 274 | 274 | |
| 275 | 275 | return $meta; |
| 276 | 276 | } |
@@ -281,36 +281,36 @@ discard block |
||
| 281 | 281 | * @param string $context Context for display |
| 282 | 282 | * @return string Episode meta details |
| 283 | 283 | */ |
| 284 | - public function episode_meta_details ( $episode_id = 0, $context = 'content' ) { |
|
| 284 | + public function episode_meta_details( $episode_id = 0, $context = 'content' ) { |
|
| 285 | 285 | |
| 286 | 286 | if ( ! $episode_id ) { |
| 287 | 287 | return; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - $file = $this->get_enclosure( $episode_id ); |
|
| 290 | + $file = $this->get_enclosure ( $episode_id ); |
|
| 291 | 291 | |
| 292 | 292 | if ( ! $file ) { |
| 293 | 293 | return; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - $link = $this->get_episode_download_link( $episode_id, 'download' ); |
|
| 297 | - $duration = get_post_meta( $episode_id , 'duration' , true ); |
|
| 298 | - $size = get_post_meta( $episode_id , 'filesize' , true ); |
|
| 296 | + $link = $this->get_episode_download_link ( $episode_id, 'download' ); |
|
| 297 | + $duration = get_post_meta ( $episode_id, 'duration', true ); |
|
| 298 | + $size = get_post_meta ( $episode_id, 'filesize', true ); |
|
| 299 | 299 | if ( ! $size ) { |
| 300 | - $size_data = $this->get_file_size( $file ); |
|
| 301 | - $size = $size_data['formatted']; |
|
| 300 | + $size_data = $this->get_file_size ( $file ); |
|
| 301 | + $size = $size_data[ 'formatted' ]; |
|
| 302 | 302 | if ( $size ) { |
| 303 | - if ( isset( $size_data['formatted'] ) ) { |
|
| 304 | - update_post_meta( $episode_id, 'filesize', $size_data['formatted'] ); |
|
| 303 | + if ( isset( $size_data[ 'formatted' ] ) ) { |
|
| 304 | + update_post_meta ( $episode_id, 'filesize', $size_data[ 'formatted' ] ); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if ( isset( $size_data['raw'] ) ) { |
|
| 308 | - update_post_meta( $episode_id, 'filesize_raw', $size_data['raw'] ); |
|
| 307 | + if ( isset( $size_data[ 'raw' ] ) ) { |
|
| 308 | + update_post_meta ( $episode_id, 'filesize_raw', $size_data[ 'raw' ] ); |
|
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - $date_recorded = get_post_meta( $episode_id, 'date_recorded', true ); |
|
| 313 | + $date_recorded = get_post_meta ( $episode_id, 'date_recorded', true ); |
|
| 314 | 314 | |
| 315 | 315 | // Build up meta data array with default values |
| 316 | 316 | $meta = array( |
@@ -321,62 +321,62 @@ discard block |
||
| 321 | 321 | 'date_recorded' => '', |
| 322 | 322 | ); |
| 323 | 323 | |
| 324 | - if( $link ) { |
|
| 325 | - $meta['link'] = $link; |
|
| 324 | + if ( $link ) { |
|
| 325 | + $meta[ 'link' ] = $link; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if( $link && apply_filters( 'ssp_show_new_window_link', true, $context ) ) { |
|
| 329 | - $meta['new_window'] = true; |
|
| 328 | + if ( $link && apply_filters ( 'ssp_show_new_window_link', true, $context ) ) { |
|
| 329 | + $meta[ 'new_window' ] = true; |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if( $link ) { |
|
| 333 | - $meta['duration'] = $duration; |
|
| 332 | + if ( $link ) { |
|
| 333 | + $meta[ 'duration' ] = $duration; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if( $size ) { |
|
| 337 | - $meta['size'] = $size; |
|
| 336 | + if ( $size ) { |
|
| 337 | + $meta[ 'size' ] = $size; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if( $date_recorded ) { |
|
| 341 | - $meta['date_recorded'] = $date_recorded; |
|
| 340 | + if ( $date_recorded ) { |
|
| 341 | + $meta[ 'date_recorded' ] = $date_recorded; |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | // Allow dynamic filtering of meta data - to remove, add or reorder meta items |
| 345 | - $meta = apply_filters( 'ssp_episode_meta_details', $meta, $episode_id, $context ); |
|
| 345 | + $meta = apply_filters ( 'ssp_episode_meta_details', $meta, $episode_id, $context ); |
|
| 346 | 346 | |
| 347 | 347 | $meta_display = ''; |
| 348 | - $meta_sep = apply_filters( 'ssp_episode_meta_separator', ' | ' ); |
|
| 348 | + $meta_sep = apply_filters ( 'ssp_episode_meta_separator', ' | ' ); |
|
| 349 | 349 | foreach ( $meta as $key => $data ) { |
| 350 | 350 | |
| 351 | - if( ! $data ) { |
|
| 351 | + if ( ! $data ) { |
|
| 352 | 352 | continue; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - if( $meta_display ) { |
|
| 355 | + if ( $meta_display ) { |
|
| 356 | 356 | $meta_display .= $meta_sep; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - switch( $key ) { |
|
| 359 | + switch ( $key ) { |
|
| 360 | 360 | |
| 361 | 361 | case 'link': |
| 362 | - $meta_display .= '<a href="' . esc_url( $data ) . '" title="' . get_the_title() . ' ">' . __( 'Download file' , 'seriously-simple-podcasting' ) . '</a>'; |
|
| 362 | + $meta_display .= '<a href="'.esc_url ( $data ).'" title="'.get_the_title ().' ">'.__ ( 'Download file', 'seriously-simple-podcasting' ).'</a>'; |
|
| 363 | 363 | break; |
| 364 | 364 | |
| 365 | 365 | case 'new_window': |
| 366 | - $play_link = add_query_arg( 'ref', 'new_window', $link ); |
|
| 367 | - $meta_display .= '<a href="' . esc_url( $play_link ) . '" target="_blank" title="' . get_the_title() . ' ">' . __( 'Play in new window' , 'seriously-simple-podcasting' ) . '</a>'; |
|
| 366 | + $play_link = add_query_arg ( 'ref', 'new_window', $link ); |
|
| 367 | + $meta_display .= '<a href="'.esc_url ( $play_link ).'" target="_blank" title="'.get_the_title ().' ">'.__ ( 'Play in new window', 'seriously-simple-podcasting' ).'</a>'; |
|
| 368 | 368 | break; |
| 369 | 369 | |
| 370 | 370 | case 'duration': |
| 371 | - $meta_display .= __( 'Duration' , 'seriously-simple-podcasting' ) . ': ' . $data; |
|
| 371 | + $meta_display .= __ ( 'Duration', 'seriously-simple-podcasting' ).': '.$data; |
|
| 372 | 372 | break; |
| 373 | 373 | |
| 374 | 374 | case 'size': |
| 375 | - $meta_display .= __( 'Size' , 'seriously-simple-podcasting' ) . ': ' . $data; |
|
| 375 | + $meta_display .= __ ( 'Size', 'seriously-simple-podcasting' ).': '.$data; |
|
| 376 | 376 | break; |
| 377 | 377 | |
| 378 | 378 | case 'date_recorded': |
| 379 | - $meta_display .= __( 'Recorded on' , 'seriously-simple-podcasting' ) . ' ' . date_i18n( get_option( 'date_format' ), strtotime( $data ) ); |
|
| 379 | + $meta_display .= __ ( 'Recorded on', 'seriously-simple-podcasting' ).' '.date_i18n ( get_option ( 'date_format' ), strtotime ( $data ) ); |
|
| 380 | 380 | break; |
| 381 | 381 | |
| 382 | 382 | // Allow for custom items to be added, but only allow a small amount of HTML tags |
@@ -392,13 +392,13 @@ discard block |
||
| 392 | 392 | 'target' => array(), |
| 393 | 393 | ), |
| 394 | 394 | ); |
| 395 | - $meta_display .= wp_kses( $data, $allowed_tags ); |
|
| 395 | + $meta_display .= wp_kses ( $data, $allowed_tags ); |
|
| 396 | 396 | break; |
| 397 | 397 | |
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - $meta_display = '<div class="podcast_meta"><aside>' . $meta_display . '</aside></div>'; |
|
| 401 | + $meta_display = '<div class="podcast_meta"><aside>'.$meta_display.'</aside></div>'; |
|
| 402 | 402 | |
| 403 | 403 | return $meta_display; |
| 404 | 404 | |
@@ -410,43 +410,43 @@ discard block |
||
| 410 | 410 | */ |
| 411 | 411 | public function add_to_home_query( $query ) { |
| 412 | 412 | |
| 413 | - if ( is_admin() ) { |
|
| 413 | + if ( is_admin () ) { |
|
| 414 | 414 | return; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - $include_in_main_query = get_option('ss_podcasting_include_in_main_query'); |
|
| 417 | + $include_in_main_query = get_option ( 'ss_podcasting_include_in_main_query' ); |
|
| 418 | 418 | if ( $include_in_main_query && $include_in_main_query == 'on' ) { |
| 419 | - if ( $query->is_home() && $query->is_main_query() ) { |
|
| 420 | - $query->set( 'post_type', array( 'post', 'podcast' ) ); |
|
| 419 | + if ( $query->is_home () && $query->is_main_query () ) { |
|
| 420 | + $query->set ( 'post_type', array( 'post', 'podcast' ) ); |
|
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - public function add_all_post_types ( $query ) { |
|
| 425 | + public function add_all_post_types( $query ) { |
|
| 426 | 426 | |
| 427 | - if ( is_admin() ) { |
|
| 427 | + if ( is_admin () ) { |
|
| 428 | 428 | return; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - if ( ! $query->is_main_query() ) { |
|
| 431 | + if ( ! $query->is_main_query () ) { |
|
| 432 | 432 | return; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - if ( is_post_type_archive( 'podcast' ) || is_tax( 'series' ) ) { |
|
| 435 | + if ( is_post_type_archive ( 'podcast' ) || is_tax ( 'series' ) ) { |
|
| 436 | 436 | |
| 437 | - $podcast_post_types = ssp_post_types( false ); |
|
| 437 | + $podcast_post_types = ssp_post_types ( false ); |
|
| 438 | 438 | |
| 439 | 439 | if ( empty( $podcast_post_types ) ) { |
| 440 | 440 | return; |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - $episode_ids = ssp_episode_ids(); |
|
| 443 | + $episode_ids = ssp_episode_ids (); |
|
| 444 | 444 | if ( ! empty( $episode_ids ) ) { |
| 445 | 445 | |
| 446 | - $query->set( 'post__in', $episode_ids ); |
|
| 446 | + $query->set ( 'post__in', $episode_ids ); |
|
| 447 | 447 | |
| 448 | - $podcast_post_types[] = 'podcast'; |
|
| 449 | - $query->set( 'post_type', $podcast_post_types ); |
|
| 448 | + $podcast_post_types[ ] = 'podcast'; |
|
| 449 | + $query->set ( 'post_type', $podcast_post_types ); |
|
| 450 | 450 | |
| 451 | 451 | } |
| 452 | 452 | |
@@ -464,29 +464,29 @@ discard block |
||
| 464 | 464 | if ( $file ) { |
| 465 | 465 | |
| 466 | 466 | // Include media functions if necessary |
| 467 | - if ( ! function_exists( 'wp_read_audio_metadata' ) ) { |
|
| 468 | - require_once( ABSPATH . 'wp-admin/includes/media.php' ); |
|
| 467 | + if ( ! function_exists ( 'wp_read_audio_metadata' ) ) { |
|
| 468 | + require_once( ABSPATH.'wp-admin/includes/media.php' ); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | // translate file URL to local file path if possible |
| 472 | - $file = $this->get_local_file_path( $file ); |
|
| 472 | + $file = $this->get_local_file_path ( $file ); |
|
| 473 | 473 | |
| 474 | 474 | // Get file data (for local file) |
| 475 | - $data = wp_read_audio_metadata( $file ); |
|
| 475 | + $data = wp_read_audio_metadata ( $file ); |
|
| 476 | 476 | |
| 477 | 477 | $raw = $formatted = ''; |
| 478 | 478 | |
| 479 | 479 | if ( $data ) { |
| 480 | - $raw = $data['filesize']; |
|
| 481 | - $formatted = $this->format_bytes( $raw ); |
|
| 480 | + $raw = $data[ 'filesize' ]; |
|
| 481 | + $formatted = $this->format_bytes ( $raw ); |
|
| 482 | 482 | } else { |
| 483 | 483 | |
| 484 | 484 | // get file data (for remote file) |
| 485 | - $data = wp_remote_head( $file, array( 'timeout' => 10, 'redirection' => 5 ) ); |
|
| 485 | + $data = wp_remote_head ( $file, array( 'timeout' => 10, 'redirection' => 5 ) ); |
|
| 486 | 486 | |
| 487 | - if ( ! is_wp_error( $data ) && is_array( $data ) && isset( $data['headers']['content-length'] ) ) { |
|
| 488 | - $raw = $data['headers']['content-length']; |
|
| 489 | - $formatted = $this->format_bytes( $raw ); |
|
| 487 | + if ( ! is_wp_error ( $data ) && is_array ( $data ) && isset( $data[ 'headers' ][ 'content-length' ] ) ) { |
|
| 488 | + $raw = $data[ 'headers' ][ 'content-length' ]; |
|
| 489 | + $formatted = $this->format_bytes ( $raw ); |
|
| 490 | 490 | } |
| 491 | 491 | } |
| 492 | 492 | |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | 'formatted' => $formatted |
| 498 | 498 | ); |
| 499 | 499 | |
| 500 | - return apply_filters( 'ssp_file_size', $size, $file ); |
|
| 500 | + return apply_filters ( 'ssp_file_size', $size, $file ); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | } |
@@ -515,30 +515,30 @@ discard block |
||
| 515 | 515 | if ( $file ) { |
| 516 | 516 | |
| 517 | 517 | // Include media functions if necessary |
| 518 | - if ( ! function_exists( 'wp_read_audio_metadata' ) ) { |
|
| 519 | - require_once( ABSPATH . 'wp-admin/includes/media.php' ); |
|
| 518 | + if ( ! function_exists ( 'wp_read_audio_metadata' ) ) { |
|
| 519 | + require_once( ABSPATH.'wp-admin/includes/media.php' ); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | // translate file URL to local file path if possible |
| 523 | - $file = $this->get_local_file_path( $file ); |
|
| 523 | + $file = $this->get_local_file_path ( $file ); |
|
| 524 | 524 | |
| 525 | 525 | // Get file data (will only work for local files) |
| 526 | - $data = wp_read_audio_metadata( $file ); |
|
| 526 | + $data = wp_read_audio_metadata ( $file ); |
|
| 527 | 527 | |
| 528 | 528 | $duration = false; |
| 529 | 529 | |
| 530 | 530 | if ( $data ) { |
| 531 | - if ( isset( $data['length_formatted'] ) && strlen( $data['length_formatted'] ) > 0 ) { |
|
| 532 | - $duration = $data['length_formatted']; |
|
| 531 | + if ( isset( $data[ 'length_formatted' ] ) && strlen ( $data[ 'length_formatted' ] ) > 0 ) { |
|
| 532 | + $duration = $data[ 'length_formatted' ]; |
|
| 533 | 533 | } else { |
| 534 | - if ( isset( $data['length'] ) && strlen( $data['length'] ) > 0 ) { |
|
| 535 | - $duration = gmdate( 'H:i:s', $data['length'] ); |
|
| 534 | + if ( isset( $data[ 'length' ] ) && strlen ( $data[ 'length' ] ) > 0 ) { |
|
| 535 | + $duration = gmdate ( 'H:i:s', $data[ 'length' ] ); |
|
| 536 | 536 | } |
| 537 | 537 | } |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | if ( $data ) { |
| 541 | - return apply_filters( 'ssp_file_duration', $duration, $file ); |
|
| 541 | + return apply_filters ( 'ssp_file_duration', $duration, $file ); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | } |
@@ -552,15 +552,15 @@ discard block |
||
| 552 | 552 | * @param integer $precision Level of precision for formatting |
| 553 | 553 | * @return mixed Formatted file size on success, false on failure |
| 554 | 554 | */ |
| 555 | - protected function format_bytes( $size , $precision = 2 ) { |
|
| 555 | + protected function format_bytes( $size, $precision = 2 ) { |
|
| 556 | 556 | |
| 557 | 557 | if ( $size ) { |
| 558 | 558 | |
| 559 | - $base = log ( $size ) / log( 1024 ); |
|
| 560 | - $suffixes = array( '' , 'k' , 'M' , 'G' , 'T' ); |
|
| 561 | - $formatted_size = round( pow( 1024 , $base - floor( $base ) ) , $precision ) . $suffixes[ floor( $base ) ]; |
|
| 559 | + $base = log ( $size ) / log ( 1024 ); |
|
| 560 | + $suffixes = array( '', 'k', 'M', 'G', 'T' ); |
|
| 561 | + $formatted_size = round ( pow ( 1024, $base - floor ( $base ) ), $precision ).$suffixes[ floor ( $base ) ]; |
|
| 562 | 562 | |
| 563 | - return apply_filters( 'ssp_file_size_formatted', $formatted_size, $size ); |
|
| 563 | + return apply_filters ( 'ssp_file_size_formatted', $formatted_size, $size ); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | return false; |
@@ -576,10 +576,10 @@ discard block |
||
| 576 | 576 | |
| 577 | 577 | // Let's hash the URL to ensure that we don't get |
| 578 | 578 | // any illegal chars that might break the cache. |
| 579 | - $key = md5( $url ); |
|
| 579 | + $key = md5 ( $url ); |
|
| 580 | 580 | |
| 581 | 581 | // Do we have anything in the cache for this URL? |
| 582 | - $attachment_id = wp_cache_get( $key, 'attachment_id' ); |
|
| 582 | + $attachment_id = wp_cache_get ( $key, 'attachment_id' ); |
|
| 583 | 583 | |
| 584 | 584 | if ( $attachment_id === false ) { |
| 585 | 585 | |
@@ -596,39 +596,39 @@ discard block |
||
| 596 | 596 | |
| 597 | 597 | |
| 598 | 598 | // Function introduced in 4.0, let's try this first. |
| 599 | - if ( function_exists( 'attachment_url_to_postid' ) ) { |
|
| 600 | - $attachment_id = absint( attachment_url_to_postid( $url ) ); |
|
| 599 | + if ( function_exists ( 'attachment_url_to_postid' ) ) { |
|
| 600 | + $attachment_id = absint ( attachment_url_to_postid ( $url ) ); |
|
| 601 | 601 | if ( 0 !== $attachment_id ) { |
| 602 | - wp_cache_set( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
| 602 | + wp_cache_set ( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
| 603 | 603 | return $attachment_id; |
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | // Then this. |
| 608 | - if ( preg_match( '#\.[a-zA-Z0-9]+$#', $url ) ) { |
|
| 609 | - $sql = $wpdb->prepare( |
|
| 608 | + if ( preg_match ( '#\.[a-zA-Z0-9]+$#', $url ) ) { |
|
| 609 | + $sql = $wpdb->prepare ( |
|
| 610 | 610 | "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND guid = %s", |
| 611 | - esc_url_raw( $url ) |
|
| 611 | + esc_url_raw ( $url ) |
|
| 612 | 612 | ); |
| 613 | - $attachment_id = absint( $wpdb->get_var( $sql ) ); |
|
| 613 | + $attachment_id = absint ( $wpdb->get_var ( $sql ) ); |
|
| 614 | 614 | if ( 0 !== $attachment_id ) { |
| 615 | - wp_cache_set( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
| 615 | + wp_cache_set ( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
| 616 | 616 | return $attachment_id; |
| 617 | 617 | } |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | // And then try this |
| 621 | - $upload_dir_paths = wp_upload_dir(); |
|
| 622 | - if ( false !== strpos( $url, $upload_dir_paths['baseurl'] ) ) { |
|
| 621 | + $upload_dir_paths = wp_upload_dir (); |
|
| 622 | + if ( false !== strpos ( $url, $upload_dir_paths[ 'baseurl' ] ) ) { |
|
| 623 | 623 | // Ensure that we have file extension that matches iTunes. |
| 624 | - $url = preg_replace( '/(?=\.(m4a|mp3|mov|mp4)$)/i', '', $url ); |
|
| 624 | + $url = preg_replace ( '/(?=\.(m4a|mp3|mov|mp4)$)/i', '', $url ); |
|
| 625 | 625 | // Remove the upload path base directory from the attachment URL |
| 626 | - $url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $url ); |
|
| 626 | + $url = str_replace ( $upload_dir_paths[ 'baseurl' ].'/', '', $url ); |
|
| 627 | 627 | // Finally, run a custom database query to get the attachment ID from the modified attachment URL |
| 628 | - $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 ); |
|
| 629 | - $attachment_id = absint( $wpdb->get_var( $sql ) ); |
|
| 628 | + $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 ); |
|
| 629 | + $attachment_id = absint ( $wpdb->get_var ( $sql ) ); |
|
| 630 | 630 | if ( 0 !== $attachment_id ) { |
| 631 | - wp_cache_set( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
| 631 | + wp_cache_set ( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
| 632 | 632 | return $attachment_id; |
| 633 | 633 | } |
| 634 | 634 | } |
@@ -646,20 +646,20 @@ discard block |
||
| 646 | 646 | public function get_attachment_mimetype( $attachment = '' ) { |
| 647 | 647 | |
| 648 | 648 | // Let's hash the URL to ensure that we don't get any illegal chars that might break the cache. |
| 649 | - $key = md5( $attachment ); |
|
| 649 | + $key = md5 ( $attachment ); |
|
| 650 | 650 | |
| 651 | 651 | if ( $attachment ) { |
| 652 | 652 | // Do we have anything in the cache for this? |
| 653 | - $mime = wp_cache_get( $key, 'mime-type' ); |
|
| 653 | + $mime = wp_cache_get ( $key, 'mime-type' ); |
|
| 654 | 654 | if ( $mime === false ) { |
| 655 | 655 | |
| 656 | 656 | // Get the ID |
| 657 | - $id = $this->get_attachment_id_from_url( $attachment ); |
|
| 657 | + $id = $this->get_attachment_id_from_url ( $attachment ); |
|
| 658 | 658 | |
| 659 | 659 | // Get the MIME type |
| 660 | - $mime = get_post_mime_type( $id ); |
|
| 660 | + $mime = get_post_mime_type ( $id ); |
|
| 661 | 661 | // Set the cache |
| 662 | - wp_cache_set( $key, $mime, 'mime-type', DAY_IN_SECONDS ); |
|
| 662 | + wp_cache_set ( $key, $mime, 'mime-type', DAY_IN_SECONDS ); |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | return $mime; |
@@ -676,8 +676,8 @@ discard block |
||
| 676 | 676 | * @return string Audio player HTML on success, false on failure |
| 677 | 677 | */ |
| 678 | 678 | public function audio_player( $src = '', $episode_id = 0 ) { |
| 679 | - $player = $this->media_player( $src, $episode_id ); |
|
| 680 | - return apply_filters( 'ssp_audio_player', $player, $src, $episode_id ); |
|
| 679 | + $player = $this->media_player ( $src, $episode_id ); |
|
| 680 | + return apply_filters ( 'ssp_audio_player', $player, $src, $episode_id ); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
@@ -686,40 +686,40 @@ discard block |
||
| 686 | 686 | * @param integer $episode_id Episode ID for audio file |
| 687 | 687 | * @return string Media player HTML on success, empty string on failure |
| 688 | 688 | */ |
| 689 | - public function media_player ( $src = '', $episode_id = 0 ) { |
|
| 689 | + public function media_player( $src = '', $episode_id = 0 ) { |
|
| 690 | 690 | $player = ''; |
| 691 | 691 | |
| 692 | 692 | if ( $src ) { |
| 693 | 693 | |
| 694 | 694 | // Get episode type and default to audio |
| 695 | - $type = $this->get_episode_type( $episode_id ); |
|
| 696 | - if( ! $type ) { |
|
| 695 | + $type = $this->get_episode_type ( $episode_id ); |
|
| 696 | + if ( ! $type ) { |
|
| 697 | 697 | $type = 'audio'; |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | // Switch to podcast player URL |
| 701 | - $src = str_replace( 'podcast-download', 'podcast-player', $src ); |
|
| 701 | + $src = str_replace ( 'podcast-download', 'podcast-player', $src ); |
|
| 702 | 702 | |
| 703 | 703 | // Set up paramters for media player |
| 704 | 704 | $params = array( 'src' => $src, 'preload' => 'none' ); |
| 705 | 705 | |
| 706 | 706 | // Use built-in WordPress media player |
| 707 | - switch( $type ) { |
|
| 708 | - case 'audio': $player = wp_audio_shortcode( $params ); break; |
|
| 707 | + switch ( $type ) { |
|
| 708 | + case 'audio': $player = wp_audio_shortcode ( $params ); break; |
|
| 709 | 709 | case 'video': |
| 710 | 710 | // Use featured image as video poster |
| 711 | - if( $episode_id && has_post_thumbnail( $episode_id ) ) { |
|
| 712 | - $poster = wp_get_attachment_url( get_post_thumbnail_id( $episode_id ) ); |
|
| 713 | - if( $poster ) { |
|
| 714 | - $params['poster'] = $poster; |
|
| 711 | + if ( $episode_id && has_post_thumbnail ( $episode_id ) ) { |
|
| 712 | + $poster = wp_get_attachment_url ( get_post_thumbnail_id ( $episode_id ) ); |
|
| 713 | + if ( $poster ) { |
|
| 714 | + $params[ 'poster' ] = $poster; |
|
| 715 | 715 | } |
| 716 | 716 | } |
| 717 | - $player = wp_video_shortcode( $params ); |
|
| 717 | + $player = wp_video_shortcode ( $params ); |
|
| 718 | 718 | break; |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | // Allow filtering so that alternative players can be used |
| 722 | - $player = apply_filters( 'ssp_media_player', $player, $src, $episode_id ); |
|
| 722 | + $player = apply_filters ( 'ssp_media_player', $player, $src, $episode_id ); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | return $player; |
@@ -734,17 +734,17 @@ discard block |
||
| 734 | 734 | public function get_image( $id = 0, $size = 'full' ) { |
| 735 | 735 | $image = ''; |
| 736 | 736 | |
| 737 | - if ( has_post_thumbnail( $id ) ) { |
|
| 737 | + if ( has_post_thumbnail ( $id ) ) { |
|
| 738 | 738 | // If not a string or an array, and not an integer, default to 200x9999. |
| 739 | - if ( is_int( $size ) || ( 0 < intval( $size ) ) ) { |
|
| 740 | - $size = array( intval( $size ), intval( $size ) ); |
|
| 741 | - } elseif ( ! is_string( $size ) && ! is_array( $size ) ) { |
|
| 739 | + if ( is_int ( $size ) || ( 0 < intval ( $size ) ) ) { |
|
| 740 | + $size = array( intval ( $size ), intval ( $size ) ); |
|
| 741 | + } elseif ( ! is_string ( $size ) && ! is_array ( $size ) ) { |
|
| 742 | 742 | $size = array( 200, 9999 ); |
| 743 | 743 | } |
| 744 | - $image = get_the_post_thumbnail( intval( $id ), $size ); |
|
| 744 | + $image = get_the_post_thumbnail ( intval ( $id ), $size ); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | - return apply_filters( 'ssp_episode_image', $image, $id ); |
|
| 747 | + return apply_filters ( 'ssp_episode_image', $image, $id ); |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | /** |
@@ -759,29 +759,29 @@ discard block |
||
| 759 | 759 | 'series' => '' |
| 760 | 760 | ); |
| 761 | 761 | |
| 762 | - $args = apply_filters( 'ssp_get_podcast_args', wp_parse_args( $args, $defaults ) ); |
|
| 762 | + $args = apply_filters ( 'ssp_get_podcast_args', wp_parse_args ( $args, $defaults ) ); |
|
| 763 | 763 | |
| 764 | 764 | $query = array(); |
| 765 | 765 | |
| 766 | - if ( 'episodes' == $args['content'] ) { |
|
| 766 | + if ( 'episodes' == $args[ 'content' ] ) { |
|
| 767 | 767 | |
| 768 | 768 | // Get selected series |
| 769 | 769 | $podcast_series = ''; |
| 770 | - if ( isset( $args['series'] ) && $args['series'] ) { |
|
| 771 | - $podcast_series = $args['series']; |
|
| 770 | + if ( isset( $args[ 'series' ] ) && $args[ 'series' ] ) { |
|
| 771 | + $podcast_series = $args[ 'series' ]; |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | // Get query args |
| 775 | - $query_args = apply_filters( 'ssp_get_podcast_query_args', ssp_episodes( -1, $podcast_series, true, '' ) ); |
|
| 775 | + $query_args = apply_filters ( 'ssp_get_podcast_query_args', ssp_episodes ( -1, $podcast_series, true, '' ) ); |
|
| 776 | 776 | |
| 777 | 777 | // The Query |
| 778 | - $query = get_posts( $query_args ); |
|
| 778 | + $query = get_posts ( $query_args ); |
|
| 779 | 779 | |
| 780 | 780 | // The Display |
| 781 | - if ( ! is_wp_error( $query ) && is_array( $query ) && count( $query ) > 0 ) { |
|
| 781 | + if ( ! is_wp_error ( $query ) && is_array ( $query ) && count ( $query ) > 0 ) { |
|
| 782 | 782 | foreach ( $query as $k => $v ) { |
| 783 | 783 | // Get the URL |
| 784 | - $query[$k]->url = get_permalink( $v->ID ); |
|
| 784 | + $query[ $k ]->url = get_permalink ( $v->ID ); |
|
| 785 | 785 | } |
| 786 | 786 | } else { |
| 787 | 787 | $query = false; |
@@ -789,27 +789,27 @@ discard block |
||
| 789 | 789 | |
| 790 | 790 | } else { |
| 791 | 791 | |
| 792 | - $terms = get_terms( 'series' ); |
|
| 792 | + $terms = get_terms ( 'series' ); |
|
| 793 | 793 | |
| 794 | - if ( count( $terms ) > 0) { |
|
| 794 | + if ( count ( $terms ) > 0 ) { |
|
| 795 | 795 | |
| 796 | 796 | foreach ( $terms as $term ) { |
| 797 | - $query[ $term->term_id ] = new stdClass(); |
|
| 797 | + $query[ $term->term_id ] = new stdClass (); |
|
| 798 | 798 | $query[ $term->term_id ]->title = $term->name; |
| 799 | - $query[ $term->term_id ]->url = get_term_link( $term ); |
|
| 799 | + $query[ $term->term_id ]->url = get_term_link ( $term ); |
|
| 800 | 800 | |
| 801 | - $query_args = apply_filters( 'ssp_get_podcast_series_query_args', ssp_episodes( -1, $term->slug, true, '' ) ); |
|
| 801 | + $query_args = apply_filters ( 'ssp_get_podcast_series_query_args', ssp_episodes ( -1, $term->slug, true, '' ) ); |
|
| 802 | 802 | |
| 803 | - $posts = get_posts( $query_args ); |
|
| 803 | + $posts = get_posts ( $query_args ); |
|
| 804 | 804 | |
| 805 | - $count = count( $posts ); |
|
| 805 | + $count = count ( $posts ); |
|
| 806 | 806 | $query[ $term->term_id ]->count = $count; |
| 807 | 807 | } |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | } |
| 811 | 811 | |
| 812 | - $query['content'] = $args['content']; |
|
| 812 | + $query[ 'content' ] = $args[ 'content' ]; |
|
| 813 | 813 | |
| 814 | 814 | return $query; |
| 815 | 815 | } |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | public function get_enclosure( $episode_id = 0 ) { |
| 823 | 823 | |
| 824 | 824 | if ( $episode_id ) { |
| 825 | - return apply_filters( 'ssp_episode_enclosure', get_post_meta( $episode_id, 'audio_file', true ), $episode_id ); |
|
| 825 | + return apply_filters ( 'ssp_episode_enclosure', get_post_meta ( $episode_id, 'audio_file', true ), $episode_id ); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | return ''; |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | |
| 841 | 841 | if ( $file != '' ) { |
| 842 | 842 | |
| 843 | - $post_types = ssp_post_types( true ); |
|
| 843 | + $post_types = ssp_post_types ( true ); |
|
| 844 | 844 | |
| 845 | 845 | $args = array( |
| 846 | 846 | 'post_type' => $post_types, |
@@ -850,17 +850,17 @@ discard block |
||
| 850 | 850 | 'meta_value' => $file |
| 851 | 851 | ); |
| 852 | 852 | |
| 853 | - $qry = new WP_Query( $args ); |
|
| 853 | + $qry = new WP_Query ( $args ); |
|
| 854 | 854 | |
| 855 | - if ( $qry->have_posts() ) { |
|
| 856 | - while ( $qry->have_posts() ) { $qry->the_post(); |
|
| 855 | + if ( $qry->have_posts () ) { |
|
| 856 | + while ( $qry->have_posts () ) { $qry->the_post (); |
|
| 857 | 857 | $episode = $post; |
| 858 | 858 | break; |
| 859 | 859 | } |
| 860 | 860 | } |
| 861 | 861 | } |
| 862 | 862 | |
| 863 | - return apply_filters( 'ssp_episode_from_file', $episode, $file ); |
|
| 863 | + return apply_filters ( 'ssp_episode_from_file', $episode, $file ); |
|
| 864 | 864 | |
| 865 | 865 | } |
| 866 | 866 | |
@@ -870,33 +870,33 @@ discard block |
||
| 870 | 870 | */ |
| 871 | 871 | public function download_file() { |
| 872 | 872 | |
| 873 | - if ( is_podcast_download() ) { |
|
| 873 | + if ( is_podcast_download () ) { |
|
| 874 | 874 | global $wp_query; |
| 875 | 875 | |
| 876 | 876 | // Get requested episode ID |
| 877 | - $episode_id = intval( $wp_query->query_vars['podcast_episode'] ); |
|
| 877 | + $episode_id = intval ( $wp_query->query_vars[ 'podcast_episode' ] ); |
|
| 878 | 878 | |
| 879 | 879 | if ( isset( $episode_id ) && $episode_id ) { |
| 880 | 880 | |
| 881 | 881 | // Get episode post object |
| 882 | - $episode = get_post( $episode_id ); |
|
| 882 | + $episode = get_post ( $episode_id ); |
|
| 883 | 883 | |
| 884 | 884 | // Make sure we have a valid episode post object |
| 885 | - if ( ! $episode || ! is_object( $episode ) || is_wp_error( $episode ) || ! isset( $episode->ID ) ) { |
|
| 885 | + if ( ! $episode || ! is_object ( $episode ) || is_wp_error ( $episode ) || ! isset( $episode->ID ) ) { |
|
| 886 | 886 | return; |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | // Do we have newlines? |
| 890 | 890 | $parts = false; |
| 891 | - if( is_string( $episode ) ) { |
|
| 892 | - $parts = explode( "\n", $episode ); |
|
| 891 | + if ( is_string ( $episode ) ) { |
|
| 892 | + $parts = explode ( "\n", $episode ); |
|
| 893 | 893 | } |
| 894 | 894 | |
| 895 | - if ( $parts && is_array( $parts ) && count( $parts ) > 1 ) { |
|
| 896 | - $file = $parts[0]; |
|
| 895 | + if ( $parts && is_array ( $parts ) && count ( $parts ) > 1 ) { |
|
| 896 | + $file = $parts[ 0 ]; |
|
| 897 | 897 | } else { |
| 898 | 898 | // Get audio file for download |
| 899 | - $file = $this->get_enclosure( $episode_id ); |
|
| 899 | + $file = $this->get_enclosure ( $episode_id ); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | // Exit if no file is found |
@@ -906,77 +906,77 @@ discard block |
||
| 906 | 906 | |
| 907 | 907 | // Get file referrer |
| 908 | 908 | $referrer = ''; |
| 909 | - if( isset( $wp_query->query_vars['podcast_ref'] ) && $wp_query->query_vars['podcast_ref'] ) { |
|
| 910 | - $referrer = $wp_query->query_vars['podcast_ref']; |
|
| 909 | + if ( isset( $wp_query->query_vars[ 'podcast_ref' ] ) && $wp_query->query_vars[ 'podcast_ref' ] ) { |
|
| 910 | + $referrer = $wp_query->query_vars[ 'podcast_ref' ]; |
|
| 911 | 911 | } else { |
| 912 | - if( isset( $_GET['ref'] ) ) { |
|
| 913 | - $referrer = esc_attr( $_GET['ref'] ); |
|
| 912 | + if ( isset( $_GET[ 'ref' ] ) ) { |
|
| 913 | + $referrer = esc_attr ( $_GET[ 'ref' ] ); |
|
| 914 | 914 | } |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | // Allow other actions - functions hooked on here must not output any data |
| 918 | - do_action( 'ssp_file_download', $file, $episode, $referrer ); |
|
| 918 | + do_action ( 'ssp_file_download', $file, $episode, $referrer ); |
|
| 919 | 919 | |
| 920 | 920 | // Set necessary headers |
| 921 | - header( "Pragma: no-cache" ); |
|
| 922 | - header( "Expires: 0" ); |
|
| 923 | - header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); |
|
| 924 | - header( "Robots: none" ); |
|
| 921 | + header ( "Pragma: no-cache" ); |
|
| 922 | + header ( "Expires: 0" ); |
|
| 923 | + header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); |
|
| 924 | + header ( "Robots: none" ); |
|
| 925 | 925 | |
| 926 | 926 | // Check file referrer |
| 927 | - if( 'download' == $referrer ) { |
|
| 927 | + if ( 'download' == $referrer ) { |
|
| 928 | 928 | |
| 929 | 929 | // Set size of file |
| 930 | 930 | // Do we have anything in Cache/DB? |
| 931 | - $size = wp_cache_get( $episode_id, 'filesize_raw' ); |
|
| 931 | + $size = wp_cache_get ( $episode_id, 'filesize_raw' ); |
|
| 932 | 932 | |
| 933 | 933 | // Nothing in the cache, let's see if we can figure it out. |
| 934 | 934 | if ( false === $size ) { |
| 935 | 935 | |
| 936 | 936 | // Do we have anything in post_meta? |
| 937 | - $size = get_post_meta( $episode_id, 'filesize_raw', true ); |
|
| 937 | + $size = get_post_meta ( $episode_id, 'filesize_raw', true ); |
|
| 938 | 938 | |
| 939 | 939 | if ( empty( $size ) ) { |
| 940 | 940 | |
| 941 | 941 | // Let's see if we can figure out the path... |
| 942 | - $attachment_id = $this->get_attachment_id_from_url( $file ); |
|
| 942 | + $attachment_id = $this->get_attachment_id_from_url ( $file ); |
|
| 943 | 943 | |
| 944 | - if ( ! empty( $attachment_id ) ) { |
|
| 945 | - $size = filesize( get_attached_file( $attachment_id ) ); |
|
| 946 | - update_post_meta( $episode_id, 'filesize_raw', $size ); |
|
| 944 | + if ( ! empty( $attachment_id ) ) { |
|
| 945 | + $size = filesize ( get_attached_file ( $attachment_id ) ); |
|
| 946 | + update_post_meta ( $episode_id, 'filesize_raw', $size ); |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | 951 | // Update the cache |
| 952 | - wp_cache_set( $episode_id, $size, 'filesize_raw' ); |
|
| 952 | + wp_cache_set ( $episode_id, $size, 'filesize_raw' ); |
|
| 953 | 953 | } |
| 954 | 954 | |
| 955 | 955 | // Send Content-Length header |
| 956 | 956 | if ( ! empty( $size ) ) { |
| 957 | - header( "Content-Length: " . $size ); |
|
| 957 | + header ( "Content-Length: ".$size ); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | // Force file download |
| 961 | - header( "Content-Type: application/force-download" ); |
|
| 961 | + header ( "Content-Type: application/force-download" ); |
|
| 962 | 962 | |
| 963 | 963 | // Set other relevant headers |
| 964 | - header( "Content-Description: File Transfer" ); |
|
| 965 | - header( "Content-Disposition: attachment; filename=\"" . basename( $file ) . "\";" ); |
|
| 966 | - header( "Content-Transfer-Encoding: binary" ); |
|
| 964 | + header ( "Content-Description: File Transfer" ); |
|
| 965 | + header ( "Content-Disposition: attachment; filename=\"".basename ( $file )."\";" ); |
|
| 966 | + header ( "Content-Transfer-Encoding: binary" ); |
|
| 967 | 967 | |
| 968 | 968 | // Encode spaces in file names until this is fixed in core (https://core.trac.wordpress.org/ticket/36998) |
| 969 | - $file = str_replace( ' ', '%20', $file ); |
|
| 969 | + $file = str_replace ( ' ', '%20', $file ); |
|
| 970 | 970 | |
| 971 | 971 | // Use ssp_readfile_chunked() if allowed on the server or simply access file directly |
| 972 | - @ssp_readfile_chunked( $file ) or header( 'Location: ' . $file ); |
|
| 972 | + @ssp_readfile_chunked ( $file ) or header ( 'Location: '.$file ); |
|
| 973 | 973 | } else { |
| 974 | 974 | |
| 975 | 975 | // Encode spaces in file names until this is fixed in core (https://core.trac.wordpress.org/ticket/36998) |
| 976 | - $file = str_replace( ' ', '%20', $file ); |
|
| 976 | + $file = str_replace ( ' ', '%20', $file ); |
|
| 977 | 977 | |
| 978 | 978 | // For all other referrers redirect to the raw file |
| 979 | - wp_redirect( $file, 302 ); |
|
| 979 | + wp_redirect ( $file, 302 ); |
|
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | // Exit to prevent other processes running later on |
@@ -993,16 +993,16 @@ discard block |
||
| 993 | 993 | public function generator_tag( $gen, $type ) { |
| 994 | 994 | |
| 995 | 995 | // Allow generator tags to be hidden if necessary |
| 996 | - if ( apply_filters( 'ssp_show_generator_tag', true, $type ) ) { |
|
| 996 | + if ( apply_filters ( 'ssp_show_generator_tag', true, $type ) ) { |
|
| 997 | 997 | |
| 998 | - $generator = 'Seriously Simple Podcasting ' . esc_attr( $this->version ); |
|
| 998 | + $generator = 'Seriously Simple Podcasting '.esc_attr ( $this->version ); |
|
| 999 | 999 | |
| 1000 | 1000 | switch ( $type ) { |
| 1001 | 1001 | case 'html': |
| 1002 | - $gen .= "\n" . '<meta name="generator" content="' . $generator . '">'; |
|
| 1002 | + $gen .= "\n".'<meta name="generator" content="'.$generator.'">'; |
|
| 1003 | 1003 | break; |
| 1004 | 1004 | case 'xhtml': |
| 1005 | - $gen .= "\n" . '<meta name="generator" content="' . $generator . '" />'; |
|
| 1005 | + $gen .= "\n".'<meta name="generator" content="'.$generator.'" />'; |
|
| 1006 | 1006 | break; |
| 1007 | 1007 | } |
| 1008 | 1008 | |
@@ -1018,53 +1018,53 @@ discard block |
||
| 1018 | 1018 | public function rss_meta_tag() { |
| 1019 | 1019 | |
| 1020 | 1020 | // Get feed slug |
| 1021 | - $feed_slug = apply_filters( 'ssp_feed_slug', $this->token ); |
|
| 1021 | + $feed_slug = apply_filters ( 'ssp_feed_slug', $this->token ); |
|
| 1022 | 1022 | |
| 1023 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 1024 | - $feed_url = $this->home_url . 'feed/' . $feed_slug; |
|
| 1023 | + if ( get_option ( 'permalink_structure' ) ) { |
|
| 1024 | + $feed_url = $this->home_url.'feed/'.$feed_slug; |
|
| 1025 | 1025 | } else { |
| 1026 | - $feed_url = $this->home_url . '?feed=' . $feed_slug; |
|
| 1026 | + $feed_url = $this->home_url.'?feed='.$feed_slug; |
|
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | - $custom_feed_url = get_option( 'ss_podcasting_feed_url' ); |
|
| 1029 | + $custom_feed_url = get_option ( 'ss_podcasting_feed_url' ); |
|
| 1030 | 1030 | if ( $custom_feed_url ) { |
| 1031 | 1031 | $feed_url = $custom_feed_url; |
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | - $feed_url = apply_filters( 'ssp_feed_url', $feed_url ); |
|
| 1034 | + $feed_url = apply_filters ( 'ssp_feed_url', $feed_url ); |
|
| 1035 | 1035 | |
| 1036 | 1036 | $html = ''; |
| 1037 | 1037 | |
| 1038 | - if( apply_filters( 'ssp_show_global_feed_tag', true ) ) { |
|
| 1039 | - $html = '<link rel="alternate" type="application/rss+xml" title="' . __( 'Podcast RSS feed', 'seriously-simple-podcasting' ) . '" href="' . esc_url( $feed_url ) . '" />'; |
|
| 1038 | + if ( apply_filters ( 'ssp_show_global_feed_tag', true ) ) { |
|
| 1039 | + $html = '<link rel="alternate" type="application/rss+xml" title="'.__ ( 'Podcast RSS feed', 'seriously-simple-podcasting' ).'" href="'.esc_url ( $feed_url ).'" />'; |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | // Check if this is a series taxonomy archive and display series-specific RSS feed tag |
| 1043 | - $current_obj = get_queried_object(); |
|
| 1044 | - if( isset( $current_obj->taxonomy ) && 'series' == $current_obj->taxonomy && isset( $current_obj->slug ) && $current_obj->slug ) { |
|
| 1043 | + $current_obj = get_queried_object (); |
|
| 1044 | + if ( isset( $current_obj->taxonomy ) && 'series' == $current_obj->taxonomy && isset( $current_obj->slug ) && $current_obj->slug ) { |
|
| 1045 | 1045 | |
| 1046 | - if( apply_filters( 'ssp_show_series_feed_tag', true, $current_obj->slug ) ) { |
|
| 1046 | + if ( apply_filters ( 'ssp_show_series_feed_tag', true, $current_obj->slug ) ) { |
|
| 1047 | 1047 | |
| 1048 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 1049 | - $series_feed_url = $feed_url . '/' . $current_obj->slug; |
|
| 1048 | + if ( get_option ( 'permalink_structure' ) ) { |
|
| 1049 | + $series_feed_url = $feed_url.'/'.$current_obj->slug; |
|
| 1050 | 1050 | } else { |
| 1051 | - $series_feed_url = $feed_url . '&podcast_series=' . $current_obj->slug; |
|
| 1051 | + $series_feed_url = $feed_url.'&podcast_series='.$current_obj->slug; |
|
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | - $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 ) . '" />'; |
|
| 1054 | + $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 ).'" />'; |
|
| 1055 | 1055 | |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | - echo "\n" . apply_filters( 'ssp_rss_meta_tag', $html ) . "\n\n"; |
|
| 1060 | + echo "\n".apply_filters ( 'ssp_rss_meta_tag', $html )."\n\n"; |
|
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | 1063 | /** |
| 1064 | 1064 | * Register plugin widgets |
| 1065 | 1065 | * @return void |
| 1066 | 1066 | */ |
| 1067 | - public function register_widgets () { |
|
| 1067 | + public function register_widgets() { |
|
| 1068 | 1068 | |
| 1069 | 1069 | $widgets = array( |
| 1070 | 1070 | 'recent-episodes' => 'Recent_Episodes', |
@@ -1073,8 +1073,8 @@ discard block |
||
| 1073 | 1073 | ); |
| 1074 | 1074 | |
| 1075 | 1075 | foreach ( $widgets as $id => $name ) { |
| 1076 | - require_once( $this->dir . '/includes/widgets/class-ssp-widget-' . $id . '.php' ); |
|
| 1077 | - register_widget( 'SSP_Widget_' . $name ); |
|
| 1076 | + require_once( $this->dir.'/includes/widgets/class-ssp-widget-'.$id.'.php' ); |
|
| 1077 | + register_widget ( 'SSP_Widget_'.$name ); |
|
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | } |
@@ -1084,25 +1084,25 @@ discard block |
||
| 1084 | 1084 | * @param array $params Shortcode paramaters |
| 1085 | 1085 | * @return string HTML output |
| 1086 | 1086 | */ |
| 1087 | - public function podcast_episode_shortcode ( $params ) { |
|
| 1087 | + public function podcast_episode_shortcode( $params ) { |
|
| 1088 | 1088 | |
| 1089 | - $atts = shortcode_atts( array( |
|
| 1089 | + $atts = shortcode_atts ( array( |
|
| 1090 | 1090 | 'episode' => 0, |
| 1091 | 1091 | 'content' => 'title,player,details', |
| 1092 | 1092 | ), $params ); |
| 1093 | 1093 | |
| 1094 | - extract( $atts ); |
|
| 1094 | + extract ( $atts ); |
|
| 1095 | 1095 | |
| 1096 | 1096 | if ( ! $episode ) { |
| 1097 | 1097 | return; |
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | 1100 | // Setup array of content items and trim whitespace |
| 1101 | - $content_items = explode( ',', $content ); |
|
| 1102 | - $content_items = array_map( 'trim', $content_items ); |
|
| 1101 | + $content_items = explode ( ',', $content ); |
|
| 1102 | + $content_items = array_map ( 'trim', $content_items ); |
|
| 1103 | 1103 | |
| 1104 | 1104 | // Get episode for display |
| 1105 | - $html = $this->podcast_episode( $episode, $content_items, 'shortcode' ); |
|
| 1105 | + $html = $this->podcast_episode ( $episode, $content_items, 'shortcode' ); |
|
| 1106 | 1106 | |
| 1107 | 1107 | return $html; |
| 1108 | 1108 | |
@@ -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,9 +1217,9 @@ 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 | |