Completed
Pull Request — develop (#1425)
by Gennady
07:04
created
includes/class-admin-installer.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function add_downloads_data_filters() {
68 68
 
69
-	    $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT );
69
+		$downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT );
70 70
 
71
-	    if ( ! $downloads_data ) {
71
+		if ( ! $downloads_data ) {
72 72
 			return;
73 73
 		}
74 74
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function add_admin_menu() {
99 99
 
100
-	    $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' );
100
+		$menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' );
101 101
 
102 102
 		$menu_text = sprintf( '<span title="%s" style="margin: 0">%s</span>', esc_attr__( 'Plugins that extend GravityView and Gravity Forms functionality.', 'gravityview' ), $menu_text );
103 103
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	}
113 113
 
114 114
 	/**
115
-     * When on the Installer page, show a different notice than on the Settings page
116
-     *
115
+	 * When on the Installer page, show a different notice than on the Settings page
116
+	 *
117 117
 	 * @param array $notice
118 118
 	 *
119 119
 	 * @return string License notice
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 	public function maybe_modify_license_notice( $notice = '' ) {
122 122
 
123 123
 		if ( ! gravityview()->request->is_admin( '', 'downloads' ) ) {
124
-            return $notice;
125
-        }
124
+			return $notice;
125
+		}
126 126
 
127
-        return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' );
127
+		return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' );
128 128
 	}
129 129
 
130 130
 	/**
@@ -162,43 +162,43 @@  discard block
 block discarded – undo
162 162
 	 * Get downloads data from transient or from API; save transient after getting data from API
163 163
 	 *
164 164
 	 * @return WP_Error|array If error, returns WP_Error. If not valid JSON, empty array. Otherwise, this structure: {
165
-     *   @type array  $info {
166
-     *       @type string $id int 17
167
-     *       @type string $slug Extension slug
168
-     *       @type string $title Extension title
169
-     *       @type string $create_date in '2018-07-19 20:03:10' format
170
-     *       @type string $modified_date
171
-     *       @type string $status
172
-     *       @type string $link URL to public plugin page
173
-     *       @type string $content
174
-     *       @type string $excerpt
175
-     *       @type string $thumbnail URL to thumbnail
176
-     *       @type array  $category Taxonomy details for the plugin's category {
177
-     *         @type int $term_id => int 30
178
-     *         @type string $name => string 'Plugins' (length=7)
179
-     *         @type string $slug => string 'plugins' (length=7)
180
-     *         @type int $term_group => int 0
181
-     *         @type int $term_taxonomy_id => int 30
182
-     *         @type string $taxonomy => string 'download_category' (length=17)
183
-     *         @type string $description => string '' (length=0)
184
-     *         @type int $parent => int 0
185
-     *         @type int $count => int 4
186
-     *         @type string $filter => string 'raw' (length=3)
187
-     *       }
188
-     *       @type array $tags {see $category above}
189
-     *       @type string $textdomain string 'gravityview' (length=11)
190
-     *   }
191
-     *   @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist
192
-     *   @type array $licensing {
193
-     *       @type bool   $enabled Is licensing enabled for the extension
194
-     *       @type string $version Version number
195
-     *       @type string $exp_unit Expiration unit ('years')
196
-     *       @type string $exp_length Expiration length ('1')
197
-     *   }
198
-     *   @type array $files Array of files. Empty if user has no access to the file. {
199
-     *       @type string $file string URL of the file download
200
-     *   }
201
-     * }
165
+	 *   @type array  $info {
166
+	 *       @type string $id int 17
167
+	 *       @type string $slug Extension slug
168
+	 *       @type string $title Extension title
169
+	 *       @type string $create_date in '2018-07-19 20:03:10' format
170
+	 *       @type string $modified_date
171
+	 *       @type string $status
172
+	 *       @type string $link URL to public plugin page
173
+	 *       @type string $content
174
+	 *       @type string $excerpt
175
+	 *       @type string $thumbnail URL to thumbnail
176
+	 *       @type array  $category Taxonomy details for the plugin's category {
177
+	 *         @type int $term_id => int 30
178
+	 *         @type string $name => string 'Plugins' (length=7)
179
+	 *         @type string $slug => string 'plugins' (length=7)
180
+	 *         @type int $term_group => int 0
181
+	 *         @type int $term_taxonomy_id => int 30
182
+	 *         @type string $taxonomy => string 'download_category' (length=17)
183
+	 *         @type string $description => string '' (length=0)
184
+	 *         @type int $parent => int 0
185
+	 *         @type int $count => int 4
186
+	 *         @type string $filter => string 'raw' (length=3)
187
+	 *       }
188
+	 *       @type array $tags {see $category above}
189
+	 *       @type string $textdomain string 'gravityview' (length=11)
190
+	 *   }
191
+	 *   @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist
192
+	 *   @type array $licensing {
193
+	 *       @type bool   $enabled Is licensing enabled for the extension
194
+	 *       @type string $version Version number
195
+	 *       @type string $exp_unit Expiration unit ('years')
196
+	 *       @type string $exp_length Expiration length ('1')
197
+	 *   }
198
+	 *   @type array $files Array of files. Empty if user has no access to the file. {
199
+	 *       @type string $file string URL of the file download
200
+	 *   }
201
+	 * }
202 202
 	 */
203 203
 	public function get_downloads_data() {
204 204
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		) );
231 231
 
232 232
 		if ( is_wp_error( $response ) ) {
233
-		    gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) );
233
+			gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) );
234 234
 			return $response;
235 235
 		}
236 236
 
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
                 <div class="gv-admin-installer-notice notice inline error">
284 284
                     <h3><?php esc_html_e( 'Extensions and plugins data cannot be loaded at the moment. Please try again later.', 'gravityview' ); ?></h3>
285 285
                     <?php
286
-                    if ( is_wp_error( $downloads_data ) ) {
287
-	                    echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' );
288
-                    }
289
-                    ?>
286
+					if ( is_wp_error( $downloads_data ) ) {
287
+						echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' );
288
+					}
289
+					?>
290 290
                 </div>
291 291
             </div>
292 292
 			<?php
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
 	protected function render_download( $download, $wp_plugins ) {
343 343
 
344 344
 
345
-        $details = $this->get_download_display_details( $download, $wp_plugins );
345
+		$details = $this->get_download_display_details( $download, $wp_plugins );
346 346
 
347
-        $download_info = $details['download_info'];
347
+		$download_info = $details['download_info'];
348 348
 
349 349
 		?>
350 350
         <div class="item <?php echo esc_attr( $details['item_class'] ); ?>">
@@ -366,43 +366,43 @@  discard block
 block discarded – undo
366 366
 
367 367
                 <div class="addon-excerpt"><?php
368 368
 
369
-                    $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] );
369
+					$excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] );
370 370
 
371
-                    // Allow some pure HTML tags, but remove everything else from the excerpt.
372
-                    $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' );
373
-                    $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' );
371
+					// Allow some pure HTML tags, but remove everything else from the excerpt.
372
+					$tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' );
373
+					$replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' );
374 374
 
375
-                    $excerpt = str_replace( $tags, $replacements, $excerpt );
376
-                    $excerpt = esc_html( strip_tags( $excerpt ) );
375
+					$excerpt = str_replace( $tags, $replacements, $excerpt );
376
+					$excerpt = esc_html( strip_tags( $excerpt ) );
377 377
 					$excerpt = str_replace( $replacements, $tags, $excerpt );
378 378
 
379 379
 					echo wpautop( $excerpt );
380
-                ?></div>
380
+				?></div>
381 381
             </div>
382 382
         </div>
383 383
 		<?php
384 384
 	}
385 385
 
386 386
 	/**
387
-     * Generates details array for the download to keep the render_download() method a bit tidier
388
-     *
387
+	 * Generates details array for the download to keep the render_download() method a bit tidier
388
+	 *
389 389
 	 * @param array $download Single download, as returned by {@see get_downloads_data}
390 390
 	 * @param array $wp_plugins All active plugins, as returned by {@see get_plugins()}
391 391
 	 *
392 392
 	 * @return array {
393
-     *   @type array $download_info
394
-     *   @type string $plugin_path
395
-     *   @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc)
396
-     *   @type string $status_label
397
-     *   @type string $button_title Title attribute to show when hovering over the download's button
398
-     *   @type string $button_class CSS class to use for the button
399
-     *   @type string $button_label Text to use for the download's anchor link
400
-     *   @type string $href URL for the download's button
401
-     *   @type bool   $spinner Whether to show the spinner icon
402
-     *   @type string $item_class CSS class for the download container
403
-     *   @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions")
404
-     *   @type bool   $is_active Is the current GravityView license (as entered in Settings) active?
405
-     * }
393
+	 *   @type array $download_info
394
+	 *   @type string $plugin_path
395
+	 *   @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc)
396
+	 *   @type string $status_label
397
+	 *   @type string $button_title Title attribute to show when hovering over the download's button
398
+	 *   @type string $button_class CSS class to use for the button
399
+	 *   @type string $button_label Text to use for the download's anchor link
400
+	 *   @type string $href URL for the download's button
401
+	 *   @type bool   $spinner Whether to show the spinner icon
402
+	 *   @type string $item_class CSS class for the download container
403
+	 *   @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions")
404
+	 *   @type bool   $is_active Is the current GravityView license (as entered in Settings) active?
405
+	 * }
406 406
 	 */
