Completed
Push — master ( d0f89d...8d008b )
by Hugh
02:54
created
includes/shortcodes/class-ssp-shortcode-podcast_playlist.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if ( ! defined ( 'ABSPATH' ) ) {
4 4
 	exit;
5 5
 }
6 6
 
@@ -21,17 +21,17 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	function shortcode( $attr ) {
23 23
 		global $content_width;
24
-		$post = get_post();
24
+		$post = get_post ();
25 25
 
26 26
 		static $instance = 0;
27 27
 		$instance++;
28 28
 
29
-		if ( ! empty( $attr['ids'] ) ) {
29
+		if ( ! empty( $attr[ 'ids' ] ) ) {
30 30
 			// 'ids' is explicitly ordered, unless you specify otherwise.
31
-			if ( empty( $attr['orderby'] ) ) {
32
-				$attr['orderby'] = 'post__in';
31
+			if ( empty( $attr[ 'orderby' ] ) ) {
32
+				$attr[ 'orderby' ] = 'post__in';
33 33
 			}
34
-			$attr['include'] = $attr['ids'];
34
+			$attr[ 'include' ] = $attr[ 'ids' ];
35 35
 		}
36 36
 
37 37
 		/**
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
 		 * @param array  $attr     An array of shortcode attributes.
48 48
 		 * @param int    $instance Unique numeric ID of this playlist shortcode instance.
49 49
 		 */
50
-		$output = apply_filters( 'post_playlist', '', $attr, $instance );
50
+		$output = apply_filters ( 'post_playlist', '', $attr, $instance );
51 51
 		if ( $output != '' ) {
52 52
 			return $output;
53 53
 		}
54 54
 
55
-		$atts = shortcode_atts( array(
55
+		$atts = shortcode_atts ( array(
56 56
 			'type'		=> 'audio',
57 57
 			'order'		=> 'ASC',
58 58
 			'orderby'	=> 'menu_order ID',
@@ -66,45 +66,45 @@  discard block
 block discarded – undo
66 66
 			'artists'	=> true
67 67
 		), $attr, 'playlist' );
68 68
 
69
-		$id = intval( $atts['id'] );
69
+		$id = intval ( $atts[ 'id' ] );
70 70
 
71
-		if ( $atts['type'] !== 'audio' ) {
72
-			$atts['type'] = 'video';
71
+		if ( $atts[ 'type' ] !== 'audio' ) {
72
+			$atts[ 'type' ] = 'video';
73 73
 		}
74 74
 
75 75
 		$args = array(
76 76
 			'post_status' => 'inherit',
77 77
 			'post_type' => 'attachment',
78
-			'post_mime_type' => $atts['type'],
79
-			'order' => $atts['order'],
80
-			'orderby' => $atts['orderby']
78
+			'post_mime_type' => $atts[ 'type' ],
79
+			'order' => $atts[ 'order' ],
80
+			'orderby' => $atts[ 'orderby' ]
81 81
 		);
82 82
 
83
-		if ( ! empty( $atts['include'] ) ) {
84
-			$args['include'] = $atts['include'];
85
-			$_attachments = get_posts( $args );
83
+		if ( ! empty( $atts[ 'include' ] ) ) {
84
+			$args[ 'include' ] = $atts[ 'include' ];
85
+			$_attachments = get_posts ( $args );
86 86
 
87 87
 			$attachments = array();
88 88
 			foreach ( $_attachments as $key => $val ) {
89
-				$attachments[$val->ID] = $_attachments[$key];
89
+				$attachments[ $val->ID ] = $_attachments[ $key ];
90 90
 			}
91
-		} elseif ( ! empty( $atts['exclude'] ) ) {
92
-			$args['post_parent'] = $id;
93
-			$args['exclude'] = $atts['exclude'];
94
-			$attachments = get_children( $args );
91
+		} elseif ( ! empty( $atts[ 'exclude' ] ) ) {
92
+			$args[ 'post_parent' ] = $id;
93
+			$args[ 'exclude' ] = $atts[ 'exclude' ];
94
+			$attachments = get_children ( $args );
95 95
 		} else {
96
-			$args['post_parent'] = $id;
97
-			$attachments = get_children( $args );
96
+			$args[ 'post_parent' ] = $id;
97
+			$attachments = get_children ( $args );
98 98
 		}
99 99
 
100 100
 		if ( empty( $attachments ) ) {
101 101
 			return '';
102 102
 		}
103 103
 
104
-		if ( is_feed() ) {
104
+		if ( is_feed () ) {
105 105
 			$output = "\n";
106 106
 			foreach ( $attachments as $att_id => $attachment ) {
107
-				$output .= wp_get_attachment_link( $att_id ) . "\n";
107
+				$output .= wp_get_attachment_link ( $att_id )."\n";
108 108
 			}
109 109
 			return $output;
110 110
 		}
@@ -115,51 +115,51 @@  discard block
 block discarded – undo
115 115
 		$default_height = 360;
116 116
 
117 117
 		$theme_width = empty( $content_width ) ? $default_width : ( $content_width - $outer );
118
-		$theme_height = empty( $content_width ) ? $default_height : round( ( $default_height * $theme_width ) / $default_width );
118
+		$theme_height = empty( $content_width ) ? $default_height : round ( ( $default_height * $theme_width ) / $default_width );
119 119
 
120 120
 		$data = array(
121
-			'type' => $atts['type'],
121
+			'type' => $atts[ 'type' ],
122 122
 			// don't pass strings to JSON, will be truthy in JS
123
-			'tracklist' => wp_validate_boolean( $atts['tracklist'] ),
124
-			'tracknumbers' => wp_validate_boolean( $atts['tracknumbers'] ),
125
-			'images' => wp_validate_boolean( $atts['images'] ),
126
-			'artists' => wp_validate_boolean( $atts['artists'] ),
123
+			'tracklist' => wp_validate_boolean ( $atts[ 'tracklist' ] ),
124
+			'tracknumbers' => wp_validate_boolean ( $atts[ 'tracknumbers' ] ),
125
+			'images' => wp_validate_boolean ( $atts[ 'images' ] ),
126
+			'artists' => wp_validate_boolean ( $atts[ 'artists' ] ),
127 127
 		);
128 128
 
129 129
 		$tracks = array();
130 130
 		foreach ( $attachments as $attachment ) {
131
-			$url = wp_get_attachment_url( $attachment->ID );
132
-			$ftype = wp_check_filetype( $url, wp_get_mime_types() );
131
+			$url = wp_get_attachment_url ( $attachment->ID );
132
+			$ftype = wp_check_filetype ( $url, wp_get_mime_types () );
133 133
 			$track = array(
134 134
 				'src' => $url,
135
-				'type' => $ftype['type'],
135
+				'type' => $ftype[ 'type' ],
136 136
 				'title' => $attachment->post_title,
137 137
 				'caption' => $attachment->post_excerpt,
138 138
 				'description' => $attachment->post_content
139 139
 			);
140 140
 
141
-			$track['meta'] = array();
142
-			$meta = wp_get_attachment_metadata( $attachment->ID );
141
+			$track[ 'meta' ] = array();
142
+			$meta = wp_get_attachment_metadata ( $attachment->ID );
143 143
 			if ( ! empty( $meta ) ) {
144 144
 
145
-				foreach ( wp_get_attachment_id3_keys( $attachment ) as $key => $label ) {
145
+				foreach ( wp_get_attachment_id3_keys ( $attachment ) as $key => $label ) {
146 146
 					if ( ! empty( $meta[ $key ] ) ) {
147
-						$track['meta'][ $key ] = $meta[ $key ];
147
+						$track[ 'meta' ][ $key ] = $meta[ $key ];
148 148
 					}
149 149
 				}
150 150
 
151
-				if ( 'video' === $atts['type'] ) {
152
-					if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
153
-						$width = $meta['width'];
154
-						$height = $meta['height'];
155
-						$theme_height = round( ( $height * $theme_width ) / $width );
151
+				if ( 'video' === $atts[ 'type' ] ) {
152
+					if ( ! empty( $meta[ 'width' ] ) && ! empty( $meta[ 'height' ] ) ) {
153
+						$width = $meta[ 'width' ];
154
+						$height = $meta[ 'height' ];
155
+						$theme_height = round ( ( $height * $theme_width ) / $width );
156 156
 					} else {
157 157
 						$width = $default_width;
158 158
 						$height = $default_height;
159 159
 					}
160 160
 
161
-					$track['dimensions'] = array(
162
-						'original' => compact( 'width', 'height' ),
161
+					$track[ 'dimensions' ] = array(
162
+						'original' => compact ( 'width', 'height' ),
163 163
 						'resized' => array(
164 164
 							'width' => $theme_width,
165 165
 							'height' => $theme_height
@@ -168,30 +168,30 @@  discard block
 block discarded – undo
168 168
 				}
169 169
 			}
170 170
 
171
-			if ( $atts['images'] ) {
172
-				$thumb_id = get_post_thumbnail_id( $attachment->ID );
171
+			if ( $atts[ 'images' ] ) {
172
+				$thumb_id = get_post_thumbnail_id ( $attachment->ID );
173 173
 				if ( ! empty( $thumb_id ) ) {
174
-					list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'full' );
175
-					$track['image'] = compact( 'src', 'width', 'height' );
176
-					list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'thumbnail' );
177
-					$track['thumb'] = compact( 'src', 'width', 'height' );
174
+					list( $src, $width, $height ) = wp_get_attachment_image_src ( $thumb_id, 'full' );
175
+					$track[ 'image' ] = compact ( 'src', 'width', 'height' );
176
+					list( $src, $width, $height ) = wp_get_attachment_image_src ( $thumb_id, 'thumbnail' );
177
+					$track[ 'thumb' ] = compact ( 'src', 'width', 'height' );
178 178
 				} else {
179
-					$src = wp_mime_type_icon( $attachment->ID );
179
+					$src = wp_mime_type_icon ( $attachment->ID );
180 180
 					$width = 48;
181 181
 					$height = 64;
182
-					$track['image'] = compact( 'src', 'width', 'height' );
183
-					$track['thumb'] = compact( 'src', 'width', 'height' );
182
+					$track[ 'image' ] = compact ( 'src', 'width', 'height' );
183
+					$track[ 'thumb' ] = compact ( 'src', 'width', 'height' );
184 184
 				}
185 185
 			}
186 186
 
187
-			$tracks[] = $track;
187
+			$tracks[ ] = $track;
188 188
 		}
189
-		$data['tracks'] = $tracks;
189
+		$data[ 'tracks' ] = $tracks;
190 190
 
191
-		$safe_type = esc_attr( $atts['type'] );
192
-		$safe_style = esc_attr( $atts['style'] );
191
+		$safe_type = esc_attr ( $atts[ 'type' ] );
192
+		$safe_style = esc_attr ( $atts[ 'style' ] );
193 193
 
194
-		ob_start();
194
+		ob_start ();
195 195
 
196 196
 		if ( 1 === $instance ) {
197 197
 			/**
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
 			 * @param string $type  Type of playlist. Possible values are 'audio' or 'video'.
203 203
 			 * @param string $style The 'theme' for the playlist. Core provides 'light' and 'dark'.
204 204
 			 */
205
-			do_action( 'wp_playlist_scripts', $atts['type'], $atts['style'] );
205
+			do_action ( 'wp_playlist_scripts', $atts[ 'type' ], $atts[ 'style' ] );
206 206
 		} ?>
207 207
 	<div class="wp-playlist wp-<?php echo $safe_type ?>-playlist wp-playlist-<?php echo $safe_style ?>">
208
-		<?php if ( 'audio' === $atts['type'] ): ?>
208
+		<?php if ( 'audio' === $atts[ 'type' ] ): ?>
209 209
 		<div class="wp-playlist-current-item"></div>
210 210
 		<?php endif ?>
211 211
 		<<?php echo $safe_type ?> controls="controls" preload="none" width="<?php
@@ -218,16 +218,16 @@  discard block
 block discarded – undo
218 218
 		<noscript>
219 219
 		<ol><?php
220 220
 		foreach ( $attachments as $att_id => $attachment ) {
221
-			printf( '<li>%s</li>', wp_get_attachment_link( $att_id ) );
221
+			printf ( '<li>%s</li>', wp_get_attachment_link ( $att_id ) );
222 222
 		}
223 223
 		?></ol>
224 224
 		</noscript>
225
-		<script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode( $data ) ?></script>
225
+		<script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode ( $data ) ?></script>
226 226
 	</div>
227 227
 		<?php
228
-		return ob_get_clean();
228
+		return ob_get_clean ();
229 229
 	}
230 230
 
231 231
 }
232 232
 
233
-$GLOBALS['ssp_shortcodes']['podcast_playlist'] = new SSP_Shortcode_Podcast_Playlist();
234 233
\ No newline at end of file
234
+$GLOBALS[ 'ssp_shortcodes' ][ 'podcast_playlist' ] = new SSP_Shortcode_Podcast_Playlist ();
235 235
\ No newline at end of file
Please login to merge, or discard this patch.
includes/shortcodes/class-ssp-shortcode-ss_podcast.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if ( ! defined ( 'ABSPATH' ) ) {
4 4
 	exit;
5 5
 }
6 6
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @param  array  $atts    Shortcode attributes
20 20
 	 * @return string          HTML output
21 21
 	 */
22
-	function shortcode ( $atts ) {
22
+	function shortcode( $atts ) {
23 23
 
24 24
 		$defaults = array(
25 25
 			'title' => '',
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 			'link_title' => true
31 31
 		);
32 32
 
33
-		$args = shortcode_atts( $defaults, $atts );
33
+		$args = shortcode_atts ( $defaults, $atts );
34 34
 
35 35
 		// Make sure we return and don't echo.
36
-		$args['echo'] = false;
36
+		$args[ 'echo' ] = false;
37 37
 
38
-		return ss_podcast( $args );
38
+		return ss_podcast ( $args );
39 39
 	}
40 40
 
41 41
 }
42 42
 
43
-$GLOBALS['ssp_shortcodes']['ss_podcast'] = new SSP_Shortcode_SS_Podcast();
44 43
\ No newline at end of file
44
+$GLOBALS[ 'ssp_shortcodes' ][ 'ss_podcast' ] = new SSP_Shortcode_SS_Podcast ();
45 45
\ No newline at end of file
Please login to merge, or discard this patch.