Completed
Push — master ( 60090c...ef8f94 )
by Hugh
09:38 queued 06:51
created
includes/class-ssp-frontend.php 1 patch
Spacing   +303 added lines, -303 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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', 'all' );
173
+		$player_visibility = get_option ( 'ss_podcasting_player_content_visibility', 'all' );
174 174
 
175
-		switch( $player_visibility ) {
175
+		switch ( $player_visibility ) {
176 176
 			case 'all': $show_player = true; break;
177
-			case 'membersonly': $show_player = is_user_logged_in(); break;
177
+			case 'membersonly': $show_player = is_user_logged_in (); break;
178 178
 		}
179 179
 
180
-		if ( $show_player && in_array( $post->post_type, $podcast_post_types ) && ! is_feed() && ! isset( $_GET['feed'] ) ) {
180
+		if ( $show_player && 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
 block discarded – undo
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
 block discarded – undo
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,24 +221,24 @@  discard block
 block discarded – undo
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
-		$player_visibility = get_option( 'ss_podcasting_player_content_visibility', 'all' );
230
+		$player_visibility = get_option ( 'ss_podcasting_player_content_visibility', 'all' );
231 231
 
232
-		switch( $player_visibility ) {
232
+		switch ( $player_visibility ) {
233 233
 			case 'all': $show_player = true; break;
234
-			case 'membersonly': $show_player = is_user_logged_in(); break;
234
+			case 'membersonly': $show_player = is_user_logged_in (); break;
235 235
 		}
236 236
 
237
-		if ( $show_player && in_array( $post->post_type, $podcast_post_types ) && ! is_feed() && ! isset( $_GET['feed'] ) ) {
237
+		if ( $show_player && in_array ( $post->post_type, $podcast_post_types ) && ! is_feed () && ! isset( $_GET[ 'feed' ] ) ) {
238 238
 
239
-			$meta = $this->episode_meta( $post->ID, $content );
239
+			$meta = $this->episode_meta ( $post->ID, $content );
240 240
 
241
-			$excerpt = $meta . $excerpt;
241
+			$excerpt = $meta.$excerpt;
242 242
 
243 243
 		}
244 244
 
@@ -259,34 +259,34 @@  discard block
 block discarded – undo
259 259
 			return $meta;
260 260
 		}
261 261
 
262
-		$file = $this->get_enclosure( $episode_id );
262
+		$file = $this->get_enclosure ( $episode_id );
263 263
 
264 264
 		if ( $file ) {
265 265
 
266
-			if ( get_option( 'permalink_structure' ) ) {
267
-				$file = $this->get_episode_download_link( $episode_id );
266
+			if ( get_option ( 'permalink_structure' ) ) {
267
+				$file = $this->get_episode_download_link ( $episode_id );
268 268
 			}
269 269
 
270 270
 			// Hide audio player in `ss_podcast` shortcode by default
271 271
 			$show_player = true;
272
-			if( 'shortcode' == $context ) {
272
+			if ( 'shortcode' == $context ) {
273 273
 				$show_player = false;
274 274
 			}
275 275
 
276 276
 			// Allow media player to be dynamically hidden/displayed
277
-			$show_player = apply_filters( 'ssp_show_media_player', $show_player, $context );
277
+			$show_player = apply_filters ( 'ssp_show_media_player', $show_player, $context );
278 278
 
279 279
 			// Show audio player if requested
280
-			if( $show_player ) {
281
-				$meta .= '<div class="podcast_player">' . $this->media_player( $file, $episode_id ) . '</div>';
280
+			if ( $show_player ) {
281
+				$meta .= '<div class="podcast_player">'.$this->media_player ( $file, $episode_id ).'</div>';
282 282
 			}
283 283
 
284
-			if ( apply_filters( 'ssp_show_episode_details', true, $episode_id, $context ) ) {
285
-				$meta .= $this->episode_meta_details( $episode_id, $context );
284
+			if ( apply_filters ( 'ssp_show_episode_details', true, $episode_id, $context ) ) {
285
+				$meta .= $this->episode_meta_details ( $episode_id, $context );
286 286
 			}
287 287
 		}
288 288
 
289
-		$meta = apply_filters( 'ssp_episode_meta', $meta, $episode_id, $context );
289
+		$meta = apply_filters ( 'ssp_episode_meta', $meta, $episode_id, $context );
290 290
 
291 291
 		return $meta;
292 292
 	}
@@ -297,36 +297,36 @@  discard block
 block discarded – undo
297 297
 	 * @param  string  $context    Context for display
298 298
 	 * @return string              Episode meta details
299 299
 	 */
300
-	public function episode_meta_details ( $episode_id = 0, $context = 'content' ) {
300
+	public function episode_meta_details( $episode_id = 0, $context = 'content' ) {
301 301
 
302 302
 		if ( ! $episode_id ) {
303 303
 			return;
304 304
 		}
305 305
 
306
-		$file = $this->get_enclosure( $episode_id );
306
+		$file = $this->get_enclosure ( $episode_id );
307 307
 
308 308
 		if ( ! $file ) {
309 309
 			return;
310 310
 		}
311 311
 
312
-		$link = $this->get_episode_download_link( $episode_id, 'download' );
313
-		$duration = get_post_meta( $episode_id , 'duration' , true );
314
-		$size = get_post_meta( $episode_id , 'filesize' , true );
312
+		$link = $this->get_episode_download_link ( $episode_id, 'download' );
313
+		$duration = get_post_meta ( $episode_id, 'duration', true );
314
+		$size = get_post_meta ( $episode_id, 'filesize', true );
315 315
 		if ( ! $size ) {
316
-			$size_data = $this->get_file_size( $file );
317
-			$size = $size_data['formatted'];
316
+			$size_data = $this->get_file_size ( $file );
317
+			$size = $size_data[ 'formatted' ];
318 318
 			if ( $size ) {
319
-				if ( isset( $size_data['formatted'] ) ) {
320
-					update_post_meta( $episode_id, 'filesize', $size_data['formatted'] );
319
+				if ( isset( $size_data[ 'formatted' ] ) ) {
320
+					update_post_meta ( $episode_id, 'filesize', $size_data[ 'formatted' ] );
321 321
 				}
322 322
 
323
-				if ( isset( $size_data['raw'] ) ) {
324
-					update_post_meta( $episode_id, 'filesize_raw', $size_data['raw'] );
323
+				if ( isset( $size_data[ 'raw' ] ) ) {
324
+					update_post_meta ( $episode_id, 'filesize_raw', $size_data[ 'raw' ] );
325 325
 				}
326 326
 			}
327 327
 		}
328 328
 
329
-		$date_recorded = get_post_meta( $episode_id, 'date_recorded', true );
329
+		$date_recorded = get_post_meta ( $episode_id, 'date_recorded', true );
330 330
 
331 331
 		// Build up meta data array with default values
332 332
 		$meta = array(
@@ -337,62 +337,62 @@  discard block
 block discarded – undo
337 337
 			'date_recorded' => '',
338 338
 		);
339 339
 
340
-		if( $link ) {
341
-			$meta['link'] = $link;
340
+		if ( $link ) {
341
+			$meta[ 'link' ] = $link;
342 342
 		}
343 343
 
344
-		if( $link && apply_filters( 'ssp_show_new_window_link', true, $context ) ) {
345
-			$meta['new_window'] = true;
344
+		if ( $link && apply_filters ( 'ssp_show_new_window_link', true, $context ) ) {
345
+			$meta[ 'new_window' ] = true;
346 346
 		}
347 347
 
348
-		if( $link ) {
349
-			$meta['duration'] = $duration;
348
+		if ( $link ) {
349
+			$meta[ 'duration' ] = $duration;
350 350
 		}
351 351
 
352
-		if( $size ) {
353
-			$meta['size'] = $size;
352
+		if ( $size ) {
353
+			$meta[ 'size' ] = $size;
354 354
 		}
355 355
 
356
-		if( $date_recorded ) {
357
-			$meta['date_recorded'] = $date_recorded;
356
+		if ( $date_recorded ) {
357
+			$meta[ 'date_recorded' ] = $date_recorded;
358 358
 		}
359 359
 
360 360
 		// Allow dynamic filtering of meta data - to remove, add or reorder meta items
361
-		$meta = apply_filters( 'ssp_episode_meta_details', $meta, $episode_id, $context );
361
+		$meta = apply_filters ( 'ssp_episode_meta_details', $meta, $episode_id, $context );
362 362
 
363 363
 		$meta_display = '';
364
-		$meta_sep = apply_filters( 'ssp_episode_meta_separator', ' | ' );
364
+		$meta_sep = apply_filters ( 'ssp_episode_meta_separator', ' | ' );
365 365
 		foreach ( $meta as $key => $data ) {
366 366
 
367
-			if( ! $data ) {
367
+			if ( ! $data ) {
368 368
 				continue;
369 369
 			}
370 370
 
371
-			if( $meta_display ) {
371
+			if ( $meta_display ) {
372 372
 				$meta_display .= $meta_sep;
373 373
 			}
374 374
 
375
-			switch( $key ) {
375
+			switch ( $key ) {
376 376
 
377 377
 				case 'link':
378
-					$meta_display .= '<a href="' . esc_url( $data ) . '" title="' . get_the_title() . ' " class="podcast-meta-download" download>' . __( 'Download file' , 'seriously-simple-podcasting' ) . '</a>';
378
+					$meta_display .= '<a href="'.esc_url ( $data ).'" title="'.get_the_title ().' " class="podcast-meta-download" download>'.__ ( 'Download file', 'seriously-simple-podcasting' ).'</a>';
379 379
 				break;
380 380
 
381 381
 				case 'new_window':
382
-					$play_link = add_query_arg( 'ref', 'new_window', $link );
383
-					$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>';
382
+					$play_link = add_query_arg ( 'ref', 'new_window', $link );
383
+					$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>';
384 384
 				break;
385 385
 
386 386
 				case 'duration':
387
-					$meta_display .= '<span class="podcast-meta-duration">' . __( 'Duration' , 'seriously-simple-podcasting' ) . ': ' . $data . '</span>';
387
+					$meta_display .= '<span class="podcast-meta-duration">'.__ ( 'Duration', 'seriously-simple-podcasting' ).': '.$data.'</span>';
388 388
 				break;
389 389
 
390 390
 				case 'size':
391
-					$meta_display .= '<span class="podcast-meta-size">' . __( 'Size' , 'seriously-simple-podcasting' ) . ': ' . $data . '</span>';
391
+					$meta_display .= '<span class="podcast-meta-size">'.__ ( 'Size', 'seriously-simple-podcasting' ).': '.$data.'</span>';
392 392
 				break;
393 393
 
394 394
 				case 'date_recorded':
395
-					$meta_display .= '<span class="podcast-meta-date">' . __( 'Recorded on' , 'seriously-simple-podcasting' ) . ' ' . date_i18n( get_option( 'date_format' ), strtotime( $data ) ) . '</span>';
395
+					$meta_display .= '<span class="podcast-meta-date">'.__ ( 'Recorded on', 'seriously-simple-podcasting' ).' '.date_i18n ( get_option ( 'date_format' ), strtotime ( $data ) ).'</span>';
396 396
 				break;
397 397
 
398 398
 				// Allow for custom items to be added, but only allow a small amount of HTML tags
@@ -408,13 +408,13 @@  discard block
 block discarded – undo
408 408
 							'target' => array(),
409 409
 						),
410 410
 					);
411
-					$meta_display .= wp_kses( $data, $allowed_tags );
411
+					$meta_display .= wp_kses ( $data, $allowed_tags );
412 412
 				break;
413 413
 
414 414
 			}
415 415
 		}
416 416
 
417
-		$meta_display = '<div class="podcast_meta"><aside>' . $meta_display . '</aside></div>';
417
+		$meta_display = '<div class="podcast_meta"><aside>'.$meta_display.'</aside></div>';
418 418
 
419 419
 		return $meta_display;
420 420
 
@@ -426,43 +426,43 @@  discard block
 block discarded – undo
426 426
 	 */
427 427
 	public function add_to_home_query( $query ) {
428 428
 
429
-		if ( is_admin() ) {
429
+		if ( is_admin () ) {
430 430
 			return;
431 431
 		}
432 432
 
433
-		$include_in_main_query = get_option('ss_podcasting_include_in_main_query');
433
+		$include_in_main_query = get_option ( 'ss_podcasting_include_in_main_query' );
434 434
 		if ( $include_in_main_query && $include_in_main_query == 'on' ) {
435
-			if ( $query->is_home() && $query->is_main_query() ) {
436
-				$query->set( 'post_type', array( 'post', 'podcast' ) );
435
+			if ( $query->is_home () && $query->is_main_query () ) {
436
+				$query->set ( 'post_type', array( 'post', 'podcast' ) );
437 437
 			}
438 438
 		}
439 439
 	}
440 440
 
441
-	public function add_all_post_types ( $query ) {
441
+	public function add_all_post_types( $query ) {
442 442
 
443
-		if ( is_admin() ) {
443
+		if ( is_admin () ) {
444 444
 			return;
445 445
 		}
446 446
 
447
-		if ( ! $query->is_main_query() ) {
447
+		if ( ! $query->is_main_query () ) {
448 448
 			return;
449 449
 		}
450 450
 
451
-		if ( is_post_type_archive( 'podcast' ) || is_tax( 'series' ) ) {
451
+		if ( is_post_type_archive ( 'podcast' ) || is_tax ( 'series' ) ) {
452 452
 
453
-			$podcast_post_types = ssp_post_types( false );
453
+			$podcast_post_types = ssp_post_types ( false );
454 454
 
455 455
 			if ( empty( $podcast_post_types ) ) {
456 456
 				return;
457 457
 			}
458 458
 
459
-			$episode_ids = ssp_episode_ids();
459
+			$episode_ids = ssp_episode_ids ();
460 460
 			if ( ! empty( $episode_ids ) ) {
461 461
 
462
-				$query->set( 'post__in', $episode_ids );
462
+				$query->set ( 'post__in', $episode_ids );
463 463
 
464
-				$podcast_post_types[] = 'podcast';
465
-				$query->set( 'post_type', $podcast_post_types );
464
+				$podcast_post_types[ ] = 'podcast';
465
+				$query->set ( 'post_type', $podcast_post_types );
466 466
 
467 467
 			}
468 468
 
@@ -480,29 +480,29 @@  discard block
 block discarded – undo
480 480
 		if ( $file ) {
481 481
 
482 482
 			// Include media functions if necessary
483
-			if ( ! function_exists( 'wp_read_audio_metadata' ) ) {
484
-				require_once( ABSPATH . 'wp-admin/includes/media.php' );
483
+			if ( ! function_exists ( 'wp_read_audio_metadata' ) ) {
484
+				require_once( ABSPATH.'wp-admin/includes/media.php' );
485 485
 			}
486 486
 
487 487
 			// translate file URL to local file path if possible
488
-			$file = $this->get_local_file_path( $file );
488
+			$file = $this->get_local_file_path ( $file );
489 489
 
490 490
 			// Get file data (for local file)
491
-			$data = wp_read_audio_metadata( $file );
491
+			$data = wp_read_audio_metadata ( $file );
492 492
 
493 493
 			$raw = $formatted = '';
494 494
 
495 495
 			if ( $data ) {
496
-				$raw = $data['filesize'];
497
-				$formatted = $this->format_bytes( $raw );
496
+				$raw = $data[ 'filesize' ];
497
+				$formatted = $this->format_bytes ( $raw );
498 498
 			} else {
499 499
 
500 500
 				// get file data (for remote file)
501
-				$data = wp_remote_head( $file, array( 'timeout' => 10, 'redirection' => 5 ) );
501
+				$data = wp_remote_head ( $file, array( 'timeout' => 10, 'redirection' => 5 ) );
502 502
 
503
-				if ( ! is_wp_error( $data ) && is_array( $data ) && isset( $data['headers']['content-length'] ) ) {
504
-					$raw = $data['headers']['content-length'];
505
-					$formatted = $this->format_bytes( $raw );
503
+				if ( ! is_wp_error ( $data ) && is_array ( $data ) && isset( $data[ 'headers' ][ 'content-length' ] ) ) {
504
+					$raw = $data[ 'headers' ][ 'content-length' ];
505
+					$formatted = $this->format_bytes ( $raw );
506 506
 				}
507 507
 			}
508 508
 
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 					'formatted' => $formatted
514 514
 				);
515 515
 
516
-				return apply_filters( 'ssp_file_size', $size, $file );
516
+				return apply_filters ( 'ssp_file_size', $size, $file );
517 517
 			}
518 518
 
519 519
 		}
@@ -531,30 +531,30 @@  discard block
 block discarded – undo
531 531
 		if ( $file ) {
532 532
 
533 533
 			// Include media functions if necessary
534
-			if ( ! function_exists( 'wp_read_audio_metadata' ) ) {
535
-				require_once( ABSPATH . 'wp-admin/includes/media.php' );
534
+			if ( ! function_exists ( 'wp_read_audio_metadata' ) ) {
535
+				require_once( ABSPATH.'wp-admin/includes/media.php' );
536 536
 			}
537 537
 
538 538
 			// translate file URL to local file path if possible
539
-			$file = $this->get_local_file_path( $file );
539
+			$file = $this->get_local_file_path ( $file );
540 540
 
541 541
 			// Get file data (will only work for local files)
542
-			$data = wp_read_audio_metadata( $file );
542
+			$data = wp_read_audio_metadata ( $file );
543 543
 
544 544
 			$duration = false;
545 545
 
546 546
 			if ( $data ) {
547
-				if ( isset( $data['length_formatted'] ) && strlen( $data['length_formatted'] ) > 0 ) {
548
-					$duration = $data['length_formatted'];
547
+				if ( isset( $data[ 'length_formatted' ] ) && strlen ( $data[ 'length_formatted' ] ) > 0 ) {
548
+					$duration = $data[ 'length_formatted' ];
549 549
 				} else {
550
-					if ( isset( $data['length'] ) && strlen( $data['length'] ) > 0 ) {
551
-						$duration = gmdate( 'H:i:s', $data['length'] );
550
+					if ( isset( $data[ 'length' ] ) && strlen ( $data[ 'length' ] ) > 0 ) {
551
+						$duration = gmdate ( 'H:i:s', $data[ 'length' ] );
552 552
 					}
553 553
 				}
554 554
 			}
555 555
 
556 556
 			if ( $data ) {
557
-				return apply_filters( 'ssp_file_duration', $duration, $file );
557
+				return apply_filters ( 'ssp_file_duration', $duration, $file );
558 558
 			}
559 559
 
560 560
 		}
@@ -568,15 +568,15 @@  discard block
 block discarded – undo
568 568
 	 * @param  integer $precision Level of precision for formatting
569 569
 	 * @return mixed              Formatted file size on success, false on failure
570 570
 	 */
571
-	protected function format_bytes( $size , $precision = 2 ) {
571
+	protected function format_bytes( $size, $precision = 2 ) {
572 572
 
573 573
 		if ( $size ) {
574 574
 
575
-		    $base = log ( $size ) / log( 1024 );
576
-		    $suffixes = array( '' , 'k' , 'M' , 'G' , 'T' );
577
-		    $formatted_size = round( pow( 1024 , $base - floor( $base ) ) , $precision ) . $suffixes[ floor( $base ) ];
575
+		    $base = log ( $size ) / log ( 1024 );
576
+		    $suffixes = array( '', 'k', 'M', 'G', 'T' );
577
+		    $formatted_size = round ( pow ( 1024, $base - floor ( $base ) ), $precision ).$suffixes[ floor ( $base ) ];
578 578
 
579
-		    return apply_filters( 'ssp_file_size_formatted', $formatted_size, $size );
579
+		    return apply_filters ( 'ssp_file_size_formatted', $formatted_size, $size );
580 580
 		}
581 581
 
582 582
 		return false;
@@ -592,10 +592,10 @@  discard block
 block discarded – undo
592 592
 
593 593
 		// Let's hash the URL to ensure that we don't get
594 594
 		// any illegal chars that might break the cache.
595
-		$key = md5( $url );
595
+		$key = md5 ( $url );
596 596
 
597 597
 		// Do we have anything in the cache for this URL?
598
-		$attachment_id = wp_cache_get( $key, 'attachment_id' );
598
+		$attachment_id = wp_cache_get ( $key, 'attachment_id' );
599 599
 
600 600
 		if ( $attachment_id === false ) {
601 601
 
@@ -612,39 +612,39 @@  discard block
 block discarded – undo
612 612
 
613 613
 
614 614
 			// Function introduced in 4.0, let's try this first.
615
-			if ( function_exists( 'attachment_url_to_postid' ) ) {
616
-				$attachment_id = absint( attachment_url_to_postid( $url ) );
615
+			if ( function_exists ( 'attachment_url_to_postid' ) ) {
616
+				$attachment_id = absint ( attachment_url_to_postid ( $url ) );
617 617
 				if ( 0 !== $attachment_id ) {
618
-					wp_cache_set( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS );
618
+					wp_cache_set ( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS );
619 619
 					return $attachment_id;
620 620
 				}
621 621
 			}
622 622
 
623 623
 			// Then this.
624
-			if ( preg_match( '#\.[a-zA-Z0-9]+$#', $url ) ) {
625
-				$sql = $wpdb->prepare(
624
+			if ( preg_match ( '#\.[a-zA-Z0-9]+$#', $url ) ) {
625
+				$sql = $wpdb->prepare (
626 626
 					"SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND guid = %s",
627
-					esc_url_raw( $url )
627
+					esc_url_raw ( $url )
628 628
 				);
629
-				$attachment_id = absint( $wpdb->get_var( $sql ) );
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
 			}
635 635
 
636 636
 			// And then try this
637
-			$upload_dir_paths = wp_upload_dir();
638
-			if ( false !== strpos( $url, $upload_dir_paths['baseurl'] ) ) {
637
+			$upload_dir_paths = wp_upload_dir ();
638
+			if ( false !== strpos ( $url, $upload_dir_paths[ 'baseurl' ] ) ) {
639 639
 				// Ensure that we have file extension that matches iTunes.
640
-				$url = preg_replace( '/(?=\.(m4a|mp3|mov|mp4)$)/i', '', $url );
640
+				$url = preg_replace ( '/(?=\.(m4a|mp3|mov|mp4)$)/i', '', $url );
641 641
 				// Remove the upload path base directory from the attachment URL
642
-				$url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $url );
642
+				$url = str_replace ( $upload_dir_paths[ 'baseurl' ].'/', '', $url );
643 643
 				// Finally, run a custom database query to get the attachment ID from the modified attachment URL
644
-				$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 );
645
-				$attachment_id = absint( $wpdb->get_var( $sql ) );
644
+				$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 );
645
+				$attachment_id = absint ( $wpdb->get_var ( $sql ) );
646 646
 				if ( 0 !== $attachment_id ) {
647
-					wp_cache_set( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS );
647
+					wp_cache_set ( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS );
648 648
 					return $attachment_id;
649 649
 				}
650 650
 			}
@@ -662,20 +662,20 @@  discard block
 block discarded – undo
662 662
 	public function get_attachment_mimetype( $attachment = '' ) {
663 663
 
664 664
 		// Let's hash the URL to ensure that we don't get any illegal chars that might break the cache.
665
-		$key = md5( $attachment );
665
+		$key = md5 ( $attachment );
666 666
 
667 667
 		if ( $attachment ) {
668 668
 			// Do we have anything in the cache for this?
669
-			$mime = wp_cache_get( $key, 'mime-type' );
669
+			$mime = wp_cache_get ( $key, 'mime-type' );
670 670
 			if ( $mime === false ) {
671 671
 
672 672
 				// Get the ID
673
-				$id = $this->get_attachment_id_from_url( $attachment );
673
+				$id = $this->get_attachment_id_from_url ( $attachment );
674 674
 
675 675
 				// Get the MIME type
676
-				$mime = get_post_mime_type( $id );
676
+				$mime = get_post_mime_type ( $id );
677 677
 				// Set the cache
678
-				wp_cache_set( $key, $mime, 'mime-type', DAY_IN_SECONDS );
678
+				wp_cache_set ( $key, $mime, 'mime-type', DAY_IN_SECONDS );
679 679
 			}
680 680
 
681 681
 		    return $mime;
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 	 * @return string        	   Audio player HTML on success, false on failure
693 693
 	 */
694 694
 	public function audio_player( $src = '', $episode_id = 0 ) {
695
-		$player = $this->media_player( $src, $episode_id );
696
-		return apply_filters( 'ssp_audio_player', $player, $src, $episode_id );
695
+		$player = $this->media_player ( $src, $episode_id );
696
+		return apply_filters ( 'ssp_audio_player', $player, $src, $episode_id );
697 697
 	}
698 698
 
699 699
 	/**
@@ -702,40 +702,40 @@  discard block
 block discarded – undo
702 702
 	 * @param  integer $episode_id Episode ID for audio file
703 703
 	 * @return string              Media player HTML on success, empty string on failure
704 704
 	 */
705
-	public function media_player ( $src = '', $episode_id = 0 ) {
705
+	public function media_player( $src = '', $episode_id = 0 ) {
706 706
 		$player = '';
707 707
 
708 708
 		if ( $src ) {
709 709
 
710 710
 			// Get episode type and default to audio
711
-			$type = $this->get_episode_type( $episode_id );
712
-			if( ! $type ) {
711
+			$type = $this->get_episode_type ( $episode_id );
712
+			if ( ! $type ) {
713 713
 				$type = 'audio';
714 714
 			}
715 715
 
716 716
 			// Switch to podcast player URL
717
-			$src = str_replace( 'podcast-download', 'podcast-player', $src );
717
+			$src = str_replace ( 'podcast-download', 'podcast-player', $src );
718 718
 
719 719
 			// Set up paramters for media player
720 720
 			$params = array( 'src' => $src, 'preload' => 'none' );
721 721
 
722 722
 			// Use built-in WordPress media player
723
-			switch( $type ) {
724
-				case 'audio': $player = wp_audio_shortcode( $params ); break;
723
+			switch ( $type ) {
724
+				case 'audio': $player = wp_audio_shortcode ( $params ); break;
725 725
 				case 'video':
726 726
 					// Use featured image as video poster
727
-					if( $episode_id && has_post_thumbnail( $episode_id ) ) {
728
-						$poster = wp_get_attachment_url( get_post_thumbnail_id( $episode_id ) );
729
-						if( $poster ) {
730
-							$params['poster'] = $poster;
727
+					if ( $episode_id && has_post_thumbnail ( $episode_id ) ) {
728
+						$poster = wp_get_attachment_url ( get_post_thumbnail_id ( $episode_id ) );
729
+						if ( $poster ) {
730
+							$params[ 'poster' ] = $poster;
731 731
 						}
732 732
 					}
733
-					$player = wp_video_shortcode( $params );
733
+					$player = wp_video_shortcode ( $params );
734 734
 				break;
735 735
 			}
736 736
 
737 737
 			// Allow filtering so that alternative players can be used
738
-			$player = apply_filters( 'ssp_media_player', $player, $src, $episode_id );
738
+			$player = apply_filters ( 'ssp_media_player', $player, $src, $episode_id );
739 739
 		}
740 740
 
741 741
 		return $player;
@@ -750,17 +750,17 @@  discard block
 block discarded – undo
750 750
 	public function get_image( $id = 0, $size = 'full' ) {
751 751
 		$image = '';
752 752
 
753
-		if ( has_post_thumbnail( $id ) ) {
753
+		if ( has_post_thumbnail ( $id ) ) {
754 754
 			// If not a string or an array, and not an integer, default to 200x9999.
755
-			if ( is_int( $size ) || ( 0 < intval( $size ) ) ) {
756
-				$size = array( intval( $size ), intval( $size ) );
757
-			} elseif ( ! is_string( $size ) && ! is_array( $size ) ) {
755
+			if ( is_int ( $size ) || ( 0 < intval ( $size ) ) ) {
756
+				$size = array( intval ( $size ), intval ( $size ) );
757
+			} elseif ( ! is_string ( $size ) && ! is_array ( $size ) ) {
758 758
 				$size = array( 200, 9999 );
759 759
 			}
760
-			$image = get_the_post_thumbnail( intval( $id ), $size );
760
+			$image = get_the_post_thumbnail ( intval ( $id ), $size );
761 761
 		}
762 762
 
763
-		return apply_filters( 'ssp_episode_image', $image, $id );
763
+		return apply_filters ( 'ssp_episode_image', $image, $id );
764 764
 	}
765 765
 
766 766
 	/**
@@ -775,29 +775,29 @@  discard block
 block discarded – undo
775 775
 			'series' => ''
776 776
 		);
777 777
 
778
-		$args = apply_filters( 'ssp_get_podcast_args', wp_parse_args( $args, $defaults ) );
778
+		$args = apply_filters ( 'ssp_get_podcast_args', wp_parse_args ( $args, $defaults ) );
779 779
 
780 780
 		$query = array();
781 781
 
782
-		if ( 'episodes' == $args['content'] ) {
782
+		if ( 'episodes' == $args[ 'content' ] ) {
783 783
 
784 784
 			// Get selected series
785 785
 			$podcast_series = '';
786
-			if ( isset( $args['series'] ) && $args['series'] ) {
787
-				$podcast_series = $args['series'];
786
+			if ( isset( $args[ 'series' ] ) && $args[ 'series' ] ) {
787
+				$podcast_series = $args[ 'series' ];
788 788
 			}
789 789
 
790 790
 			// Get query args
791
-			$query_args = apply_filters( 'ssp_get_podcast_query_args', ssp_episodes( -1, $podcast_series, true, '' ) );
791
+			$query_args = apply_filters ( 'ssp_get_podcast_query_args', ssp_episodes ( -1, $podcast_series, true, '' ) );
792 792
 
793 793
 			// The Query
794
-			$query = get_posts( $query_args );
794
+			$query = get_posts ( $query_args );
795 795
 
796 796
 			// The Display
797
-			if ( ! is_wp_error( $query ) && is_array( $query ) && count( $query ) > 0 ) {
797
+			if ( ! is_wp_error ( $query ) && is_array ( $query ) && count ( $query ) > 0 ) {
798 798
 				foreach ( $query as $k => $v ) {
799 799
 					// Get the URL
800
-					$query[$k]->url = get_permalink( $v->ID );
800
+					$query[ $k ]->url = get_permalink ( $v->ID );
801 801
 				}
802 802
 			} else {
803 803
 				$query = false;
@@ -805,27 +805,27 @@  discard block
 block discarded – undo
805 805
 
806 806
 		} else {
807 807
 
808
-			$terms = get_terms( 'series' );
808
+			$terms = get_terms ( 'series' );
809 809
 
810
-			if ( count( $terms ) > 0) {
810
+			if ( count ( $terms ) > 0 ) {
811 811
 
812 812
 				foreach ( $terms as $term ) {
813
-					$query[ $term->term_id ] = new stdClass();
813
+					$query[ $term->term_id ] = new stdClass ();
814 814
 					$query[ $term->term_id ]->title = $term->name;
815
-		    		$query[ $term->term_id ]->url = get_term_link( $term );
815
+		    		$query[ $term->term_id ]->url = get_term_link ( $term );
816 816
 
817
-		    		$query_args = apply_filters( 'ssp_get_podcast_series_query_args', ssp_episodes( -1, $term->slug, true, '' ) );
817
+		    		$query_args = apply_filters ( 'ssp_get_podcast_series_query_args', ssp_episodes ( -1, $term->slug, true, '' ) );
818 818
 
819
-		    		$posts = get_posts( $query_args );
819
+		    		$posts = get_posts ( $query_args );
820 820
 
821
-		    		$count = count( $posts );
821
+		    		$count = count ( $posts );
822 822
 		    		$query[ $term->term_id ]->count = $count;
823 823
 			    }
824 824
 			}
825 825
 
826 826
 		}
827 827
 
828
-		$query['content'] = $args['content'];
828
+		$query[ 'content' ] = $args[ 'content' ];
829 829
 
830 830
 		return $query;
831 831
 	}
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 	public function get_enclosure( $episode_id = 0 ) {
839 839
 
840 840
 		if ( $episode_id ) {
841
-			return apply_filters( 'ssp_episode_enclosure', get_post_meta( $episode_id, 'audio_file', true ), $episode_id );
841
+			return apply_filters ( 'ssp_episode_enclosure', get_post_meta ( $episode_id, 'audio_file', true ), $episode_id );
842 842
 		}
843 843
 
844 844
 		return '';
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 
857 857
 		if ( $file != '' ) {
858 858
 
859
-			$post_types = ssp_post_types( true );
859
+			$post_types = ssp_post_types ( true );
860 860
 
861 861
 			$args = array(
862 862
 				'post_type' => $post_types,
@@ -866,17 +866,17 @@  discard block
 block discarded – undo
866 866
 				'meta_value' => $file
867 867
 			);
868 868
 
869
-			$qry = new WP_Query( $args );
869
+			$qry = new WP_Query ( $args );
870 870
 
871
-			if ( $qry->have_posts() ) {
872
-				while ( $qry->have_posts() ) { $qry->the_post();
871
+			if ( $qry->have_posts () ) {
872
+				while ( $qry->have_posts () ) { $qry->the_post ();
873 873
 					$episode = $post;
874 874
 					break;
875 875
 				}
876 876
 			}
877 877
 		}
878 878
 
879
-		return apply_filters( 'ssp_episode_from_file', $episode, $file );
879
+		return apply_filters ( 'ssp_episode_from_file', $episode, $file );
880 880
 
881 881
 	}
882 882
 
@@ -886,33 +886,33 @@  discard block
 block discarded – undo
886 886
 	 */
887 887
 	public function download_file() {
888 888
 
889
-		if ( is_podcast_download() ) {
889
+		if ( is_podcast_download () ) {
890 890
 			global $wp_query;
891 891
 
892 892
 			// Get requested episode ID
893
-			$episode_id = intval( $wp_query->query_vars['podcast_episode'] );
893
+			$episode_id = intval ( $wp_query->query_vars[ 'podcast_episode' ] );
894 894
 
895 895
 			if ( isset( $episode_id ) && $episode_id ) {
896 896
 
897 897
 				// Get episode post object
898
-				$episode = get_post( $episode_id );
898
+				$episode = get_post ( $episode_id );
899 899
 
900 900
 				// Make sure we have a valid episode post object
901
-				if ( ! $episode || ! is_object( $episode ) || is_wp_error( $episode ) || ! isset( $episode->ID ) ) {
901
+				if ( ! $episode || ! is_object ( $episode ) || is_wp_error ( $episode ) || ! isset( $episode->ID ) ) {
902 902
 					return;
903 903
 				}
904 904
 
905 905
 				// Do we have newlines?
906 906
 				$parts = false;
907
-				if( is_string( $episode ) ) {
908
-					$parts = explode( "\n", $episode );
907
+				if ( is_string ( $episode ) ) {
908
+					$parts = explode ( "\n", $episode );
909 909
 				}
910 910
 
911
-				if ( $parts && is_array( $parts ) && count( $parts ) > 1 ) {
912
-					$file = $parts[0];
911
+				if ( $parts && is_array ( $parts ) && count ( $parts ) > 1 ) {
912
+					$file = $parts[ 0 ];
913 913
 				} else {
914 914
 					// Get audio file for download
915
-					$file = $this->get_enclosure( $episode_id );
915
+					$file = $this->get_enclosure ( $episode_id );
916 916
 				}
917 917
 
918 918
 				// Exit if no file is found
@@ -922,77 +922,77 @@  discard block
 block discarded – undo
922 922
 
923 923
 				// Get file referrer
924 924
 				$referrer = '';
925
-				if( isset( $wp_query->query_vars['podcast_ref'] ) && $wp_query->query_vars['podcast_ref'] ) {
926
-					$referrer = $wp_query->query_vars['podcast_ref'];
925
+				if ( isset( $wp_query->query_vars[ 'podcast_ref' ] ) && $wp_query->query_vars[ 'podcast_ref' ] ) {
926
+					$referrer = $wp_query->query_vars[ 'podcast_ref' ];
927 927
 				} else {
928
-					if( isset( $_GET['ref'] ) ) {
929
-						$referrer = esc_attr( $_GET['ref'] );
928
+					if ( isset( $_GET[ 'ref' ] ) ) {
929
+						$referrer = esc_attr ( $_GET[ 'ref' ] );
930 930
 					}
931 931
 				}
932 932
 
933 933
 				// Allow other actions - functions hooked on here must not output any data
934
-			    do_action( 'ssp_file_download', $file, $episode, $referrer );
934
+			    do_action ( 'ssp_file_download', $file, $episode, $referrer );
935 935
 
936 936
 			    // Set necessary headers
937
-				header( "Pragma: no-cache" );
938
-				header( "Expires: 0" );
939
-				header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
940
-				header( "Robots: none" );
937
+				header ( "Pragma: no-cache" );
938
+				header ( "Expires: 0" );
939
+				header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
940
+				header ( "Robots: none" );
941 941
 
942 942
 		        // Check file referrer
943
-		        if( 'download' == $referrer ) {
943
+		        if ( 'download' == $referrer ) {
944 944
 
945 945
 		        	// Set size of file
946 946
 					// Do we have anything in Cache/DB?
947
-					$size = wp_cache_get( $episode_id, 'filesize_raw' );
947
+					$size = wp_cache_get ( $episode_id, 'filesize_raw' );
948 948
 
949 949
 					// Nothing in the cache, let's see if we can figure it out.
950 950
 					if ( false === $size ) {
951 951
 
952 952
 						// Do we have anything in post_meta?
953
-						$size = get_post_meta( $episode_id, 'filesize_raw', true );
953
+						$size = get_post_meta ( $episode_id, 'filesize_raw', true );
954 954
 
955 955
 						if ( empty( $size ) ) {
956 956
 
957 957
 							// Let's see if we can figure out the path...
958
-							$attachment_id = $this->get_attachment_id_from_url( $file );
958
+							$attachment_id = $this->get_attachment_id_from_url ( $file );
959 959
 
960
-							if ( ! empty( $attachment_id )  ) {
961
-								$size = filesize( get_attached_file( $attachment_id ) );
962
-								update_post_meta( $episode_id, 'filesize_raw', $size );
960
+							if ( ! empty( $attachment_id ) ) {
961
+								$size = filesize ( get_attached_file ( $attachment_id ) );
962
+								update_post_meta ( $episode_id, 'filesize_raw', $size );
963 963
 							}
964 964
 
965 965
 						}
966 966
 
967 967
 						// Update the cache
968
-						wp_cache_set( $episode_id, $size, 'filesize_raw' );
968
+						wp_cache_set ( $episode_id, $size, 'filesize_raw' );
969 969
 					}
970 970
 
971 971
 					// Send Content-Length header
972 972
 		        	if ( ! empty( $size ) ) {
973
-						header( "Content-Length: " . $size );
973
+						header ( "Content-Length: ".$size );
974 974
 					}
975 975
 
976 976
 		        	// Force file download
977
-		        	header( "Content-Type: application/force-download" );
977
+		        	header ( "Content-Type: application/force-download" );
978 978
 
979 979
 			        // Set other relevant headers
980
-			        header( "Content-Description: File Transfer" );
981
-			        header( "Content-Disposition: attachment; filename=\"" . basename( $file ) . "\";" );
982
-			        header( "Content-Transfer-Encoding: binary" );
980
+			        header ( "Content-Description: File Transfer" );
981
+			        header ( "Content-Disposition: attachment; filename=\"".basename ( $file )."\";" );
982
+			        header ( "Content-Transfer-Encoding: binary" );
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
 			        // Use ssp_readfile_chunked() if allowed on the server or simply access file directly
988
-					@ssp_readfile_chunked( $file ) or header( 'Location: ' . $file );
988
+					@ssp_readfile_chunked ( $file ) or header ( 'Location: '.$file );
989 989
 				} else {
990 990
 
991 991
 					// Encode spaces in file names until this is fixed in core (https://core.trac.wordpress.org/ticket/36998)
992
-					$file = str_replace( ' ', '%20', $file );
992
+					$file = str_replace ( ' ', '%20', $file );
993 993
 
994 994
 					// For all other referrers redirect to the raw file
995
-					wp_redirect( $file, 302 );
995
+					wp_redirect ( $file, 302 );
996 996
 				}
997 997
 
998 998
 				// Exit to prevent other processes running later on
@@ -1009,16 +1009,16 @@  discard block
 block discarded – undo
1009 1009
 	public function generator_tag( $gen, $type ) {
1010 1010
 
1011 1011
 		// Allow generator tags to be hidden if necessary
1012
-		if ( apply_filters( 'ssp_show_generator_tag', true, $type ) ) {
1012
+		if ( apply_filters ( 'ssp_show_generator_tag', true, $type ) ) {
1013 1013
 
1014
-			$generator = 'Seriously Simple Podcasting ' . esc_attr( $this->version );
1014
+			$generator = 'Seriously Simple Podcasting '.esc_attr ( $this->version );
1015 1015
 
1016 1016
 			switch ( $type ) {
1017 1017
 				case 'html':
1018
-					$gen .= "\n" . '<meta name="generator" content="' . $generator . '">';
1018
+					$gen .= "\n".'<meta name="generator" content="'.$generator.'">';
1019 1019
 				break;
1020 1020
 				case 'xhtml':
1021
-					$gen .= "\n" . '<meta name="generator" content="' . $generator . '" />';
1021
+					$gen .= "\n".'<meta name="generator" content="'.$generator.'" />';
1022 1022
 				break;
1023 1023
 			}
1024 1024
 
@@ -1034,53 +1034,53 @@  discard block
 block discarded – undo
1034 1034
 	public function rss_meta_tag() {
1035 1035
 
1036 1036
 		// Get feed slug
1037
-		$feed_slug = apply_filters( 'ssp_feed_slug', $this->token );
1037
+		$feed_slug = apply_filters ( 'ssp_feed_slug', $this->token );
1038 1038
 
1039
-		if ( get_option( 'permalink_structure' ) ) {
1040
-			$feed_url = $this->home_url . 'feed/' . $feed_slug;
1039
+		if ( get_option ( 'permalink_structure' ) ) {
1040
+			$feed_url = $this->home_url.'feed/'.$feed_slug;
1041 1041
 		} else {
1042
-			$feed_url = $this->home_url . '?feed=' . $feed_slug;
1042
+			$feed_url = $this->home_url.'?feed='.$feed_slug;
1043 1043
 		}
1044 1044
 
1045
-		$custom_feed_url = get_option( 'ss_podcasting_feed_url' );
1045
+		$custom_feed_url = get_option ( 'ss_podcasting_feed_url' );
1046 1046
 		if ( $custom_feed_url ) {
1047 1047
 			$feed_url = $custom_feed_url;
1048 1048
 		}
1049 1049
 
1050
-		$feed_url = apply_filters( 'ssp_feed_url', $feed_url );
1050
+		$feed_url = apply_filters ( 'ssp_feed_url', $feed_url );
1051 1051
 
1052 1052
 		$html = '';
1053 1053
 
1054
-		if( apply_filters( 'ssp_show_global_feed_tag', true ) ) {
1055
-			$html = '<link rel="alternate" type="application/rss+xml" title="' . __( 'Podcast RSS feed', 'seriously-simple-podcasting' ) . '" href="' . esc_url( $feed_url ) . '" />';
1054
+		if ( apply_filters ( 'ssp_show_global_feed_tag', true ) ) {
1055
+			$html = '<link rel="alternate" type="application/rss+xml" title="'.__ ( 'Podcast RSS feed', 'seriously-simple-podcasting' ).'" href="'.esc_url ( $feed_url ).'" />';
1056 1056
 		}
1057 1057
 
1058 1058
 		// Check if this is a series taxonomy archive and display series-specific RSS feed tag
1059
-		$current_obj = get_queried_object();
1060
-		if( isset( $current_obj->taxonomy ) && 'series' == $current_obj->taxonomy && isset( $current_obj->slug ) && $current_obj->slug ) {
1059
+		$current_obj = get_queried_object ();
1060
+		if ( isset( $current_obj->taxonomy ) && 'series' == $current_obj->taxonomy && isset( $current_obj->slug ) && $current_obj->slug ) {
1061 1061
 
1062
-			if( apply_filters( 'ssp_show_series_feed_tag', true, $current_obj->slug ) ) {
1062
+			if ( apply_filters ( 'ssp_show_series_feed_tag', true, $current_obj->slug ) ) {
1063 1063
 
1064
-				if ( get_option( 'permalink_structure' ) ) {
1065
-					$series_feed_url = $feed_url . '/' . $current_obj->slug;
1064
+				if ( get_option ( 'permalink_structure' ) ) {
1065
+					$series_feed_url = $feed_url.'/'.$current_obj->slug;
1066 1066
 				} else {
1067
-					$series_feed_url = $feed_url . '&podcast_series=' . $current_obj->slug;
1067
+					$series_feed_url = $feed_url.'&podcast_series='.$current_obj->slug;
1068 1068
 				}
1069 1069
 
1070
-				$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 ) . '" />';
1070
+				$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 ).'" />';
1071 1071
 
1072 1072
 			}
1073 1073
 
1074 1074
 		}
1075 1075
 
1076
-		echo "\n" . apply_filters( 'ssp_rss_meta_tag', $html ) . "\n\n";
1076
+		echo "\n".apply_filters ( 'ssp_rss_meta_tag', $html )."\n\n";
1077 1077
 	}
1078 1078
 
1079 1079
 	/**
1080 1080
 	 * Register plugin widgets
1081 1081
 	 * @return void
1082 1082
 	 */
1083
-	public function register_widgets () {
1083
+	public function register_widgets() {
1084 1084
 
1085 1085
 		$widgets = array(
1086 1086
 			'recent-episodes' => 'Recent_Episodes',
@@ -1090,8 +1090,8 @@  discard block
 block discarded – undo
1090 1090
 		);
1091 1091
 
1092 1092
 		foreach ( $widgets as $id => $name ) {
1093
-			require_once( $this->dir . '/includes/widgets/class-ssp-widget-' . $id . '.php' );
1094
-			register_widget( 'SSP_Widget_' . $name );
1093
+			require_once( $this->dir.'/includes/widgets/class-ssp-widget-'.$id.'.php' );
1094
+			register_widget ( 'SSP_Widget_'.$name );
1095 1095
 		}
1096 1096
 
1097 1097
 	}
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 	 * Register plugin shortcodes
1101 1101
 	 * @return void
1102 1102
 	 */
1103
-	public function register_shortcodes () {
1103
+	public function register_shortcodes() {
1104 1104
 
1105 1105
 		$shortcodes = array(
1106 1106
 			'podcast_episode',
@@ -1109,8 +1109,8 @@  discard block
 block discarded – undo
1109 1109
 		);
1110 1110
 
1111 1111
 		foreach ( $shortcodes as $shortcode ) {
1112
-			require_once( $this->dir . '/includes/shortcodes/class-ssp-shortcode-' . $shortcode . '.php' );
1113
-			add_shortcode( $shortcode, array( $GLOBALS['ssp_shortcodes'][ $shortcode ], 'shortcode' ) );
1112
+			require_once( $this->dir.'/includes/shortcodes/class-ssp-shortcode-'.$shortcode.'.php' );
1113
+			add_shortcode ( $shortcode, array( $GLOBALS[ 'ssp_shortcodes' ][ $shortcode ], 'shortcode' ) );
1114 1114
 		}
1115 1115
 
1116 1116
 	}
@@ -1121,64 +1121,64 @@  discard block
 block discarded – undo
1121 1121
 	 * @param  array   $content_items Orderd array of content items to display
1122 1122
 	 * @return string                 HTML of episode with specified content items
1123 1123
 	 */
1124
-	public function podcast_episode ( $episode_id = 0, $content_items = array( 'title', 'player', 'details' ), $context = '' ) {
1124
+	public function podcast_episode( $episode_id = 0, $content_items = array( 'title', 'player', 'details' ), $context = '' ) {
1125 1125
 		global $post, $episode_context;
1126 1126
 
1127
-		if ( ! $episode_id || ! is_array( $content_items ) || empty( $content_items ) ) {
1127
+		if ( ! $episode_id || ! is_array ( $content_items ) || empty( $content_items ) ) {
1128 1128
 			return;
1129 1129
 		}
1130 1130
 
1131 1131
 		// Get episode object
1132
-		$episode = get_post( $episode_id );
1132
+		$episode = get_post ( $episode_id );
1133 1133
 
1134
-		if ( ! $episode || is_wp_error( $episode ) ) {
1134
+		if ( ! $episode || is_wp_error ( $episode ) ) {
1135 1135
 			return;
1136 1136
 		}
1137 1137
 
1138
-		$html = '<div class="podcast-episode episode-' . esc_attr( $episode_id ) . '">' . "\n";
1138
+		$html = '<div class="podcast-episode episode-'.esc_attr ( $episode_id ).'">'."\n";
1139 1139
 
1140 1140
 			// Setup post data for episode post object
1141 1141
 			$post = $episode;
1142
-			setup_postdata( $post );
1142
+			setup_postdata ( $post );
1143 1143
 
1144 1144
 			$episode_context = $context;
1145 1145
 
1146 1146
 			// Display specified content items in the order supplied
1147 1147
 			foreach ( $content_items as $item ) {
1148 1148
 
1149
-				switch( $item ) {
1149
+				switch ( $item ) {
1150 1150
 
1151 1151
 					case 'title':
1152
-						$html .= '<h3 class="episode-title">' . get_the_title() . '</h3>' . "\n";
1152
+						$html .= '<h3 class="episode-title">'.get_the_title ().'</h3>'."\n";
1153 1153
 					break;
1154 1154
 
1155 1155
 					case 'excerpt':
1156
-						$html .= '<p class="episode-excerpt">' . get_the_excerpt() . '</p>' . "\n";
1156
+						$html .= '<p class="episode-excerpt">'.get_the_excerpt ().'</p>'."\n";
1157 1157
 					break;
1158 1158
 
1159 1159
 					case 'content':
1160
-						$html .= '<div class="episode-content">' . apply_filters( 'the_content', get_the_content() ) . '</div>' . "\n";
1160
+						$html .= '<div class="episode-content">'.apply_filters ( 'the_content', get_the_content () ).'</div>'."\n";
1161 1161
 					break;
1162 1162
 
1163 1163
 					case 'player':
1164
-						$file = $this->get_enclosure( $episode_id );
1165
-						if ( get_option( 'permalink_structure' ) ) {
1166
-							$file = $this->get_episode_download_link( $episode_id );
1164
+						$file = $this->get_enclosure ( $episode_id );
1165
+						if ( get_option ( 'permalink_structure' ) ) {
1166
+							$file = $this->get_episode_download_link ( $episode_id );
1167 1167
 						}
1168
-		    			$html .= '<div class="podcast_player">' . $this->media_player( $file, $episode_id ) . '</div>' . "\n";
1168
+		    			$html .= '<div class="podcast_player">'.$this->media_player ( $file, $episode_id ).'</div>'."\n";
1169 1169
 					break;
1170 1170
 
1171 1171
 					case 'details':
1172
-						$html .= $this->episode_meta_details( $episode_id, $episode_context );
1172
+						$html .= $this->episode_meta_details ( $episode_id, $episode_context );
1173 1173
 					break;
1174 1174
 
1175 1175
 				}
1176 1176
 			}
1177 1177
 
1178 1178
 			// Reset post data after fetching episode details
1179
-			wp_reset_postdata();
1179
+			wp_reset_postdata ();
1180 1180
 
1181
-		$html .= '</div>' . "\n";
1181
+		$html .= '</div>'."\n";
1182 1182
 
1183 1183
 	    return $html;
1184 1184
 	}
@@ -1193,26 +1193,26 @@  discard block
 block discarded – undo
1193 1193
 	function get_local_file_path( $file ) {
1194 1194
 
1195 1195
 		// Identify file by root path and not URL (required for getID3 class)
1196
-		$site_root = trailingslashit( ABSPATH );
1196
+		$site_root = trailingslashit ( ABSPATH );
1197 1197
 
1198 1198
 		// Remove common dirs from the ends of site_url and site_root, so that file can be outside of the WordPress installation
1199
-		$root_chunks = explode( '/', $site_root );
1200
-		$url_chunks  = explode( '/', $this->site_url );
1199
+		$root_chunks = explode ( '/', $site_root );
1200
+		$url_chunks  = explode ( '/', $this->site_url );
1201 1201
 
1202
-		end( $root_chunks );
1203
-		end( $url_chunks );
1202
+		end ( $root_chunks );
1203
+		end ( $url_chunks );
1204 1204
 
1205
-		while ( ! is_null( key( $root_chunks ) ) && ! is_null( key( $url_chunks ) ) && ( current( $root_chunks ) == current( $url_chunks ) ) ) {
1206
-			array_pop( $root_chunks );
1207
-			array_pop( $url_chunks );
1208
-			end( $root_chunks );
1209
-			end( $url_chunks );
1205
+		while ( ! is_null ( key ( $root_chunks ) ) && ! is_null ( key ( $url_chunks ) ) && ( current ( $root_chunks ) == current ( $url_chunks ) ) ) {
1206
+			array_pop ( $root_chunks );
1207
+			array_pop ( $url_chunks );
1208
+			end ( $root_chunks );
1209
+			end ( $url_chunks );
1210 1210
 		}
1211 1211
 
1212
-		$site_root = implode('/', $root_chunks);
1213
-		$site_url  = implode('/', $url_chunks);
1212
+		$site_root = implode ( '/', $root_chunks );
1213
+		$site_url  = implode ( '/', $url_chunks );
1214 1214
 
1215
-		$file = str_replace( $site_url, $site_root, $file );
1215
+		$file = str_replace ( $site_url, $site_root, $file );
1216 1216
 
1217 1217
 		return $file;
1218 1218
 	}
@@ -1224,16 +1224,16 @@  discard block
 block discarded – undo
1224 1224
 	 * @param  string $type         Type of feed
1225 1225
 	 * @return string               Updated content type
1226 1226
 	 */
1227
-	public function feed_content_type ( $content_type = '', $type = '' ) {
1227
+	public function feed_content_type( $content_type = '', $type = '' ) {
1228 1228
 
1229
-		if( 'podcast' == $type ) {
1229
+		if ( 'podcast' == $type ) {
1230 1230
 			$content_type = 'text/xml';
1231 1231
 		}
1232 1232
 
1233 1233
 		return $content_type;
1234 1234
 	}
1235 1235
 
1236
-	public function load_localisation () {
1237
-		load_plugin_textdomain( 'seriously-simple-podcasting', false, basename( dirname( $this->file ) ) . '/languages/' );
1236
+	public function load_localisation() {
1237
+		load_plugin_textdomain ( 'seriously-simple-podcasting', false, basename ( dirname ( $this->file ) ).'/languages/' );
1238 1238
 	}
1239 1239
 }
Please login to merge, or discard this patch.