407 407
 	private function get_download_display_details( $download, $wp_plugins ) {
408 408
 
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 			'slug' => '',
414 414
 			'excerpt' => '',
415 415
 			'link' => '',
416
-            'coming_soon' => false,
416
+			'coming_soon' => false,
417 417
 			'installer_title' => null, // May not be defined
418 418
 			'installer_excerpt' => null, // May not be defined
419 419
 		) );
@@ -456,14 +456,14 @@  discard block
 block discarded – undo
456 456
 			$href         = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license;
457 457
 		}
458 458
 
459
-        elseif ( ! empty( $download_info['coming_soon'] ) ) {
460
-	        $spinner      = false;
461
-	        $status       = 'notinstalled';
462
-	        $status_label = __( 'Coming Soon', 'gravityview' );
463
-	        $button_label = __( 'Learn More', 'gravityview' );
464
-	        $button_class = 'button-primary button-large';
465
-	        $href         = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' );
466
-        }
459
+		elseif ( ! empty( $download_info['coming_soon'] ) ) {
460
+			$spinner      = false;
461
+			$status       = 'notinstalled';
462
+			$status_label = __( 'Coming Soon', 'gravityview' );
463
+			$button_label = __( 'Learn More', 'gravityview' );
464
+			$button_class = 'button-primary button-large';
465
+			$href         = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' );
466
+		}
467 467
 
468 468
 		// Access but the plugin is not installed
469 469
 		elseif ( ! $wp_plugin ) {
@@ -503,18 +503,18 @@  discard block
 block discarded – undo
503 503
 		}
504 504
 
505 505
 		return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' );
506
-    }
506
+	}
507 507
 
508 508
 	/**
509
-     * Returns the base price for an extension
510
-     *
509
+	 * Returns the base price for an extension
510
+	 *
511 511
 	 * @param array $download
512 512
 	 *
513 513
 	 * @return float Base price for an extension. If not for sale separately, returns 0
514 514
 	 */
515 515
 	private function get_download_base_price( $download ) {
516 516
 
517
-	    $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 );
517
+		$base_price = \GV\Utils::get( $download, 'pricing/amount', 0 );
518 518
 		$base_price = \GFCommon::to_number( $base_price );
519 519
 
520 520
 		unset( $download['pricing']['amount'] );
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 		}
526 526
 
527 527
 		return floatval( $base_price );
528
-    }
528
+	}
529 529
 
530 530
 	/**
531 531
 	 * Handle AJAX request to activate extension
@@ -543,8 +543,8 @@  discard block
 block discarded – undo
543 543
 
544 544
 		if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) {
545 545
 			wp_send_json_error( array(
546
-                'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() )
547
-            ) );
546
+				'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() )
547
+			) );
548 548
 		}
549 549
 
550 550
 		wp_send_json_success();
@@ -565,10 +565,10 @@  discard block
 block discarded – undo
565 565
 		deactivate_plugins( $data['path'] );
566 566
 
567 567
 		if( is_plugin_active( $data['path'] ) ) {
568
-            wp_send_json_error( array(
569
-                'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) )
570
-            ) );
571
-        }
568
+			wp_send_json_error( array(
569
+				'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) )
570
+			) );
571
+		}
572 572
 
573 573
 		wp_send_json_success();
574 574
 	}
Please login to merge, or discard this patch.
includes/extensions/duplicate-entry/class-duplicate-entry.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	public static function get_duplicate_link( $entry, $view_id, $post_id = null ) {
248 248
 
249
-        $base = GravityView_API::directory_link( $post_id ? : $view_id, true );
249
+		$base = GravityView_API::directory_link( $post_id ? : $view_id, true );
250 250
 
251 251
 		if ( empty( $base ) ) {
252 252
 			gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) );
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 			'action'	=> 'duplicate',
258 258
 			'entry_id'	=> $entry['id'],
259 259
 			'gvid' => $view_id,
260
-            'view_id' => $view_id,
260
+			'view_id' => $view_id,
261 261
 		), $base );
262 262
 
263 263
 		return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry['id'] ) ), $actionurl );
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 		 * @since 2.5
461 461
 		 * @param  array $duplicated_entry The duplicated entry
462 462
 		 * @param  array $entry The original entry
463
-		*/
463
+		 */
464 464
 		do_action( 'gravityview/duplicate-entry/duplicated', $duplicated_entry, $entry );
465 465
 
466 466
 		gravityview()->log->debug( 'Duplicate response: {duplicate_response}', array( 'duplicate_response' => $duplicate_response ) );
Please login to merge, or discard this patch.
includes/admin/metaboxes/views/view-configuration.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 
32 32
 			<?php
33 33
 
34
-                do_action('gravityview_render_widgets_active_areas', $curr_template, 'footer', $post->ID );
34
+				do_action('gravityview_render_widgets_active_areas', $curr_template, 'footer', $post->ID );
35 35
 
36
-    			do_action('gravityview_render_field_pickers', 'directory' );
36
+				do_action('gravityview_render_field_pickers', 'directory' );
37 37
 
38
-            ?>
38
+			?>
39 39
 
40 40
 			<?php // list of available widgets to be shown in the popup ?>
41 41
             <div id="directory-available-widgets" class="hide-if-js gv-tooltip">
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 
61 61
 			<div id="single-active-fields" class="gv-grid">
62 62
 				<?php
63
-                if(!empty( $curr_template ) ) {
64
-				    do_action('gravityview_render_directory_active_areas', $curr_template, 'single', $post->ID, true );
65
-                }
66
-			    ?>
63
+				if(!empty( $curr_template ) ) {
64
+					do_action('gravityview_render_directory_active_areas', $curr_template, 'single', $post->ID, true );
65
+				}
66
+				?>
67 67
 			</div>
68 68
             <?php
69
-                do_action('gravityview_render_field_pickers', 'single' );
69
+				do_action('gravityview_render_field_pickers', 'single' );
70 70
 			?>
71 71
 		</div>
72 72
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 			</div>
86 86
 
87 87
 			<?php
88
-			    do_action('gravityview_render_field_pickers', 'edit' );
88
+				do_action('gravityview_render_field_pickers', 'edit' );
89 89
 			?>
90 90
 
91 91
 		</div>
Please login to merge, or discard this patch.
includes/class-admin-views.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -63,28 +63,28 @@  discard block
 block discarded – undo
63 63
 	}
64 64
 
65 65
 	/**
66
-     * When on the Add/Edit View screen, suggest most popular articles related to that
67
-     *
66
+	 * When on the Add/Edit View screen, suggest most popular articles related to that
67
+	 *
68 68
 	 * @param array $localization_data Data to be passed to the Support Port JS
69 69
 	 *
70 70
 	 * @return array
71 71
 	 */
72 72
 	function suggest_support_articles( $localization_data = array() ) {
73 73
 
74
-	    if( ! gravityview()->request->is_view() ) {
75
-	        return $localization_data;
76
-        }
74
+		if( ! gravityview()->request->is_view() ) {
75
+			return $localization_data;
76
+		}
77 77
 
78 78
 		$localization_data['suggest'] = array(
79
-            '57ef23539033602e61d4a560',
80
-            '54c67bb9e4b0512429885513',
81
-            '54c67bb9e4b0512429885512',
82
-            '54c67bbbe4b07997ea3f3f6b',
83
-            '54d1a33ae4b086c0c0964ce9',
84
-            '57ef253c9033602e61d4a563',
85
-            '552355bfe4b0221aadf2572b',
86
-            '54c67bcde4b051242988553e',
87
-        );
79
+			'57ef23539033602e61d4a560',
80
+			'54c67bb9e4b0512429885513',
81
+			'54c67bb9e4b0512429885512',
82
+			'54c67bbbe4b07997ea3f3f6b',
83
+			'54d1a33ae4b086c0c0964ce9',
84
+			'57ef253c9033602e61d4a563',
85
+			'552355bfe4b0221aadf2572b',
86
+			'54c67bcde4b051242988553e',
87
+		);
88 88
 
89 89
 		return $localization_data;
90 90
 	}
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
 
176 176
 		if( 'form_list' === GFForms::get_page() ) {
177 177
 			$priority = 790;
178
-        }
178
+		}
179 179
 
