@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | // This is from Gravity Forms's code |
| 111 | 111 | $file_path = esc_attr(str_replace(" ", "%20", $file_path)); |
| 112 | 112 | |
| 113 | - $display_dropbox_link = apply_filters( 'gravityview_display_dropbox_link', true, $file_path ); |
|
| 113 | + $display_dropbox_link = apply_filters( 'gravityview_display_dropbox_link', true, $file_path ); |
|
| 114 | 114 | |
| 115 | - if ( !$display_dropbox_link && empty( $field_settings['link_to_file'] ) ){ |
|
| 116 | - $file_path = false !== strpos($file_path, 'www.dropbox') ? str_replace("www.dropbox","dl.dropboxusercontent",$file_path) : $file_path; |
|
| 117 | - $file_path = false !== strpos($file_path, '?dl=0') ? str_replace("?dl=0","",$file_path) : $file_path; |
|
| 118 | - } |
|
| 115 | + if ( !$display_dropbox_link && empty( $field_settings['link_to_file'] ) ){ |
|
| 116 | + $file_path = false !== strpos($file_path, 'www.dropbox') ? str_replace("www.dropbox","dl.dropboxusercontent",$file_path) : $file_path; |
|
| 117 | + $file_path = false !== strpos($file_path, '?dl=0') ? str_replace("?dl=0","",$file_path) : $file_path; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | 120 | // If the field is set to link to the single entry, link to it. |
| 121 | 121 | $link = !empty( $field_settings['show_as_link'] ) ? GravityView_API::entry_link( $entry, $field ) : $file_path; |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | $content = apply_filters( 'gravityview/fields/fileupload/link_content', $content, $gravityview_view->getCurrentField() ); |
| 284 | 284 | |
| 285 | - $content = gravityview_get_link( $link, $content, $link_atts ); |
|
| 285 | + $content = gravityview_get_link( $link, $content, $link_atts ); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | $output_arr[] = array( |
@@ -24,16 +24,16 @@ discard block |
||
| 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 | ); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $output_arr = array(); |
| 89 | 89 | |
| 90 | 90 | // Get an array of file paths for the field. |
| 91 | - $file_paths = rgar( $field , 'multipleFiles' ) ? json_decode( $value ) : array( $value ); |
|
| 91 | + $file_paths = rgar( $field, 'multipleFiles' ) ? json_decode( $value ) : array( $value ); |
|
| 92 | 92 | |
| 93 | 93 | // The $value JSON was probably truncated; let's check lead_detail_long. |
| 94 | 94 | if ( ! is_array( $file_paths ) ) { |
@@ -102,26 +102,26 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // Process each file path |
| 105 | - foreach( $file_paths as $file_path ) { |
|
| 105 | + foreach ( $file_paths as $file_path ) { |
|
| 106 | 106 | |
| 107 | 107 | // If the site is HTTPS, use HTTPS |
| 108 | - if(function_exists('set_url_scheme')) { $file_path = set_url_scheme($file_path); } |
|
| 108 | + if ( function_exists( 'set_url_scheme' ) ) { $file_path = set_url_scheme( $file_path ); } |
|
| 109 | 109 | |
| 110 | 110 | // This is from Gravity Forms's code |
| 111 | - $file_path = esc_attr(str_replace(" ", "%20", $file_path)); |
|
| 111 | + $file_path = esc_attr( str_replace( " ", "%20", $file_path ) ); |
|
| 112 | 112 | |
| 113 | 113 | $display_dropbox_link = apply_filters( 'gravityview_display_dropbox_link', true, $file_path ); |
| 114 | 114 | |
| 115 | - if ( !$display_dropbox_link && empty( $field_settings['link_to_file'] ) ){ |
|
| 116 | - $file_path = false !== strpos($file_path, 'www.dropbox') ? str_replace("www.dropbox","dl.dropboxusercontent",$file_path) : $file_path; |
|
| 117 | - $file_path = false !== strpos($file_path, '?dl=0') ? str_replace("?dl=0","",$file_path) : $file_path; |
|
| 115 | + if ( ! $display_dropbox_link && empty( $field_settings[ 'link_to_file' ] ) ) { |
|
| 116 | + $file_path = false !== strpos( $file_path, 'www.dropbox' ) ? str_replace( "www.dropbox", "dl.dropboxusercontent", $file_path ) : $file_path; |
|
| 117 | + $file_path = false !== strpos( $file_path, '?dl=0' ) ? str_replace( "?dl=0", "", $file_path ) : $file_path; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // If the field is set to link to the single entry, link to it. |
| 121 | - $link = !empty( $field_settings['show_as_link'] ) ? GravityView_API::entry_link( $entry, $field ) : $file_path; |
|
| 121 | + $link = ! empty( $field_settings[ 'show_as_link' ] ) ? GravityView_API::entry_link( $entry, $field ) : $file_path; |
|
| 122 | 122 | |
| 123 | 123 | // Get file path information |
| 124 | - $file_path_info = pathinfo($file_path); |
|
| 124 | + $file_path_info = pathinfo( $file_path ); |
|
| 125 | 125 | |
| 126 | 126 | $html_format = NULL; |
| 127 | 127 | |
@@ -130,30 +130,30 @@ discard block |
||
| 130 | 130 | $disable_wrapped_link = false; |
| 131 | 131 | |
| 132 | 132 | // Is this an image? |
| 133 | - $image = new GravityView_Image(array( |
|
| 133 | + $image = new GravityView_Image( array( |
|
| 134 | 134 | 'src' => $file_path, |
| 135 | - 'class' => 'gv-image gv-field-id-'.$field_settings['id'], |
|
| 136 | - 'alt' => $field_settings['label'], |
|
| 137 | - 'width' => (gravityview_get_context() === 'single' ? NULL : 250) |
|
| 138 | - )); |
|
| 135 | + 'class' => 'gv-image gv-field-id-' . $field_settings[ 'id' ], |
|
| 136 | + 'alt' => $field_settings[ 'label' ], |
|
| 137 | + 'width' => ( gravityview_get_context() === 'single' ? NULL : 250 ) |
|
| 138 | + ) ); |
|
| 139 | 139 | |
| 140 | 140 | $content = $image->html(); |
| 141 | 141 | |
| 142 | 142 | // The new default content is the image, if it exists. If not, use the file name as the content. |
| 143 | - $content = !empty( $content ) ? $content : $file_path_info['basename']; |
|
| 143 | + $content = ! empty( $content ) ? $content : $file_path_info[ 'basename' ]; |
|
| 144 | 144 | |
| 145 | 145 | // If pathinfo() gave us the extension of the file, run the switch statement using that. |
| 146 | - $extension = empty( $file_path_info['extension'] ) ? NULL : strtolower( $file_path_info['extension'] ); |
|
| 146 | + $extension = empty( $file_path_info[ 'extension' ] ) ? NULL : strtolower( $file_path_info[ 'extension' ] ); |
|
| 147 | 147 | |
| 148 | 148 | |
| 149 | - switch( true ) { |
|
| 149 | + switch ( true ) { |
|
| 150 | 150 | |
| 151 | 151 | // Audio file |
| 152 | 152 | case in_array( $extension, wp_get_audio_extensions() ): |
| 153 | 153 | |
| 154 | 154 | $disable_lightbox = true; |
| 155 | 155 | |
| 156 | - if( shortcode_exists( 'audio' ) ) { |
|
| 156 | + if ( shortcode_exists( 'audio' ) ) { |
|
| 157 | 157 | |
| 158 | 158 | $disable_wrapped_link = true; |
| 159 | 159 | |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | $audio_settings = apply_filters( 'gravityview_audio_settings', array( |
| 166 | 166 | 'src' => $file_path, |
| 167 | - 'class' => 'wp-audio-shortcode gv-audio gv-field-id-'.$field_settings['id'] |
|
| 168 | - )); |
|
| 167 | + 'class' => 'wp-audio-shortcode gv-audio gv-field-id-' . $field_settings[ 'id' ] |
|
| 168 | + ) ); |
|
| 169 | 169 | |
| 170 | 170 | /** |
| 171 | 171 | * Generate the audio shortcode |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $disable_lightbox = true; |
| 185 | 185 | |
| 186 | - if( shortcode_exists( 'video' ) ) { |
|
| 186 | + if ( shortcode_exists( 'video' ) ) { |
|
| 187 | 187 | |
| 188 | 188 | $disable_wrapped_link = true; |
| 189 | 189 | |
@@ -194,8 +194,8 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | $video_settings = apply_filters( 'gravityview_video_settings', array( |
| 196 | 196 | 'src' => $file_path, |
| 197 | - 'class' => 'wp-video-shortcode gv-video gv-field-id-'.$field_settings['id'] |
|
| 198 | - )); |
|
| 197 | + 'class' => 'wp-video-shortcode gv-video gv-field-id-' . $field_settings[ 'id' ] |
|
| 198 | + ) ); |
|
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | 201 | * Generate the video shortcode |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | break; |
| 218 | 218 | |
| 219 | 219 | // if not image, do not set the lightbox (@since 1.5.3) |
| 220 | - case !in_array( $extension, array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ) ): |
|
| 220 | + case ! in_array( $extension, array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ) ): |
|
| 221 | 221 | |
| 222 | 222 | $disable_lightbox = true; |
| 223 | 223 | |
@@ -227,10 +227,10 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | // If using Link to File, override the content. |
| 229 | 229 | // (We do this here so that the $disable_lightbox can be set. Yes, there's a little more processing time, but oh well.) |
| 230 | - if( !empty( $field_settings['link_to_file'] ) ) { |
|
| 230 | + if ( ! empty( $field_settings[ 'link_to_file' ] ) ) { |
|
| 231 | 231 | |
| 232 | 232 | // Force the content to be the file name |
| 233 | - $content = $file_path_info["basename"]; |
|
| 233 | + $content = $file_path_info[ "basename" ]; |
|
| 234 | 234 | |
| 235 | 235 | // Restore the wrapped link |
| 236 | 236 | $disable_wrapped_link = false; |
@@ -238,13 +238,13 @@ discard block |
||
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // Whether to use lightbox or not |
| 241 | - if( $disable_lightbox || empty( $gravityview_view->atts['lightbox'] ) || !empty( $field_settings['show_as_link'] ) ) { |
|
| 241 | + if ( $disable_lightbox || empty( $gravityview_view->atts[ 'lightbox' ] ) || ! empty( $field_settings[ 'show_as_link' ] ) ) { |
|
| 242 | 242 | |
| 243 | - $link_atts = empty( $field_settings['show_as_link'] ) ? array( 'target' => '_blank' ) : array(); |
|
| 243 | + $link_atts = empty( $field_settings[ 'show_as_link' ] ) ? array( 'target' => '_blank' ) : array(); |
|
| 244 | 244 | |
| 245 | 245 | } else { |
| 246 | 246 | |
| 247 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
| 247 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
| 248 | 248 | |
| 249 | 249 | $link_atts = array( |
| 250 | 250 | 'rel' => sprintf( "%s-%s", $gv_class, $entry_slug ), |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $disable_wrapped_link = apply_filters( 'gravityview/fields/fileupload/disable_link', $disable_wrapped_link, $gravityview_view->getCurrentField() ); |
| 271 | 271 | |
| 272 | 272 | // If the HTML output hasn't been overridden by the switch statement above, use the default format |
| 273 | - if( !empty( $content ) && empty( $disable_wrapped_link ) ) { |
|
| 273 | + if ( ! empty( $content ) && empty( $disable_wrapped_link ) ) { |
|
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | 276 | * Modify the link text (defaults to the file name) |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | $content = gravityview_get_link( $link, $content, $link_atts ); |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - $output_arr[] = array( |
|
| 288 | + $output_arr[ ] = array( |
|
| 289 | 289 | 'file_path' => $file_path, |
| 290 | 290 | 'content' => $content |
| 291 | 291 | ); |
@@ -112,7 +112,7 @@ |
||
| 112 | 112 | |
| 113 | 113 | $display_dropbox_link = apply_filters( 'gravityview_display_dropbox_link', true, $file_path ); |
| 114 | 114 | |
| 115 | - if ( !$display_dropbox_link && empty( $field_settings['link_to_file'] ) ){ |
|
| 115 | + if ( !$display_dropbox_link && empty( $field_settings['link_to_file'] ) ) { |
|
| 116 | 116 | $file_path = false !== strpos($file_path, 'www.dropbox') ? str_replace("www.dropbox","dl.dropboxusercontent",$file_path) : $file_path; |
| 117 | 117 | $file_path = false !== strpos($file_path, '?dl=0') ? str_replace("?dl=0","",$file_path) : $file_path; |
| 118 | 118 | } |