@@ -559,11 +559,11 @@ discard block |
||
559 | 559 | |
560 | 560 | if ( $size ) { |
561 | 561 | |
562 | - $base = log ( $size ) / log( 1024 ); |
|
563 | - $suffixes = array( '' , 'k' , 'M' , 'G' , 'T' ); |
|
564 | - $formatted_size = round( pow( 1024 , $base - floor( $base ) ) , $precision ) . $suffixes[ floor( $base ) ]; |
|
562 | + $base = log ( $size ) / log( 1024 ); |
|
563 | + $suffixes = array( '' , 'k' , 'M' , 'G' , 'T' ); |
|
564 | + $formatted_size = round( pow( 1024 , $base - floor( $base ) ) , $precision ) . $suffixes[ floor( $base ) ]; |
|
565 | 565 | |
566 | - return apply_filters( 'ssp_file_size_formatted', $formatted_size, $size ); |
|
566 | + return apply_filters( 'ssp_file_size_formatted', $formatted_size, $size ); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | return false; |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | wp_cache_set( $key, $mime, 'mime-type', DAY_IN_SECONDS ); |
666 | 666 | } |
667 | 667 | |
668 | - return $mime; |
|
668 | + return $mime; |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | return false; |
@@ -799,15 +799,15 @@ discard block |
||
799 | 799 | foreach ( $terms as $term ) { |
800 | 800 | $query[ $term->term_id ] = new stdClass(); |
801 | 801 | $query[ $term->term_id ]->title = $term->name; |
802 | - $query[ $term->term_id ]->url = get_term_link( $term ); |
|
802 | + $query[ $term->term_id ]->url = get_term_link( $term ); |
|
803 | 803 | |
804 | - $query_args = apply_filters( 'ssp_get_podcast_series_query_args', ssp_episodes( -1, $term->slug, true, '' ) ); |
|
804 | + $query_args = apply_filters( 'ssp_get_podcast_series_query_args', ssp_episodes( -1, $term->slug, true, '' ) ); |
|
805 | 805 | |
806 | - $posts = get_posts( $query_args ); |
|
806 | + $posts = get_posts( $query_args ); |
|
807 | 807 | |
808 | - $count = count( $posts ); |
|
809 | - $query[ $term->term_id ]->count = $count; |
|
810 | - } |
|
808 | + $count = count( $posts ); |
|
809 | + $query[ $term->term_id ]->count = $count; |
|
810 | + } |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | } |
@@ -918,18 +918,18 @@ discard block |
||
918 | 918 | } |
919 | 919 | |
920 | 920 | // Allow other actions - functions hooked on here must not output any data |
921 | - do_action( 'ssp_file_download', $file, $episode, $referrer ); |
|
921 | + do_action( 'ssp_file_download', $file, $episode, $referrer ); |
|
922 | 922 | |
923 | - // Set necessary headers |
|
923 | + // Set necessary headers |
|
924 | 924 | header( "Pragma: no-cache" ); |
925 | 925 | header( "Expires: 0" ); |
926 | 926 | header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); |
927 | 927 | header( "Robots: none" ); |
928 | 928 | |
929 | - // Check file referrer |
|
930 | - if( 'download' == $referrer ) { |
|
929 | + // Check file referrer |
|
930 | + if( 'download' == $referrer ) { |
|
931 | 931 | |
932 | - // Set size of file |
|
932 | + // Set size of file |
|
933 | 933 | // Do we have anything in Cache/DB? |
934 | 934 | $size = wp_cache_get( $episode_id, 'filesize_raw' ); |
935 | 935 | |
@@ -956,22 +956,22 @@ discard block |
||
956 | 956 | } |
957 | 957 | |
958 | 958 | // Send Content-Length header |
959 | - if ( ! empty( $size ) ) { |
|
959 | + if ( ! empty( $size ) ) { |
|
960 | 960 | header( "Content-Length: " . $size ); |
961 | 961 | } |
962 | 962 | |
963 | - // Force file download |
|
964 | - header( "Content-Type: application/force-download" ); |
|
963 | + // Force file download |
|
964 | + header( "Content-Type: application/force-download" ); |
|
965 | 965 | |
966 | - // Set other relevant headers |
|
967 | - header( "Content-Description: File Transfer" ); |
|
968 | - header( "Content-Disposition: attachment; filename=\"" . basename( $file ) . "\";" ); |
|
969 | - header( "Content-Transfer-Encoding: binary" ); |
|
966 | + // Set other relevant headers |
|
967 | + header( "Content-Description: File Transfer" ); |
|
968 | + header( "Content-Disposition: attachment; filename=\"" . basename( $file ) . "\";" ); |
|
969 | + header( "Content-Transfer-Encoding: binary" ); |
|
970 | 970 | |
971 | - // Encode spaces in file names until this is fixed in core (https://core.trac.wordpress.org/ticket/36998) |
|
971 | + // Encode spaces in file names until this is fixed in core (https://core.trac.wordpress.org/ticket/36998) |
|
972 | 972 | $file = str_replace( ' ', '%20', $file ); |
973 | 973 | |
974 | - // Use ssp_readfile_chunked() if allowed on the server or simply access file directly |
|
974 | + // Use ssp_readfile_chunked() if allowed on the server or simply access file directly |
|
975 | 975 | @ssp_readfile_chunked( $file ) or header( 'Location: ' . $file ); |
976 | 976 | } else { |
977 | 977 | |
@@ -1090,34 +1090,34 @@ discard block |
||
1090 | 1090 | public function podcast_episode_shortcode ( $params ) { |
1091 | 1091 | |
1092 | 1092 | $atts = shortcode_atts( array( |
1093 | - 'episode' => 0, |
|
1094 | - 'content' => 'title,player,details', |
|
1095 | - ), $params ); |
|
1093 | + 'episode' => 0, |
|
1094 | + 'content' => 'title,player,details', |
|
1095 | + ), $params ); |
|
1096 | 1096 | |
1097 | 1097 | extract( $atts ); |
1098 | 1098 | |
1099 | 1099 | // If no episode ID is specified then use the current post's ID |
1100 | - if ( ! $episode ) { |
|
1100 | + if ( ! $episode ) { |
|
1101 | 1101 | |
1102 | - global $post; |
|
1103 | - if( isset( $post->ID ) ) { |
|
1104 | - $episode = intval( $post->ID ); |
|
1105 | - } |
|
1102 | + global $post; |
|
1103 | + if( isset( $post->ID ) ) { |
|
1104 | + $episode = intval( $post->ID ); |
|
1105 | + } |
|
1106 | 1106 | |
1107 | - if ( ! $episode ) { |
|
1108 | - return; |
|
1109 | - } |
|
1107 | + if ( ! $episode ) { |
|
1108 | + return; |
|
1109 | + } |
|
1110 | 1110 | |
1111 | - } |
|
1111 | + } |
|
1112 | 1112 | |
1113 | - // Setup array of content items and trim whitespace |
|
1114 | - $content_items = explode( ',', $content ); |
|
1115 | - $content_items = array_map( 'trim', $content_items ); |
|
1113 | + // Setup array of content items and trim whitespace |
|
1114 | + $content_items = explode( ',', $content ); |
|
1115 | + $content_items = array_map( 'trim', $content_items ); |
|
1116 | 1116 | |
1117 | - // Get episode for display |
|
1118 | - $html = $this->podcast_episode( $episode, $content_items, 'shortcode' ); |
|
1117 | + // Get episode for display |
|
1118 | + $html = $this->podcast_episode( $episode, $content_items, 'shortcode' ); |
|
1119 | 1119 | |
1120 | - return $html; |
|
1120 | + return $html; |
|
1121 | 1121 | |
1122 | 1122 | } |
1123 | 1123 | |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | if ( get_option( 'permalink_structure' ) ) { |
1172 | 1172 | $file = $this->get_episode_download_link( $episode_id ); |
1173 | 1173 | } |
1174 | - $html .= '<div class="podcast_player">' . $this->media_player( $file, $episode_id ) . '</div>' . "\n"; |
|
1174 | + $html .= '<div class="podcast_player">' . $this->media_player( $file, $episode_id ) . '</div>' . "\n"; |
|
1175 | 1175 | break; |
1176 | 1176 | |
1177 | 1177 | case 'details': |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | |
1187 | 1187 | $html .= '</div>' . "\n"; |
1188 | 1188 | |
1189 | - return $html; |
|
1189 | + return $html; |
|
1190 | 1190 | } |
1191 | 1191 | |
1192 | 1192 | /** |
@@ -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,58 +33,58 @@ 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 | // Handle localisation |
87 | - add_action( 'plugins_loaded', array( $this, 'load_localisation' ) ); |
|
87 | + add_action ( 'plugins_loaded', array( $this, 'load_localisation' ) ); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -95,36 +95,36 @@ discard block |
||
95 | 95 | public function get_episode_download_link( $episode_id, $referrer = '' ) { |
96 | 96 | |
97 | 97 | // Get file URL |
98 | - $file = $this->get_enclosure( $episode_id ); |
|
98 | + $file = $this->get_enclosure ( $episode_id ); |
|
99 | 99 | |
100 | 100 | if ( ! $file ) { |
101 | 101 | return; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Get download link based on permalink structure |
105 | - if ( get_option( 'permalink_structure' ) ) { |
|
106 | - $episode = get_post( $episode_id ); |
|
105 | + if ( get_option ( 'permalink_structure' ) ) { |
|
106 | + $episode = get_post ( $episode_id ); |
|
107 | 107 | |
108 | 108 | // Get file extension - default to MP3 to prevent empty extension strings |
109 | - $ext = pathinfo( $file, PATHINFO_EXTENSION ); |
|
110 | - if( ! $ext ) { |
|
109 | + $ext = pathinfo ( $file, PATHINFO_EXTENSION ); |
|
110 | + if ( ! $ext ) { |
|
111 | 111 | $ext = 'mp3'; |
112 | 112 | } |
113 | 113 | |
114 | - $link = $this->home_url . 'podcast-download/' . $episode_id . '/' . $episode->post_name . '.' . $ext; |
|
114 | + $link = $this->home_url.'podcast-download/'.$episode_id.'/'.$episode->post_name.'.'.$ext; |
|
115 | 115 | } else { |
116 | - $link = add_query_arg( array( 'podcast_episode' => $episode_id ), $this->home_url ); |
|
116 | + $link = add_query_arg ( array( 'podcast_episode' => $episode_id ), $this->home_url ); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // Allow for dyamic referrer |
120 | - $referrer = apply_filters( 'ssp_download_referrer', $referrer, $episode_id ); |
|
120 | + $referrer = apply_filters ( 'ssp_download_referrer', $referrer, $episode_id ); |
|
121 | 121 | |
122 | 122 | // Add referrer flag if supplied |
123 | 123 | if ( $referrer ) { |
124 | - $link = add_query_arg( array( 'ref' => $referrer ), $link ); |
|
124 | + $link = add_query_arg ( array( 'ref' => $referrer ), $link ); |
|
125 | 125 | } |
126 | 126 | |
127 | - return apply_filters( 'ssp_episode_download_link', esc_url( $link ), $episode_id, $file ); |
|
127 | + return apply_filters ( 'ssp_episode_download_link', esc_url ( $link ), $episode_id, $file ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function get_episode_type( $episode_id = 0 ) { |
136 | 136 | |
137 | - if( ! $episode_id ) { |
|
137 | + if ( ! $episode_id ) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | - $type = get_post_meta( $episode_id , 'episode_type' , true ); |
|
141 | + $type = get_post_meta ( $episode_id, 'episode_type', true ); |
|
142 | 142 | |
143 | - if( ! $type ) { |
|
143 | + if ( ! $type ) { |
|
144 | 144 | $type = 'audio'; |
145 | 145 | } |
146 | 146 | |
@@ -156,32 +156,32 @@ discard block |
||
156 | 156 | global $post, $wp_current_filter, $episode_context; |
157 | 157 | |
158 | 158 | // Don't output unformatted data on excerpts |
159 | - if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) { |
|
159 | + if ( in_array ( 'get_the_excerpt', (array) $wp_current_filter ) ) { |
|
160 | 160 | return $content; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Don't output episode meta in shortcode or widget |
164 | - if ( isset( $episode_context ) && in_array( $episode_context, array( 'shortcode', 'widget' ) ) ) { |
|
164 | + if ( isset( $episode_context ) && in_array ( $episode_context, array( 'shortcode', 'widget' ) ) ) { |
|
165 | 165 | return $content; |
166 | 166 | } |
167 | 167 | |
168 | - if( post_password_required( $post->ID ) ) { |
|
168 | + if ( post_password_required ( $post->ID ) ) { |
|
169 | 169 | return $content; |
170 | 170 | } |
171 | 171 | |
172 | - $podcast_post_types = ssp_post_types( true ); |
|
172 | + $podcast_post_types = ssp_post_types ( true ); |
|
173 | 173 | |
174 | - if ( in_array( $post->post_type, $podcast_post_types ) && ! is_feed() && ! isset( $_GET['feed'] ) ) { |
|
174 | + if ( in_array ( $post->post_type, $podcast_post_types ) && ! is_feed () && ! isset( $_GET[ 'feed' ] ) ) { |
|
175 | 175 | |
176 | 176 | // Get episode meta data |
177 | - $meta = $this->episode_meta( $post->ID, 'content' ); |
|
177 | + $meta = $this->episode_meta ( $post->ID, 'content' ); |
|
178 | 178 | |
179 | 179 | // Get specified player position |
180 | - $player_position = get_option( 'ss_podcasting_player_content_location', 'above' ); |
|
180 | + $player_position = get_option ( 'ss_podcasting_player_content_location', 'above' ); |
|
181 | 181 | |
182 | - switch( $player_position ) { |
|
183 | - case 'above': $content = $meta . $content; break; |
|
184 | - case 'below': $content = $content . $meta; break; |
|
182 | + switch ( $player_position ) { |
|
183 | + case 'above': $content = $meta.$content; break; |
|
184 | + case 'below': $content = $content.$meta; break; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return string Modified excerpt |
196 | 196 | */ |
197 | 197 | public function get_excerpt_meta_data( $excerpt = '' ) { |
198 | - return $this->excerpt_meta_data( $excerpt, 'excerpt' ); |
|
198 | + return $this->excerpt_meta_data ( $excerpt, 'excerpt' ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return string Modified excerpt |
205 | 205 | */ |
206 | 206 | public function get_embed_meta_data( $excerpt = '' ) { |
207 | - return $this->excerpt_meta_data( $excerpt, 'embed' ); |
|
207 | + return $this->excerpt_meta_data ( $excerpt, 'embed' ); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -215,17 +215,17 @@ discard block |
||
215 | 215 | public function excerpt_meta_data( $excerpt = '', $content = 'excerpt' ) { |
216 | 216 | global $post; |
217 | 217 | |
218 | - if( post_password_required( $post->ID ) ) { |
|
218 | + if ( post_password_required ( $post->ID ) ) { |
|
219 | 219 | return $excerpt; |
220 | 220 | } |
221 | 221 | |
222 | - $podcast_post_types = ssp_post_types( true ); |
|
222 | + $podcast_post_types = ssp_post_types ( true ); |
|
223 | 223 | |
224 | - if ( ( in_array( $post->post_type, $podcast_post_types ) ) && ! is_feed() ) { |
|
224 | + if ( ( in_array ( $post->post_type, $podcast_post_types ) ) && ! is_feed () ) { |
|
225 | 225 | |
226 | - $meta = $this->episode_meta( $post->ID, $content ); |
|
226 | + $meta = $this->episode_meta ( $post->ID, $content ); |
|
227 | 227 | |
228 | - $excerpt = $meta . $excerpt; |
|
228 | + $excerpt = $meta.$excerpt; |
|
229 | 229 | |
230 | 230 | } |
231 | 231 | |
@@ -246,34 +246,34 @@ discard block |
||
246 | 246 | return $meta; |
247 | 247 | } |
248 | 248 | |
249 | - $file = $this->get_enclosure( $episode_id ); |
|
249 | + $file = $this->get_enclosure ( $episode_id ); |
|
250 | 250 | |
251 | 251 | if ( $file ) { |
252 | 252 | |
253 | - if ( get_option( 'permalink_structure' ) ) { |
|
254 | - $file = $this->get_episode_download_link( $episode_id ); |
|
253 | + if ( get_option ( 'permalink_structure' ) ) { |
|
254 | + $file = $this->get_episode_download_link ( $episode_id ); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | // Hide audio player in `ss_podcast` shortcode by default |
258 | 258 | $show_player = true; |
259 | - if( 'shortcode' == $context ) { |
|
259 | + if ( 'shortcode' == $context ) { |
|
260 | 260 | $show_player = false; |
261 | 261 | } |
262 | 262 | |
263 | 263 | // Allow media player to be dynamically hidden/displayed |
264 | - $show_player = apply_filters( 'ssp_show_media_player', $show_player, $context ); |
|
264 | + $show_player = apply_filters ( 'ssp_show_media_player', $show_player, $context ); |
|
265 | 265 | |
266 | 266 | // Show audio player if requested |
267 | - if( $show_player ) { |
|
268 | - $meta .= '<div class="podcast_player">' . $this->media_player( $file, $episode_id ) . '</div>'; |
|
267 | + if ( $show_player ) { |
|
268 | + $meta .= '<div class="podcast_player">'.$this->media_player ( $file, $episode_id ).'</div>'; |
|
269 | 269 | } |
270 | 270 | |
271 | - if ( apply_filters( 'ssp_show_episode_details', true, $episode_id, $context ) ) { |
|
272 | - $meta .= $this->episode_meta_details( $episode_id, $context ); |
|
271 | + if ( apply_filters ( 'ssp_show_episode_details', true, $episode_id, $context ) ) { |
|
272 | + $meta .= $this->episode_meta_details ( $episode_id, $context ); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
276 | - $meta = apply_filters( 'ssp_episode_meta', $meta, $episode_id, $context ); |
|
276 | + $meta = apply_filters ( 'ssp_episode_meta', $meta, $episode_id, $context ); |
|
277 | 277 | |
278 | 278 | return $meta; |
279 | 279 | } |
@@ -284,36 +284,36 @@ discard block |
||
284 | 284 | * @param string $context Context for display |
285 | 285 | * @return string Episode meta details |
286 | 286 | */ |
287 | - public function episode_meta_details ( $episode_id = 0, $context = 'content' ) { |
|
287 | + public function episode_meta_details( $episode_id = 0, $context = 'content' ) { |
|
288 | 288 | |
289 | 289 | if ( ! $episode_id ) { |
290 | 290 | return; |
291 | 291 | } |
292 | 292 | |
293 | - $file = $this->get_enclosure( $episode_id ); |
|
293 | + $file = $this->get_enclosure ( $episode_id ); |
|
294 | 294 | |
295 | 295 | if ( ! $file ) { |
296 | 296 | return; |
297 | 297 | } |
298 | 298 | |
299 | - $link = $this->get_episode_download_link( $episode_id, 'download' ); |
|
300 | - $duration = get_post_meta( $episode_id , 'duration' , true ); |
|
301 | - $size = get_post_meta( $episode_id , 'filesize' , true ); |
|
299 | + $link = $this->get_episode_download_link ( $episode_id, 'download' ); |
|
300 | + $duration = get_post_meta ( $episode_id, 'duration', true ); |
|
301 | + $size = get_post_meta ( $episode_id, 'filesize', true ); |
|
302 | 302 | if ( ! $size ) { |
303 | - $size_data = $this->get_file_size( $file ); |
|
304 | - $size = $size_data['formatted']; |
|
303 | + $size_data = $this->get_file_size ( $file ); |
|
304 | + $size = $size_data[ 'formatted' ]; |
|
305 | 305 | if ( $size ) { |
306 | - if ( isset( $size_data['formatted'] ) ) { |
|
307 | - update_post_meta( $episode_id, 'filesize', $size_data['formatted'] ); |
|
306 | + if ( isset( $size_data[ 'formatted' ] ) ) { |
|
307 | + update_post_meta ( $episode_id, 'filesize', $size_data[ 'formatted' ] ); |
|
308 | 308 | } |
309 | 309 | |
310 | - if ( isset( $size_data['raw'] ) ) { |
|
311 | - update_post_meta( $episode_id, 'filesize_raw', $size_data['raw'] ); |
|
310 | + if ( isset( $size_data[ 'raw' ] ) ) { |
|
311 | + update_post_meta ( $episode_id, 'filesize_raw', $size_data[ 'raw' ] ); |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
316 | - $date_recorded = get_post_meta( $episode_id, 'date_recorded', true ); |
|
316 | + $date_recorded = get_post_meta ( $episode_id, 'date_recorded', true ); |
|
317 | 317 | |
318 | 318 | // Build up meta data array with default values |
319 | 319 | $meta = array( |
@@ -324,62 +324,62 @@ discard block |
||
324 | 324 | 'date_recorded' => '', |
325 | 325 | ); |
326 | 326 | |
327 | - if( $link ) { |
|
328 | - $meta['link'] = $link; |
|
327 | + if ( $link ) { |
|
328 | + $meta[ 'link' ] = $link; |
|
329 | 329 | } |
330 | 330 | |
331 | - if( $link && apply_filters( 'ssp_show_new_window_link', true, $context ) ) { |
|
332 | - $meta['new_window'] = true; |
|
331 | + if ( $link && apply_filters ( 'ssp_show_new_window_link', true, $context ) ) { |
|
332 | + $meta[ 'new_window' ] = true; |
|
333 | 333 | } |
334 | 334 | |
335 | - if( $link ) { |
|
336 | - $meta['duration'] = $duration; |
|
335 | + if ( $link ) { |
|
336 | + $meta[ 'duration' ] = $duration; |
|
337 | 337 | } |
338 | 338 | |
339 | - if( $size ) { |
|
340 | - $meta['size'] = $size; |
|
339 | + if ( $size ) { |
|
340 | + $meta[ 'size' ] = $size; |
|
341 | 341 | } |
342 | 342 | |
343 | - if( $date_recorded ) { |
|
344 | - $meta['date_recorded'] = $date_recorded; |
|
343 | + if ( $date_recorded ) { |
|
344 | + $meta[ 'date_recorded' ] = $date_recorded; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | // Allow dynamic filtering of meta data - to remove, add or reorder meta items |
348 | - $meta = apply_filters( 'ssp_episode_meta_details', $meta, $episode_id, $context ); |
|
348 | + $meta = apply_filters ( 'ssp_episode_meta_details', $meta, $episode_id, $context ); |
|
349 | 349 | |
350 | 350 | $meta_display = ''; |
351 | - $meta_sep = apply_filters( 'ssp_episode_meta_separator', ' | ' ); |
|
351 | + $meta_sep = apply_filters ( 'ssp_episode_meta_separator', ' | ' ); |
|
352 | 352 | foreach ( $meta as $key => $data ) { |
353 | 353 | |
354 | - if( ! $data ) { |
|
354 | + if ( ! $data ) { |
|
355 | 355 | continue; |
356 | 356 | } |
357 | 357 | |
358 | - if( $meta_display ) { |
|
358 | + if ( $meta_display ) { |
|
359 | 359 | $meta_display .= $meta_sep; |
360 | 360 | } |
361 | 361 | |
362 | - switch( $key ) { |
|
362 | + switch ( $key ) { |
|
363 | 363 | |
364 | 364 | case 'link': |
365 | - $meta_display .= '<a href="' . esc_url( $data ) . '" title="' . get_the_title() . ' " class="podcast-meta-download" download>' . __( 'Download file' , 'seriously-simple-podcasting' ) . '</a>'; |
|
365 | + $meta_display .= '<a href="'.esc_url ( $data ).'" title="'.get_the_title ().' " class="podcast-meta-download" download>'.__ ( 'Download file', 'seriously-simple-podcasting' ).'</a>'; |
|
366 | 366 | break; |
367 | 367 | |
368 | 368 | case 'new_window': |
369 | - $play_link = add_query_arg( 'ref', 'new_window', $link ); |
|
370 | - $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>'; |
|
369 | + $play_link = add_query_arg ( 'ref', 'new_window', $link ); |
|
370 | + $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>'; |
|
371 | 371 | break; |
372 | 372 | |
373 | 373 | case 'duration': |
374 | - $meta_display .= '<span class="podcast-meta-duration">' . __( 'Duration' , 'seriously-simple-podcasting' ) . ': ' . $data . '</span>'; |
|
374 | + $meta_display .= '<span class="podcast-meta-duration">'.__ ( 'Duration', 'seriously-simple-podcasting' ).': '.$data.'</span>'; |
|
375 | 375 | break; |
376 | 376 | |
377 | 377 | case 'size': |
378 | - $meta_display .= '<span class="podcast-meta-size">' . __( 'Size' , 'seriously-simple-podcasting' ) . ': ' . $data . '</span>'; |
|
378 | + $meta_display .= '<span class="podcast-meta-size">'.__ ( 'Size', 'seriously-simple-podcasting' ).': '.$data.'</span>'; |
|
379 | 379 | break; |
380 | 380 | |
381 | 381 | case 'date_recorded': |
382 | - $meta_display .= '<span class="podcast-meta-date">' . __( 'Recorded on' , 'seriously-simple-podcasting' ) . ' ' . date_i18n( get_option( 'date_format' ), strtotime( $data ) ) . '</span>'; |
|
382 | + $meta_display .= '<span class="podcast-meta-date">'.__ ( 'Recorded on', 'seriously-simple-podcasting' ).' '.date_i18n ( get_option ( 'date_format' ), strtotime ( $data ) ).'</span>'; |
|
383 | 383 | break; |
384 | 384 | |
385 | 385 | // Allow for custom items to be added, but only allow a small amount of HTML tags |
@@ -395,13 +395,13 @@ discard block |
||
395 | 395 | 'target' => array(), |
396 | 396 | ), |
397 | 397 | ); |
398 | - $meta_display .= wp_kses( $data, $allowed_tags ); |
|
398 | + $meta_display .= wp_kses ( $data, $allowed_tags ); |
|
399 | 399 | break; |
400 | 400 | |
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
404 | - $meta_display = '<div class="podcast_meta"><aside>' . $meta_display . '</aside></div>'; |
|
404 | + $meta_display = '<div class="podcast_meta"><aside>'.$meta_display.'</aside></div>'; |
|
405 | 405 | |
406 | 406 | return $meta_display; |
407 | 407 | |
@@ -413,43 +413,43 @@ discard block |
||
413 | 413 | */ |
414 | 414 | public function add_to_home_query( $query ) { |
415 | 415 | |
416 | - if ( is_admin() ) { |
|
416 | + if ( is_admin () ) { |
|
417 | 417 | return; |
418 | 418 | } |
419 | 419 | |
420 | - $include_in_main_query = get_option('ss_podcasting_include_in_main_query'); |
|
420 | + $include_in_main_query = get_option ( 'ss_podcasting_include_in_main_query' ); |
|
421 | 421 | if ( $include_in_main_query && $include_in_main_query == 'on' ) { |
422 | - if ( $query->is_home() && $query->is_main_query() ) { |
|
423 | - $query->set( 'post_type', array( 'post', 'podcast' ) ); |
|
422 | + if ( $query->is_home () && $query->is_main_query () ) { |
|
423 | + $query->set ( 'post_type', array( 'post', 'podcast' ) ); |
|
424 | 424 | } |
425 | 425 | } |
426 | 426 | } |
427 | 427 | |
428 | - public function add_all_post_types ( $query ) { |
|
428 | + public function add_all_post_types( $query ) { |
|
429 | 429 | |
430 | - if ( is_admin() ) { |
|
430 | + if ( is_admin () ) { |
|
431 | 431 | return; |
432 | 432 | } |
433 | 433 | |
434 | - if ( ! $query->is_main_query() ) { |
|
434 | + if ( ! $query->is_main_query () ) { |
|
435 | 435 | return; |
436 | 436 | } |
437 | 437 | |
438 | - if ( is_post_type_archive( 'podcast' ) || is_tax( 'series' ) ) { |
|
438 | + if ( is_post_type_archive ( 'podcast' ) || is_tax ( 'series' ) ) { |
|
439 | 439 | |
440 | - $podcast_post_types = ssp_post_types( false ); |
|
440 | + $podcast_post_types = ssp_post_types ( false ); |
|
441 | 441 | |
442 | 442 | if ( empty( $podcast_post_types ) ) { |
443 | 443 | return; |
444 | 444 | } |
445 | 445 | |
446 | - $episode_ids = ssp_episode_ids(); |
|
446 | + $episode_ids = ssp_episode_ids (); |
|
447 | 447 | if ( ! empty( $episode_ids ) ) { |
448 | 448 | |
449 | - $query->set( 'post__in', $episode_ids ); |
|
449 | + $query->set ( 'post__in', $episode_ids ); |
|
450 | 450 | |
451 | - $podcast_post_types[] = 'podcast'; |
|
452 | - $query->set( 'post_type', $podcast_post_types ); |
|
451 | + $podcast_post_types[ ] = 'podcast'; |
|
452 | + $query->set ( 'post_type', $podcast_post_types ); |
|
453 | 453 | |
454 | 454 | } |
455 | 455 | |
@@ -467,29 +467,29 @@ discard block |
||
467 | 467 | if ( $file ) { |
468 | 468 | |
469 | 469 | // Include media functions if necessary |
470 | - if ( ! function_exists( 'wp_read_audio_metadata' ) ) { |
|
471 | - require_once( ABSPATH . 'wp-admin/includes/media.php' ); |
|
470 | + if ( ! function_exists ( 'wp_read_audio_metadata' ) ) { |
|
471 | + require_once( ABSPATH.'wp-admin/includes/media.php' ); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | // translate file URL to local file path if possible |
475 | - $file = $this->get_local_file_path( $file ); |
|
475 | + $file = $this->get_local_file_path ( $file ); |
|
476 | 476 | |
477 | 477 | // Get file data (for local file) |
478 | - $data = wp_read_audio_metadata( $file ); |
|
478 | + $data = wp_read_audio_metadata ( $file ); |
|
479 | 479 | |
480 | 480 | $raw = $formatted = ''; |
481 | 481 | |
482 | 482 | if ( $data ) { |
483 | - $raw = $data['filesize']; |
|
484 | - $formatted = $this->format_bytes( $raw ); |
|
483 | + $raw = $data[ 'filesize' ]; |
|
484 | + $formatted = $this->format_bytes ( $raw ); |
|
485 | 485 | } else { |
486 | 486 | |
487 | 487 | // get file data (for remote file) |
488 | - $data = wp_remote_head( $file, array( 'timeout' => 10, 'redirection' => 5 ) ); |
|
488 | + $data = wp_remote_head ( $file, array( 'timeout' => 10, 'redirection' => 5 ) ); |
|
489 | 489 | |
490 | - if ( ! is_wp_error( $data ) && is_array( $data ) && isset( $data['headers']['content-length'] ) ) { |
|
491 | - $raw = $data['headers']['content-length']; |
|
492 | - $formatted = $this->format_bytes( $raw ); |
|
490 | + if ( ! is_wp_error ( $data ) && is_array ( $data ) && isset( $data[ 'headers' ][ 'content-length' ] ) ) { |
|
491 | + $raw = $data[ 'headers' ][ 'content-length' ]; |
|
492 | + $formatted = $this->format_bytes ( $raw ); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | 'formatted' => $formatted |
501 | 501 | ); |
502 | 502 | |
503 | - return apply_filters( 'ssp_file_size', $size, $file ); |
|
503 | + return apply_filters ( 'ssp_file_size', $size, $file ); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | } |
@@ -518,30 +518,30 @@ discard block |
||
518 | 518 | if ( $file ) { |
519 | 519 | |
520 | 520 | // Include media functions if necessary |
521 | - if ( ! function_exists( 'wp_read_audio_metadata' ) ) { |
|
522 | - require_once( ABSPATH . 'wp-admin/includes/media.php' ); |
|
521 | + if ( ! function_exists ( 'wp_read_audio_metadata' ) ) { |
|
522 | + require_once( ABSPATH.'wp-admin/includes/media.php' ); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | // translate file URL to local file path if possible |
526 | - $file = $this->get_local_file_path( $file ); |
|
526 | + $file = $this->get_local_file_path ( $file ); |
|
527 | 527 | |
528 | 528 | // Get file data (will only work for local files) |
529 | - $data = wp_read_audio_metadata( $file ); |
|
529 | + $data = wp_read_audio_metadata ( $file ); |
|
530 | 530 | |
531 | 531 | $duration = false; |
532 | 532 | |
533 | 533 | if ( $data ) { |
534 | - if ( isset( $data['length_formatted'] ) && strlen( $data['length_formatted'] ) > 0 ) { |
|
535 | - $duration = $data['length_formatted']; |
|
534 | + if ( isset( $data[ 'length_formatted' ] ) && strlen ( $data[ 'length_formatted' ] ) > 0 ) { |
|
535 | + $duration = $data[ 'length_formatted' ]; |
|
536 | 536 | } else { |
537 | - if ( isset( $data['length'] ) && strlen( $data['length'] ) > 0 ) { |
|
538 | - $duration = gmdate( 'H:i:s', $data['length'] ); |
|
537 | + if ( isset( $data[ 'length' ] ) && strlen ( $data[ 'length' ] ) > 0 ) { |
|
538 | + $duration = gmdate ( 'H:i:s', $data[ 'length' ] ); |
|
539 | 539 | } |
540 | 540 | } |
541 | 541 | } |
542 | 542 | |
543 | 543 | if ( $data ) { |
544 | - return apply_filters( 'ssp_file_duration', $duration, $file ); |
|
544 | + return apply_filters ( 'ssp_file_duration', $duration, $file ); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | } |
@@ -555,15 +555,15 @@ discard block |
||
555 | 555 | * @param integer $precision Level of precision for formatting |
556 | 556 | * @return mixed Formatted file size on success, false on failure |
557 | 557 | */ |
558 | - protected function format_bytes( $size , $precision = 2 ) { |
|
558 | + protected function format_bytes( $size, $precision = 2 ) { |
|
559 | 559 | |
560 | 560 | if ( $size ) { |
561 | 561 | |
562 | - $base = log ( $size ) / log( 1024 ); |
|
563 | - $suffixes = array( '' , 'k' , 'M' , 'G' , 'T' ); |
|
564 | - $formatted_size = round( pow( 1024 , $base - floor( $base ) ) , $precision ) . $suffixes[ floor( $base ) ]; |
|
562 | + $base = log ( $size ) / log ( 1024 ); |
|
563 | + $suffixes = array( '', 'k', 'M', 'G', 'T' ); |
|
564 | + $formatted_size = round ( pow ( 1024, $base - floor ( $base ) ), $precision ).$suffixes[ floor ( $base ) ]; |
|
565 | 565 | |
566 | - return apply_filters( 'ssp_file_size_formatted', $formatted_size, $size ); |
|
566 | + return apply_filters ( 'ssp_file_size_formatted', $formatted_size, $size ); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | return false; |
@@ -579,10 +579,10 @@ discard block |
||
579 | 579 | |
580 | 580 | // Let's hash the URL to ensure that we don't get |
581 | 581 | // any illegal chars that might break the cache. |
582 | - $key = md5( $url ); |
|
582 | + $key = md5 ( $url ); |
|
583 | 583 | |
584 | 584 | // Do we have anything in the cache for this URL? |
585 | - $attachment_id = wp_cache_get( $key, 'attachment_id' ); |
|
585 | + $attachment_id = wp_cache_get ( $key, 'attachment_id' ); |
|
586 | 586 | |
587 | 587 | if ( $attachment_id === false ) { |
588 | 588 | |
@@ -599,39 +599,39 @@ discard block |
||
599 | 599 | |
600 | 600 | |
601 | 601 | // Function introduced in 4.0, let's try this first. |
602 | - if ( function_exists( 'attachment_url_to_postid' ) ) { |
|
603 | - $attachment_id = absint( attachment_url_to_postid( $url ) ); |
|
602 | + if ( function_exists ( 'attachment_url_to_postid' ) ) { |
|
603 | + $attachment_id = absint ( attachment_url_to_postid ( $url ) ); |
|
604 | 604 | if ( 0 !== $attachment_id ) { |
605 | - wp_cache_set( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
605 | + wp_cache_set ( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
606 | 606 | return $attachment_id; |
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
610 | 610 | // Then this. |
611 | - if ( preg_match( '#\.[a-zA-Z0-9]+$#', $url ) ) { |
|
612 | - $sql = $wpdb->prepare( |
|
611 | + if ( preg_match ( '#\.[a-zA-Z0-9]+$#', $url ) ) { |
|
612 | + $sql = $wpdb->prepare ( |
|
613 | 613 | "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND guid = %s", |
614 | - esc_url_raw( $url ) |
|
614 | + esc_url_raw ( $url ) |
|
615 | 615 | ); |
616 | - $attachment_id = absint( $wpdb->get_var( $sql ) ); |
|
616 | + $attachment_id = absint ( $wpdb->get_var ( $sql ) ); |
|
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 | // And then try this |
624 | - $upload_dir_paths = wp_upload_dir(); |
|
625 | - if ( false !== strpos( $url, $upload_dir_paths['baseurl'] ) ) { |
|
624 | + $upload_dir_paths = wp_upload_dir (); |
|
625 | + if ( false !== strpos ( $url, $upload_dir_paths[ 'baseurl' ] ) ) { |
|
626 | 626 | // Ensure that we have file extension that matches iTunes. |
627 | - $url = preg_replace( '/(?=\.(m4a|mp3|mov|mp4)$)/i', '', $url ); |
|
627 | + $url = preg_replace ( '/(?=\.(m4a|mp3|mov|mp4)$)/i', '', $url ); |
|
628 | 628 | // Remove the upload path base directory from the attachment URL |
629 | - $url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $url ); |
|
629 | + $url = str_replace ( $upload_dir_paths[ 'baseurl' ].'/', '', $url ); |
|
630 | 630 | // Finally, run a custom database query to get the attachment ID from the modified attachment URL |
631 | - $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 ); |
|
632 | - $attachment_id = absint( $wpdb->get_var( $sql ) ); |
|
631 | + $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 ); |
|
632 | + $attachment_id = absint ( $wpdb->get_var ( $sql ) ); |
|
633 | 633 | if ( 0 !== $attachment_id ) { |
634 | - wp_cache_set( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
634 | + wp_cache_set ( $key, $attachment_id, 'attachment_id', DAY_IN_SECONDS ); |
|
635 | 635 | return $attachment_id; |
636 | 636 | } |
637 | 637 | } |
@@ -649,20 +649,20 @@ discard block |
||
649 | 649 | public function get_attachment_mimetype( $attachment = '' ) { |
650 | 650 | |
651 | 651 | // Let's hash the URL to ensure that we don't get any illegal chars that might break the cache. |
652 | - $key = md5( $attachment ); |
|
652 | + $key = md5 ( $attachment ); |
|
653 | 653 | |
654 | 654 | if ( $attachment ) { |
655 | 655 | // Do we have anything in the cache for this? |
656 | - $mime = wp_cache_get( $key, 'mime-type' ); |
|
656 | + $mime = wp_cache_get ( $key, 'mime-type' ); |
|
657 | 657 | if ( $mime === false ) { |
658 | 658 | |
659 | 659 | // Get the ID |
660 | - $id = $this->get_attachment_id_from_url( $attachment ); |
|
660 | + $id = $this->get_attachment_id_from_url ( $attachment ); |
|
661 | 661 | |
662 | 662 | // Get the MIME type |
663 | - $mime = get_post_mime_type( $id ); |
|
663 | + $mime = get_post_mime_type ( $id ); |
|
664 | 664 | // Set the cache |
665 | - wp_cache_set( $key, $mime, 'mime-type', DAY_IN_SECONDS ); |
|
665 | + wp_cache_set ( $key, $mime, 'mime-type', DAY_IN_SECONDS ); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | return $mime; |
@@ -679,8 +679,8 @@ discard block |
||
679 | 679 | * @return string Audio player HTML on success, false on failure |
680 | 680 | */ |
681 | 681 | public function audio_player( $src = '', $episode_id = 0 ) { |
682 | - $player = $this->media_player( $src, $episode_id ); |
|
683 | - return apply_filters( 'ssp_audio_player', $player, $src, $episode_id ); |
|
682 | + $player = $this->media_player ( $src, $episode_id ); |
|
683 | + return apply_filters ( 'ssp_audio_player', $player, $src, $episode_id ); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | /** |
@@ -689,40 +689,40 @@ discard block |
||
689 | 689 | * @param integer $episode_id Episode ID for audio file |
690 | 690 | * @return string Media player HTML on success, empty string on failure |
691 | 691 | */ |
692 | - public function media_player ( $src = '', $episode_id = 0 ) { |
|
692 | + public function media_player( $src = '', $episode_id = 0 ) { |
|
693 | 693 | $player = ''; |
694 | 694 | |
695 | 695 | if ( $src ) { |
696 | 696 | |
697 | 697 | // Get episode type and default to audio |
698 | - $type = $this->get_episode_type( $episode_id ); |
|
699 | - if( ! $type ) { |
|
698 | + $type = $this->get_episode_type ( $episode_id ); |
|
699 | + if ( ! $type ) { |
|
700 | 700 | $type = 'audio'; |
701 | 701 | } |
702 | 702 | |
703 | 703 | // Switch to podcast player URL |
704 | - $src = str_replace( 'podcast-download', 'podcast-player', $src ); |
|
704 | + $src = str_replace ( 'podcast-download', 'podcast-player', $src ); |
|
705 | 705 | |
706 | 706 | // Set up paramters for media player |
707 | 707 | $params = array( 'src' => $src, 'preload' => 'none' ); |
708 | 708 | |
709 | 709 | // Use built-in WordPress media player |
710 | - switch( $type ) { |
|
711 | - case 'audio': $player = wp_audio_shortcode( $params ); break; |
|
710 | + switch ( $type ) { |
|
711 | + case 'audio': $player = wp_audio_shortcode ( $params ); break; |
|
712 | 712 | case 'video': |
713 | 713 | // Use featured image as video poster |
714 | - if( $episode_id && has_post_thumbnail( $episode_id ) ) { |
|
715 | - $poster = wp_get_attachment_url( get_post_thumbnail_id( $episode_id ) ); |
|
716 | - if( $poster ) { |
|
717 | - $params['poster'] = $poster; |
|
714 | + if ( $episode_id && has_post_thumbnail ( $episode_id ) ) { |
|
715 | + $poster = wp_get_attachment_url ( get_post_thumbnail_id ( $episode_id ) ); |
|
716 | + if ( $poster ) { |
|
717 | + $params[ 'poster' ] = $poster; |
|
718 | 718 | } |
719 | 719 | } |
720 | - $player = wp_video_shortcode( $params ); |
|
720 | + $player = wp_video_shortcode ( $params ); |
|
721 | 721 | break; |
722 | 722 | } |
723 | 723 | |
724 | 724 | // Allow filtering so that alternative players can be used |
725 | - $player = apply_filters( 'ssp_media_player', $player, $src, $episode_id ); |
|
725 | + $player = apply_filters ( 'ssp_media_player', $player, $src, $episode_id ); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | return $player; |
@@ -737,17 +737,17 @@ discard block |
||
737 | 737 | public function get_image( $id = 0, $size = 'full' ) { |
738 | 738 | $image = ''; |
739 | 739 | |
740 | - if ( has_post_thumbnail( $id ) ) { |
|
740 | + if ( has_post_thumbnail ( $id ) ) { |
|
741 | 741 | // If not a string or an array, and not an integer, default to 200x9999. |
742 | - if ( is_int( $size ) || ( 0 < intval( $size ) ) ) { |
|
743 | - $size = array( intval( $size ), intval( $size ) ); |
|
744 | - } elseif ( ! is_string( $size ) && ! is_array( $size ) ) { |
|
742 | + if ( is_int ( $size ) || ( 0 < intval ( $size ) ) ) { |
|
743 | + $size = array( intval ( $size ), intval ( $size ) ); |
|
744 | + } elseif ( ! is_string ( $size ) && ! is_array ( $size ) ) { |
|
745 | 745 | $size = array( 200, 9999 ); |
746 | 746 | } |
747 | - $image = get_the_post_thumbnail( intval( $id ), $size ); |
|
747 | + $image = get_the_post_thumbnail ( intval ( $id ), $size ); |
|
748 | 748 | } |
749 | 749 | |
750 | - return apply_filters( 'ssp_episode_image', $image, $id ); |
|
750 | + return apply_filters ( 'ssp_episode_image', $image, $id ); |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | /** |
@@ -762,29 +762,29 @@ discard block |
||
762 | 762 | 'series' => '' |
763 | 763 | ); |
764 | 764 | |
765 | - $args = apply_filters( 'ssp_get_podcast_args', wp_parse_args( $args, $defaults ) ); |
|
765 | + $args = apply_filters ( 'ssp_get_podcast_args', wp_parse_args ( $args, $defaults ) ); |
|
766 | 766 | |
767 | 767 | $query = array(); |
768 | 768 | |
769 | - if ( 'episodes' == $args['content'] ) { |
|
769 | + if ( 'episodes' == $args[ 'content' ] ) { |
|
770 | 770 | |
771 | 771 | // Get selected series |
772 | 772 | $podcast_series = ''; |
773 | - if ( isset( $args['series'] ) && $args['series'] ) { |
|
774 | - $podcast_series = $args['series']; |
|
773 | + if ( isset( $args[ 'series' ] ) && $args[ 'series' ] ) { |
|
774 | + $podcast_series = $args[ 'series' ]; |
|
775 | 775 | } |
776 | 776 | |
777 | 777 | // Get query args |
778 | - $query_args = apply_filters( 'ssp_get_podcast_query_args', ssp_episodes( -1, $podcast_series, true, '' ) ); |
|
778 | + $query_args = apply_filters ( 'ssp_get_podcast_query_args', ssp_episodes ( -1, $podcast_series, true, '' ) ); |
|
779 | 779 | |
780 | 780 | // The Query |
781 | - $query = get_posts( $query_args ); |
|
781 | + $query = get_posts ( $query_args ); |
|
782 | 782 | |
783 | 783 | // The Display |
784 | - if ( ! is_wp_error( $query ) && is_array( $query ) && count( $query ) > 0 ) { |
|
784 | + if ( ! is_wp_error ( $query ) && is_array ( $query ) && count ( $query ) > 0 ) { |
|
785 | 785 | foreach ( $query as $k => $v ) { |
786 | 786 | // Get the URL |
787 | - $query[$k]->url = get_permalink( $v->ID ); |
|
787 | + $query[ $k ]->url = get_permalink ( $v->ID ); |
|
788 | 788 | } |
789 | 789 | } else { |
790 | 790 | $query = false; |
@@ -792,27 +792,27 @@ discard block |
||
792 | 792 | |
793 | 793 | } else { |
794 | 794 | |
795 | - $terms = get_terms( 'series' ); |
|
795 | + $terms = get_terms ( 'series' ); |
|
796 | 796 | |
797 | - if ( count( $terms ) > 0) { |
|
797 | + if ( count ( $terms ) > 0 ) { |
|
798 | 798 | |
799 | 799 | foreach ( $terms as $term ) { |
800 | - $query[ $term->term_id ] = new stdClass(); |
|
800 | + $query[ $term->term_id ] = new stdClass (); |
|
801 | 801 | $query[ $term->term_id ]->title = $term->name; |
802 | - $query[ $term->term_id ]->url = get_term_link( $term ); |
|
802 | + $query[ $term->term_id ]->url = get_term_link ( $term ); |
|
803 | 803 | |
804 | - $query_args = apply_filters( 'ssp_get_podcast_series_query_args', ssp_episodes( -1, $term->slug, true, '' ) ); |
|
804 | + $query_args = apply_filters ( 'ssp_get_podcast_series_query_args', ssp_episodes ( -1, $term->slug, true, '' ) ); |
|
805 | 805 | |
806 | - $posts = get_posts( $query_args ); |
|
806 | + $posts = get_posts ( $query_args ); |
|
807 | 807 | |
808 | - $count = count( $posts ); |
|
808 | + $count = count ( $posts ); |
|
809 | 809 | $query[ $term->term_id ]->count = $count; |
810 | 810 | } |
811 | 811 | } |
812 | 812 | |
813 | 813 | } |
814 | 814 | |
815 | - $query['content'] = $args['content']; |
|
815 | + $query[ 'content' ] = $args[ 'content' ]; |
|
816 | 816 | |
817 | 817 | return $query; |
818 | 818 | } |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | public function get_enclosure( $episode_id = 0 ) { |
826 | 826 | |
827 | 827 | if ( $episode_id ) { |
828 | - return apply_filters( 'ssp_episode_enclosure', get_post_meta( $episode_id, 'audio_file', true ), $episode_id ); |
|
828 | + return apply_filters ( 'ssp_episode_enclosure', get_post_meta ( $episode_id, 'audio_file', true ), $episode_id ); |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | return ''; |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | |
844 | 844 | if ( $file != '' ) { |
845 | 845 | |
846 | - $post_types = ssp_post_types( true ); |
|
846 | + $post_types = ssp_post_types ( true ); |
|
847 | 847 | |
848 | 848 | $args = array( |
849 | 849 | 'post_type' => $post_types, |
@@ -853,17 +853,17 @@ discard block |
||
853 | 853 | 'meta_value' => $file |
854 | 854 | ); |
855 | 855 | |
856 | - $qry = new WP_Query( $args ); |
|
856 | + $qry = new WP_Query ( $args ); |
|
857 | 857 | |
858 | - if ( $qry->have_posts() ) { |
|
859 | - while ( $qry->have_posts() ) { $qry->the_post(); |
|
858 | + if ( $qry->have_posts () ) { |
|
859 | + while ( $qry->have_posts () ) { $qry->the_post (); |
|
860 | 860 | $episode = $post; |
861 | 861 | break; |
862 | 862 | } |
863 | 863 | } |
864 | 864 | } |
865 | 865 | |
866 | - return apply_filters( 'ssp_episode_from_file', $episode, $file ); |
|
866 | + return apply_filters ( 'ssp_episode_from_file', $episode, $file ); |
|
867 | 867 | |
868 | 868 | } |
869 | 869 | |
@@ -873,33 +873,33 @@ discard block |
||
873 | 873 | */ |
874 | 874 | public function download_file() { |
875 | 875 | |
876 | - if ( is_podcast_download() ) { |
|
876 | + if ( is_podcast_download () ) { |
|
877 | 877 | global $wp_query; |
878 | 878 | |
879 | 879 | // Get requested episode ID |
880 | - $episode_id = intval( $wp_query->query_vars['podcast_episode'] ); |
|
880 | + $episode_id = intval ( $wp_query->query_vars[ 'podcast_episode' ] ); |
|
881 | 881 | |
882 | 882 | if ( isset( $episode_id ) && $episode_id ) { |
883 | 883 | |
884 | 884 | // Get episode post object |
885 | - $episode = get_post( $episode_id ); |
|
885 | + $episode = get_post ( $episode_id ); |
|
886 | 886 | |
887 | 887 | // Make sure we have a valid episode post object |
888 | - if ( ! $episode || ! is_object( $episode ) || is_wp_error( $episode ) || ! isset( $episode->ID ) ) { |
|
888 | + if ( ! $episode || ! is_object ( $episode ) || is_wp_error ( $episode ) || ! isset( $episode->ID ) ) { |
|
889 | 889 | return; |
890 | 890 | } |
891 | 891 | |
892 | 892 | // Do we have newlines? |
893 | 893 | $parts = false; |
894 | - if( is_string( $episode ) ) { |
|
895 | - $parts = explode( "\n", $episode ); |
|
894 | + if ( is_string ( $episode ) ) { |
|
895 | + $parts = explode ( "\n", $episode ); |
|
896 | 896 | } |
897 | 897 | |
898 | - if ( $parts && is_array( $parts ) && count( $parts ) > 1 ) { |
|
899 | - $file = $parts[0]; |
|
898 | + if ( $parts && is_array ( $parts ) && count ( $parts ) > 1 ) { |
|
899 | + $file = $parts[ 0 ]; |
|
900 | 900 | } else { |
901 | 901 | // Get audio file for download |
902 | - $file = $this->get_enclosure( $episode_id ); |
|
902 | + $file = $this->get_enclosure ( $episode_id ); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | // Exit if no file is found |
@@ -909,77 +909,77 @@ discard block |
||
909 | 909 | |
910 | 910 | // Get file referrer |
911 | 911 | $referrer = ''; |
912 | - if( isset( $wp_query->query_vars['podcast_ref'] ) && $wp_query->query_vars['podcast_ref'] ) { |
|
913 | - $referrer = $wp_query->query_vars['podcast_ref']; |
|
912 | + if ( isset( $wp_query->query_vars[ 'podcast_ref' ] ) && $wp_query->query_vars[ 'podcast_ref' ] ) { |
|
913 | + $referrer = $wp_query->query_vars[ 'podcast_ref' ]; |
|
914 | 914 | } else { |
915 | - if( isset( $_GET['ref'] ) ) { |
|
916 | - $referrer = esc_attr( $_GET['ref'] ); |
|
915 | + if ( isset( $_GET[ 'ref' ] ) ) { |
|
916 | + $referrer = esc_attr ( $_GET[ 'ref' ] ); |
|
917 | 917 | } |
918 | 918 | } |
919 | 919 | |
920 | 920 | // Allow other actions - functions hooked on here must not output any data |
921 | - do_action( 'ssp_file_download', $file, $episode, $referrer ); |
|
921 | + do_action ( 'ssp_file_download', $file, $episode, $referrer ); |
|
922 | 922 | |
923 | 923 | // Set necessary headers |
924 | - header( "Pragma: no-cache" ); |
|
925 | - header( "Expires: 0" ); |
|
926 | - header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); |
|
927 | - header( "Robots: none" ); |
|
924 | + header ( "Pragma: no-cache" ); |
|
925 | + header ( "Expires: 0" ); |
|
926 | + header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); |
|
927 | + header ( "Robots: none" ); |
|
928 | 928 | |
929 | 929 | // Check file referrer |
930 | - if( 'download' == $referrer ) { |
|
930 | + if ( 'download' == $referrer ) { |
|
931 | 931 | |
932 | 932 | // Set size of file |
933 | 933 | // Do we have anything in Cache/DB? |
934 | - $size = wp_cache_get( $episode_id, 'filesize_raw' ); |
|
934 | + $size = wp_cache_get ( $episode_id, 'filesize_raw' ); |
|
935 | 935 | |
936 | 936 | // Nothing in the cache, let's see if we can figure it out. |
937 | 937 | if ( false === $size ) { |
938 | 938 | |
939 | 939 | // Do we have anything in post_meta? |
940 | - $size = get_post_meta( $episode_id, 'filesize_raw', true ); |
|
940 | + $size = get_post_meta ( $episode_id, 'filesize_raw', true ); |
|
941 | 941 | |
942 | 942 | if ( empty( $size ) ) { |
943 | 943 | |
944 | 944 | // Let's see if we can figure out the path... |
945 | - $attachment_id = $this->get_attachment_id_from_url( $file ); |
|
945 | + $attachment_id = $this->get_attachment_id_from_url ( $file ); |
|
946 | 946 | |
947 | - if ( ! empty( $attachment_id ) ) { |
|
948 | - $size = filesize( get_attached_file( $attachment_id ) ); |
|
949 | - update_post_meta( $episode_id, 'filesize_raw', $size ); |
|
947 | + if ( ! empty( $attachment_id ) ) { |
|
948 | + $size = filesize ( get_attached_file ( $attachment_id ) ); |
|
949 | + update_post_meta ( $episode_id, 'filesize_raw', $size ); |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | } |
953 | 953 | |
954 | 954 | // Update the cache |
955 | - wp_cache_set( $episode_id, $size, 'filesize_raw' ); |
|
955 | + wp_cache_set ( $episode_id, $size, 'filesize_raw' ); |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | // Send Content-Length header |
959 | 959 | if ( ! empty( $size ) ) { |
960 | - header( "Content-Length: " . $size ); |
|
960 | + header ( "Content-Length: ".$size ); |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | // Force file download |
964 | - header( "Content-Type: application/force-download" ); |
|
964 | + header ( "Content-Type: application/force-download" ); |
|
965 | 965 | |
966 | 966 | // Set other relevant headers |
967 | - header( "Content-Description: File Transfer" ); |
|
968 | - header( "Content-Disposition: attachment; filename=\"" . basename( $file ) . "\";" ); |
|
969 | - header( "Content-Transfer-Encoding: binary" ); |
|
967 | + header ( "Content-Description: File Transfer" ); |
|
968 | + header ( "Content-Disposition: attachment; filename=\"".basename ( $file )."\";" ); |
|
969 | + header ( "Content-Transfer-Encoding: binary" ); |
|
970 | 970 | |
971 | 971 | // Encode spaces in file names until this is fixed in core (https://core.trac.wordpress.org/ticket/36998) |
972 | - $file = str_replace( ' ', '%20', $file ); |
|
972 | + $file = str_replace ( ' ', '%20', $file ); |
|
973 | 973 | |
974 | 974 | // Use ssp_readfile_chunked() if allowed on the server or simply access file directly |
975 | - @ssp_readfile_chunked( $file ) or header( 'Location: ' . $file ); |
|
975 | + @ssp_readfile_chunked ( $file ) or header ( 'Location: '.$file ); |
|
976 | 976 | } else { |
977 | 977 | |
978 | 978 | // Encode spaces in file names until this is fixed in core (https://core.trac.wordpress.org/ticket/36998) |
979 | - $file = str_replace( ' ', '%20', $file ); |
|
979 | + $file = str_replace ( ' ', '%20', $file ); |
|
980 | 980 | |
981 | 981 | // For all other referrers redirect to the raw file |
982 | - wp_redirect( $file, 302 ); |
|
982 | + wp_redirect ( $file, 302 ); |
|
983 | 983 | } |
984 | 984 | |
985 | 985 | // Exit to prevent other processes running later on |
@@ -996,16 +996,16 @@ discard block |
||
996 | 996 | public function generator_tag( $gen, $type ) { |
997 | 997 | |
998 | 998 | // Allow generator tags to be hidden if necessary |
999 | - if ( apply_filters( 'ssp_show_generator_tag', true, $type ) ) { |
|
999 | + if ( apply_filters ( 'ssp_show_generator_tag', true, $type ) ) { |
|
1000 | 1000 | |
1001 | - $generator = 'Seriously Simple Podcasting ' . esc_attr( $this->version ); |
|
1001 | + $generator = 'Seriously Simple Podcasting '.esc_attr ( $this->version ); |
|
1002 | 1002 | |
1003 | 1003 | switch ( $type ) { |
1004 | 1004 | case 'html': |
1005 | - $gen .= "\n" . '<meta name="generator" content="' . $generator . '">'; |
|
1005 | + $gen .= "\n".'<meta name="generator" content="'.$generator.'">'; |
|
1006 | 1006 | break; |
1007 | 1007 | case 'xhtml': |
1008 | - $gen .= "\n" . '<meta name="generator" content="' . $generator . '" />'; |
|
1008 | + $gen .= "\n".'<meta name="generator" content="'.$generator.'" />'; |
|
1009 | 1009 | break; |
1010 | 1010 | } |
1011 | 1011 | |
@@ -1021,53 +1021,53 @@ discard block |
||
1021 | 1021 | public function rss_meta_tag() { |
1022 | 1022 | |
1023 | 1023 | // Get feed slug |
1024 | - $feed_slug = apply_filters( 'ssp_feed_slug', $this->token ); |
|
1024 | + $feed_slug = apply_filters ( 'ssp_feed_slug', $this->token ); |
|
1025 | 1025 | |
1026 | - if ( get_option( 'permalink_structure' ) ) { |
|
1027 | - $feed_url = $this->home_url . 'feed/' . $feed_slug; |
|
1026 | + if ( get_option ( 'permalink_structure' ) ) { |
|
1027 | + $feed_url = $this->home_url.'feed/'.$feed_slug; |
|
1028 | 1028 | } else { |
1029 | - $feed_url = $this->home_url . '?feed=' . $feed_slug; |
|
1029 | + $feed_url = $this->home_url.'?feed='.$feed_slug; |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | - $custom_feed_url = get_option( 'ss_podcasting_feed_url' ); |
|
1032 | + $custom_feed_url = get_option ( 'ss_podcasting_feed_url' ); |
|
1033 | 1033 | if ( $custom_feed_url ) { |
1034 | 1034 | $feed_url = $custom_feed_url; |
1035 | 1035 | } |
1036 | 1036 | |
1037 | - $feed_url = apply_filters( 'ssp_feed_url', $feed_url ); |
|
1037 | + $feed_url = apply_filters ( 'ssp_feed_url', $feed_url ); |
|
1038 | 1038 | |
1039 | 1039 | $html = ''; |
1040 | 1040 | |
1041 | - if( apply_filters( 'ssp_show_global_feed_tag', true ) ) { |
|
1042 | - $html = '<link rel="alternate" type="application/rss+xml" title="' . __( 'Podcast RSS feed', 'seriously-simple-podcasting' ) . '" href="' . esc_url( $feed_url ) . '" />'; |
|
1041 | + if ( apply_filters ( 'ssp_show_global_feed_tag', true ) ) { |
|
1042 | + $html = '<link rel="alternate" type="application/rss+xml" title="'.__ ( 'Podcast RSS feed', 'seriously-simple-podcasting' ).'" href="'.esc_url ( $feed_url ).'" />'; |
|
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | // Check if this is a series taxonomy archive and display series-specific RSS feed tag |
1046 | - $current_obj = get_queried_object(); |
|
1047 | - if( isset( $current_obj->taxonomy ) && 'series' == $current_obj->taxonomy && isset( $current_obj->slug ) && $current_obj->slug ) { |
|
1046 | + $current_obj = get_queried_object (); |
|
1047 | + if ( isset( $current_obj->taxonomy ) && 'series' == $current_obj->taxonomy && isset( $current_obj->slug ) && $current_obj->slug ) { |
|
1048 | 1048 | |
1049 | - if( apply_filters( 'ssp_show_series_feed_tag', true, $current_obj->slug ) ) { |
|
1049 | + if ( apply_filters ( 'ssp_show_series_feed_tag', true, $current_obj->slug ) ) { |
|
1050 | 1050 | |
1051 | - if ( get_option( 'permalink_structure' ) ) { |
|
1052 | - $series_feed_url = $feed_url . '/' . $current_obj->slug; |
|
1051 | + if ( get_option ( 'permalink_structure' ) ) { |
|
1052 | + $series_feed_url = $feed_url.'/'.$current_obj->slug; |
|
1053 | 1053 | } else { |
1054 | - $series_feed_url = $feed_url . '&podcast_series=' . $current_obj->slug; |
|
1054 | + $series_feed_url = $feed_url.'&podcast_series='.$current_obj->slug; |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | - $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 ) . '" />'; |
|
1057 | + $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 ).'" />'; |
|
1058 | 1058 | |
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | } |
1062 | 1062 | |
1063 | - echo "\n" . apply_filters( 'ssp_rss_meta_tag', $html ) . "\n\n"; |
|
1063 | + echo "\n".apply_filters ( 'ssp_rss_meta_tag', $html )."\n\n"; |
|
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | /** |
1067 | 1067 | * Register plugin widgets |
1068 | 1068 | * @return void |
1069 | 1069 | */ |
1070 | - public function register_widgets () { |
|
1070 | + public function register_widgets() { |
|
1071 | 1071 | |
1072 | 1072 | $widgets = array( |
1073 | 1073 | 'recent-episodes' => 'Recent_Episodes', |
@@ -1076,8 +1076,8 @@ discard block |
||
1076 | 1076 | ); |
1077 | 1077 | |
1078 | 1078 | foreach ( $widgets as $id => $name ) { |
1079 | - require_once( $this->dir . '/includes/widgets/class-ssp-widget-' . $id . '.php' ); |
|
1080 | - register_widget( 'SSP_Widget_' . $name ); |
|
1079 | + require_once( $this->dir.'/includes/widgets/class-ssp-widget-'.$id.'.php' ); |
|
1080 | + register_widget ( 'SSP_Widget_'.$name ); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | } |
@@ -1087,21 +1087,21 @@ discard block |
||
1087 | 1087 | * @param array $params Shortcode paramaters |
1088 | 1088 | * @return string HTML output |
1089 | 1089 | */ |
1090 | - public function podcast_episode_shortcode ( $params ) { |
|
1090 | + public function podcast_episode_shortcode( $params ) { |
|
1091 | 1091 | |
1092 | - $atts = shortcode_atts( array( |
|
1092 | + $atts = shortcode_atts ( array( |
|
1093 | 1093 | 'episode' => 0, |
1094 | 1094 | 'content' => 'title,player,details', |
1095 | 1095 | ), $params ); |
1096 | 1096 | |
1097 | - extract( $atts ); |
|
1097 | + extract ( $atts ); |
|
1098 | 1098 | |
1099 | 1099 | // If no episode ID is specified then use the current post's ID |
1100 | 1100 | if ( ! $episode ) { |
1101 | 1101 | |
1102 | 1102 | global $post; |
1103 | - if( isset( $post->ID ) ) { |
|
1104 | - $episode = intval( $post->ID ); |
|
1103 | + if ( isset( $post->ID ) ) { |
|
1104 | + $episode = intval ( $post->ID ); |
|
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | if ( ! $episode ) { |
@@ -1111,11 +1111,11 @@ discard block |
||
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | // Setup array of content items and trim whitespace |
1114 | - $content_items = explode( ',', $content ); |
|
1115 | - $content_items = array_map( 'trim', $content_items ); |
|
1114 | + $content_items = explode ( ',', $content ); |
|
1115 | + $content_items = array_map ( 'trim', $content_items ); |
|
1116 | 1116 | |
1117 | 1117 | // Get episode for display |
1118 | - $html = $this->podcast_episode( $episode, $content_items, 'shortcode' ); |
|
1118 | + $html = $this->podcast_episode ( $episode, $content_items, 'shortcode' ); |
|
1119 | 1119 | |
1120 | 1120 | return $html; |
1121 | 1121 | |
@@ -1127,64 +1127,64 @@ discard block |
||
1127 | 1127 | * @param array $content_items Orderd array of content items to display |
1128 | 1128 | * @return string HTML of episode with specified content items |
1129 | 1129 | */ |
1130 | - public function podcast_episode ( $episode_id = 0, $content_items = array( 'title', 'player', 'details' ), $context = '' ) { |
|
1130 | + public function podcast_episode( $episode_id = 0, $content_items = array( 'title', 'player', 'details' ), $context = '' ) { |
|
1131 | 1131 | global $post, $episode_context; |
1132 | 1132 | |
1133 | - if ( ! $episode_id || ! is_array( $content_items ) || empty( $content_items ) ) { |
|
1133 | + if ( ! $episode_id || ! is_array ( $content_items ) || empty( $content_items ) ) { |
|
1134 | 1134 | return; |
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | // Get episode object |
1138 | - $episode = get_post( $episode_id ); |
|
1138 | + $episode = get_post ( $episode_id ); |
|
1139 | 1139 | |
1140 | - if ( ! $episode || is_wp_error( $episode ) ) { |
|
1140 | + if ( ! $episode || is_wp_error ( $episode ) ) { |
|
1141 | 1141 | return; |
1142 | 1142 | } |
1143 | 1143 | |
1144 | - $html = '<div class="podcast-episode episode-' . esc_attr( $episode_id ) . '">' . "\n"; |
|
1144 | + $html = '<div class="podcast-episode episode-'.esc_attr ( $episode_id ).'">'."\n"; |
|
1145 | 1145 | |
1146 | 1146 | // Setup post data for episode post object |
1147 | 1147 | $post = $episode; |
1148 | - setup_postdata( $post ); |
|
1148 | + setup_postdata ( $post ); |
|
1149 | 1149 | |
1150 | 1150 | $episode_context = $context; |
1151 | 1151 | |
1152 | 1152 | // Display specified content items in the order supplied |
1153 | 1153 | foreach ( $content_items as $item ) { |
1154 | 1154 | |
1155 | - switch( $item ) { |
|
1155 | + switch ( $item ) { |
|
1156 | 1156 | |
1157 | 1157 | case 'title': |
1158 | - $html .= '<h3 class="episode-title">' . get_the_title() . '</h3>' . "\n"; |
|
1158 | + $html .= '<h3 class="episode-title">'.get_the_title ().'</h3>'."\n"; |
|
1159 | 1159 | break; |
1160 | 1160 | |
1161 | 1161 | case 'excerpt': |
1162 | - $html .= '<p class="episode-excerpt">' . get_the_excerpt() . '</p>' . "\n"; |
|
1162 | + $html .= '<p class="episode-excerpt">'.get_the_excerpt ().'</p>'."\n"; |
|
1163 | 1163 | break; |
1164 | 1164 | |
1165 | 1165 | case 'content': |
1166 | - $html .= '<div class="episode-content">' . apply_filters( 'the_content', get_the_content() ) . '</div>' . "\n"; |
|
1166 | + $html .= '<div class="episode-content">'.apply_filters ( 'the_content', get_the_content () ).'</div>'."\n"; |
|
1167 | 1167 | break; |
1168 | 1168 | |
1169 | 1169 | case 'player': |
1170 | - $file = $this->get_enclosure( $episode_id ); |
|
1171 | - if ( get_option( 'permalink_structure' ) ) { |
|
1172 | - $file = $this->get_episode_download_link( $episode_id ); |
|
1170 | + $file = $this->get_enclosure ( $episode_id ); |
|
1171 | + if ( get_option ( 'permalink_structure' ) ) { |
|
1172 | + $file = $this->get_episode_download_link ( $episode_id ); |
|
1173 | 1173 | } |
1174 | - $html .= '<div class="podcast_player">' . $this->media_player( $file, $episode_id ) . '</div>' . "\n"; |
|
1174 | + $html .= '<div class="podcast_player">'.$this->media_player ( $file, $episode_id ).'</div>'."\n"; |
|
1175 | 1175 | break; |
1176 | 1176 | |
1177 | 1177 | case 'details': |
1178 | - $html .= $this->episode_meta_details( $episode_id, $episode_context ); |
|
1178 | + $html .= $this->episode_meta_details ( $episode_id, $episode_context ); |
|
1179 | 1179 | break; |
1180 | 1180 | |
1181 | 1181 | } |
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | // Reset post data after fetching episode details |
1185 | - wp_reset_postdata(); |
|
1185 | + wp_reset_postdata (); |
|
1186 | 1186 | |
1187 | - $html .= '</div>' . "\n"; |
|
1187 | + $html .= '</div>'."\n"; |
|
1188 | 1188 | |
1189 | 1189 | return $html; |
1190 | 1190 | } |
@@ -1199,26 +1199,26 @@ discard block |
||
1199 | 1199 | function get_local_file_path( $file ) { |
1200 | 1200 | |
1201 | 1201 | // Identify file by root path and not URL (required for getID3 class) |
1202 | - $site_root = trailingslashit( ABSPATH ); |
|
1202 | + $site_root = trailingslashit ( ABSPATH ); |
|
1203 | 1203 | |
1204 | 1204 | // Remove common dirs from the ends of site_url and site_root, so that file can be outside of the WordPress installation |
1205 | - $root_chunks = explode( '/', $site_root ); |
|
1206 | - $url_chunks = explode( '/', $this->site_url ); |
|
1205 | + $root_chunks = explode ( '/', $site_root ); |
|
1206 | + $url_chunks = explode ( '/', $this->site_url ); |
|
1207 | 1207 | |
1208 | - end( $root_chunks ); |
|
1209 | - end( $url_chunks ); |
|
1208 | + end ( $root_chunks ); |
|
1209 | + end ( $url_chunks ); |
|
1210 | 1210 | |
1211 | - while ( ! is_null( key( $root_chunks ) ) && ! is_null( key( $url_chunks ) ) && ( current( $root_chunks ) == current( $url_chunks ) ) ) { |
|
1212 | - array_pop( $root_chunks ); |
|
1213 | - array_pop( $url_chunks ); |
|
1214 | - end( $root_chunks ); |
|
1215 | - end( $url_chunks ); |
|
1211 | + while ( ! is_null ( key ( $root_chunks ) ) && ! is_null ( key ( $url_chunks ) ) && ( current ( $root_chunks ) == current ( $url_chunks ) ) ) { |
|
1212 | + array_pop ( $root_chunks ); |
|
1213 | + array_pop ( $url_chunks ); |
|
1214 | + end ( $root_chunks ); |
|
1215 | + end ( $url_chunks ); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | - $site_root = implode('/', $root_chunks); |
|
1219 | - $site_url = implode('/', $url_chunks); |
|
1218 | + $site_root = implode ( '/', $root_chunks ); |
|
1219 | + $site_url = implode ( '/', $url_chunks ); |
|
1220 | 1220 | |
1221 | - $file = str_replace( $site_url, $site_root, $file ); |
|
1221 | + $file = str_replace ( $site_url, $site_root, $file ); |
|
1222 | 1222 | |
1223 | 1223 | return $file; |
1224 | 1224 | } |
@@ -1230,16 +1230,16 @@ discard block |
||
1230 | 1230 | * @param string $type Type of feed |
1231 | 1231 | * @return string Updated content type |
1232 | 1232 | */ |
1233 | - public function feed_content_type ( $content_type = '', $type = '' ) { |
|
1233 | + public function feed_content_type( $content_type = '', $type = '' ) { |
|
1234 | 1234 | |
1235 | - if( 'podcast' == $type ) { |
|
1235 | + if ( 'podcast' == $type ) { |
|
1236 | 1236 | $content_type = 'text/xml'; |
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | return $content_type; |
1240 | 1240 | } |
1241 | 1241 | |
1242 | - public function load_localisation () { |
|
1243 | - load_plugin_textdomain( 'seriously-simple-podcasting', false, basename( dirname( $this->file ) ) . '/languages/' ); |
|
1242 | + public function load_localisation() { |
|
1243 | + load_plugin_textdomain ( 'seriously-simple-podcasting', false, basename ( dirname ( $this->file ) ).'/languages/' ); |
|
1244 | 1244 | } |
1245 | 1245 | } |