180 180
 		if( empty( $connected_views ) ) {
181 181
 
182
-		    $menu_items['gravityview'] = array(
182
+			$menu_items['gravityview'] = array(
183 183
 				'label'          => esc_attr__( 'Create a View', 'gravityview' ),
184 184
 				'icon'           => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>',
185 185
 				'title'          => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ),
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
 		// If there were no items added, then let's create the parent menu
211 211
 		if( $sub_menu_items ) {
212 212
 
213
-		    $sub_menu_items[] = array(
214
-			    'label' => esc_attr__( 'Create a View', 'gravityview' ),
215
-                'link_class' => 'gv-create-view',
216
-			    'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ),
217
-			    'url'   => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ),
218
-			    'capabilities'   => array( 'edit_gravityviews' ),
219
-            );
213
+			$sub_menu_items[] = array(
214
+				'label' => esc_attr__( 'Create a View', 'gravityview' ),
215
+				'link_class' => 'gv-create-view',
216
+				'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ),
217
+				'url'   => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ),
218
+				'capabilities'   => array( 'edit_gravityviews' ),
219
+			);
220 220
 
221 221
 			// Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown
222 222
 			$sub_menu_items[] = array(
@@ -599,17 +599,17 @@  discard block
 block discarded – undo
599 599
 	 * Render html for displaying available fields based on a Form ID
600 600
 	 * $blacklist_field_types - contains the field types which are not proper to be shown in a directory.
601 601
 	 *
602
-     * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action
602
+	 * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action
603 603
 	 * @access public
604
-     *
604
+	 *
605 605
 	 * @param int $form Gravity Forms Form ID (default: '')
606 606
 	 * @param string $context (default: 'single')
607
-     *
607
+	 *
608 608
 	 * @return void
609 609
 	 */
610 610
 	function render_available_fields( $form = 0, $context = 'single' ) {
611 611
 
612
-	    // Determine if form is a preset and convert it to an array with fields
612
+		// Determine if form is a preset and convert it to an array with fields
613 613
 		$form = ( is_string( $form ) && preg_match( '/^preset_/', $form ) ) ? GravityView_Ajax::pre_get_form_fields( $form ) : $form;
614 614
 
615 615
 		/**
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 
622 622
 		if ( ! is_array( $blacklist_field_types ) ) {
623 623
 
624
-		    gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) );
624
+			gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) );
625 625
 
626 626
 			$blacklist_field_types = array();
627 627
 		}
@@ -753,12 +753,12 @@  discard block
 block discarded – undo
753 753
 				/**
754 754
 				 * @since 1.7.2
755 755
 				 */
756
-			    'other_entries' => array(
757
-				    'label'	=> __('Other Entries', 'gravityview'),
758
-				    'type'	=> 'other_entries',
759
-				    'desc'	=> __('Display other entries created by the entry creator.', 'gravityview'),
760
-			    ),
761
-	        );
756
+				'other_entries' => array(
757
+					'label'	=> __('Other Entries', 'gravityview'),
758
+					'type'	=> 'other_entries',
759
+					'desc'	=> __('Display other entries created by the entry creator.', 'gravityview'),
760
+				),
761
+			);
762 762
 
763 763
 			if( 'single' !== $zone) {
764 764
 
@@ -906,9 +906,9 @@  discard block
 block discarded – undo
906 906
 
907 907
 				$joined_forms = gravityview_get_joined_forms( $post->ID );
908 908
 
909
-                foreach ( $joined_forms as $form ) {
910
-                    $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone );
911
-                }
909
+				foreach ( $joined_forms as $form ) {
910
+					$available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone );
911
+				}
912 912
 			} else {
913 913
 				$available_items[ $form ] = \GV\Widget::registered();
914 914
 			}
@@ -936,9 +936,9 @@  discard block
 block discarded – undo
936 936
 
937 937
 										if ( $form_id ) {
938 938
 											$original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ;
939
-                                        } else {
939
+										} else {
940 940
 											$original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ;
941
-                                        }
941
+										}
942 942
 
943 943
 										if ( !$original_item ) {
944 944
 											gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) );
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
 
991 991
 	/**
992 992
 	 * Render the widget active areas
993
-     * @param  string $template_id The current slug of the selected View template
993
+	 * @param  string $template_id The current slug of the selected View template
994 994
 	 * @param  string $zone    Either 'header' or 'footer'
995 995
 	 * @param  string $post_id Current Post ID (view)
996 996
 	 * @return string          html
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
 		$is_widgets_page = ( $pagenow === 'widgets.php' );
1175 1175
 
1176 1176
 		// Add the GV font (with the Astronaut)
1177
-        wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version );
1177
+		wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version );
1178 1178
 		wp_register_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), \GV\Plugin::$version );
1179 1179
 
1180 1180
 		wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), \GV\Plugin::$version, true );
@@ -1182,66 +1182,66 @@  discard block
 block discarded – undo
1182 1182
 		if( GFForms::get_page() === 'form_list' ) {
1183 1183
 			wp_enqueue_style( 'gravityview_views_styles' );
1184 1184
 			return;
1185
-        }
1185
+		}
1186 1186
 
1187 1187
 		// Don't process any scripts below here if it's not a GravityView page.
1188 1188
 		if( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) {
1189
-		    return;
1189
+			return;
1190 1190
 		}
1191 1191
 
1192
-        wp_enqueue_script( 'jquery-ui-datepicker' );
1193
-        wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version );
1194
-
1195
-        $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
1196
-
1197
-        //enqueue scripts
1198
-        wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version );
1199
-
1200
-        wp_localize_script('gravityview_views_scripts', 'gvGlobals', array(
1201
-            'cookiepath' => COOKIEPATH,
1202
-            'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ),
1203
-            'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ),
1204
-            'label_viewname' => __( 'Enter View name here', 'gravityview' ),
1205
-            'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ),
1206
-            'label_add_search_field' => __( 'Add Search Field', 'gravityview' ),
1207
-            'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ),
1208
-            'label_close' => __( 'Close', 'gravityview' ),
1209
-            'label_cancel' => __( 'Cancel', 'gravityview' ),
1210
-            'label_continue' => __( 'Continue', 'gravityview' ),
1211
-            'label_ok' => __( 'Ok', 'gravityview' ),
1212
-            'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ),
1213
-            'loading_text' => esc_html__( 'Loading&hellip;', 'gravityview' ),
1214
-            'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ),
1215
-            'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ),
1216
-            'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ),
1217
-        ));
1192
+		wp_enqueue_script( 'jquery-ui-datepicker' );
1193
+		wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version );
1194
+
1195
+		$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
1196
+
1197
+		//enqueue scripts
1198
+		wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version );
1199
+
1200
+		wp_localize_script('gravityview_views_scripts', 'gvGlobals', array(
1201
+			'cookiepath' => COOKIEPATH,
1202
+			'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ),
1203
+			'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ),
1204
+			'label_viewname' => __( 'Enter View name here', 'gravityview' ),
1205
+			'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ),
1206
+			'label_add_search_field' => __( 'Add Search Field', 'gravityview' ),
1207
+			'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ),
1208
+			'label_close' => __( 'Close', 'gravityview' ),
1209
+			'label_cancel' => __( 'Cancel', 'gravityview' ),
1210
+			'label_continue' => __( 'Continue', 'gravityview' ),
1211
+			'label_ok' => __( 'Ok', 'gravityview' ),
1212
+			'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ),
1213
+			'loading_text' => esc_html__( 'Loading&hellip;', 'gravityview' ),
1214
+			'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ),
1215
+			'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ),
1216
+			'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ),
1217
+		));
1218 1218
 
1219 1219
 		wp_enqueue_style( 'gravityview_views_styles' );
1220 1220
 
1221
-        // Enqueue scripts needed for merge tags
1222
-        self::enqueue_gravity_forms_scripts();
1221
+		// Enqueue scripts needed for merge tags
1222
+		self::enqueue_gravity_forms_scripts();
1223 1223
 	}
1224 1224
 
1225 1225
 	/**
1226 1226
 	 * Enqueue Gravity Forms scripts, needed for Merge Tags
1227
-     *
1228
-     * @since 1.0.5-beta
1229
-     *
1230
-     * @return void
1227
+	 *
1228
+	 * @since 1.0.5-beta
1229
+	 *
1230
+	 * @return void
1231 1231
 	 */
