Completed
Push — develop ( c6767a...8970db )
by
unknown
39:15 queued 19:16
created
includes/fields/class-gravityview-field-fileupload.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -26,21 +26,21 @@  discard block
 block discarded – undo
26 26
 
27 27
 	public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) {
28 28
 
29
-		unset( $field_options['search_filter'] );
29
+		unset( $field_options[ 'search_filter' ] );
30 30
 
31
-		if( 'edit' === $context ) {
31
+		if ( 'edit' === $context ) {
32 32
 			return $field_options;
33 33
 		}
34 34
 
35
-		$add_options['link_to_file'] = array(
35
+		$add_options[ 'link_to_file' ] = array(
36 36
 			'type' => 'checkbox',
37 37
 			'label' => __( 'Display as a Link:', 'gk-gravityview' ),
38
-			'desc' => __('Display the uploaded files as links, rather than embedded content.', 'gk-gravityview'),
38
+			'desc' => __( 'Display the uploaded files as links, rather than embedded content.', 'gk-gravityview' ),
39 39
 			'value' => false,
40 40
 			'merge_tags' => false,
41 41
 		);
42 42
 
43
-		$add_options['image_width'] = array(
43
+		$add_options[ 'image_width' ] = array(
44 44
 			'type' => 'text',
45 45
 			'label' => __( 'Custom Width:', 'gk-gravityview' ),
46 46
 			'desc' => __( 'Override the default image width (250).', 'gk-gravityview' ),
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
 			'merge_tags' => false,
49 49
 		);
50 50
 
51
-		$field = \GV\GF_Field::by_id( \GV\GF_Form::by_id( $form_id), $field_id );
51
+		$field = \GV\GF_Field::by_id( \GV\GF_Form::by_id( $form_id ), $field_id );
52 52
 
53 53
 		// Only allow alt text on single files currently.
54
-		if( empty( $field->field->multipleFiles ) ) {
54
+		if ( empty( $field->field->multipleFiles ) ) {
55 55
 
56
-			$add_options['alt_text'] = array(
56
+			$add_options[ 'alt_text' ] = array(
57 57
 				'type'       => 'text',
58 58
 				'label'      => __( 'Alternative text', 'gk-gravityview' ),
59 59
 				'desc'       => __( 'Define an alternative text description of a file. For supported file types only. By default, the field label is used.', 'gk-gravityview' ),
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
 			/** A compatibility array that's required by some of the deprecated filters. */
149 149
 			$field_compat = array(
150
-				'form' => (isset($context->source->form) ? $context->source->form : ''),
150
+				'form' => ( isset( $context->source->form ) ? $context->source->form : '' ),
151 151
 				'field_id' => $context->field->ID,
152 152
 				'field' => $field,
153 153
 				'field_settings' => $field_settings,
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 				'format' => 'html',
157 157
 				'entry' => $entry,
158 158
 				'field_type' => $context->field->type,
159
-				'field_path' => (isset($context->template->located_template) ? $context->template->located_template : ''),
159
+				'field_path' => ( isset( $context->template->located_template ) ? $context->template->located_template : '' ),
160 160
 			);
161 161
 		} else {
162 162
 
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 			$base_id = null;
175 175
 
176 176
 			$is_single = gravityview_get_context() === 'single';
177
-			$lightbox = ! empty( $gravityview_view->atts['lightbox'] );
177
+			$lightbox = ! empty( $gravityview_view->atts[ 'lightbox' ] );
178 178
 			$field_compat = $gravityview_view->getCurrentField();
179 179
 		}
180 180
 
181 181
 		$output_arr = array();
182 182
 
183 183
 		// Get an array of file paths for the field.
184
-		$file_paths = (int) \GV\Utils::get( $field, 'multipleFiles' ) !== 1 ? array( $value ) : $value;
184
+		$file_paths = (int)\GV\Utils::get( $field, 'multipleFiles' ) !== 1 ? array( $value ) : $value;
185 185
 
186 186
 		// The $value JSON was probably truncated; let's check lead_detail_long.
187 187
 		if ( ! is_array( $file_paths ) ) {
@@ -202,19 +202,19 @@  discard block
 block discarded – undo
202 202
 
203 203
 			$file_info = self::get_file_info( $file_path, $field, $field_settings, $context, $index );
204 204
 
205
-			$file_path = $file_info['file_path'];
206
-			$basename = $file_info['basename'];
207
-			$extension = $file_info['extension'];
208
-			$insecure_file_path = $file_info['insecure_file_path'];
209
-			$secure_file_path = $file_info['secure_file_path'];
210
-			$is_secure = $file_info['is_secure'];
205
+			$file_path = $file_info[ 'file_path' ];
206
+			$basename = $file_info[ 'basename' ];
207
+			$extension = $file_info[ 'extension' ];
208
+			$insecure_file_path = $file_info[ 'insecure_file_path' ];
209
+			$secure_file_path = $file_info[ 'secure_file_path' ];
210
+			$is_secure = $file_info[ 'is_secure' ];
211 211
 
212 212
 			$disable_lightbox   = false;
213 213
 			$text               = $basename;
214 214
 
215 215
 			$alt = \GV\Utils::get( $field_settings, 'alt_text' );
216
-			$alt = ( '' === $alt ) ? $field_settings['label'] : $alt;
217
-			$alt = GFCommon::replace_variables( $alt, GFAPI::get_form( $entry['form_id'] ), $entry );
216
+			$alt = ( '' === $alt ) ? $field_settings[ 'label' ] : $alt;
217
+			$alt = GFCommon::replace_variables( $alt, GFAPI::get_form( $entry[ 'form_id' ] ), $entry );
218 218
 
219 219
 			// Audio
220 220
 			if ( in_array( $extension, wp_get_audio_extensions() ) ) {
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 					 */
230 230
 					$audio_settings = apply_filters( 'gravityview_audio_settings', array(
231 231
 						'src' => $insecure_file_path, // Needs to be insecure path so WP can parse extension
232
-						'class' => 'wp-audio-shortcode gv-audio gv-field-id-'.$field_settings['id']
232
+						'class' => 'wp-audio-shortcode gv-audio gv-field-id-' . $field_settings[ 'id' ]
233 233
 					), $context );
234 234
 
235 235
 					/**
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 					 */
259 259
 					$video_settings = apply_filters( 'gravityview_video_settings', array(
260 260
 						'src' => $insecure_file_path, // Needs to be insecure path so WP can parse extension
261
-						'class' => 'wp-video-shortcode gv-video gv-field-id-'.$field_settings['id']
261
+						'class' => 'wp-video-shortcode gv-video gv-field-id-' . $field_settings[ 'id' ]
262 262
 					), $context );
263 263
 
264 264
 					/**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 					$file_path = add_query_arg( array( 'gv-iframe' => 'true' ), $file_path );
283 283
 				}
284 284
 
285
-				$field_settings['link_to_file'] = true;
285
+				$field_settings[ 'link_to_file' ] = true;
286 286
 
287 287
 			// Images
288 288
 			} else if ( in_array( $extension, GravityView_Image::get_image_extensions() ) ) {
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 
291 291
 				$image_atts = array(
292 292
 					'src'   => $file_path,
293
-					'class' => 'gv-image gv-field-id-' . $field_settings['id'],
293
+					'class' => 'gv-image gv-field-id-' . $field_settings[ 'id' ],
294 294
 					'alt'   => $alt,
295
-					'width' => ( $is_single ? null : ( $width ? $width: 250 ) )
295
+					'width' => ( $is_single ? null : ( $width ? $width : 250 ) )
296 296
 				);
297 297
 
298 298
 				if ( $is_secure ) {
299
-					$image_atts['validate_src'] = false;
299
+					$image_atts[ 'validate_src' ] = false;
300 300
 				}
301 301
 
302 302
 				/**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 				unset( $gv_entry );
319 319
 
320
-				if ( $lightbox && empty( $field_settings['show_as_link'] ) ) {
320
+				if ( $lightbox && empty( $field_settings[ 'show_as_link' ] ) ) {
321 321
 
322 322
 					$lightbox_link_atts = array(
323 323
 						'rel'   => sprintf( "%s-%s", $gv_class, $entry_slug ),
@@ -332,13 +332,13 @@  discard block
 block discarded – undo
332 332
 				}
333 333
 
334 334
 				// Show as link should render the image regardless.
335
-				if ( ! empty( $field_settings['show_as_link'] ) ) {
335
+				if ( ! empty( $field_settings[ 'show_as_link' ] ) ) {
336 336
 					$text = $rendered;
337 337
 				}
338 338
 			}
339 339
 			// For all other non-media file types (ZIP, for example), always show as a link regardless of setting.
340 340
 			else {
341
-				$field_settings['link_to_file'] = true;
341
+				$field_settings[ 'link_to_file' ] = true;
342 342
 				$disable_lightbox = true;
343 343
 			}
344 344
 
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 			$disable_wrapped_link = apply_filters( 'gravityview/fields/fileupload/disable_link', false, $field_compat, $context );
355 355
 
356 356
 			// Output textualized content where
357
-			if ( ! $disable_wrapped_link && ( ! empty( $field_settings['link_to_file'] ) || ! empty( $field_settings['show_as_link'] ) ) ) {
357
+			if ( ! $disable_wrapped_link && ( ! empty( $field_settings[ 'link_to_file' ] ) || ! empty( $field_settings[ 'show_as_link' ] ) ) ) {
358 358
 				/**
359 359
 				 * Modify the link text (defaults to the file name)
360 360
 				 *
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 				 */
368 368
 				$content = apply_filters( 'gravityview/fields/fileupload/link_content', $text, $field_compat, $context );
369 369
 
370
-				if ( empty( $field_settings['show_as_link'] ) ) {
370
+				if ( empty( $field_settings[ 'show_as_link' ] ) ) {
371 371
 					/**
372 372
 					 * @filter `gravityview/fields/fileupload/link_atts` Modify the link attributes for a file upload field
373 373
 					 * @since 2.0 Added $context
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 				$content = empty( $rendered ) ? $text : $rendered;
389 389
 			}
390 390
 
391
-			$output_arr[] = array(
391
+			$output_arr[ ] = array(
392 392
 				'file_path' => $file_path,
393 393
 				'content' => $content
394 394
 			);
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 		$file_path_info = pathinfo( $file_path );
440 440
 
441 441
 		// If pathinfo() gave us the extension of the file, run the switch statement using that.
442
-		$extension = empty( $file_path_info['extension'] ) ? null : strtolower( $file_path_info['extension'] );
442
+		$extension = empty( $file_path_info[ 'extension' ] ) ? null : strtolower( $file_path_info[ 'extension' ] );
443 443
 
444 444
 		/**
445 445
 		 * @filter `gravityview/fields/fileupload/extension` Modify the file extension before it's used in display logic
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 		 */
451 451
 		$extension = apply_filters( 'gravityview/fields/fileupload/extension', $extension, $file_path );
452 452
 
453
-		$basename = $file_path_info['basename'];
453
+		$basename = $file_path_info[ 'basename' ];
454 454
 
455 455
 		// Get the secure download URL
456 456
 		$is_secure          = false;
Please login to merge, or discard this patch.