Completed
Push — develop ( 642c95...06c687 )
by Gennady
75:21 queued 53:04
created
includes/fields/class-gravityview-field-fileupload.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
 
25 25
 	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
26 26
 
27
-		unset( $field_options['search_filter'] );
27
+		unset( $field_options[ 'search_filter' ] );
28 28
 
29
-		if( 'edit' === $context ) {
29
+		if ( 'edit' === $context ) {
30 30
 			return $field_options;
31 31
 		}
32 32
 
33
-		$add_options['link_to_file'] = array(
33
+		$add_options[ 'link_to_file' ] = array(
34 34
 			'type' => 'checkbox',
35 35
 			'label' => __( 'Display as a Link:', 'gravityview' ),
36
-			'desc' => __('Display the uploaded files as links, rather than embedded content.', 'gravityview'),
36
+			'desc' => __( 'Display the uploaded files as links, rather than embedded content.', 'gravityview' ),
37 37
 			'value' => false,
38 38
 			'merge_tags' => false,
39 39
 		);
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 			$base_id = null;
120 120
 
121 121
 			$is_single = gravityview_get_context() === 'single';
122
-			$lightbox = ! empty( $gravityview_view->atts['lightbox'] );
122
+			$lightbox = ! empty( $gravityview_view->atts[ 'lightbox' ] );
123 123
 			$field_compat = $gravityview_view->getCurrentField();
124 124
 		}
125 125
 
126 126
 		$output_arr = array();
127 127
 
128 128
 		// Get an array of file paths for the field.
129
-		$file_paths = \GV\Utils::get( $field , 'multipleFiles' ) ? json_decode( $value ) : array( $value );
129
+		$file_paths = \GV\Utils::get( $field, 'multipleFiles' ) ? json_decode( $value ) : array( $value );
130 130
 
131 131
 		// The $value JSON was probably truncated; let's check lead_detail_long.
132 132
 		if ( ! is_array( $file_paths ) ) {
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			$rendered = null;
146 146
 
147 147
 			// If the site is HTTPS, use HTTPS
148
-			if ( function_exists('set_url_scheme') ) {
148
+			if ( function_exists( 'set_url_scheme' ) ) {
149 149
 				$file_path = set_url_scheme( $file_path );
150 150
 			}
151 151
 
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 			$file_path_info = pathinfo( $file_path );
157 157
 
158 158
 			// If pathinfo() gave us the extension of the file, run the switch statement using that.
159
-			$extension = empty( $file_path_info['extension'] ) ? NULL : strtolower( $file_path_info['extension'] );
160
-			$basename = $file_path_info['basename'];
159
+			$extension = empty( $file_path_info[ 'extension' ] ) ? NULL : strtolower( $file_path_info[ 'extension' ] );
160
+			$basename = $file_path_info[ 'basename' ];
161 161
 
162 162
 			// Get the secure download URL
163 163
 			$is_secure = false;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 					 */
195 195
 					$audio_settings = apply_filters( 'gravityview_audio_settings', array(
196 196
 						'src' => $insecure_file_path, // Needs to be insecure path so WP can parse extension
197
-						'class' => 'wp-audio-shortcode gv-audio gv-field-id-'.$field_settings['id']
197
+						'class' => 'wp-audio-shortcode gv-audio gv-field-id-' . $field_settings[ 'id' ]
198 198
 					), $context );
199 199
 
200 200
 					/**
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 					 */
231 231
 					$video_settings = apply_filters( 'gravityview_video_settings', array(
232 232
 						'src' => $insecure_file_path, // Needs to be insecure path so WP can parse extension
233
-						'class' => 'wp-video-shortcode gv-video gv-field-id-'.$field_settings['id']
233
+						'class' => 'wp-video-shortcode gv-video gv-field-id-' . $field_settings[ 'id' ]
234 234
 					), $context );
235 235
 
236 236
 					/**
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
 			} else if ( in_array( $extension, array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ) ) ) {
263 263
 				$image_atts = array(
264 264
 					'src'   => $file_path,
265
-					'class' => 'gv-image gv-field-id-' . $field_settings['id'],
266
-					'alt'   => $field_settings['label'],
265
+					'class' => 'gv-image gv-field-id-' . $field_settings[ 'id' ],
266
+					'alt'   => $field_settings[ 'label' ],
267 267
 					'width' => ( $is_single ? null : 250 )
268 268
 				);
269 269
 
270 270
 				if ( $is_secure ) {
271
-					$image_atts['validate_src'] = false;
271
+					$image_atts[ 'validate_src' ] = false;
272 272
 				}
273 273
 
274 274
 				/**
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 
284 284
 				$image = new GravityView_Image( $image_atts );
285 285
 
286
-				$entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry );
286
+				$entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry );
287 287
 
288
-				if ( $lightbox && empty( $field_settings['show_as_link'] ) ) {
288
+				if ( $lightbox && empty( $field_settings[ 'show_as_link' ] ) ) {
289 289
 					$lightbox_link_atts = array(
290 290
 						'rel'   => sprintf( "%s-%s", $gv_class, $entry_slug ),
291 291
 						'class' => 'thickbox',
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 				}
298 298
 
299 299
 				// Show as link should render the image regardless.
300
-				if ( ! empty( $field_settings['show_as_link'] ) ) {
300
+				if ( ! empty( $field_settings[ 'show_as_link' ] ) ) {
301 301
 					$text = $rendered;
302 302
 				}
303 303
 			}
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 			$disable_wrapped_link = apply_filters( 'gravityview/fields/fileupload/disable_link', false, $field_compat, $context );
315 315
 
316 316
 			// Output textualized content where 
317
-			if ( ! $disable_wrapped_link && ( ! empty( $field_settings['link_to_file'] ) || ! empty( $field_settings['show_as_link'] ) ) ) {
317
+			if ( ! $disable_wrapped_link && ( ! empty( $field_settings[ 'link_to_file' ] ) || ! empty( $field_settings[ 'show_as_link' ] ) ) ) {
318 318
 				/**
319 319
 				 * Modify the link text (defaults to the file name)
320 320
 				 *
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 				 */
328 328
 				$content = apply_filters( 'gravityview/fields/fileupload/link_content', $text, $field_compat, $context );
329 329
 
330
-				if ( empty( $field_settings['show_as_link'] ) ) {
330
+				if ( empty( $field_settings[ 'show_as_link' ] ) ) {
331 331
 					/**
332 332
 					 * @filter `gravityview/fields/fileupload/link_atts` Modify the link attributes for a file upload field
333 333
 					 * @param array|string $link_atts Array or attributes string
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 				$content = empty( $rendered ) ? $text : $rendered;
344 344
 			}
345 345
 
346
-			$output_arr[] = array(
346
+			$output_arr[ ] = array(
347 347
 				'file_path' => $file_path,
348 348
 				'content' => $content
349 349
 			);
Please login to merge, or discard this patch.