1232 1232
 	static function enqueue_gravity_forms_scripts() {
1233 1233
 		GFForms::register_scripts();
1234 1234
 
1235 1235
 		$scripts = array(
1236
-		    'sack',
1237
-		    'gform_gravityforms',
1238
-		    'gform_forms',
1239
-		    'gform_form_admin',
1240
-		    'jquery-ui-autocomplete'
1236
+			'sack',
1237
+			'gform_gravityforms',
1238
+			'gform_forms',
1239
+			'gform_form_admin',
1240
+			'jquery-ui-autocomplete'
1241 1241
 		);
1242 1242
 
1243 1243
 		if ( wp_is_mobile() ) {
1244
-		    $scripts[] = 'jquery-touch-punch';
1244
+			$scripts[] = 'jquery-touch-punch';
1245 1245
 		}
1246 1246
 
1247 1247
 		wp_enqueue_script( $scripts );
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry.php 1 patch
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -18,83 +18,83 @@  discard block
 block discarded – undo
18 18
 
19 19
 class GravityView_Edit_Entry {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
21
+	/**
22
+	 * @var string
23
+	 */
24 24
 	static $file;
25 25
 
26 26
 	static $instance;
27 27
 
28
-    /**
29
-     * Component instances.
30
-     * @var array
31
-     */
32
-    public $instances = array();
28
+	/**
29
+	 * Component instances.
30
+	 * @var array
31
+	 */
32
+	public $instances = array();
33 33
 
34 34
 
35 35
 	function __construct() {
36 36
 
37
-        self::$file = plugin_dir_path( __FILE__ );
37
+		self::$file = plugin_dir_path( __FILE__ );
38 38
 
39
-        if( is_admin() ) {
40
-            $this->load_components( 'admin' );
41
-        }
39
+		if( is_admin() ) {
40
+			$this->load_components( 'admin' );
41
+		}
42 42
 
43 43
 		$this->load_components( 'locking' );
44 44
 
45
-        $this->load_components( 'render' );
45
+		$this->load_components( 'render' );
46 46
 
47
-        // If GF User Registration Add-on exists
48
-        $this->load_components( 'user-registration' );
47
+		// If GF User Registration Add-on exists
48
+		$this->load_components( 'user-registration' );
49 49
 
50
-        $this->add_hooks();
50
+		$this->add_hooks();
51 51
 
52 52
 		// Process hooks for addons that may or may not be present
53 53
 		$this->addon_specific_hooks();
54 54
 	}
55 55
 
56 56
 
57
-    static function getInstance() {
57
+	static function getInstance() {
58 58
 
59
-        if( empty( self::$instance ) ) {
60
-            self::$instance = new GravityView_Edit_Entry;
61
-        }
59
+		if( empty( self::$instance ) ) {
60
+			self::$instance = new GravityView_Edit_Entry;
61
+		}
62 62
 
63
-        return self::$instance;
64
-    }
63
+		return self::$instance;
64
+	}
65 65
 
66 66
 
67
-    private function load_components( $component ) {
67
+	private function load_components( $component ) {
68 68
 
69
-        $dir = trailingslashit( self::$file );
69
+		$dir = trailingslashit( self::$file );
70 70
 
71
-        $filename  = $dir . 'class-edit-entry-' . $component . '.php';
72
-        $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
71
+		$filename  = $dir . 'class-edit-entry-' . $component . '.php';
72
+		$classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
73 73
 
74
-        // Loads component and pass extension's instance so that component can
75
-        // talk each other.
76
-        require_once $filename;
77
-        $this->instances[ $component ] = new $classname( $this );
78
-        $this->instances[ $component ]->load();
74
+		// Loads component and pass extension's instance so that component can
75
+		// talk each other.
76
+		require_once $filename;
77
+		$this->instances[ $component ] = new $classname( $this );
78
+		$this->instances[ $component ]->load();
79 79
 
80
-    }
80
+	}
81 81
 
82
-    private function add_hooks() {
82
+	private function add_hooks() {
83 83
 
84
-        // Add front-end access to Gravity Forms delete file action
85
-        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') );
84
+		// Add front-end access to Gravity Forms delete file action
85
+		add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') );
86 86
 
87
-        // Make sure this hook is run for non-admins
88
-        add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') );
87
+		// Make sure this hook is run for non-admins
88
+		add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') );
89 89
 
90
-        add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
90
+		add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
91 91
 
92
-        // add template path to check for field
93
-        add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
92
+		// add template path to check for field
93
+		add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
94 94
 
95 95
 		add_filter( 'gravityview/field/is_visible', array( $this, 'maybe_not_visible' ), 10, 3 );
96 96
 
97
-    }
97
+	}
98 98
 
99 99
 	/**
100 100
 	 * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin
@@ -152,74 +152,74 @@  discard block
 block discarded – undo
152 152
 		return false;
153 153
 	}
154 154
 
155
-    /**
156
-     * Include this extension templates path
157
-     * @param array $file_paths List of template paths ordered
158
-     */
159
-    public function add_template_path( $file_paths ) {
160
-
161
-        // Index 100 is the default GravityView template path.
162
-        $file_paths[ 110 ] = self::$file;
163
-
164
-        return $file_paths;
165
-    }
166
-
167
-    /**
168
-     *
169
-     * Return a well formatted nonce key according to GravityView Edit Entry protocol
170
-     *
171
-     * @param $view_id int GravityView view id
172
-     * @param $form_id int Gravity Forms form id
173
-     * @param $entry_id int Gravity Forms entry id
174
-     * @return string
175
-     */
176
-    public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
177
-        return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
178
-    }
179
-
180
-
181
-    /**
182
-     * The edit entry link creates a secure link with a nonce
183
-     *
184
-     * It also mimics the URL structure Gravity Forms expects to have so that
185
-     * it formats the display of the edit form like it does in the backend, like
186
-     * "You can edit this post from the post page" fields, for example.
187
-     *
188
-     * @param $entry array Gravity Forms entry object
189
-     * @param $view_id int GravityView view id
190
-     * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
191
-     * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
192
-     * @return string
193
-     */
194
-    public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
195
-
196
-        $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
197
-
198
-        $base = gv_entry_link( $entry, $post_id ? : $view_id  );
199
-
200
-        $url = add_query_arg( array(
201
-            'edit' => wp_create_nonce( $nonce_key )
202
-        ), $base );
203
-
204
-        if( $post_id ) {
205
-	        $url = add_query_arg( array( 'gvid' => $view_id ), $url );
206
-        }
207
-
208
-	    /**
209
-	     * Allow passing params to dynamically populate entry with values
210
-	     * @since 1.9.2
211
-	     */
212
-	    if( !empty( $field_values ) ) {
213
-
214
-		    if( is_array( $field_values ) ) {
215
-			    // If already an array, no parse_str() needed
216
-			    $params = $field_values;
217
-		    } else {
218
-			    parse_str( $field_values, $params );
219
-		    }
220
-
221
-		    $url = add_query_arg( $params, $url );
222
-	    }
155
+	/**
156
+	 * Include this extension templates path
157
+	 * @param array $file_paths List of template paths ordered
158
+	 */
159
+	public function add_template_path( $file_paths ) {
160
+
161
+		// Index 100 is the default GravityView template path.
162
+		$file_paths[ 110 ] = self::$file;
163
+
164
+		return $file_paths;
165
+	}
166
+
167
+	/**
168
+	 *
169
+	 * Return a well formatted nonce key according to GravityView Edit Entry protocol
170
+	 *
171
+	 * @param $view_id int GravityView view id
172
+	 * @param $form_id int Gravity Forms form id
173
+	 * @param $entry_id int Gravity Forms entry id
174
+	 * @return string
175
+	 */
176
+	public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
177
+		return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
178
+	}
179
+
180
+
181
+	/**
182
+	 * The edit entry link creates a secure link with a nonce
183
+	 *
184
+	 * It also mimics the URL structure Gravity Forms expects to have so that
185
+	 * it formats the display of the edit form like it does in the backend, like
186
+	 * "You can edit this post from the post page" fields, for example.
187
+	 *
188
+	 * @param $entry array Gravity Forms entry object
189
+	 * @param $view_id int GravityView view id
190
+	 * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
191
+	 * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
192
+	 * @return string
193
+	 */
194
+	public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
195
+
196
+		$nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
197
+
198
+		$base = gv_entry_link( $entry, $post_id ? : $view_id  );
199
+
200
+		$url = add_query_arg( array(
201
+			'edit' => wp_create_nonce( $nonce_key )
202
+		), $base );
203
+
204
+		if( $post_id ) {
205
+			$url = add_query_arg( array( 'gvid' => $view_id ), $url );
206
+		}
207
+
208
+		/**
209
+		 * Allow passing params to dynamically populate entry with values
210
+		 * @since 1.9.2
211
+		 */
212
+		if( !empty( $field_values ) ) {
213
+
214
+			if( is_array( $field_values ) ) {
215
+				// If already an array, no parse_str() needed
216
+				$params = $field_values;
217
+			} else {
218
+				parse_str( $field_values, $params );
219
+			}
220
+
221
+			$url = add_query_arg( $params, $url );
222
+		}
223 223
 
224 224
 		/**
225 225
 		 * @filter `gravityview/edit/link` Filter the edit URL link.
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 		 * @param \GV\View $view The View.
229 229
 		 */
230 230
 		return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id  ) );
231
-    }
231
+	}
232 232
 
