@@ -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,10 +102,10 @@ 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 | 111 | $file_path = esc_attr( str_replace( " ", "%20", $file_path ) ); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $file_path_info = pathinfo( $file_path ); |
| 124 | 124 | |
| 125 | 125 | // If the field is set to link to the single entry, link to it. |
| 126 | - $link = !empty( $field_settings['show_as_link'] ) ? GravityView_API::entry_link( $entry, $field ) : $file_path; |
|
| 126 | + $link = ! empty( $field_settings[ 'show_as_link' ] ) ? GravityView_API::entry_link( $entry, $field ) : $file_path; |
|
| 127 | 127 | |
| 128 | 128 | $html_format = NULL; |
| 129 | 129 | |
@@ -132,30 +132,30 @@ discard block |
||
| 132 | 132 | $disable_wrapped_link = false; |
| 133 | 133 | |
| 134 | 134 | // Is this an image? |
| 135 | - $image = new GravityView_Image(array( |
|
| 135 | + $image = new GravityView_Image( array( |
|
| 136 | 136 | 'src' => $file_path, |
| 137 | - 'class' => 'gv-image gv-field-id-'.$field_settings['id'], |
|
| 138 | - 'alt' => $field_settings['label'], |
|
| 137 | + 'class' => 'gv-image gv-field-id-' . $field_settings[ 'id' ], |
|
| 138 | + 'alt' => $field_settings[ 'label' ], |
|
| 139 | 139 | 'width' => ( gravityview_get_context() === 'single' ? NULL : 250 ) |
| 140 | - )); |
|
| 140 | + ) ); |
|
| 141 | 141 | |
| 142 | 142 | $content = $image->html(); |
| 143 | 143 | |
| 144 | 144 | // The new default content is the image, if it exists. If not, use the file name as the content. |
| 145 | - $content = !empty( $content ) ? $content : $file_path_info['basename']; |
|
| 145 | + $content = ! empty( $content ) ? $content : $file_path_info[ 'basename' ]; |
|
| 146 | 146 | |
| 147 | 147 | // If pathinfo() gave us the extension of the file, run the switch statement using that. |
| 148 | - $extension = empty( $file_path_info['extension'] ) ? NULL : strtolower( $file_path_info['extension'] ); |
|
| 148 | + $extension = empty( $file_path_info[ 'extension' ] ) ? NULL : strtolower( $file_path_info[ 'extension' ] ); |
|
| 149 | 149 | |
| 150 | 150 | |
| 151 | - switch( true ) { |
|
| 151 | + switch ( true ) { |
|
| 152 | 152 | |
| 153 | 153 | // Audio file |
| 154 | 154 | case in_array( $extension, wp_get_audio_extensions() ): |
| 155 | 155 | |
| 156 | 156 | $disable_lightbox = true; |
| 157 | 157 | |
| 158 | - if( shortcode_exists( 'audio' ) ) { |
|
| 158 | + if ( shortcode_exists( 'audio' ) ) { |
|
| 159 | 159 | |
| 160 | 160 | $disable_wrapped_link = true; |
| 161 | 161 | |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | $audio_settings = apply_filters( 'gravityview_audio_settings', array( |
| 168 | 168 | 'src' => $file_path, |
| 169 | - 'class' => 'wp-audio-shortcode gv-audio gv-field-id-'.$field_settings['id'] |
|
| 170 | - )); |
|
| 169 | + 'class' => 'wp-audio-shortcode gv-audio gv-field-id-' . $field_settings[ 'id' ] |
|
| 170 | + ) ); |
|
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * Generate the audio shortcode |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | $disable_lightbox = true; |
| 187 | 187 | |
| 188 | - if( shortcode_exists( 'video' ) ) { |
|
| 188 | + if ( shortcode_exists( 'video' ) ) { |
|
| 189 | 189 | |
| 190 | 190 | $disable_wrapped_link = true; |
| 191 | 191 | |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | $video_settings = apply_filters( 'gravityview_video_settings', array( |
| 198 | 198 | 'src' => $file_path, |
| 199 | - 'class' => 'wp-video-shortcode gv-video gv-field-id-'.$field_settings['id'] |
|
| 200 | - )); |
|
| 199 | + 'class' => 'wp-video-shortcode gv-video gv-field-id-' . $field_settings[ 'id' ] |
|
| 200 | + ) ); |
|
| 201 | 201 | |
| 202 | 202 | /** |
| 203 | 203 | * Generate the video shortcode |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | break; |
| 220 | 220 | |
| 221 | 221 | // if not image, do not set the lightbox (@since 1.5.3) |
| 222 | - case !in_array( $extension, array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ) ): |
|
| 222 | + case ! in_array( $extension, array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ) ): |
|
| 223 | 223 | |
| 224 | 224 | $disable_lightbox = true; |
| 225 | 225 | |
@@ -229,10 +229,10 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | // If using Link to File, override the content. |
| 231 | 231 | // (We do this here so that the $disable_lightbox can be set. Yes, there's a little more processing time, but oh well.) |
| 232 | - if( !empty( $field_settings['link_to_file'] ) ) { |
|
| 232 | + if ( ! empty( $field_settings[ 'link_to_file' ] ) ) { |
|
| 233 | 233 | |
| 234 | 234 | // Force the content to be the file name |
| 235 | - $content = $file_path_info["basename"]; |
|
| 235 | + $content = $file_path_info[ "basename" ]; |
|
| 236 | 236 | |
| 237 | 237 | // Restore the wrapped link |
| 238 | 238 | $disable_wrapped_link = false; |
@@ -240,13 +240,13 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | // Whether to use lightbox or not |
| 243 | - if( $disable_lightbox || empty( $gravityview_view->atts['lightbox'] ) || !empty( $field_settings['show_as_link'] ) ) { |
|
| 243 | + if ( $disable_lightbox || empty( $gravityview_view->atts[ 'lightbox' ] ) || ! empty( $field_settings[ 'show_as_link' ] ) ) { |
|
| 244 | 244 | |
| 245 | - $link_atts = empty( $field_settings['show_as_link'] ) ? array( 'target' => '_blank' ) : array(); |
|
| 245 | + $link_atts = empty( $field_settings[ 'show_as_link' ] ) ? array( 'target' => '_blank' ) : array(); |
|
| 246 | 246 | |
| 247 | 247 | } else { |
| 248 | 248 | |
| 249 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
| 249 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
| 250 | 250 | |
| 251 | 251 | $link_atts = array( |
| 252 | 252 | 'rel' => sprintf( "%s-%s", $gv_class, $entry_slug ), |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $disable_wrapped_link = apply_filters( 'gravityview/fields/fileupload/disable_link', $disable_wrapped_link, $gravityview_view->getCurrentField() ); |
| 273 | 273 | |
| 274 | 274 | // If the HTML output hasn't been overridden by the switch statement above, use the default format |
| 275 | - if( !empty( $content ) && empty( $disable_wrapped_link ) ) { |
|
| 275 | + if ( ! empty( $content ) && empty( $disable_wrapped_link ) ) { |
|
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | 278 | * Modify the link text (defaults to the file name) |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | $content = gravityview_get_link( $link, $content, $link_atts ); |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - $output_arr[] = array( |
|
| 290 | + $output_arr[ ] = array( |
|
| 291 | 291 | 'file_path' => $file_path, |
| 292 | 292 | 'content' => $content |
| 293 | 293 | ); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public static function get_instance() { |
| 35 | 35 | |
| 36 | - if( ! self::$instance ) { |
|
| 36 | + if ( ! self::$instance ) { |
|
| 37 | 37 | self::$instance = new self; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) ); |
| 57 | 57 | add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 ); |
| 58 | 58 | add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 ); |
| 59 | - add_action( 'admin_init', array( $this, 'add_caps') ); |
|
| 59 | + add_action( 'admin_init', array( $this, 'add_caps' ) ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
@@ -77,18 +77,18 @@ discard block |
||
| 77 | 77 | public function filter_user_has_cap( $usercaps = array(), $caps = array(), $args = array(), $user = NULL ) { |
| 78 | 78 | |
| 79 | 79 | // Empty caps_to_check array |
| 80 | - if( ! $usercaps || ! $caps ) { |
|
| 80 | + if ( ! $usercaps || ! $caps ) { |
|
| 81 | 81 | return $usercaps; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Enable all GravityView caps_to_check if `gravityview_full_access` is enabled |
| 86 | 86 | */ |
| 87 | - if( ! empty( $usercaps['gravityview_full_access'] ) ) { |
|
| 87 | + if ( ! empty( $usercaps[ 'gravityview_full_access' ] ) ) { |
|
| 88 | 88 | |
| 89 | 89 | $all_gravityview_caps = self::all_caps(); |
| 90 | 90 | |
| 91 | - foreach( $all_gravityview_caps as $gv_cap ) { |
|
| 91 | + foreach ( $all_gravityview_caps as $gv_cap ) { |
|
| 92 | 92 | $usercaps[ $gv_cap ] = true; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | $all = $administrator; |
| 307 | 307 | |
| 308 | 308 | // If role is set, return caps_to_check for just that role. |
| 309 | - if( $single_role ) { |
|
| 309 | + if ( $single_role ) { |
|
| 310 | 310 | $caps = isset( ${$single_role} ) ? ${$single_role} : false; |
| 311 | 311 | return $flat_array ? $caps : array( $single_role => $caps ); |
| 312 | 312 | } |
@@ -355,9 +355,9 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | if ( true === $allow_logged_out ) { |
| 357 | 357 | |
| 358 | - $all_caps = self::all_caps('editor'); |
|
| 358 | + $all_caps = self::all_caps( 'editor' ); |
|
| 359 | 359 | |
| 360 | - if( array_intersect( $all_caps, (array) $caps_to_check ) ) { |
|
| 360 | + if ( array_intersect( $all_caps, (array)$caps_to_check ) ) { |
|
| 361 | 361 | return true; |
| 362 | 362 | } |
| 363 | 363 | } |
@@ -378,13 +378,13 @@ discard block |
||
| 378 | 378 | $caps_to_check = self::maybe_add_full_access_caps( $caps_to_check ); |
| 379 | 379 | |
| 380 | 380 | foreach ( $caps_to_check as $cap ) { |
| 381 | - if( ! is_null( $object_id ) ) { |
|
| 381 | + if ( ! is_null( $object_id ) ) { |
|
| 382 | 382 | $has_cap = $user_id ? user_can( $user_id, $cap, $object_id ) : current_user_can( $cap, $object_id ); |
| 383 | 383 | } else { |
| 384 | 384 | $has_cap = $user_id ? user_can( $user_id, $cap ) : current_user_can( $cap ); |
| 385 | 385 | } |
| 386 | 386 | // At the first successful response, stop checking |
| 387 | - if( $has_cap ) { |
|
| 387 | + if ( $has_cap ) { |
|
| 388 | 388 | break; |
| 389 | 389 | } |
| 390 | 390 | } |
@@ -408,15 +408,15 @@ discard block |
||
| 408 | 408 | $all_gravityview_caps = self::all_caps(); |
| 409 | 409 | |
| 410 | 410 | // Are there any $caps_to_check that are from GravityView? |
| 411 | - if( $has_gravityview_caps = array_intersect( $caps_to_check, $all_gravityview_caps ) ) { |
|
| 412 | - $caps_to_check[] = 'gravityview_full_access'; |
|
| 411 | + if ( $has_gravityview_caps = array_intersect( $caps_to_check, $all_gravityview_caps ) ) { |
|
| 412 | + $caps_to_check[ ] = 'gravityview_full_access'; |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | $all_gravity_forms_caps = class_exists( 'GFCommon' ) ? GFCommon::all_caps() : array(); |
| 416 | 416 | |
| 417 | 417 | // Are there any $caps_to_check that are from Gravity Forms? |
| 418 | - if( $all_gravity_forms_caps = array_intersect( $caps_to_check, $all_gravity_forms_caps ) ) { |
|
| 419 | - $caps_to_check[] = 'gform_full_access'; |
|
| 418 | + if ( $all_gravity_forms_caps = array_intersect( $caps_to_check, $all_gravity_forms_caps ) ) { |
|
| 419 | + $caps_to_check[ ] = 'gform_full_access'; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | return array_unique( $caps_to_check ); |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $capabilities = self::all_caps(); |
| 439 | 439 | |
| 440 | 440 | // Loop through each role and remove GV caps_to_check |
| 441 | - foreach( $wp_roles->get_names() as $role_slug => $role_name ) { |
|
| 441 | + foreach ( $wp_roles->get_names() as $role_slug => $role_name ) { |
|
| 442 | 442 | foreach ( $capabilities as $cap ) { |
| 443 | 443 | $wp_roles->remove_cap( $role_slug, $cap ); |
| 444 | 444 | } |