233 233
 	/**
234 234
 	 * Edit mode doesn't allow certain field types.
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
 	}
284 284
 
285 285
 
286
-    /**
287
-     * checks if user has permissions to edit a specific entry
288
-     *
289
-     * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
290
-     *
291
-     * @param  array $entry Gravity Forms entry array
292
-     * @param \GV\View int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0
293
-     * @return bool
294
-     */
295
-    public static function check_user_cap_edit_entry( $entry, $view = 0 ) {
286
+	/**
287
+	 * checks if user has permissions to edit a specific entry
288
+	 *
289
+	 * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
290
+	 *
291
+	 * @param  array $entry Gravity Forms entry array
292
+	 * @param \GV\View int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0
293
+	 * @return bool
294
+	 */
295
+	public static function check_user_cap_edit_entry( $entry, $view = 0 ) {
296 296
 
297
-        // No permission by default
298
-        $user_can_edit = false;
297
+		// No permission by default
298
+		$user_can_edit = false;
299 299
 
300 300
 		// get user_edit setting
301 301
 		if ( empty( $view ) ) {
@@ -313,59 +313,59 @@  discard block
 block discarded – undo
313 313
 			$user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
314 314
 		}
315 315
 
316
-        // If they can edit any entries (as defined in Gravity Forms)
317
-        // Or if they can edit other people's entries
318
-        // Then we're good.
319
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
316
+		// If they can edit any entries (as defined in Gravity Forms)
317
+		// Or if they can edit other people's entries
318
+		// Then we're good.
319
+		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
320 320
 
321
-            gravityview()->log->debug( 'User has ability to edit all entries.' );
321
+			gravityview()->log->debug( 'User has ability to edit all entries.' );
322 322
 
323
-            $user_can_edit = true;
323
+			$user_can_edit = true;
324 324
 
325
-        } else if( !isset( $entry['created_by'] ) ) {
325
+		} else if( !isset( $entry['created_by'] ) ) {
326 326
 
327
-            gravityview()->log->error( 'Entry `created_by` doesn\'t exist.');
327
+			gravityview()->log->error( 'Entry `created_by` doesn\'t exist.');
328 328
 
329
-            $user_can_edit = false;
329
+			$user_can_edit = false;
330 330
 
331
-        } else {
331
+		} else {
332 332
 
333 333
 
334
-            $current_user = wp_get_current_user();
334
+			$current_user = wp_get_current_user();
335 335
 
336
-            // User edit is disabled
337
-            if( empty( $user_edit ) ) {
336
+			// User edit is disabled
337
+			if( empty( $user_edit ) ) {
338 338
 
339
-                gravityview()->log->debug( 'User Edit is disabled. Returning false.' );
339
+				gravityview()->log->debug( 'User Edit is disabled. Returning false.' );
340 340
 
341
-                $user_can_edit = false;
342
-            }
341
+				$user_can_edit = false;
342
+			}
343 343
 
344
-            // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
345
-            else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
344
+			// User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
345
+			else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
346 346
 
347
-                gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) );
347
+				gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) );
348 348
 
349
-                $user_can_edit = true;
349
+				$user_can_edit = true;
350 350
 
351
-            } else if( ! is_user_logged_in() ) {
351
+			} else if( ! is_user_logged_in() ) {
352 352
 
353
-                gravityview()->log->debug( 'No user defined; edit entry requires logged in user' );
354
-            }
353
+				gravityview()->log->debug( 'No user defined; edit entry requires logged in user' );
354
+			}
355 355
 
356
-        }
356
+		}
357 357
 
358
-        /**
359
-         * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
360
-         * @since 1.15 Added `$entry` and `$view_id` parameters
361
-         * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
362
-         * @param[in] array $entry Gravity Forms entry array {@since 1.15}
363
-         * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
364
-         */
365
-        $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
358
+		/**
359
+		 * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
360
+		 * @since 1.15 Added `$entry` and `$view_id` parameters
361
+		 * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
362
+		 * @param[in] array $entry Gravity Forms entry array {@since 1.15}
363
+		 * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
364
+		 */
365
+		$user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
366 366
 
367
-        return (bool)$user_can_edit;
368
-    }
367
+		return (bool)$user_can_edit;
368
+	}
369 369
 
370 370
 
371 371
 
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-render.php 1 patch
Indentation   +300 added lines, -300 removed lines patch added patch discarded remove patch
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
 
103 103
 	/**
104 104
 	 * ID of the current post. May also be ID of the current View.
105
-     *
106
-     * @since 2.0.13
107 105
 	 *
108
-     * @var int
106
+	 * @since 2.0.13
107
+	 *
108
+	 * @var int
109 109
 	 */
110 110
 	public $post_id;
111 111
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	public function prevent_maybe_process_form() {
191 191
 
192
-	    if( ! $this->is_edit_entry_submission() ) {
192
+		if( ! $this->is_edit_entry_submission() ) {
193 193
 			return;
194 194
 		}
195 195
 
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
 	 * When Edit entry view is requested setup the vars
229 229
 	 */
230 230
 	private function setup_vars() {
231
-        global $post;
231
+		global $post;
232 232
 
233 233
 		$gravityview_view = GravityView_View::getInstance();
234 234
 
235 235
 
236 236
 		$entries = $gravityview_view->getEntries();
237
-	    self::$original_entry = $entries[0];
238
-	    $this->entry = $entries[0];
237
+		self::$original_entry = $entries[0];
238
+		$this->entry = $entries[0];
239 239
 
240 240
 		self::$original_form = GFAPI::get_form( $this->entry['form_id'] );
241 241
 		$this->form = $gravityview_view->getForm();
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 
378 378
 			GFFormsModel::save_lead( $form, $this->entry );
379 379
 
380
-	        // Delete the values for hidden inputs
381
-	        $this->unset_hidden_field_values();
380
+			// Delete the values for hidden inputs
381
+			$this->unset_hidden_field_values();
382 382
 
383 383
 			$this->entry['date_created'] = $date_created;
384 384
 
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 			// Perform actions normally performed after updating a lead
392 392
 			$this->after_update();
393 393
 
394
-	        /**
394
+			/**
395 395
 			 * Must be AFTER after_update()!
396 396
 			 * @see https://github.com/gravityview/GravityView/issues/764
397 397
 			 */
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 
400 400
 			/**
401 401
 			 * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry
402
-             * @since 2.1 Added $gv_data parameter
402
+			 * @since 2.1 Added $gv_data parameter
403 403
 			 * @param array $form Gravity Forms form array
404 404
 			 * @param string $entry_id Numeric ID of the entry that was updated
405 405
 			 * @param GravityView_Edit_Entry_Render $this This object
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 * @return void
424 424
 	 */
425 425
 	private function unset_hidden_field_values() {
426
-	    global $wpdb;
426
+		global $wpdb;
427 427
 
428 428
 		/**
429 429
 		 * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
448 448
 		}
449 449
 
450
-	    foreach ( $this->entry as $input_id => $field_value ) {
450
+		foreach ( $this->entry as $input_id => $field_value ) {
451 451
 
452 452
 			if ( ! is_numeric( $input_id ) ) {
453 453
 				continue;
@@ -457,8 +457,8 @@  discard block
 block discarded – undo
457 457
 				continue;
458 458
 			}
459 459
 
460
-		    // Reset fields that are or would be hidden
461
-		    if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) {
460
+			// Reset fields that are or would be hidden
461
+			if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) {
462 462
 
463 463
 				$empty_value = $field->get_value_save_entry(
464 464
 					is_array( $field->get_entry_inputs() ) ? array() : '',
@@ -470,16 +470,16 @@  discard block
 block discarded – undo
470 470
 					$empty_value = '';
471 471
 				}
472 472
 
473
-			    $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
473
+				$lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
474 474
 
475
-			    GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
475
+				GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
476 476
 
477
-			    // Prevent the $_POST values of hidden fields from being used as default values when rendering the form
477
+				// Prevent the $_POST values of hidden fields from being used as default values when rendering the form
478 478
 				// after submission
479
-			    $post_input_id = 'input_' . str_replace( '.', '_', $input_id );
480
-			    $_POST[ $post_input_id ] = '';
481
-		    }
482
-	    }
479
+				$post_input_id = 'input_' . str_replace( '.', '_', $input_id );
480
+				$_POST[ $post_input_id ] = '';
481
+			}
482
+		}
483 483
 	}
484 484
 
485 485
 	/**
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 
635 635
 		$form = $this->filter_conditional_logic( $this->form );
636 636
 
637
-	    /** @var GF_Field $field */
637
+		/** @var GF_Field $field */
638 638
 		foreach( $form['fields'] as $k => &$field ) {
639 639
 
640 640
 			/**
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 
651 651
 			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
652 652
 				foreach( $field->inputs as $key => $input ) {
653
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
653
+					$field->inputs[ $key ][ 'id' ] = (string)$input['id'];
654 654
 				}
655 655
 			}
656 656
 		}
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 
691 691
 				$inputs = $field->get_entry_inputs();
692 692
 				if ( is_array( $inputs ) ) {
693
-				    foreach ( $inputs as $input ) {
693
+					foreach ( $inputs as $input ) {
694 694
 						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
695 695
 
696 696
 						if ( 'product' === $field->type ) {
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 						}
710 710
 
711 711
 						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
712
-				    }
712
+					}
713 713
 				} else {
714 714
 					// Set to what it previously was if it's not editable
715 715
 					if ( ! in_array( $field->id, $allowed_fields ) ) {
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
756 756
 
757 757
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
758
-	        $ary = stripslashes_deep( $ary );
758
+			$ary = stripslashes_deep( $ary );
759 759
 			$img_url = \GV\Utils::get( $ary, 0 );
760 760
 
761 761
 			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 	private function maybe_update_post_fields( $form ) {
829 829
 
830 830
 		if( empty( $this->entry['post_id'] ) ) {
831
-	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
831
+			gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
832 832
 			return;
833 833
 		}
834 834
 
@@ -863,49 +863,49 @@  discard block
 block discarded – undo
863 863
 
864 864
 				switch( $field->type ) {
865 865
 
866
-				    case 'post_title':
867
-				        $post_title = $value;
868
-				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
869
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
870
-				        }
871
-				        $updated_post->post_title = $post_title;
872
-				        $updated_post->post_name  = $post_title;
873
-				        unset( $post_title );
874
-				        break;
875
-
876
-				    case 'post_content':
877
-				        $post_content = $value;
878
-				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
879
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
880
-				        }
881
-				        $updated_post->post_content = $post_content;
882
-				        unset( $post_content );
883
-				        break;
884
-				    case 'post_excerpt':
885
-				        $updated_post->post_excerpt = $value;
886
-				        break;
887
-				    case 'post_tags':
888
-				        wp_set_post_tags( $post_id, $value, false );
889
-				        break;
890
-				    case 'post_category':
891
-				        break;
892
-				    case 'post_custom_field':
866
+					case 'post_title':
867
+						$post_title = $value;
868
+						if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
869
+							$post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
870
+						}
871
+						$updated_post->post_title = $post_title;
872
+						$updated_post->post_name  = $post_title;
873
+						unset( $post_title );
874
+						break;
875
+
876
+					case 'post_content':
877
+						$post_content = $value;
878
+						if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
879
+							$post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
880
+						}
881
+						$updated_post->post_content = $post_content;
882
+						unset( $post_content );
883
+						break;
884
+					case 'post_excerpt':
885
+						$updated_post->post_excerpt = $value;
886
+						break;
887
+					case 'post_tags':
888
+						wp_set_post_tags( $post_id, $value, false );
889
+						break;
890
+					case 'post_category':
891
+						break;
892
+					case 'post_custom_field':
893 893
 						if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) {
894 894
 							$value = $value[ $field_id ];
895 895
 						}
896 896
 
897
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
898
-				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
899
-				        }
897
+						if( ! empty( $field->customFieldTemplateEnabled ) ) {
898
+							$value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
899
+						}
900 900
 
901 901
 						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
902 902
 
903
-				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
904
-				        break;
903
+						update_post_meta( $post_id, $field->postCustomFieldName, $value );
904
+						break;
905 905
 
906
-				    case 'post_image':
907
-				        $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
908
-				        break;
906
+					case 'post_image':
907
+						$value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
908
+						break;
909 909
 
910 910
 				}
911 911
 
@@ -1075,14 +1075,14 @@  discard block
 block discarded – undo
1075 1075
 			?><h2 class="gv-edit-entry-title">
1076 1076
 				<span><?php
1077 1077
 
1078
-				    /**
1079
-				     * @filter `gravityview_edit_entry_title` Modify the edit entry title
1080
-				     * @param string $edit_entry_title Modify the "Edit Entry" title
1081
-				     * @param GravityView_Edit_Entry_Render $this This object
1082
-				     */
1083
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
1078
+					/**
1079
+					 * @filter `gravityview_edit_entry_title` Modify the edit entry title
1080
+					 * @param string $edit_entry_title Modify the "Edit Entry" title
1081
+					 * @param GravityView_Edit_Entry_Render $this This object
1082
+					 */
1083
+					$edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
1084 1084
 
1085
-				    echo esc_attr( $edit_entry_title );
1085
+					echo esc_attr( $edit_entry_title );
1086 1086
 			?></span>
1087 1087
 			</h2>
1088 1088
 
@@ -1137,13 +1137,13 @@  discard block
 block discarded – undo
1137 1137
 				);
1138 1138
 
1139 1139
 				/**
1140
-				* @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels
1141
-				* @since 1.16.3
1142
-				* @param array $labels Default button labels associative array
1143
-				* @param array $form The Gravity Forms form
1144
-				* @param array $entry The Gravity Forms entry
1145
-				* @param int $view_id The current View ID
1146
-				*/
1140
+				 * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels
1141
+				 * @since 1.16.3
1142
+				 * @param array $labels Default button labels associative array
1143
+				 * @param array $form The Gravity Forms form
1144
+				 * @param array $entry The Gravity Forms entry
1145
+				 * @param int $view_id The current View ID
1146
+				 */
1147 1147
 				$labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id );
1148 1148
 
1149 1149
 				$this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit'];
@@ -1180,26 +1180,26 @@  discard block
 block discarded – undo
1180 1180
 
1181 1181
 				switch ( $edit_redirect ) {
1182 1182
 
1183
-                    case '0':
1184
-	                    $redirect_url = $back_link;
1185
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1186
-                        break;
1187
-
1188
-                    case '1':
1189
-	                    $redirect_url = $directory_link = GravityView_API::directory_link();
1190
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
1191
-	                    break;
1192
-
1193
-                    case '2':
1194
-	                    $redirect_url = $edit_redirect_url;
1195
-	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1196
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
1197
-                        break;
1198
-
1199
-                    case '':
1200
-                    default:
1201
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1202
-                        break;
1183
+					case '0':
1184
+						$redirect_url = $back_link;
1185
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1186
+						break;
1187
+
1188
+					case '1':
1189
+						$redirect_url = $directory_link = GravityView_API::directory_link();
1190
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
1191
+						break;
1192
+
1193
+					case '2':
1194
+						$redirect_url = $edit_redirect_url;
1195
+						$redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1196
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
1197
+						break;
1198
+
1199
+					case '':
1200
+					default:
1201
+						$entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1202
+						break;
1203 1203
 				}
1204 1204
 
1205 1205
 				if ( isset( $redirect_url ) ) {
@@ -1265,13 +1265,13 @@  discard block
 block discarded – undo
1265 1265
 				);
1266 1266
 
1267 1267
 				/**
1268
-				* @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels
1269
-				* @since 1.16.3
1270
-				* @param array $labels Default button labels associative array
1271
-				* @param array $form The Gravity Forms form
1272
-				* @param array $entry The Gravity Forms entry
1273
-				* @param int $view_id The current View ID
1274
-				*/
1268
+				 * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels
1269
+				 * @since 1.16.3
1270
+				 * @param array $labels Default button labels associative array
1271
+				 * @param array $form The Gravity Forms form
1272
+				 * @param array $entry The Gravity Forms entry
1273
+				 * @param int $view_id The current View ID
1274
+				 */
1275 1275
 				$labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id );
1276 1276
 
1277 1277
 				GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form;
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
 
1318 1318
 		ob_get_clean();
1319 1319
 
1320
-	    remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1320
+		remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1321 1321
 		remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1322 1322
 		remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) );
1323 1323
 		remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) );
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 
1378 1378
 		// for now we don't support Save and Continue feature.
1379 1379
 		if( ! self::$supports_save_and_continue ) {
1380
-	        unset( $form['save'] );
1380
+			unset( $form['save'] );
1381 1381
 		}
1382 1382
 
1383 1383
 		$form = $this->unselect_default_values( $form );
@@ -1404,30 +1404,30 @@  discard block
 block discarded – undo
1404 1404
 			return $field_content;
1405 1405
 		}
1406 1406
 
1407
-        $message = null;
1407
+		$message = null;
1408 1408
 
1409
-        // First, make sure they have the capability to edit the post.
1410
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1409
+		// First, make sure they have the capability to edit the post.
1410
+		if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1411 1411
 
1412
-            /**
1413
-             * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1414
-             * @param string $message The existing "You don't have permission..." text
1415
-             */
1416
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1412
+			/**
1413
+			 * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1414
+			 * @param string $message The existing "You don't have permission..." text
1415
+			 */
1416
+			$message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1417 1417
 
1418
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1419
-            /**
1420
-             * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1421
-             * @param string $message The existing "This field is not editable; the post no longer exists." text
1422
-             */
1423
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1424
-        }
1418
+		} elseif( null === get_post( $this->entry['post_id'] ) ) {
1419
+			/**
1420
+			 * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1421
+			 * @param string $message The existing "This field is not editable; the post no longer exists." text
1422
+			 */
1423
+			$message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1424
+		}
1425 1425
 
1426
-        if( $message ) {
1427
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1428
-        }
1426
+		if( $message ) {
1427
+			$field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1428
+		}
1429 1429
 
1430
-        return $field_content;
1430
+		return $field_content;
1431 1431
 	}
1432 1432
 
1433 1433
 	/**
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 			|| ! empty( $field_content )
1456 1456
 			|| in_array( $field->type, array( 'honeypot' ) )
1457 1457
 		) {
1458
-	        return $field_content;
1458
+			return $field_content;
1459 1459
 		}
1460 1460
 
1461 1461
 		// SET SOME FIELD DEFAULTS TO PREVENT ISSUES
@@ -1463,24 +1463,24 @@  discard block
 block discarded – undo
1463 1463
 
1464 1464
 		$field_value = $this->get_field_value( $field );
1465 1465
 
1466
-	    // Prevent any PHP warnings, like undefined index
1467
-	    ob_start();
1466
+		// Prevent any PHP warnings, like undefined index
1467
+		ob_start();
1468 1468
 
1469
-	    $return = null;
1469
+		$return = null;
1470 1470
 
1471 1471
 		/** @var GravityView_Field $gv_field */
1472 1472
 		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1473 1473
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1474 1474
 		} else {
1475
-	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
1476
-	    }
1475
+			$return = $field->get_field_input( $this->form, $field_value, $this->entry );
1476
+		}
1477 1477
 
1478
-	    // If there was output, it's an error
1479
-	    $warnings = ob_get_clean();
1478
+		// If there was output, it's an error
1479
+		$warnings = ob_get_clean();
1480 1480
 
1481
-	    if( !empty( $warnings ) ) {
1482
-		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1483
-	    }
1481
+		if( !empty( $warnings ) ) {
1482
+			gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1483
+		}
1484 1484
 
1485 1485
 		return $return;
1486 1486
 	}
@@ -1515,8 +1515,8 @@  discard block
 block discarded – undo
1515 1515
 				$input_id = strval( $input['id'] );
1516 1516
 
1517 1517
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1518
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1519
-				    $allow_pre_populated = false;
1518
+					$field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1519
+					$allow_pre_populated = false;
1520 1520
 				}
1521 1521
 
1522 1522
 			}
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
 			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1541 1541
 				$categories = array();
1542 1542
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1543
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1543
+					$categories[] = GFCommon::format_post_category( $cat_string, true );
1544 1544
 				}
1545 1545
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1546 1546
 			}
@@ -1550,25 +1550,25 @@  discard block
 block discarded – undo
1550 1550
 		// if value is empty get the default value if defined
1551 1551
 		$field_value = $field->get_value_default_if_empty( $field_value );
1552 1552
 
1553
-	    /**
1554
-	     * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1555
-	     * @since 1.11
1556
-	     * @since 1.20 Added third param
1557
-	     * @param mixed $field_value field value used to populate the input
1558
-	     * @param object $field Gravity Forms field object ( Class GF_Field )
1559
-	     * @param GravityView_Edit_Entry_Render $this Current object
1560
-	     */
1561
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1562
-
1563
-	    /**
1564
-	     * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1565
-	     * @since 1.17
1566
-	     * @since 1.20 Added third param
1567
-	     * @param mixed $field_value field value used to populate the input
1568
-	     * @param GF_Field $field Gravity Forms field object
1569
-	     * @param GravityView_Edit_Entry_Render $this Current object
1570
-	     */
1571
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1553
+		/**
1554
+		 * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1555
+		 * @since 1.11
1556
+		 * @since 1.20 Added third param
1557
+		 * @param mixed $field_value field value used to populate the input
1558
+		 * @param object $field Gravity Forms field object ( Class GF_Field )
1559
+		 * @param GravityView_Edit_Entry_Render $this Current object
1560
+		 */
1561
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1562
+
1563
+		/**
1564
+		 * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1565
+		 * @since 1.17
1566
+		 * @since 1.20 Added third param
1567
+		 * @param mixed $field_value field value used to populate the input
1568
+		 * @param GF_Field $field Gravity Forms field object
1569
+		 * @param GravityView_Edit_Entry_Render $this Current object
1570
+		 */
1571
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1572 1572
 
1573 1573
 		return $field_value;
1574 1574
 	}
@@ -1595,7 +1595,7 @@  discard block
 block discarded – undo
1595 1595
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1596 1596
 			// expects certain field array items to be set.
1597 1597
 			foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) {
1598
-	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1598
+				$field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1599 1599
 			}
1600 1600
 
1601 1601
 			switch( RGFormsModel::get_input_type( $field ) ) {
@@ -1609,61 +1609,61 @@  discard block
 block discarded – undo
1609 1609
 				 */
1610 1610
 				case 'fileupload':
1611 1611
 
1612
-				    // Set the previous value
1613
-				    $entry = $this->get_entry();
1612
+					// Set the previous value
1613
+					$entry = $this->get_entry();
1614 1614
 
1615
-				    $input_name = 'input_'.$field->id;
1616
-				    $form_id = $form['id'];
1615
+					$input_name = 'input_'.$field->id;
1616
+					$form_id = $form['id'];
1617 1617
 
1618
-				    $value = NULL;
1618
+					$value = NULL;
1619 1619
 
1620
-				    // Use the previous entry value as the default.
1621
-				    if( isset( $entry[ $field->id ] ) ) {
1622
-				        $value = $entry[ $field->id ];
1623
-				    }
1620
+					// Use the previous entry value as the default.
1621
+					if( isset( $entry[ $field->id ] ) ) {
1622
+						$value = $entry[ $field->id ];
1623
+					}
1624 1624
 
1625
-				    // If this is a single upload file
1626
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1627
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1628
-				        $value = $file_path['url'];
1625
+					// If this is a single upload file
1626
+					if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1627
+						$file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1628
+						$value = $file_path['url'];
1629 1629
 
1630
-				    } else {
1630
+					} else {
1631 1631
 
1632
-				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1633
-				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1634
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1632
+						// Fix PHP warning on line 1498 of form_display.php for post_image fields
1633
+						// Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1634
+						$_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1635 1635
 
1636
-				    }
1636
+					}
1637 1637
 
1638
-				    if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1638
+					if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1639 1639
 
1640
-				        // If there are fresh uploads, process and merge them.
1641
-				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1642
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1643
-				            $value = empty( $value ) ? '[]' : $value;
1644
-				            $value = stripslashes_deep( $value );
1645
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1646
-				        }
1640
+						// If there are fresh uploads, process and merge them.
1641
+						// Otherwise, use the passed values, which should be json-encoded array of URLs
1642
+						if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1643
+							$value = empty( $value ) ? '[]' : $value;
1644
+							$value = stripslashes_deep( $value );
1645
+							$value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1646
+						}
1647 1647
 
1648
-				    } else {
1648
+					} else {
1649 1649
 
1650
-				        // A file already exists when editing an entry
1651
-				        // We set this to solve issue when file upload fields are required.
1652
-				        GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1650
+						// A file already exists when editing an entry
1651
+						// We set this to solve issue when file upload fields are required.
1652
+						GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1653 1653
 
1654
-				    }
1654
+					}
1655 1655
 
1656
-				    $this->entry[ $input_name ] = $value;
1657
-				    $_POST[ $input_name ] = $value;
1656
+					$this->entry[ $input_name ] = $value;
1657
+					$_POST[ $input_name ] = $value;
1658 1658
 
1659
-				    break;
1659
+					break;
1660 1660
 
1661 1661
 				case 'number':
1662
-				    // Fix "undefined index" issue at line 1286 in form_display.php
1663
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1664
-				        $_POST['input_'.$field->id ] = NULL;
1665
-				    }
1666
-				    break;
1662
+					// Fix "undefined index" issue at line 1286 in form_display.php
1663
+					if( !isset( $_POST['input_'.$field->id ] ) ) {
1664
+						$_POST['input_'.$field->id ] = NULL;
1665
+					}
1666
+					break;
1667 1667
 			}
1668 1668
 
1669 1669
 		}
@@ -1748,43 +1748,43 @@  discard block
 block discarded – undo
1748 1748
 				case 'fileupload' :
1749 1749
 				case 'post_image':
1750 1750
 
1751
-				    // in case nothing is uploaded but there are already files saved
1752
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1753
-				        $field->failed_validation = false;
1754
-				        unset( $field->validation_message );
1755
-				    }
1751
+					// in case nothing is uploaded but there are already files saved
1752
+					if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1753
+						$field->failed_validation = false;
1754
+						unset( $field->validation_message );
1755
+					}
1756 1756
 
1757
-				    // validate if multi file upload reached max number of files [maxFiles] => 2
1758
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1757
+					// validate if multi file upload reached max number of files [maxFiles] => 2
1758
+					if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1759 1759
 
1760
-				        $input_name = 'input_' . $field->id;
1761
-				        //uploaded
1762
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1760
+						$input_name = 'input_' . $field->id;
1761
+						//uploaded
1762
+						$file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1763 1763
 
1764
-				        //existent
1765
-				        $entry = $this->get_entry();
1766
-				        $value = NULL;
1767
-				        if( isset( $entry[ $field->id ] ) ) {
1768
-				            $value = json_decode( $entry[ $field->id ], true );
1769
-				        }
1764
+						//existent
1765
+						$entry = $this->get_entry();
1766
+						$value = NULL;
1767
+						if( isset( $entry[ $field->id ] ) ) {
1768
+							$value = json_decode( $entry[ $field->id ], true );
1769
+						}
1770 1770
 
1771
-				        // count uploaded files and existent entry files
1772
-				        $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1773
-						               ( is_array( $value ) ? count( $value ) : 0 );
1771
+						// count uploaded files and existent entry files
1772
+						$count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1773
+									   ( is_array( $value ) ? count( $value ) : 0 );
1774 1774
 
1775
-				        if( $count_files > $field->maxFiles ) {
1776
-				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1777
-				            $field->failed_validation = 1;
1778
-				            $gv_valid = false;
1775
+						if( $count_files > $field->maxFiles ) {
1776
+							$field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1777
+							$field->failed_validation = 1;
1778
+							$gv_valid = false;
1779 1779
 
1780
-				            // in case of error make sure the newest upload files are removed from the upload input
1781
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1782
-				        }
1780
+							// in case of error make sure the newest upload files are removed from the upload input
1781
+							GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1782
+						}
1783 1783
 
1784
-				    }
1784
+					}
1785 1785
 
1786 1786
 
1787
-				    break;
1787
+					break;
1788 1788
 
1789 1789
 			}
1790 1790
 
@@ -1795,47 +1795,47 @@  discard block
 block discarded – undo
1795 1795
 
1796 1796
 				switch ( $field_type ) {
1797 1797
 
1798
-				    // Captchas don't need to be re-entered.
1799
-				    case 'captcha':
1798
+					// Captchas don't need to be re-entered.
1799
+					case 'captcha':
1800 1800
 
1801
-				        // Post Image fields aren't editable, so we un-fail them.
1802
-				    case 'post_image':
1803
-				        $field->failed_validation = false;
1804
-				        unset( $field->validation_message );
1805
-				        break;
1801
+						// Post Image fields aren't editable, so we un-fail them.
1802
+					case 'post_image':
1803
+						$field->failed_validation = false;
1804
+						unset( $field->validation_message );
1805
+						break;
1806 1806
 
1807 1807
 				}
1808 1808
 
1809 1809
 				// You can't continue inside a switch, so we do it after.
1810 1810
 				if( empty( $field->failed_validation ) ) {
1811
-				    continue;
1811
+					continue;
1812 1812
 				}
1813 1813
 
1814 1814
 				// checks if the No Duplicates option is not validating entry against itself, since
1815 1815
 				// we're editing a stored entry, it would also assume it's a duplicate.
1816 1816
 				if( !empty( $field->noDuplicates ) ) {
1817 1817
 
1818
-				    $entry = $this->get_entry();
1818
+					$entry = $this->get_entry();
1819 1819
 
1820
-				    // If the value of the entry is the same as the stored value
1821
-				    // Then we can assume it's not a duplicate, it's the same.
1822
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1823
-				        //if value submitted was not changed, then don't validate
1824
-				        $field->failed_validation = false;
1820
+					// If the value of the entry is the same as the stored value
1821
+					// Then we can assume it's not a duplicate, it's the same.
1822
+					if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1823
+						//if value submitted was not changed, then don't validate
1824
+						$field->failed_validation = false;
1825 1825
 
1826
-				        unset( $field->validation_message );
1826
+						unset( $field->validation_message );
1827 1827
 
1828
-				        gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1828
+						gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1829 1829
 
1830
-				        continue;
1831
-				    }
1830
+						continue;
1831
+					}
1832 1832
 				}
1833 1833
 
1834 1834
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1835 1835
 				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1836
-				    unset( $field->validation_message );
1837
-	                $field->validation_message = false;
1838
-				    continue;
1836
+					unset( $field->validation_message );
1837
+					$field->validation_message = false;
1838
+					continue;
1839 1839
 				}
1840 1840
 
1841 1841
 				$gv_valid = false;
@@ -1899,8 +1899,8 @@  discard block
 block discarded – undo
1899 1899
 		// Hide fields depending on admin settings
1900 1900
 		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1901 1901
 
1902
-	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1903
-	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1902
+		// If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1903
+		$fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1904 1904
 
1905 1905
 		/**
1906 1906
 		 * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form
@@ -1991,11 +1991,11 @@  discard block
 block discarded – undo
1991 1991
 		// The edit tab has been configured, so we loop through to configured settings
1992 1992
 		foreach ( $configured_fields as $configured_field ) {
1993 1993
 
1994
-	        /** @var GF_Field $field */
1995
-	        foreach ( $fields as $field ) {
1994
+			/** @var GF_Field $field */
1995
+			foreach ( $fields as $field ) {
1996 1996
 				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1997
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1998
-				    break;
1997
+					$edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1998
+					break;
1999 1999
 				}
2000 2000
 
2001 2001
 			}
@@ -2051,28 +2051,28 @@  discard block
 block discarded – undo
2051 2051
 	 */
2052 2052
 	private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) {
2053 2053
 
2054
-	    /**
2054
+		/**
2055 2055
 		 * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true
2056
-	     * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
2057
-	     * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
2058
-	     * @since 1.9.1
2059
-	     * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions.
2060
-	     * @param array $form GF Form array
2061
-	     * @param int $view_id View ID
2062
-	     */
2063
-	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
2064
-
2065
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
2056
+		 * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
2057
+		 * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
2058
+		 * @since 1.9.1
2059
+		 * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions.
2060
+		 * @param array $form GF Form array
2061
+		 * @param int $view_id View ID
2062
+		 */
2063
+		$use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
2064
+
2065
+		if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
2066 2066
 			foreach( $fields as $k => $field ) {
2067 2067
 				if( $field->adminOnly ) {
2068
-				    unset( $fields[ $k ] );
2068
+					unset( $fields[ $k ] );
2069 2069
 				}
2070 2070
 			}
2071 2071
 			return array_values( $fields );
2072 2072
 		}
2073 2073
 
2074
-	    foreach( $fields as &$field ) {
2075
-		    $field->adminOnly = false;
2074
+		foreach( $fields as &$field ) {
2075
+			$field->adminOnly = false;
2076 2076
 		}
2077 2077
 
2078 2078
 		return $fields;
@@ -2092,13 +2092,13 @@  discard block
 block discarded – undo
2092 2092
 	 */
2093 2093
 	private function unselect_default_values( $form ) {
2094 2094
 
2095
-	    foreach ( $form['fields'] as &$field ) {
2095
+		foreach ( $form['fields'] as &$field ) {
2096 2096
 
2097 2097
 			if ( empty( $field->choices ) ) {
2098
-                continue;
2098
+				continue;
2099 2099
 			}
2100 2100
 
2101
-            foreach ( $field->choices as &$choice ) {
2101
+			foreach ( $field->choices as &$choice ) {
2102 2102
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
2103 2103
 					$choice['isSelected'] = false;
2104 2104
 				}
@@ -2135,36 +2135,36 @@  discard block
 block discarded – undo
2135 2135
 
2136 2136
 			if( 'checkbox' === $field->type ) {
2137 2137
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
2138
-				    $input_id = $input['id'];
2139
-				    $choice = $field->choices[ $key ];
2140
-				    $value = \GV\Utils::get( $this->entry, $input_id );
2141
-				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
2142
-				    if( $match ) {
2143
-				        $field->choices[ $key ]['isSelected'] = true;
2144
-				    }
2138
+					$input_id = $input['id'];
2139
+					$choice = $field->choices[ $key ];
2140
+					$value = \GV\Utils::get( $this->entry, $input_id );
2141
+					$match = RGFormsModel::choice_value_match( $field, $choice, $value );
2142
+					if( $match ) {
2143
+						$field->choices[ $key ]['isSelected'] = true;
2144
+					}
2145 2145
 				}
2146 2146
 			} else {
2147 2147
 
2148 2148
 				// We need to run through each field to set the default values
2149 2149
 				foreach ( $this->entry as $field_id => $field_value ) {
2150 2150
 
2151
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
2151
+					if( floatval( $field_id ) === floatval( $field->id ) ) {
2152 2152
 
2153
-				        if( 'list' === $field->type ) {
2154
-				            $list_rows = maybe_unserialize( $field_value );
2153
+						if( 'list' === $field->type ) {
2154
+							$list_rows = maybe_unserialize( $field_value );
2155 2155
 
2156
-				            $list_field_value = array();
2157
-				            foreach ( (array) $list_rows as $row ) {
2158
-				                foreach ( (array) $row as $column ) {
2159
-				                    $list_field_value[] = $column;
2160
-				                }
2161
-				            }
2156
+							$list_field_value = array();
2157
+							foreach ( (array) $list_rows as $row ) {
2158
+								foreach ( (array) $row as $column ) {
2159
+									$list_field_value[] = $column;
2160
+								}
2161
+							}
2162 2162
 
2163
-				            $field->defaultValue = serialize( $list_field_value );
2164
-				        } else {
2165
-				            $field->defaultValue = $field_value;
2166
-				        }
2167
-				    }
2163
+							$field->defaultValue = serialize( $list_field_value );
2164
+						} else {
2165
+							$field->defaultValue = $field_value;
2166
+						}
2167
+					}
2168 2168
 				}
2169 2169
 			}
2170 2170
 		}
@@ -2225,7 +2225,7 @@  discard block
 block discarded – undo
2225 2225
 			foreach ( $form['fields'] as &$field ) {
2226 2226
 				foreach ( $remove_conditions_rule as $_remove_conditions_r ) {
2227 2227
 
2228
-				    list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2228
+					list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2229 2229
 
2230 2230
 					if ( $field['id'] == $rule_field_id ) {
2231 2231
 						unset( $field->conditionalLogic['rules'][ $rule_i ] );
@@ -2276,7 +2276,7 @@  discard block
 block discarded – undo
2276 2276
 			return $has_conditional_logic;
2277 2277
 		}
2278 2278
 
2279
-	    /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
2279
+		/** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
2280 2280
 		return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );
2281 2281
 	}
2282 2282
 
@@ -2343,14 +2343,14 @@  discard block
 block discarded – undo
2343 2343
 
2344 2344
 		if( $echo && $error !== true ) {
2345 2345
 
2346
-	        $error = esc_html( $error );
2346
+			$error = esc_html( $error );
2347 2347
 
2348
-	        /**
2349
-	         * @since 1.9
2350
-	         */
2351
-	        if ( ! empty( $this->entry ) ) {
2352
-		        $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
2353
-	        }
2348
+			/**
2349
+			 * @since 1.9
2350
+			 */
2351
+			if ( ! empty( $this->entry ) ) {
2352
+				$error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
2353
+			}
2354 2354
 
2355 2355
 			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
2356 2356
 		}
Please login to merge, or discard this patch.