Completed
Push — master ( 21157a...9cf7be )
by Zack
84:58 queued 65:12
created
includes/class-gv-license-handler.php 4 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,6 +53,9 @@  discard block
 block discarded – undo
53 53
 		add_action( 'wp_ajax_gravityview_license', array( $this, 'license_call' ) );
54 54
 	}
55 55
 
56
+	/**
57
+	 * @param boolean $echo
58
+	 */
56 59
 	function settings_edd_license_activation( $field, $echo ) {
57 60
 
58 61
 		wp_enqueue_script( 'gv-admin-edd-license', GRAVITYVIEW_URL . 'assets/js/admin-edd-license.js', array( 'jquery' ) );
@@ -241,7 +244,7 @@  discard block
 block discarded – undo
241 244
 	 * Generate the status message box HTML based on the current status
242 245
 	 *
243 246
 	 * @since 1.7.4
244
-	 * @param $message
247
+	 * @param string $message
245 248
 	 * @param string $class
246 249
 	 *
247 250
 	 * @return string
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -340,7 +340,7 @@
 block discarded – undo
340 340
 		// Update option with passed data license
341 341
 		$settings = $this->Addon->get_app_settings();
342 342
 
343
-        $settings['license_key'] = $license_data->license_key = trim( $data['license'] );
343
+		$settings['license_key'] = $license_data->license_key = trim( $data['license'] );
344 344
 		$settings['license_key_status'] = $license_data->license;
345 345
 		$settings['license_key_response'] = (array)$license_data;
346 346
 
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @return GV_License_Handler
35 35
 	 */
36 36
 	public static function get_instance( GravityView_Settings $GFAddOn ) {
37
-		if( empty( self::$instance ) ) {
37
+		if ( empty( self::$instance ) ) {
38 38
 			self::$instance = new self( $GFAddOn );
39 39
 		}
40 40
 		return self::$instance;
@@ -60,37 +60,37 @@  discard block
 block discarded – undo
60 60
 		$status = trim( $this->Addon->get_app_setting( 'license_key_status' ) );
61 61
 		$key = trim( $this->Addon->get_app_setting( 'license_key' ) );
62 62
 
63
-		if( !empty( $key ) ) {
63
+		if ( ! empty( $key ) ) {
64 64
 			$response = $this->Addon->get_app_setting( 'license_key_response' );
65
-			$response = is_array( $response ) ? (object) $response : json_decode( $response );
65
+			$response = is_array( $response ) ? (object)$response : json_decode( $response );
66 66
 		} else {
67 67
 			$response = array();
68 68
 		}
69 69
 
70 70
 		wp_localize_script( 'gv-admin-edd-license', 'GVGlobals', array(
71 71
 			'license_box' => $this->get_license_message( $response )
72
-		));
72
+		) );
73 73
 
74 74
 
75 75
 		$fields = array(
76 76
 			array(
77 77
 				'name'  => 'edd-activate',
78
-				'value' => __('Activate License', 'gravityview'),
79
-				'data-pending_text' => __('Verifying license…', 'gravityview'),
78
+				'value' => __( 'Activate License', 'gravityview' ),
79
+				'data-pending_text' => __( 'Verifying license…', 'gravityview' ),
80 80
 				'data-edd_action' => 'activate_license',
81 81
 				'class' => 'button-primary',
82 82
 			),
83 83
 			array(
84 84
 				'name'  => 'edd-deactivate',
85
-				'value' => __('Deactivate License', 'gravityview'),
86
-				'data-pending_text' => __('Deactivating license…', 'gravityview'),
85
+				'value' => __( 'Deactivate License', 'gravityview' ),
86
+				'data-pending_text' => __( 'Deactivating license…', 'gravityview' ),
87 87
 				'data-edd_action' => 'deactivate_license',
88 88
 				'class' => ( empty( $status ) ? 'button-primary hide' : 'button-primary' ),
89 89
 			),
90 90
 			array(
91 91
 				'name'  => 'edd-check',
92
-				'value' => __('Check License', 'gravityview'),
93
-				'data-pending_text' => __('Verifying license…', 'gravityview'),
92
+				'value' => __( 'Check License', 'gravityview' ),
93
+				'data-pending_text' => __( 'Verifying license…', 'gravityview' ),
94 94
 				'title' => 'Check the license before saving it',
95 95
 				'data-edd_action' => 'check_license',
96 96
 				'class' => 'button-secondary',
@@ -100,17 +100,17 @@  discard block
 block discarded – undo
100 100
 
101 101
 		$class = 'button gv-edd-action';
102 102
 
103
-		$class .= ( !empty( $key ) && $status !== 'valid' ) ? '' : ' hide';
103
+		$class .= ( ! empty( $key ) && $status !== 'valid' ) ? '' : ' hide';
104 104
 
105 105
 		$disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled';
106 106
 
107 107
 		$submit = '<div class="gv-edd-button-wrapper">';
108 108
 		foreach ( $fields as $field ) {
109
-			$field['type'] = 'button';
110
-			$field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class;
111
-			$field['style'] = 'margin-left: 10px;';
112
-			if( $disabled_attribute ) {
113
-				$field['disabled'] = $disabled_attribute;
109
+			$field[ 'type' ] = 'button';
110
+			$field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] . ' ' . $class : $class;
111
+			$field[ 'style' ] = 'margin-left: 10px;';
112
+			if ( $disabled_attribute ) {
113
+				$field[ 'disabled' ] = $disabled_attribute;
114 114
 			}
115 115
 			$submit .= $this->Addon->settings_submit( $field, $echo );
116 116
 		}
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	private function setup_edd() {
128 128
 
129
-		if( !class_exists('EDD_SL_Plugin_Updater') ) {
130
-			require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php');
129
+		if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
130
+			require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php' );
131 131
 		}
132 132
 
133 133
 		// setup the updater
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 			'url'       => home_url(),
164 164
 		);
165 165
 
166
-		if( !empty( $action ) ) {
167
-			$settings['edd_action'] = esc_attr( $action );
166
+		if ( ! empty( $action ) ) {
167
+			$settings[ 'edd_action' ] = esc_attr( $action );
168 168
 		}
169 169
 
170 170
 		$settings = array_map( 'urlencode', $settings );
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
 	 */
179 179
 	private function _license_get_remote_response( $data, $license = '' ) {
180 180
 
181
-		$api_params = $this->_get_edd_settings( $data['edd_action'], $license );
181
+		$api_params = $this->_get_edd_settings( $data[ 'edd_action' ], $license );
182 182
 
183 183
 		$url = add_query_arg( $api_params, self::url );
184 184
 
185 185
 		$response = wp_remote_get( $url, array(
186 186
 			'timeout'   => 15,
187 187
 			'sslverify' => false,
188
-		));
188
+		) );
189 189
 
190 190
 		if ( is_wp_error( $response ) ) {
191 191
 			return array();
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		// Not JSON
197 197
 		if ( empty( $license_data ) ) {
198 198
 
199
-			delete_transient( 'gravityview_' . esc_attr( $data['field_id'] ) . '_valid' );
199
+			delete_transient( 'gravityview_' . esc_attr( $data[ 'field_id' ] ) . '_valid' );
200 200
 
201 201
 			// Change status
202 202
 			return array();
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 	 */
219 219
 	function get_license_message( $license_data ) {
220 220
 
221
-		if( empty( $license_data ) ) {
221
+		if ( empty( $license_data ) ) {
222 222
 			$class = 'hide';
223 223
 			$message = '';
224 224
 		} else {
225 225
 
226
-			if( ! empty( $license_data->error ) ) {
226
+			if ( ! empty( $license_data->error ) ) {
227 227
 				$class = 'error';
228 228
 				$string_key = $license_data->license;
229 229
 			} else {
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 				$string_key = $license_data->license;
232 232
 			}
233 233
 
234
-			$message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings( $string_key, $license_data ) );
234
+			$message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings( 'status' ), $this->strings( $string_key, $license_data ) );
235 235
 		}
236 236
 
237 237
 		return $this->generate_license_box( $message, $class );
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
 	 */
273 273
 	public function license_call( $array = array() ) {
274 274
 
275
-		$is_ajax = ( defined('DOING_AJAX') && DOING_AJAX );
276
-		$data = empty( $array ) ? $_POST['data'] : $array;
275
+		$is_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX );
276
+		$data = empty( $array ) ? $_POST[ 'data' ] : $array;
277 277
 		$has_cap = GVCommon::has_cap( 'gravityview_edit_settings' );
278 278
 
279
-		if ( $is_ajax && empty( $data['license'] ) ) {
280
-			die( - 1 );
279
+		if ( $is_ajax && empty( $data[ 'license' ] ) ) {
280
+			die( -1 );
281 281
 		}
282 282
 
283 283
 		// If the user isn't allowed to edit settings, show an error message
284
-		if( ! $has_cap ) {
284
+		if ( ! $has_cap ) {
285 285
 			$license_data = new stdClass();
286 286
 			$license_data->error = 'capability';
287 287
 			$license_data->message = $this->get_license_message( $license_data );
@@ -304,9 +304,9 @@  discard block
 block discarded – undo
304 304
 
305 305
 			$json = json_encode( $license_data );
306 306
 
307
-			$update_license = ( ! isset( $data['update'] ) || ! empty( $data['update'] ) );
307
+			$update_license = ( ! isset( $data[ 'update' ] ) || ! empty( $data[ 'update' ] ) );
308 308
 
309
-			$is_check_action_button = ( 'check_license' === $data['edd_action'] && defined( 'DOING_AJAX' ) && DOING_AJAX );
309
+			$is_check_action_button = ( 'check_license' === $data[ 'edd_action' ] && defined( 'DOING_AJAX' ) && DOING_AJAX );
310 310
 
311 311
 			// Failed is the response from trying to de-activate a license and it didn't work.
312 312
 			// This likely happened because people entered in a different key and clicked "Deactivate",
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 			// most likely a mistake.
315 315
 			if ( $license_data->license !== 'failed' && ! $is_check_action_button && $update_license ) {
316 316
 
317
-				if ( ! empty( $data['field_id'] ) ) {
318
-					set_transient( 'gravityview_' . esc_attr( $data['field_id'] ) . '_valid', $license_data, DAY_IN_SECONDS );
317
+				if ( ! empty( $data[ 'field_id' ] ) ) {
318
+					set_transient( 'gravityview_' . esc_attr( $data[ 'field_id' ] ) . '_valid', $license_data, DAY_IN_SECONDS );
319 319
 				}
320 320
 
321 321
 				$this->license_call_update_settings( $license_data, $data );
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		if ( $is_ajax ) {
327 327
 			exit( $json );
328 328
 		} else { // Non-ajax call
329
-			return ( rgget('format', $data ) === 'object' ) ? $license_data : $json;
329
+			return ( rgget( 'format', $data ) === 'object' ) ? $license_data : $json;
330 330
 		}
331 331
 	}
332 332
 
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 		// Update option with passed data license
341 341
 		$settings = $this->Addon->get_app_settings();
342 342
 
343
-        $settings['license_key'] = $license_data->license_key = trim( $data['license'] );
344
-		$settings['license_key_status'] = $license_data->license;
345
-		$settings['license_key_response'] = (array)$license_data;
343
+        $settings[ 'license_key' ] = $license_data->license_key = trim( $data[ 'license' ] );
344
+		$settings[ 'license_key_status' ] = $license_data->license;
345
+		$settings[ 'license_key_response' ] = (array)$license_data;
346 346
 
347 347
 		$this->Addon->update_app_settings( $settings );
348 348
 	}
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	 * @return string Renewal or account URL
355 355
 	 */
356 356
 	private function get_license_renewal_url( $license_data ) {
357
-		$renew_license_url = ( ! empty( $license_data ) && !empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation', $license_data->license_key ) : 'https://gravityview.co/account/';
357
+		$renew_license_url = ( ! empty( $license_data ) && ! empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation', $license_data->license_key ) : 'https://gravityview.co/account/';
358 358
 		return $renew_license_url;
359 359
 	}
360 360
 
@@ -368,30 +368,30 @@  discard block
 block discarded – undo
368 368
 
369 369
 
370 370
 		$strings = array(
371
-			'status' => esc_html__('Status', 'gravityview'),
372
-			'error' => esc_html__('There was an error processing the request.', 'gravityview'),
373
-			'failed'  => esc_html__('Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview'),
374
-			'site_inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'),
375
-			'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview') . ' ' . sprintf( esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>' ),
376
-			'deactivated' => esc_html__('The license has been deactivated.', 'gravityview'),
377
-			'valid' => esc_html__('The license key is valid and active.', 'gravityview'),
378
-			'invalid' => esc_html__('The license key entered is invalid.', 'gravityview'),
379
-			'missing' => esc_html__('The license key was not defined.', 'gravityview'),
380
-			'revoked' => esc_html__('This license key has been revoked.', 'gravityview'),
381
-			'expired' => sprintf( esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ),
371
+			'status' => esc_html__( 'Status', 'gravityview' ),
372
+			'error' => esc_html__( 'There was an error processing the request.', 'gravityview' ),
373
+			'failed'  => esc_html__( 'Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview' ),
374
+			'site_inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ),
375
+			'no_activations_left' => esc_html__( 'Invalid: this license has reached its activation limit.', 'gravityview' ) . ' ' . sprintf( esc_html__( 'You can manage license activations %son your GravityView account page%s.', 'gravityview' ), '<a href="https://gravityview.co/account/#licenses">', '</a>' ),
376
+			'deactivated' => esc_html__( 'The license has been deactivated.', 'gravityview' ),
377
+			'valid' => esc_html__( 'The license key is valid and active.', 'gravityview' ),
378
+			'invalid' => esc_html__( 'The license key entered is invalid.', 'gravityview' ),
379
+			'missing' => esc_html__( 'The license key was not defined.', 'gravityview' ),
380
+			'revoked' => esc_html__( 'This license key has been revoked.', 'gravityview' ),
381
+			'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="' . esc_url( $this->get_license_renewal_url( $license_data ) ) . '">', '</a>' ),
382 382
 			'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ),
383 383
 
384
-			'verifying_license' => esc_html__('Verifying license&hellip;', 'gravityview'),
385
-			'activate_license' => esc_html__('Activate License', 'gravityview'),
386
-			'deactivate_license' => esc_html__('Deactivate License', 'gravityview'),
387
-			'check_license' => esc_html__('Verify License', 'gravityview'),
384
+			'verifying_license' => esc_html__( 'Verifying license&hellip;', 'gravityview' ),
385
+			'activate_license' => esc_html__( 'Activate License', 'gravityview' ),
386
+			'deactivate_license' => esc_html__( 'Deactivate License', 'gravityview' ),
387
+			'check_license' => esc_html__( 'Verify License', 'gravityview' ),
388 388
 		);
389 389
 
390
-		if( empty( $status ) ) {
390
+		if ( empty( $status ) ) {
391 391
 			return $strings;
392 392
 		}
393 393
 
394
-		if( isset( $strings[ $status ] ) ) {
394
+		if ( isset( $strings[ $status ] ) ) {
395 395
 			return $strings[ $status ];
396 396
 		}
397 397
 
@@ -401,19 +401,19 @@  discard block
 block discarded – undo
401 401
 	public function validate_license_key( $value, $field ) {
402 402
 
403 403
 		// No license? No status.
404
-		if( empty( $value ) ) {
404
+		if ( empty( $value ) ) {
405 405
 			return NULL;
406 406
 		}
407 407
 
408
-		$response = $this->license_call(array(
408
+		$response = $this->license_call( array(
409 409
 			'license' => $this->Addon->get_app_setting( 'license_key' ),
410 410
 			'edd_action' => 'check_license',
411
-			'field_id' => $field['name'],
412
-		));
411
+			'field_id' => $field[ 'name' ],
412
+		) );
413 413
 
414 414
 		$response = is_string( $response ) ? json_decode( $response, true ) : $response;
415 415
 
416
-		switch( $response['license'] ) {
416
+		switch ( $response[ 'license' ] ) {
417 417
 			case 'valid':
418 418
 				$return = true;
419 419
 				break;
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -295,7 +295,8 @@  discard block
 block discarded – undo
295 295
 			if ( empty( $license_data ) ) {
296 296
 				if ( $is_ajax ) {
297 297
 					exit( json_encode( array() ) );
298
-				} else { // Non-ajax call
298
+				} else {
299
+// Non-ajax call
299 300
 					return json_encode( array() );
300 301
 				}
301 302
 			}
@@ -325,7 +326,8 @@  discard block
 block discarded – undo
325 326
 
326 327
 		if ( $is_ajax ) {
327 328
 			exit( $json );
328
-		} else { // Non-ajax call
329
+		} else {
330
+// Non-ajax call
329 331
 			return ( rgget('format', $data ) === 'object' ) ? $license_data : $json;
330 332
 		}
331 333
 	}
Please login to merge, or discard this patch.
includes/class-gvlogic-shortcode.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -225,7 +225,7 @@
 block discarded – undo
225 225
 	 * Does the if and the comparison match?
226 226
 	 * @uses GVCommon::matches_operation
227 227
 	 *
228
-	 * @return boolean True: yep; false: nope
228
+	 * @return boolean|null True: yep; false: nope
229 229
 	 */
230 230
 	function set_is_match() {
231 231
 		$this->is_match = GVCommon::matches_operation( $this->if, $this->comparison, $this->operation );
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public static function get_instance() {
87 87
 
88
-		if( empty( self::$instance ) ) {
88
+		if ( empty( self::$instance ) ) {
89 89
 			self::$instance = new self;
90 90
 		}
91 91
 
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 
119 119
 		$operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS );
120 120
 
121
-		if( $with_values ) {
121
+		if ( $with_values ) {
122 122
 			$operators_with_values = array();
123
-			foreach( $operators as $key ) {
123
+			foreach ( $operators as $key ) {
124 124
 				$operators_with_values[ $key ] = '';
125 125
 			}
126 126
 			return $operators_with_values;
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
 	 */
138 138
 	function set_operation( $operation = '' ) {
139 139
 
140
-		if( empty( $operation ) ) {
140
+		if ( empty( $operation ) ) {
141 141
 			return false;
142 142
 		}
143 143
 
144 144
 		$operators = $this->get_operators( false );
145 145
 
146
-		if( !in_array( $operation, $operators ) ) {
147
-			do_action( 'gravityview_log_debug', __METHOD__ .' Attempted to add invalid operation type.', $operation );
146
+		if ( ! in_array( $operation, $operators ) ) {
147
+			do_action( 'gravityview_log_debug', __METHOD__ . ' Attempted to add invalid operation type.', $operation );
148 148
 			return false;
149 149
 		}
150 150
 
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	function setup_operation_and_comparison() {
166 166
 
167
-		foreach( $this->atts as $key => $value ) {
167
+		foreach ( $this->atts as $key => $value ) {
168 168
 
169 169
 			$valid = $this->set_operation( $key );
170 170
 
171
-			if( $valid ) {
171
+			if ( $valid ) {
172 172
 				$this->comparison = $value;
173 173
 				return true;
174 174
 			}
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
 		$this->parse_atts();
199 199
 
200 200
 		// We need an "if"
201
-		if( false === $this->if ) {
202
-			do_action( 'gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->atts );
201
+		if ( false === $this->if ) {
202
+			do_action( 'gravityview_log_error', __METHOD__ . ' $atts->if is empty.', $this->atts );
203 203
 			return null;
204 204
 		}
205 205
 
206 206
 		$setup = $this->setup_operation_and_comparison();
207 207
 
208 208
 		// We need an operation and comparison value
209
-		if( ! $setup ) {
210
-			do_action( 'gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts );
209
+		if ( ! $setup ) {
210
+			do_action( 'gravityview_log_error', __METHOD__ . ' No valid operators were passed.', $this->atts );
211 211
 			return null;
212 212
 		}
213 213
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	function get_output() {
240 240
 
241
-		if( $this->is_match ) {
241
+		if ( $this->is_match ) {
242 242
 			$output = $this->content;
243 243
 		} else {
244 244
 			$output = $this->else_content;
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
 		 * @param string $output HTML/text output
253 253
 		 * @param GVLogic_Shortcode $this This class
254 254
 		 */
255
-		$output = apply_filters('gravityview/gvlogic/output', $output, $this );
255
+		$output = apply_filters( 'gravityview/gvlogic/output', $output, $this );
256 256
 
257
-		do_action( 'gravityview_log_debug', __METHOD__ .' Output: ', $output );
257
+		do_action( 'gravityview_log_debug', __METHOD__ . ' Output: ', $output );
258 258
 
259 259
 		return $output;
260 260
 	}
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 
271 271
 		$content = explode( '[else]', $this->passed_content );
272 272
 
273
-		$this->content = $content[0];
273
+		$this->content = $content[ 0 ];
274 274
 
275
-		$else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL;
275
+		$else_attr = isset( $this->atts[ 'else' ] ) ? $this->atts[ 'else' ] : NULL;
276 276
 
277
-		$this->else_content = isset( $content[1] ) ? $content[1] : $else_attr;
277
+		$this->else_content = isset( $content[ 1 ] ) ? $content[ 1 ] : $else_attr;
278 278
 	}
279 279
 
280 280
 	/**
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 		$this->atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $this->passed_atts, $this->atts ) : $this->atts;
298 298
 
299 299
 		// Strip whitespace if it's not default false
300
-		$this->if = is_string( $this->atts['if'] ) ? trim( $this->atts['if'] ) : false;
300
+		$this->if = is_string( $this->atts[ 'if' ] ) ? trim( $this->atts[ 'if' ] ) : false;
301 301
 
302 302
 		// Make sure the "if" isn't processed in self::setup_operation_and_comparison()
303
-		unset( $this->atts['if'] );
303
+		unset( $this->atts[ 'if' ] );
304 304
 	}
305 305
 }
306 306
 
Please login to merge, or discard this patch.
includes/class-oembed.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -211,6 +211,7 @@
 block discarded – undo
211 211
 	 * @var $view_id
212 212
 	 *
213 213
 	 * @see render_handler
214
+	 * @param string $url
214 215
 	 */
215 216
 	private function set_vars( $matches, $attr, $url, $rawattr ) {
216 217
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	static function getInstance() {
44 44
 
45
-		if( empty( self::$instance ) ) {
45
+		if ( empty( self::$instance ) ) {
46 46
 			self::$instance = new self;
47 47
 
48 48
 			self::$instance->initialize();
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		// Catch either
95 95
 		$match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})";
96 96
 
97
-		return '#'.$match_regex.'#i';
97
+		return '#' . $match_regex . '#i';
98 98
 	}
99 99
 
100 100
 	/**
@@ -113,18 +113,18 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$post_id = url_to_postid( $url );
115 115
 
116
-		if( empty( $post_id ) ) {
116
+		if ( empty( $post_id ) ) {
117 117
 
118 118
 			$args = array(
119 119
 				'post_status' => 'publish',
120 120
 				'name' => $slug,
121
-				'post_type' => array('any', 'gravityview'),
121
+				'post_type' => array( 'any', 'gravityview' ),
122 122
 			);
123 123
 
124 124
 			$posts = get_posts( $args );
125 125
 
126
-			if( !empty( $posts ) ) {
127
-				$post_id = $posts[0]->ID;
126
+			if ( ! empty( $posts ) ) {
127
+				$post_id = $posts[ 0 ]->ID;
128 128
 			}
129 129
 		}
130 130
 
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
 	public function render_handler( $matches, $attr, $url, $rawattr ) {
158 158
 
159 159
 		// If not using permalinks, re-assign values for matching groups
160
-		if( !empty( $matches['entry_slug2'] ) ) {
161
-			$matches['is_cpt'] = $matches['is_cpt2'];
162
-			$matches['slug'] = $matches['slug2'];
163
-			$matches['entry_slug'] = $matches['entry_slug2'];
164
-			unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] );
160
+		if ( ! empty( $matches[ 'entry_slug2' ] ) ) {
161
+			$matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ];
162
+			$matches[ 'slug' ] = $matches[ 'slug2' ];
163
+			$matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ];
164
+			unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] );
165 165
 		}
166 166
 
167 167
 		// No Entry was found
168
-		if( empty( $matches['entry_slug'] ) ) {
168
+		if ( empty( $matches[ 'entry_slug' ] ) ) {
169 169
 
170
-			do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches );
170
+			do_action( 'gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches );
171 171
 
172 172
 			return '';
173 173
 		}
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 		// Setup the data used
178 178
 		$this->set_vars( $matches, $attr, $url, $rawattr );
179 179
 
180
-		if( is_admin() && !$this->is_full_oembed_preview ) {
180
+		if ( is_admin() && ! $this->is_full_oembed_preview ) {
181 181
 			$return = $this->render_admin( $matches, $attr, $url, $rawattr );
182 182
 		} else {
183 183
 
184
-			if( $this->is_full_oembed_preview ) {
184
+			if ( $this->is_full_oembed_preview ) {
185 185
 				$return .= $this->generate_preview_notice();
186 186
 			}
187 187
 
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 	private function generate_preview_notice() {
201 201
 		$floaty = GravityView_Admin::get_floaty();
202 202
 		$title = esc_html__( 'This will look better when it is embedded.', 'gravityview' );
203
-		$message = esc_html__('Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview');
204
-		return '<div class="updated notice">'. $floaty. '<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>';
203
+		$message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview' );
204
+		return '<div class="updated notice">' . $floaty . '<h3>' . $title . '</h3><p>' . $message . '</p><br style="clear:both;" /></div>';
205 205
 	}
206 206
 
207 207
 	/**
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	private function set_vars( $matches, $attr, $url, $rawattr ) {
216 216
 
217
-		$this->entry_id = $matches['entry_slug'];
217
+		$this->entry_id = $matches[ 'entry_slug' ];
218 218
 
219
-		$post_id = $this->get_postid_from_url_and_slug( $url, $matches['slug'] );
219
+		$post_id = $this->get_postid_from_url_and_slug( $url, $matches[ 'slug' ] );
220 220
 
221 221
 		// The URL didn't have the View Custom Post Type structure.
222
-		if( empty( $matches['is_cpt'] ) || $matches['is_cpt'] !== 'gravityview' ) {
222
+		if ( empty( $matches[ 'is_cpt' ] ) || $matches[ 'is_cpt' ] !== 'gravityview' ) {
223 223
 
224
-			do_action('gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches );
224
+			do_action( 'gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches );
225 225
 
226 226
 			$this->view_id = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id );
227 227
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		}
233 233
 
234 234
 		// The inline content has $_POST['type'] set to "embed", while the "Add Media" modal doesn't set that.
235
-		$this->is_full_oembed_preview = ( isset( $_POST['action'] ) && $_POST['action'] === 'parse-embed' && !isset( $_POST['type'] ) );
235
+		$this->is_full_oembed_preview = ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] === 'parse-embed' && ! isset( $_POST[ 'type' ] ) );
236 236
 	}
237 237
 
238 238
 	/**
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
 		// Floaty the astronaut
251 251
 		$image = GravityView_Admin::get_floaty();
252 252
 
253
-		$embed_heading = sprintf( esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id );
253
+		$embed_heading = sprintf( esc_html__( 'Embed Entry %d', 'gravityview' ), $this->entry_id );
254 254
 
255
-		$embed_text = sprintf( esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id );
255
+		$embed_text = sprintf( esc_html__( 'This entry will be displayed as it is configured in View %d', 'gravityview' ), $this->view_id );
256 256
 
257 257
 		return '
258 258
 		<div class="loading-placeholder" style="background-color:#e6f0f5;">
259
-			<h3 style="margin:0; padding:0; font-family: \'Open Sans\', sans-serif;">'.$image.$embed_heading.'</h3>
259
+			<h3 style="margin:0; padding:0; font-family: \'Open Sans\', sans-serif;">'.$image . $embed_heading . '</h3>
260 260
 			<p style="margin:0; padding:0; font-family: \'Open Sans\', sans-serif;">
261
-				'.$embed_text.'
261
+				'.$embed_text . '
262 262
 			</p>
263 263
 			<br style="clear: both;">
264 264
 		</div>';
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
 	private function render_frontend( $matches, $attr, $url, $rawattr ) {
314 314
 
315 315
 		// If it's already been parsed, don't re-output it.
316
-		if( !empty( $this->output[ $this->entry_id ] ) ) {
316
+		if ( ! empty( $this->output[ $this->entry_id ] ) ) {
317 317
 			return $this->output[ $this->entry_id ];
318 318
 		}
319 319
 
320 320
 		$entry_output = $this->generate_entry_output();
321 321
 
322 322
 		// Wrap a container div around the output to allow for custom styling
323
-		$output = sprintf('<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-'.$this->entry_id.'">%s</div>', $entry_output );
323
+		$output = sprintf( '<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-' . $this->entry_id . '">%s</div>', $entry_output );
324 324
 
325 325
 		/**
326 326
 		 * @filter `gravityview/oembed/entry` Filter the output of the oEmbed entry embed
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		 *  @var string $url The original URL that was matched by the regex. \n
334 334
 		 *  @var array $rawattr The original unmodified attributes.
335 335
 		 */
336
-		$output = apply_filters('gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) );
336
+		$output = apply_filters( 'gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) );
337 337
 
338 338
 		unset( $entry_output );
339 339
 
Please login to merge, or discard this patch.
includes/class-settings.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -301,6 +301,7 @@
 block discarded – undo
301 301
 	 * Make protected public
302 302
 	 * @inheritDoc
303 303
 	 * @access public
304
+	 * @param string $setting_name
304 305
 	 */
305 306
 	public function get_app_setting( $setting_name ) {
306 307
 
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
                     type="' . $field['type'] . '"
419 419
                     name="' . esc_attr( $name ) . '"
420 420
                     value="' . $value . '" ' .
421
-		        implode( ' ', $attributes ) .
422
-		        ' />';
421
+				implode( ' ', $attributes ) .
422
+				' />';
423 423
 
424 424
 		if ( $echo ) {
425 425
 			echo $html;
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 					array(
649 649
 						'label' => _x( 'Permanently Delete', 'Setting: what to do when uninstalling plugin', 'gravityview' ),
650 650
 						'value' => 'delete',
651
-					    'tooltip' => sprintf( '<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __( 'Delete all GravityView content and settings', 'gravityview' ), __( 'If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview' ), __( 'When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview' ) ),
651
+						'tooltip' => sprintf( '<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __( 'Delete all GravityView content and settings', 'gravityview' ), __( 'If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview' ), __( 'When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview' ) ),
652 652
 					),
653 653
 				),
654 654
 				'description'   => sprintf( __( 'Should GravityView content and entry approval status be removed from the site when the GravityView plugin is deleted?', 'gravityview' ), __( 'Permanently Delete', 'gravityview' ) ),
@@ -674,36 +674,36 @@  discard block
 block discarded – undo
674 674
 		}
675 675
 
676 676
 
677
-        $sections = array(
678
-            array(
679
-                'description' =>      sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ),
680
-                'fields'      => $fields,
681
-            )
682
-        );
677
+		$sections = array(
678
+			array(
679
+				'description' =>      sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ),
680
+				'fields'      => $fields,
681
+			)
682
+		);
683 683
 
684
-        // custom 'update settings' button
685
-        $button = array(
686
-            'class' => 'button button-primary button-hero',
687
-            'type'     => 'save',
688
-        );
684
+		// custom 'update settings' button
685
+		$button = array(
686
+			'class' => 'button button-primary button-hero',
687
+			'type'     => 'save',
688
+		);
689 689
 
690 690
 		if( $disabled_attribute ) {
691 691
 			$button['disabled'] = $disabled_attribute;
692 692
 		}
693 693
 
694 694
 
695
-        /**
696
-         * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page
697
-         * Extensions can tap in here to insert their own section and settings.
698
-         * <code>
699
-         *   $sections[] = array(
700
-         *      'title' => __( 'GravityView My Extension Settings', 'gravityview' ),
701
-         *      'fields' => $settings,
702
-         *   );
703
-         * </code>
704
-         * @param array $extension_settings Empty array, ready for extension settings!
705
-         */
706
-        $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() );
695
+		/**
696
+		 * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page
697
+		 * Extensions can tap in here to insert their own section and settings.
698
+		 * <code>
699
+		 *   $sections[] = array(
700
+		 *      'title' => __( 'GravityView My Extension Settings', 'gravityview' ),
701
+		 *      'fields' => $settings,
702
+		 *   );
703
+		 * </code>
704
+		 * @param array $extension_settings Empty array, ready for extension settings!
705
+		 */
706
+		$extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() );
707 707
 
708 708
 		// If there are extensions, add a section for them
709 709
 		if ( ! empty( $extension_sections ) ) {
@@ -716,13 +716,13 @@  discard block
 block discarded – undo
716 716
 				}
717 717
 			}
718 718
 
719
-            $k = count( $extension_sections ) - 1 ;
720
-            $extension_sections[ $k ]['fields'][] = $button;
719
+			$k = count( $extension_sections ) - 1 ;
720
+			$extension_sections[ $k ]['fields'][] = $button;
721 721
 			$sections = array_merge( $sections, $extension_sections );
722 722
 		} else {
723
-            // add the 'update settings' button to the general section
724
-            $sections[0]['fields'][] = $button;
725
-        }
723
+			// add the 'update settings' button to the general section
724
+			$sections[0]['fields'][] = $button;
725
+		}
726 726
 
727 727
 		return $sections;
728 728
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -441,8 +441,9 @@
 block discarded – undo
441 441
 		$field['name']  = 'gform-settings-save';
442 442
 		$field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton';
443 443
 
444
-		if ( ! rgar( $field, 'value' ) )
445
-			$field['value'] = __( 'Update Settings', 'gravityview' );
444
+		if ( ! rgar( $field, 'value' ) ) {
445
+					$field['value'] = __( 'Update Settings', 'gravityview' );
446
+		}
446 447
 
447 448
 		$output = $this->settings_submit( $field, false );
448 449
 
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public function __construct( $prevent_multiple_instances = '' ) {
73 73
 
74
-		if( $prevent_multiple_instances === 'get_instance' ) {
74
+		if ( $prevent_multiple_instances === 'get_instance' ) {
75 75
 			return parent::__construct();
76 76
 		}
77 77
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public static function get_instance() {
85 85
 
86
-		if( empty( self::$instance ) ) {
86
+		if ( empty( self::$instance ) ) {
87 87
 			self::$instance = new self( 'get_instance' );
88 88
 		}
89 89
 
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 		 * Prevent Gravity Forms from showing the uninstall tab on the settings page
107 107
 		 * @hack
108 108
 		 */
109
-		if( $caps === $this->_capabilities_uninstall ) {
109
+		if ( $caps === $this->_capabilities_uninstall ) {
110 110
 			return false;
111 111
 		}
112 112
 
113
-		if( empty( $caps ) ) {
113
+		if ( empty( $caps ) ) {
114 114
 			$caps = array( 'gravityview_full_access' );
115 115
 		}
116 116
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		add_filter( 'gform_addon_app_settings_menu_gravityview', array( $this, 'modify_app_settings_menu_title' ) );
134 134
 
135 135
 		/** @since 1.7.6 */
136
-		add_action('network_admin_menu', array( $this, 'add_network_menu' ) );
136
+		add_action( 'network_admin_menu', array( $this, 'add_network_menu' ) );
137 137
 
138 138
 		parent::init_admin();
139 139
 	}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function modify_app_settings_menu_title( $setting_tabs ) {
149 149
 
150
-		$setting_tabs[0]['label'] = __( 'GravityView Settings', 'gravityview');
150
+		$setting_tabs[ 0 ][ 'label' ] = __( 'GravityView Settings', 'gravityview' );
151 151
 
152 152
 		return $setting_tabs;
153 153
 	}
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	private function _load_license_handler() {
166 166
 
167
-		if( !empty( $this->License_Handler ) ) {
167
+		if ( ! empty( $this->License_Handler ) ) {
168 168
 			return;
169 169
 		}
170 170
 
171
-		require_once( GRAVITYVIEW_DIR . 'includes/class-gv-license-handler.php');
171
+		require_once( GRAVITYVIEW_DIR . 'includes/class-gv-license-handler.php' );
172 172
 
173 173
 		$this->License_Handler = GV_License_Handler::get_instance( $this );
174 174
 	}
@@ -180,60 +180,60 @@  discard block
 block discarded – undo
180 180
 	function license_key_notice() {
181 181
 
182 182
 		// Only show on GravityView pages
183
-		if( ! gravityview_is_admin_page() ) {
183
+		if ( ! gravityview_is_admin_page() ) {
184 184
 			return;
185 185
 		}
186 186
 
187
-		$license_status = self::getSetting('license_key_status');
188
-		$license_id = self::getSetting('license_key');
187
+		$license_status = self::getSetting( 'license_key_status' );
188
+		$license_id = self::getSetting( 'license_key' );
189 189
 		$license_id = empty( $license_id ) ? 'license' : $license_id;
190 190
 
191
-		$message = esc_html__('Your GravityView license %s. This means you&rsquo;re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview');
191
+		$message = esc_html__( 'Your GravityView license %s. This means you&rsquo;re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview' );
192 192
 
193 193
 		/**
194 194
 		 * I wanted to remove the period from after the buttons in the string,
195 195
 		 * but didn't want to mess up the translation strings for the translators.
196 196
 		 */
197 197
 		$message = mb_substr( $message, 0, mb_strlen( $message ) - 1 );
198
-		$title = __('Inactive License', 'gravityview');
198
+		$title = __( 'Inactive License', 'gravityview' );
199 199
 		$status = '';
200 200
 		$update_below = false;
201 201
 		$primary_button_link = admin_url( 'edit.php?post_type=gravityview&amp;page=gravityview_settings' );
202 202
 		switch ( $license_status ) {
203 203
 			case 'invalid':
204
-				$title = __('Invalid License', 'gravityview');
205
-				$status = __('is invalid', 'gravityview');
204
+				$title = __( 'Invalid License', 'gravityview' );
205
+				$status = __( 'is invalid', 'gravityview' );
206 206
 				break;
207 207
 			case 'deactivated':
208
-				$status = __('is inactive', 'gravityview');
209
-				$update_below = __('Activate your license key below.', 'gravityview');
208
+				$status = __( 'is inactive', 'gravityview' );
209
+				$update_below = __( 'Activate your license key below.', 'gravityview' );
210 210
 				break;
211 211
 			/** @noinspection PhpMissingBreakStatementInspection */
212 212
 			case '':
213 213
 				$license_status = 'site_inactive';
214 214
 				// break intentionally left blank
215 215
 			case 'site_inactive':
216
-				$status = __('has not been activated', 'gravityview');
217
-				$update_below = __('Activate your license key below.', 'gravityview');
216
+				$status = __( 'has not been activated', 'gravityview' );
217
+				$update_below = __( 'Activate your license key below.', 'gravityview' );
218 218
 				break;
219 219
 		}
220
-		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice';
220
+		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content=' . $license_status . '&utm_campaign=Admin%20Notice';
221 221
 
222 222
 		// Show a different notice on settings page for inactive licenses (hide the buttons)
223
-		if( $update_below && gravityview_is_admin_page( '', 'settings' ) ) {
223
+		if ( $update_below && gravityview_is_admin_page( '', 'settings' ) ) {
224 224
 			$message = sprintf( $message, $status, '<div class="hidden">', '', '', '</div><a href="#" onclick="jQuery(\'#license_key\').focus(); return false;">' . $update_below . '</a>' );
225 225
 		} else {
226 226
 			$message = sprintf( $message, $status, "\n\n" . '<a href="' . $primary_button_link . '" class="button button-primary">', '</a>', '<a href="' . esc_url( $url ) . '" class="button button-secondary">', '</a>' );
227 227
 		}
228 228
 
229
-		if( !empty( $status ) ) {
229
+		if ( ! empty( $status ) ) {
230 230
 			GravityView_Admin_Notices::add_notice( array(
231 231
 				'message' => $message,
232 232
 				'class'	=> 'updated',
233 233
 				'title' => $title,
234 234
 				'cap' => 'gravityview_edit_settings',
235
-				'dismiss' => sha1( $license_status.'_'.$license_id ),
236
-			));
235
+				'dismiss' => sha1( $license_status . '_' . $license_id ),
236
+			) );
237 237
 		}
238 238
 	}
239 239
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 
246 246
 		$styles = parent::styles();
247 247
 
248
-		$styles[] = array(
248
+		$styles[ ] = array(
249 249
 			'handle'  => 'gravityview_settings',
250 250
 			'src'     => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ),
251 251
 			'version' => GravityView_Plugin::version,
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 * @return void
269 269
 	 */
270 270
 	public function add_network_menu() {
271
-		if( GravityView_Plugin::is_network_activated() ) {
271
+		if ( GravityView_Plugin::is_network_activated() ) {
272 272
 			add_menu_page( __( 'Settings', 'gravityview' ), __( 'GravityView', 'gravityview' ), $this->_capabilities_app_settings, "{$this->_slug}_settings", array( $this, 'app_tab_page' ), 'none' );
273 273
 		}
274 274
 	}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		 * If multisite and not network admin, we don't want the settings to show.
286 286
 		 * @since 1.7.6
287 287
 		 */
288
-		$show_submenu = !is_multisite() ||  is_main_site() || !GravityView_Plugin::is_network_activated() || ( is_network_admin() && GravityView_Plugin::is_network_activated() );
288
+		$show_submenu = ! is_multisite() || is_main_site() || ! GravityView_Plugin::is_network_activated() || ( is_network_admin() && GravityView_Plugin::is_network_activated() );
289 289
 
290 290
 		/**
291 291
 		 * Override whether to show the Settings menu on a per-blog basis.
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		 */
295 295
 		$show_submenu = apply_filters( 'gravityview/show-settings-menu', $show_submenu );
296 296
 
297
-		if( $show_submenu ) {
297
+		if ( $show_submenu ) {
298 298
 			add_submenu_page( 'edit.php?post_type=gravityview', __( 'Settings', 'gravityview' ), __( 'Settings', 'gravityview' ), $this->_capabilities_app_settings, $this->_slug . '_settings', array( $this, 'app_tab_page' ) );
299 299
 		}
300 300
 	}
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		/**
326 326
 		 * Backward compatibility with Redux
327 327
 		 */
328
-		if( $setting_name === 'license' ) {
328
+		if ( $setting_name === 'license' ) {
329 329
 			return array(
330 330
 				'license' => parent::get_app_setting( 'license_key' ),
331 331
 				'status' => parent::get_app_setting( 'license_key_status' ),
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 
390 390
 		$return = $text . $activation;
391 391
 
392
-		if( $echo ) {
392
+		if ( $echo ) {
393 393
 			echo $return;
394 394
 		}
395 395
 
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
 	 */
417 417
 	public function settings_submit( $field, $echo = true ) {
418 418
 
419
-		$field['type']  = ( isset($field['type']) && in_array( $field['type'], array('submit','reset','button') ) ) ? $field['type'] : 'submit';
419
+		$field[ 'type' ] = ( isset( $field[ 'type' ] ) && in_array( $field[ 'type' ], array( 'submit', 'reset', 'button' ) ) ) ? $field[ 'type' ] : 'submit';
420 420
 
421 421
 		$attributes    = $this->get_field_attributes( $field );
422 422
 		$default_value = rgar( $field, 'value' ) ? rgar( $field, 'value' ) : rgar( $field, 'default_value' );
423
-		$value         = $this->get_setting( $field['name'], $default_value );
423
+		$value         = $this->get_setting( $field[ 'name' ], $default_value );
424 424
 
425 425
 
426
-		$attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary gfbutton';
427
-		$name    = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_'.$field['name'];
426
+		$attributes[ 'class' ] = isset( $attributes[ 'class' ] ) ? esc_attr( $attributes[ 'class' ] ) : 'button-primary gfbutton';
427
+		$name = ( $field[ 'name' ] === 'gform-settings-save' ) ? $field[ 'name' ] : '_gaddon_setting_' . $field[ 'name' ];
428 428
 
429 429
 		if ( empty( $value ) ) {
430 430
 			$value = __( 'Update Settings', 'gravityview' );
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 		$attributes = $this->get_field_attributes( $field );
434 434
 
435 435
 		$html = '<input
436
-                    type="' . $field['type'] . '"
436
+                    type="' . $field[ 'type' ] . '"
437 437
                     name="' . esc_attr( $name ) . '"
438 438
                     value="' . $value . '" ' .
439 439
 		        implode( ' ', $attributes ) .
@@ -455,16 +455,16 @@  discard block
 block discarded – undo
455 455
 	 * @return string
456 456
 	 */
457 457
 	public function settings_save( $field, $echo = true ) {
458
-		$field['type']  = 'submit';
459
-		$field['name']  = 'gform-settings-save';
460
-		$field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton';
458
+		$field[ 'type' ]  = 'submit';
459
+		$field[ 'name' ]  = 'gform-settings-save';
460
+		$field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] : 'button-primary gfbutton';
461 461
 
462 462
 		if ( ! rgar( $field, 'value' ) )
463
-			$field['value'] = __( 'Update Settings', 'gravityview' );
463
+			$field[ 'value' ] = __( 'Update Settings', 'gravityview' );
464 464
 
465 465
 		$output = $this->settings_submit( $field, false );
466 466
 
467
-		if( $echo ) {
467
+		if ( $echo ) {
468 468
 			echo $output;
469 469
 		}
470 470
 
@@ -478,11 +478,11 @@  discard block
 block discarded – undo
478 478
 	 */
479 479
 	public function single_setting_label( $field ) {
480 480
 
481
-		echo $field['label'];
481
+		echo $field[ 'label' ];
482 482
 
483 483
 
484
-		if ( isset( $field['tooltip'] ) ) {
485
-			echo ' ' . gform_tooltip( $field['tooltip'], rgar( $field, 'tooltip_class' ), true );
484
+		if ( isset( $field[ 'tooltip' ] ) ) {
485
+			echo ' ' . gform_tooltip( $field[ 'tooltip' ], rgar( $field, 'tooltip_class' ), true );
486 486
 		}
487 487
 
488 488
 		if ( rgar( $field, 'required' ) ) {
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 		}
491 491
 
492 492
 		// Added by GravityView
493
-		if ( isset( $field['description'] ) ) {
494
-			echo '<span class="description">'. $field['description'] .'</span>';
493
+		if ( isset( $field[ 'description' ] ) ) {
494
+			echo '<span class="description">' . $field[ 'description' ] . '</span>';
495 495
 		}
496 496
 
497 497
 	}
@@ -553,11 +553,11 @@  discard block
 block discarded – undo
553 553
 
554 554
 		// If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response),
555 555
 		// then we assume it's changed. If it's changed, unset the status and the previous response.
556
-		if( $local_key !== $response_key ) {
556
+		if ( $local_key !== $response_key ) {
557 557
 
558
-			unset( $posted_settings['license_key_response'] );
559
-			unset( $posted_settings['license_key_status'] );
560
-			GFCommon::add_error_message( __('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
558
+			unset( $posted_settings[ 'license_key_response' ] );
559
+			unset( $posted_settings[ 'license_key_status' ] );
560
+			GFCommon::add_error_message( __( 'The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
561 561
 		}
562 562
 
563 563
 		return $posted_settings;
@@ -592,25 +592,25 @@  discard block
 block discarded – undo
592 592
 				'label'             => __( 'License Key', 'gravityview' ),
593 593
 				'description'          => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates &amp; support.', 'gravityview' ),
594 594
 				'type'              => 'edd_license',
595
-				'data-pending-text' => __('Verifying license&hellip;', 'gravityview'),
596
-				'default_value'           => $default_settings['license_key'],
595
+				'data-pending-text' => __( 'Verifying license&hellip;', 'gravityview' ),
596
+				'default_value'           => $default_settings[ 'license_key' ],
597 597
 				'class'             => ( '' == $this->get_app_setting( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key',
598 598
 			),
599 599
 			array(
600 600
 				'name'       => 'license_key_response',
601
-				'default_value'  => $default_settings['license_key_response'],
601
+				'default_value'  => $default_settings[ 'license_key_response' ],
602 602
 				'type'     => 'hidden',
603 603
 			),
604 604
 			array(
605 605
 				'name'       => 'license_key_status',
606
-				'default_value'  => $default_settings['license_key_status'],
606
+				'default_value'  => $default_settings[ 'license_key_status' ],
607 607
 				'type'     => 'hidden',
608 608
 			),
609 609
 			array(
610 610
 				'name'       => 'support-email',
611 611
 				'type'     => 'text',
612 612
 				'validate' => 'email',
613
-				'default_value'  => $default_settings['support-email'],
613
+				'default_value'  => $default_settings[ 'support-email' ],
614 614
 				'label'    => __( 'Support Email', 'gravityview' ),
615 615
 				'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ),
616 616
 				'class'    => 'code regular-text',
@@ -622,44 +622,44 @@  discard block
 block discarded – undo
622 622
 				'name'         => 'support_port',
623 623
 				'type'       => 'radio',
624 624
 				'label'      => __( 'Show Support Port?', 'gravityview' ),
625
-				'default_value'    => $default_settings['support_port'],
625
+				'default_value'    => $default_settings[ 'support_port' ],
626 626
 				'horizontal' => 1,
627 627
 				'choices'    => array(
628 628
 					array(
629
-						'label' => _x('Show', 'Setting: Show or Hide', 'gravityview'),
629
+						'label' => _x( 'Show', 'Setting: Show or Hide', 'gravityview' ),
630 630
 						'value' => '1',
631 631
 					),
632 632
 					array(
633
-						'label' => _x('Hide', 'Setting: Show or Hide', 'gravityview'),
633
+						'label' => _x( 'Hide', 'Setting: Show or Hide', 'gravityview' ),
634 634
 						'value' => '0',
635 635
 					),
636 636
 				),
637
-				'tooltip' => '<p><img src="' . esc_url_raw( plugins_url('assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE ) ) . '" alt="' . esc_attr__( 'The Support Port looks like this.', 'gravityview' ) . '" class="alignright" style="max-width:40px; margin:.5em;" />' . esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview') . '</p>',
637
+				'tooltip' => '<p><img src="' . esc_url_raw( plugins_url( 'assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE ) ) . '" alt="' . esc_attr__( 'The Support Port looks like this.', 'gravityview' ) . '" class="alignright" style="max-width:40px; margin:.5em;" />' . esc_html__( 'The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview' ) . '</p>',
638 638
 				'description'   => __( 'Show the Support Port on GravityView pages?', 'gravityview' ),
639 639
 			),
640 640
 			array(
641 641
 				'name'         => 'no-conflict-mode',
642 642
 				'type'       => 'radio',
643 643
 				'label'      => __( 'No-Conflict Mode', 'gravityview' ),
644
-				'default_value'    => $default_settings['no-conflict-mode'],
644
+				'default_value'    => $default_settings[ 'no-conflict-mode' ],
645 645
 				'horizontal' => 1,
646 646
 				'choices'    => array(
647 647
 					array(
648
-						'label' => _x('On', 'Setting: On or off', 'gravityview'),
648
+						'label' => _x( 'On', 'Setting: On or off', 'gravityview' ),
649 649
 						'value' => '1',
650 650
 					),
651 651
 					array(
652
-						'label' => _x('Off', 'Setting: On or off', 'gravityview'),
652
+						'label' => _x( 'Off', 'Setting: On or off', 'gravityview' ),
653 653
 						'value' => '0',
654 654
 					),
655 655
 				),
656
-				'description'   => __( 'Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview' ) . ' ' . __('If your Edit View tabs are ugly, enable this setting.', 'gravityview'),
656
+				'description'   => __( 'Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview' ) . ' ' . __( 'If your Edit View tabs are ugly, enable this setting.', 'gravityview' ),
657 657
 			),
658 658
 			array(
659 659
 				'name'       => 'delete-on-uninstall',
660 660
 				'type'       => 'radio',
661 661
 				'label'      => __( 'Remove Data on Delete?', 'gravityview' ),
662
-				'default_value'    => $default_settings['delete-on-uninstall'],
662
+				'default_value'    => $default_settings[ 'delete-on-uninstall' ],
663 663
 				'horizontal' => 1,
664 664
 				'choices'    => array(
665 665
 					array(
@@ -685,20 +685,20 @@  discard block
 block discarded – undo
685 685
 		 * @since 1.7.4
686 686
 		 */
687 687
 		foreach ( $fields as &$field ) {
688
-			$field['name']          = isset( $field['name'] ) ? $field['name'] : rgget('id', $field );
689
-			$field['label']         = isset( $field['label'] ) ? $field['label'] : rgget('title', $field );
690
-			$field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : rgget('default', $field );
691
-			$field['description']   = isset( $field['description'] ) ? $field['description'] : rgget('subtitle', $field );
688
+			$field[ 'name' ]          = isset( $field[ 'name' ] ) ? $field[ 'name' ] : rgget( 'id', $field );
689
+			$field[ 'label' ]         = isset( $field[ 'label' ] ) ? $field[ 'label' ] : rgget( 'title', $field );
690
+			$field[ 'default_value' ] = isset( $field[ 'default_value' ] ) ? $field[ 'default_value' ] : rgget( 'default', $field );
691
+			$field[ 'description' ]   = isset( $field[ 'description' ] ) ? $field[ 'description' ] : rgget( 'subtitle', $field );
692 692
 
693
-			if( $disabled_attribute ) {
694
-				$field['disabled']  = $disabled_attribute;
693
+			if ( $disabled_attribute ) {
694
+				$field[ 'disabled' ] = $disabled_attribute;
695 695
 			}
696 696
 		}
697 697
 
698 698
 
699 699
         $sections = array(
700 700
             array(
701
-                'description' =>      sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ),
701
+                'description' =>      sprintf( '<span class="version-info description">%s</span>', sprintf( __( 'You are running GravityView version %s', 'gravityview' ), GravityView_Plugin::version ) ),
702 702
                 'fields'      => $fields,
703 703
             )
704 704
         );
@@ -709,8 +709,8 @@  discard block
 block discarded – undo
709 709
             'type'     => 'save',
710 710
         );
711 711
 
712
-		if( $disabled_attribute ) {
713
-			$button['disabled'] = $disabled_attribute;
712
+		if ( $disabled_attribute ) {
713
+			$button[ 'disabled' ] = $disabled_attribute;
714 714
 		}
715 715
 
716 716
 
@@ -730,20 +730,20 @@  discard block
 block discarded – undo
730 730
 		// If there are extensions, add a section for them
731 731
 		if ( ! empty( $extension_sections ) ) {
732 732
 
733
-			if( $disabled_attribute ) {
733
+			if ( $disabled_attribute ) {
734 734
 				foreach ( $extension_sections as &$section ) {
735
-					foreach ( $section['fields'] as &$field ) {
736
-						$field['disabled'] = $disabled_attribute;
735
+					foreach ( $section[ 'fields' ] as &$field ) {
736
+						$field[ 'disabled' ] = $disabled_attribute;
737 737
 					}
738 738
 				}
739 739
 			}
740 740
 
741
-            $k = count( $extension_sections ) - 1 ;
742
-            $extension_sections[ $k ]['fields'][] = $button;
741
+            $k = count( $extension_sections ) - 1;
742
+            $extension_sections[ $k ][ 'fields' ][ ] = $button;
743 743
 			$sections = array_merge( $sections, $extension_sections );
744 744
 		} else {
745 745
             // add the 'update settings' button to the general section
746
-            $sections[0]['fields'][] = $button;
746
+            $sections[ 0 ][ 'fields' ][ ] = $button;
747 747
         }
748 748
 
749 749
 		return $sections;
Please login to merge, or discard this patch.
includes/connector-functions.php 2 patches
Doc Comments   +3 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,7 +41,6 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @see GVCommon::get_forms()
43 43
  * @access public
44
- * @param mixed $form_id
45 44
  * @return array (id, title)
46 45
  */
47 46
 function gravityview_get_forms() {
@@ -53,7 +52,7 @@  discard block
 block discarded – undo
53 52
  *
54 53
  * @see GVCommon::get_form_fields()
55 54
  * @access public
56
- * @param string|array $form_id (default: '') or $form object
55
+ * @param string|array $form (default: '') or $form object
57 56
  * @return array
58 57
  */
59 58
 function gravityview_get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) {
@@ -91,6 +90,7 @@  discard block
 block discarded – undo
91 90
  * @param int|array $form_ids The ID of the form or an array IDs of the Forms. Zero for all forms.
92 91
  * @param mixed $passed_criteria (default: null)
93 92
  * @param mixed &$total (default: null)
93
+ * @param integer $total
94 94
  * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays
95 95
  */
96 96
 function gravityview_get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) {
@@ -103,7 +103,6 @@  discard block
 block discarded – undo
103 103
  * Since 1.4, supports custom entry slugs. The way that GravityView fetches an entry based on the custom slug is by searching `gravityview_unique_id` meta. The `$entry_slug` is fetched by getting the current query var set by `is_single_entry()`
104 104
  *
105 105
  * @access public
106
- * @param mixed $entry_id
107 106
  * @param boolean $force_allow_ids Force the get_entry() method to allow passed entry IDs, even if the `gravityview_custom_entry_slug_allow_id` filter returns false.
108 107
  * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true {@since 1.14}
109 108
  * @return array|boolean
@@ -177,7 +176,7 @@  discard block
 block discarded – undo
177 176
  *
178 177
  * @param int $view_id ID of the View you want the form of
179 178
  *
180
- * @return int
179
+ * @return string
181 180
  */
182 181
 function gravityview_get_form_id( $view_id ) {
183 182
 	return GVCommon::get_meta_form_id( $view_id );
@@ -188,7 +187,6 @@  discard block
 block discarded – undo
188 187
  *
189 188
  * @see GravityView_Template::template_id
190 189
  *
191
- * @param int $view_id The ID of the View to get the layout of
192 190
  *
193 191
  * @return string GravityView_Template::template_id value. Empty string if not.
194 192
  */
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
  * @param  mixed $field_id Field ID or Field array
290 290
  * @return string field type
291 291
  */
292
-function gravityview_get_field_type(  $form = null , $field_id = '' ) {
293
-	return GVCommon::get_field_type(  $form, $field_id );
292
+function gravityview_get_field_type( $form = null, $field_id = '' ) {
293
+	return GVCommon::get_field_type( $form, $field_id );
294 294
 }
295 295
 
296 296
 
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
  * @return string HTML of the output. Empty string if $view_id is empty.
304 304
  */
305 305
 function get_gravityview( $view_id = '', $atts = array() ) {
306
-	if( !empty( $view_id ) ) {
307
-		$atts['id'] = $view_id;
306
+	if ( ! empty( $view_id ) ) {
307
+		$atts[ 'id' ] = $view_id;
308 308
 		$args = wp_parse_args( $atts, GravityView_View_Data::get_default_args() );
309 309
 		$GravityView_frontend = GravityView_frontend::getInstance();
310 310
 		$GravityView_frontend->setGvOutputData( GravityView_View_Data::getInstance( $view_id ) );
@@ -347,15 +347,15 @@  discard block
 block discarded – undo
347 347
  */
348 348
 function gravityview_view_has_single_checkbox_or_radio( $form, $view_fields ) {
349 349
 
350
-	if( $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) {
350
+	if ( $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) {
351 351
 
352 352
 		/** @var GF_Field_Radio|GF_Field_Checkbox $form_field */
353
-		foreach( $form_fields as $form_field ) {
353
+		foreach ( $form_fields as $form_field ) {
354 354
 			$field_id = $form_field->id;
355
-			foreach( $view_fields as $zone ) {
356
-				foreach( $zone as $field ) {
355
+			foreach ( $view_fields as $zone ) {
356
+				foreach ( $zone as $field ) {
357 357
 					// If it's an input, not the parent and the parent ID matches a checkbox or radio
358
-					if( ( strpos( $field['id'], '.' ) > 0 ) && floor( $field['id'] ) === floor( $field_id ) ) {
358
+					if ( ( strpos( $field[ 'id' ], '.' ) > 0 ) && floor( $field[ 'id' ] ) === floor( $field_id ) ) {
359 359
 						return true;
360 360
 					}
361 361
 				}
Please login to merge, or discard this patch.
includes/extensions/delete-entry/class-delete-entry.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -170,7 +170,6 @@
 block discarded – undo
170 170
 	 *
171 171
 	 * @since 1.5.1
172 172
 	 * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
173
-	 * @param  string      $field_type  Type of field options to render (`field` or `widget`)
174 173
 	 * @param  string      $template_id Table slug
175 174
 	 * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
176 175
 	 * @param  string      $context     What context are we in? Example: `single` or `directory`
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
 		self::getInstance()->set_entry( $entry );
230 230
 
231
-        $base = GravityView_API::directory_link( $post_id, true );
231
+		$base = GravityView_API::directory_link( $post_id, true );
232 232
 
233 233
 		if( empty( $base ) ) {
234 234
 			do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id );
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
 		// Use the slug instead of the ID for consistent security
239 239
 		$entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry );
240 240
 
241
-        $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id;
241
+		$view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id;
242 242
 
243 243
 		$actionurl = add_query_arg( array(
244 244
 			'action'	=> 'delete',
245 245
 			'entry_id'		=> $entry_slug,
246 246
 			'gvid' => $view_id,
247
-            'view_id' => $view_id,
247
+			'view_id' => $view_id,
248 248
 		), $base );
249 249
 
250 250
 		$url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' );
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	private function add_hooks() {
42 42
 		add_action( 'wp', array( $this, 'process_delete' ), 10000 );
43 43
 
44
-		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field'), 10, 3 );
44
+		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
45 45
 
46 46
 		add_action( 'gravityview_before', array( $this, 'display_message' ) );
47 47
 
48 48
 		// For the Delete Entry Link, you don't want visible to all users.
49
-		add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps'), 10, 5 );
49
+		add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
50 50
 
51 51
 		// Modify the field options based on the name of the field type
52 52
 		add_filter( 'gravityview_template_delete_link_options', array( $this, 'delete_link_field_options' ), 10, 5 );
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		// add template path to check for field
55 55
 		add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
56 56
 
57
-		add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button'), 10, 3 );
57
+		add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button' ), 10, 3 );
58 58
 	}
59 59
 
60 60
 	/**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	static function getInstance() {
67 67
 
68
-		if( empty( self::$instance ) ) {
68
+		if ( empty( self::$instance ) ) {
69 69
 			self::$instance = new self;
70 70
 		}
71 71
 
@@ -101,20 +101,20 @@  discard block
 block discarded – undo
101 101
 	function delete_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
102 102
 
103 103
 		// Always a link, never a filter
104
-		unset( $field_options['show_as_link'], $field_options['search_filter'] );
104
+		unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] );
105 105
 
106 106
 		// Delete Entry link should only appear to visitors capable of editing entries
107
-		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
107
+		unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] );
108 108
 
109
-		$add_option['delete_link'] = array(
109
+		$add_option[ 'delete_link' ] = array(
110 110
 			'type' => 'text',
111 111
 			'label' => __( 'Delete Link Text', 'gravityview' ),
112 112
 			'desc' => NULL,
113
-			'value' => __('Delete Entry', 'gravityview'),
113
+			'value' => __( 'Delete Entry', 'gravityview' ),
114 114
 			'merge_tags' => true,
115 115
 		);
116 116
 
117
-		$field_options['allow_edit_cap'] = array(
117
+		$field_options[ 'allow_edit_cap' ] = array(
118 118
 			'type' => 'select',
119 119
 			'label' => __( 'Allow the following users to delete the entry:', 'gravityview' ),
120 120
 			'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
140 140
 
141
-		$entry_default_fields['delete_link'] = array(
142
-			'label' => __('Delete Entry', 'gravityview'),
141
+		$entry_default_fields[ 'delete_link' ] = array(
142
+			'label' => __( 'Delete Entry', 'gravityview' ),
143 143
 			'type' => 'delete_link',
144
-			'desc'	=> __('A link to delete the entry. Respects the Delete Entry permissions.', 'gravityview'),
144
+			'desc'	=> __( 'A link to delete the entry. Respects the Delete Entry permissions.', 'gravityview' ),
145 145
 		);
146 146
 
147 147
 		return $entry_default_fields;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	function add_available_field( $available_fields = array() ) {
156 156
 
157
-		$available_fields['delete_link'] = array(
157
+		$available_fields[ 'delete_link' ] = array(
158 158
 			'label_text' => __( 'Delete Entry', 'gravityview' ),
159 159
 			'field_id' => 'delete_link',
160 160
 			'label_type' => 'field',
@@ -182,12 +182,12 @@  discard block
 block discarded – undo
182 182
 		$caps = $visibility_caps;
183 183
 
184 184
 		// If we're configuring fields in the edit context, we want a limited selection
185
-		if( $field_id === 'delete_link' ) {
185
+		if ( $field_id === 'delete_link' ) {
186 186
 
187 187
 			// Remove other built-in caps.
188
-			unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
188
+			unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] );
189 189
 
190
-			$caps['read'] = _x('Entry Creator', 'User capability', 'gravityview');
190
+			$caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' );
191 191
 		}
192 192
 
193 193
 		return $caps;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @param [type] $entry [description]
201 201
 	 */
202 202
 	function set_entry( $entry = null ) {
203
-		$this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[0] : $entry;
203
+		$this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[ 0 ] : $entry;
204 204
 	}
205 205
 
206 206
 	/**
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
 
231 231
         $base = GravityView_API::directory_link( $post_id, true );
232 232
 
233
-		if( empty( $base ) ) {
234
-			do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id );
233
+		if ( empty( $base ) ) {
234
+			do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: ' . $post_id );
235 235
 			return NULL;
236 236
 		}
237 237
 
238 238
 		// Use the slug instead of the ID for consistent security
239
-		$entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry );
239
+		$entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry );
240 240
 
241 241
         $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id;
242 242
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
             'view_id' => $view_id,
248 248
 		), $base );
249 249
 
250
-		$url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' );
250
+		$url = wp_nonce_url( $actionurl, 'delete_' . $entry_slug, 'delete' );
251 251
 
252 252
 		return $url;
253 253
 	}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	function add_delete_button( $form = array(), $entry = array(), $view_id = NULL ) {
265 265
 
266 266
 		// Only show the link to those who are allowed to see it.
267
-		if( !self::check_user_cap_delete_entry( $entry ) ) {
267
+		if ( ! self::check_user_cap_delete_entry( $entry ) ) {
268 268
 			return;
269 269
 		}
270 270
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 		$show_delete_button = apply_filters( 'gravityview/delete-entry/show-delete-button', true );
276 276
 
277 277
 		// If the button is hidden by the filter, don't show.
278
-		if( !$show_delete_button ) {
278
+		if ( ! $show_delete_button ) {
279 279
 			return;
280 280
 		}
281 281
 
@@ -305,24 +305,24 @@  discard block
 block discarded – undo
305 305
 	function process_delete() {
306 306
 
307 307
 		// If the form is submitted
308
-		if( RGForms::get("action") === "delete") {
308
+		if ( RGForms::get( "action" ) === "delete" ) {
309 309
 
310
-			$nonce_key = self::get_nonce_key( $_GET['entry_id'] );
310
+			$nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] );
311 311
 
312 312
 			// Make sure it's a valid request
313 313
 			check_admin_referer( $nonce_key, 'delete' );
314 314
 
315 315
 			// Get the entry slug
316
-			$entry_slug = esc_attr( $_GET['entry_id'] );
316
+			$entry_slug = esc_attr( $_GET[ 'entry_id' ] );
317 317
 
318 318
 			// See if there's an entry there
319 319
 			$entry = gravityview_get_entry( $entry_slug );
320 320
 
321
-			if( $entry ) {
321
+			if ( $entry ) {
322 322
 
323 323
 				$has_permission = $this->user_can_delete_entry( $entry );
324 324
 
325
-				if( is_wp_error( $has_permission ) ) {
325
+				if ( is_wp_error( $has_permission ) ) {
326 326
 
327 327
 					$messages = array(
328 328
 						'message' => urlencode( $has_permission->get_error_message() ),
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
 				} else {
333 333
 
334 334
 					// Delete the entry
335
-					$delete_response = $this->delete_or_trash_entry( $entry['id'] );
335
+					$delete_response = $this->delete_or_trash_entry( $entry[ 'id' ] );
336 336
 
337
-					if( is_wp_error( $delete_response ) ) {
337
+					if ( is_wp_error( $delete_response ) ) {
338 338
 
339 339
 						$messages = array(
340 340
 							'message' => urlencode( $delete_response->get_error_message() ),
@@ -353,10 +353,10 @@  discard block
 block discarded – undo
353 353
 
354 354
 			} else {
355 355
 
356
-				do_action('gravityview_log_debug', __METHOD__ . ' Delete entry failed: there was no entry with the entry slug '. $entry_slug );
356
+				do_action( 'gravityview_log_debug', __METHOD__ . ' Delete entry failed: there was no entry with the entry slug ' . $entry_slug );
357 357
 
358 358
 				$messages = array(
359
-					'message' => urlencode( __('The entry does not exist.', 'gravityview') ),
359
+					'message' => urlencode( __( 'The entry does not exist.', 'gravityview' ) ),
360 360
 					'status' => 'error',
361 361
 				);
362 362
 			}
@@ -398,14 +398,14 @@  discard block
 block discarded – undo
398 398
 
399 399
 		$mode = $this->get_delete_mode();
400 400
 
401
-		if( 'delete' === $mode ) {
401
+		if ( 'delete' === $mode ) {
402 402
 
403 403
 			do_action( 'gravityview_log_debug', __METHOD__ . ' Starting delete entry: ', $entry_id );
404 404
 
405 405
 			// Delete the entry
406 406
 			$delete_response = GFAPI::delete_entry( $entry_id );
407 407
 
408
-			if( ! is_wp_error( $delete_response ) ) {
408
+			if ( ! is_wp_error( $delete_response ) ) {
409 409
 				$delete_response = 'deleted';
410 410
 			}
411 411
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 			$trashed = GFAPI::update_entry_property( $entry_id, 'status', 'trash' );
419 419
 			new GravityView_Cache;
420 420
 
421
-			if( ! $trashed ) {
422
-				$delete_response = new WP_Error( 'trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview' ) );
421
+			if ( ! $trashed ) {
422
+				$delete_response = new WP_Error( 'trash_entry_failed', __( 'Moving the entry to the trash failed.', 'gravityview' ) );
423 423
 			} else {
424 424
 				$delete_response = 'trashed';
425 425
 			}
@@ -439,13 +439,13 @@  discard block
 block discarded – undo
439 439
 	public function verify_nonce() {
440 440
 
441 441
 		// No delete entry request was made
442
-		if( empty( $_GET['entry_id'] ) || empty( $_GET['delete'] ) ) {
442
+		if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'delete' ] ) ) {
443 443
 			return false;
444 444
 		}
445 445
 
446
-		$nonce_key = self::get_nonce_key( $_GET['entry_id'] );
446
+		$nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] );
447 447
 
448
-		$valid = wp_verify_nonce( $_GET['delete'], $nonce_key );
448
+		$valid = wp_verify_nonce( $_GET[ 'delete' ], $nonce_key );
449 449
 
450 450
 		/**
451 451
 		 * @filter `gravityview/delete-entry/verify_nonce` Override Delete Entry nonce validation. Return true to declare nonce valid.
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 */
468 468
 	public static function get_confirm_dialog() {
469 469
 
470
-		$confirm = __('Are you sure you want to delete this entry? This cannot be undone.', 'gravityview');
470
+		$confirm = __( 'Are you sure you want to delete this entry? This cannot be undone.', 'gravityview' );
471 471
 
472 472
 		/**
473 473
 		 * @filter `gravityview/delete-entry/confirm-text` Modify the Delete Entry Javascript confirmation text
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 		 */
476 476
 		$confirm = apply_filters( 'gravityview/delete-entry/confirm-text', $confirm );
477 477
 
478
-		return 'return window.confirm(\''. esc_js( $confirm ) .'\');';
478
+		return 'return window.confirm(\'' . esc_js( $confirm ) . '\');';
479 479
 	}
480 480
 
481 481
 	/**
@@ -493,16 +493,16 @@  discard block
 block discarded – undo
493 493
 
494 494
 		$error = NULL;
495 495
 
496
-		if( ! $this->verify_nonce() ) {
497
-			$error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview');
496
+		if ( ! $this->verify_nonce() ) {
497
+			$error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview' );
498 498
 		}
499 499
 
500
-		if( ! self::check_user_cap_delete_entry( $entry ) ) {
501
-			$error = __( 'You do not have permission to delete this entry.', 'gravityview');
500
+		if ( ! self::check_user_cap_delete_entry( $entry ) ) {
501
+			$error = __( 'You do not have permission to delete this entry.', 'gravityview' );
502 502
 		}
503 503
 
504
-		if( $entry['status'] === 'trash' ) {
505
-			if( 'trash' === $this->get_delete_mode() ) {
504
+		if ( $entry[ 'status' ] === 'trash' ) {
505
+			if ( 'trash' === $this->get_delete_mode() ) {
506 506
 				$error = __( 'The entry is already in the trash.', 'gravityview' );
507 507
 			} else {
508 508
 				$error = __( 'You cannot delete the entry; it is already in the trash.', 'gravityview' );
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
 		}
511 511
 
512 512
 		// No errors; everything's fine here!
513
-		if( empty( $error ) ) {
513
+		if ( empty( $error ) ) {
514 514
 			return true;
515 515
 		}
516 516
 
517
-		do_action('gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]' . $error );
517
+		do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]' . $error );
518 518
 
519 519
 		return new WP_Error( 'gravityview-delete-entry-permissions', $error );
520 520
 	}
@@ -536,32 +536,32 @@  discard block
 block discarded – undo
536 536
 
537 537
 		$current_user = wp_get_current_user();
538 538
 
539
-		$entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL;
539
+		$entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL;
540 540
 
541 541
 		// Or if they can delete any entries (as defined in Gravity Forms), we're good.
542
-		if( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) {
542
+		if ( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) {
543 543
 
544
-			do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' );
544
+			do_action( 'gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' );
545 545
 
546 546
 			return true;
547 547
 		}
548 548
 
549 549
 
550 550
 		// If field options are passed, check if current user can view the link
551
-		if( !empty( $field ) ) {
551
+		if ( ! empty( $field ) ) {
552 552
 
553 553
 			// If capability is not defined, something is not right!
554
-			if( empty( $field['allow_edit_cap'] ) ) {
554
+			if ( empty( $field[ 'allow_edit_cap' ] ) ) {
555 555
 
556 556
 				do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Cannot read delete entry field caps', $field );
557 557
 
558 558
 				return false;
559 559
 			}
560 560
 
561
-			if( GVCommon::has_cap( $field['allow_edit_cap'] ) ) {
561
+			if ( GVCommon::has_cap( $field[ 'allow_edit_cap' ] ) ) {
562 562
 
563 563
 				// Do not return true if cap is read, as we need to check if the current user created the entry
564
-				if( $field['allow_edit_cap'] !== 'read' ) {
564
+				if ( $field[ 'allow_edit_cap' ] !== 'read' ) {
565 565
 					return true;
566 566
 				}
567 567
 
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
 
575 575
 		}
576 576
 
577
-		if( !isset( $entry['created_by'] ) ) {
577
+		if ( ! isset( $entry[ 'created_by' ] ) ) {
578 578
 
579
-			do_action('gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.');
579
+			do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.' );
580 580
 
581 581
 			return false;
582 582
 		}
@@ -584,24 +584,24 @@  discard block
 block discarded – undo
584 584
 		$view_id = empty( $view_id ) ? $gravityview_view->getViewId() : $view_id;
585 585
 
586 586
 		// Only checks user_delete view option if view is already set
587
-		if( $view_id ) {
587
+		if ( $view_id ) {
588 588
 
589 589
 			$current_view = gravityview_get_current_view_data( $view_id );
590 590
 
591
-			$user_delete = isset( $current_view['atts']['user_delete'] ) ? $current_view['atts']['user_delete'] : false;
591
+			$user_delete = isset( $current_view[ 'atts' ][ 'user_delete' ] ) ? $current_view[ 'atts' ][ 'user_delete' ] : false;
592 592
 
593
-			if( empty( $user_delete ) ) {
593
+			if ( empty( $user_delete ) ) {
594 594
 
595
-				do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.' );
595
+				do_action( 'gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.' );
596 596
 
597 597
 				return false;
598 598
 			}
599 599
 		}
600 600
 
601 601
 		// If the logged-in user is the same as the user who created the entry, we're good.
602
-		if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
602
+		if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) {
603 603
 
604
-			do_action('gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID ) );
604
+			do_action( 'gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID ) );
605 605
 
606 606
 			return true;
607 607
 		}
@@ -624,31 +624,31 @@  discard block
 block discarded – undo
624 624
 	 */
625 625
 	public function display_message( $current_view_id = 0 ) {
626 626
 
627
-		if( empty( $_GET['status'] ) || ! self::verify_nonce() ) {
627
+		if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) {
628 628
 			return;
629 629
 		}
630 630
 
631 631
 		// Entry wasn't deleted from current View
632
-		if( intval( $_GET['gvid'] ) !== intval( $current_view_id ) ) {
632
+		if ( intval( $_GET[ 'gvid' ] ) !== intval( $current_view_id ) ) {
633 633
 			return;
634 634
 		}
635 635
 
636
-		$status = esc_attr( $_GET['status'] );
637
-		$message_from_url = rgget('message');
636
+		$status = esc_attr( $_GET[ 'status' ] );
637
+		$message_from_url = rgget( 'message' );
638 638
 		$message_from_url = urldecode( stripslashes_deep( $message_from_url ) );
639 639
 		$class = '';
640 640
 
641 641
 		switch ( $status ) {
642 642
 			case 'error':
643 643
 				$class = ' gv-error error';
644
-				$error_message = __('There was an error deleting the entry: %s', 'gravityview');
644
+				$error_message = __( 'There was an error deleting the entry: %s', 'gravityview' );
645 645
 				$message = sprintf( $error_message, $message_from_url );
646 646
 				break;
647 647
 			case 'trashed':
648
-				$message = __('The entry was successfully moved to the trash.', 'gravityview');
648
+				$message = __( 'The entry was successfully moved to the trash.', 'gravityview' );
649 649
 				break;
650 650
 			default:
651
-				$message = __('The entry was successfully deleted.', 'gravityview');
651
+				$message = __( 'The entry was successfully deleted.', 'gravityview' );
652 652
 				break;
653 653
 		}
654 654
 
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 		$message = apply_filters( 'gravityview/delete-entry/message', esc_attr( $message ), $status, $message_from_url );
663 663
 
664 664
 		// DISPLAY ERROR/SUCCESS MESSAGE
665
-		echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>';
665
+		echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>';
666 666
 	}
667 667
 
668 668
 
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-admin.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,6 @@
 block discarded – undo
69 69
      * Change wording for the Edit context to read Entry Creator
70 70
      *
71 71
      * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
-     * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73 72
      * @param  string      $template_id Table slug
74 73
      * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75 74
      * @param  string      $context     What context are we in? Example: `single` or `directory`
Please login to merge, or discard this patch.
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -10,175 +10,175 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 if ( ! defined( 'WPINC' ) ) {
13
-    die;
13
+	die;
14 14
 }
15 15
 
16 16
 
17 17
 class GravityView_Edit_Entry_Admin {
18 18
 
19
-    protected $loader;
19
+	protected $loader;
20 20
 
21
-    function __construct( GravityView_Edit_Entry $loader ) {
22
-        $this->loader = $loader;
23
-    }
21
+	function __construct( GravityView_Edit_Entry $loader ) {
22
+		$this->loader = $loader;
23
+	}
24 24
 
25
-    function load() {
26
-
27
-        if( !is_admin() ) {
28
-            return;
29
-        }
30
-
31
-        // Add Edit Link as a default field, outside those set in the Gravity Form form
32
-        add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
33
-
34
-        // For the Edit Entry Link, you don't want visible to all users.
35
-        add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
25
+	function load() {
26
+
27
+		if( !is_admin() ) {
28
+			return;
29
+		}
30
+
31
+		// Add Edit Link as a default field, outside those set in the Gravity Form form
32
+		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
33
+
34
+		// For the Edit Entry Link, you don't want visible to all users.
35
+		add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
36 36
 
37
-        // Modify the field options based on the name of the field type
38
-        add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
37
+		// Modify the field options based on the name of the field type
38
+		add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
39 39
 
40
-        // add tooltips
41
-        add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
42
-
43
-        // custom fields' options for zone EDIT
44
-        add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
45
-    }
46
-
47
-    /**
48
-     * Add Edit Link as a default field, outside those set in the Gravity Form form
49
-     * @param array $entry_default_fields Existing fields
50
-     * @param  string|array $form form_ID or form object
51
-     * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
52
-     */
53
-    function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54
-
55
-        if( $zone !== 'edit' ) {
56
-
57
-            $entry_default_fields['edit_link'] = array(
58
-                'label' => __('Edit Entry', 'gravityview'),
59
-                'type' => 'edit_link',
60
-                'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
61
-            );
62
-
63
-        }
64
-
65
-        return $entry_default_fields;
66
-    }
67
-
68
-    /**
69
-     * Change wording for the Edit context to read Entry Creator
70
-     *
71
-     * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
-     * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73
-     * @param  string      $template_id Table slug
74
-     * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75
-     * @param  string      $context     What context are we in? Example: `single` or `directory`
76
-     * @param  string      $input_type  (textarea, list, select, etc.)
77
-     * @return array                   Array of field options with `label`, `value`, `type`, `default` keys
78
-     */
79
-    function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
80
-
81
-        $caps = $visibility_caps;
82
-
83
-        // If we're configuring fields in the edit context, we want a limited selection
84
-        if( $context === 'edit' ) {
85
-
86
-            // Remove other built-in caps.
87
-            unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
88
-
89
-            $caps['read'] = _x('Entry Creator','User capability', 'gravityview');
90
-        }
91
-
92
-        return $caps;
93
-    }
94
-
95
-    /**
96
-     * Add "Edit Link Text" setting to the edit_link field settings
97
-     * @param  [type] $field_options [description]
98
-     * @param  [type] $template_id   [description]
99
-     * @param  [type] $field_id      [description]
100
-     * @param  [type] $context       [description]
101
-     * @param  [type] $input_type    [description]
102
-     * @return [type]                [description]
103
-     */
104
-    function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105
-
106
-        // Always a link, never a filter
107
-        unset( $field_options['show_as_link'], $field_options['search_filter'] );
108
-
109
-        // Edit Entry link should only appear to visitors capable of editing entries
110
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
111
-
112
-        $add_option['edit_link'] = array(
113
-            'type' => 'text',
114
-            'label' => __( 'Edit Link Text', 'gravityview' ),
115
-            'desc' => NULL,
116
-            'value' => __('Edit Entry', 'gravityview'),
117
-            'merge_tags' => true,
118
-        );
119
-
120
-        return array_merge( $add_option, $field_options );
121
-    }
122
-
123
-    /**
124
-     * Add tooltips
125
-     * @param  array $tooltips Existing tooltips
126
-     * @return array           Modified tooltips
127
-     */
128
-    function tooltips( $tooltips ) {
129
-
130
-        $return = $tooltips;
131
-
132
-        $return['allow_edit_cap'] = array(
133
-            'title' => __('Limiting Edit Access', 'gravityview'),
134
-            'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
135
-        );
136
-
137
-        return $return;
138
-    }
139
-
140
-    /**
141
-     * Manipulate the fields' options for the EDIT ENTRY screen
142
-     * @param  [type] $field_options [description]
143
-     * @param  [type] $template_id   [description]
144
-     * @param  [type] $field_id      [description]
145
-     * @param  [type] $context       [description]
146
-     * @param  [type] $input_type    [description]
147
-     * @return [type]                [description]
148
-     */
149
-    function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150
-
151
-        // We only want to modify the settings for the edit context
152
-        if( 'edit' !== $context ) {
153
-
154
-            /**
155
-             * @since 1.8.4
156
-             */
157
-            $field_options['new_window'] = array(
158
-                'type' => 'checkbox',
159
-                'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160
-                'value' => false,
161
-            );
162
-
163
-            return $field_options;
164
-        }
165
-
166
-        //  Entry field is only for logged in users
167
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
168
-
169
-        $add_options = array(
170
-            'allow_edit_cap' => array(
171
-                'type' => 'select',
172
-                'label' => __( 'Make field editable to:', 'gravityview' ),
173
-                'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
174
-                'tooltip' => 'allow_edit_cap',
175
-                'class' => 'widefat',
176
-                'value' => 'read', // Default: entry creator
177
-            ),
178
-        );
179
-
180
-        return array_merge( $field_options, $add_options );
181
-    }
40
+		// add tooltips
41
+		add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
42
+
43
+		// custom fields' options for zone EDIT
44
+		add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
45
+	}
46
+
47
+	/**
48
+	 * Add Edit Link as a default field, outside those set in the Gravity Form form
49
+	 * @param array $entry_default_fields Existing fields
50
+	 * @param  string|array $form form_ID or form object
51
+	 * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
52
+	 */
53
+	function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54
+
55
+		if( $zone !== 'edit' ) {
56
+
57
+			$entry_default_fields['edit_link'] = array(
58
+				'label' => __('Edit Entry', 'gravityview'),
59
+				'type' => 'edit_link',
60
+				'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
61
+			);
62
+
63
+		}
64
+
65
+		return $entry_default_fields;
66
+	}
67
+
68
+	/**
69
+	 * Change wording for the Edit context to read Entry Creator
70
+	 *
71
+	 * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
+	 * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73
+	 * @param  string      $template_id Table slug
74
+	 * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75
+	 * @param  string      $context     What context are we in? Example: `single` or `directory`
76
+	 * @param  string      $input_type  (textarea, list, select, etc.)
77
+	 * @return array                   Array of field options with `label`, `value`, `type`, `default` keys
78
+	 */
79
+	function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
80
+
81
+		$caps = $visibility_caps;
82
+
83
+		// If we're configuring fields in the edit context, we want a limited selection
84
+		if( $context === 'edit' ) {
85
+
86
+			// Remove other built-in caps.
87
+			unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
88
+
89
+			$caps['read'] = _x('Entry Creator','User capability', 'gravityview');
90
+		}
91
+
92
+		return $caps;
93
+	}
94
+
95
+	/**
96
+	 * Add "Edit Link Text" setting to the edit_link field settings
97
+	 * @param  [type] $field_options [description]
98
+	 * @param  [type] $template_id   [description]
99
+	 * @param  [type] $field_id      [description]
100
+	 * @param  [type] $context       [description]
101
+	 * @param  [type] $input_type    [description]
102
+	 * @return [type]                [description]
103
+	 */
104
+	function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105
+
106
+		// Always a link, never a filter
107
+		unset( $field_options['show_as_link'], $field_options['search_filter'] );
108
+
109
+		// Edit Entry link should only appear to visitors capable of editing entries
110
+		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
111
+
112
+		$add_option['edit_link'] = array(
113
+			'type' => 'text',
114
+			'label' => __( 'Edit Link Text', 'gravityview' ),
115
+			'desc' => NULL,
116
+			'value' => __('Edit Entry', 'gravityview'),
117
+			'merge_tags' => true,
118
+		);
119
+
120
+		return array_merge( $add_option, $field_options );
121
+	}
122
+
123
+	/**
124
+	 * Add tooltips
125
+	 * @param  array $tooltips Existing tooltips
126
+	 * @return array           Modified tooltips
127
+	 */
128
+	function tooltips( $tooltips ) {
129
+
130
+		$return = $tooltips;
131
+
132
+		$return['allow_edit_cap'] = array(
133
+			'title' => __('Limiting Edit Access', 'gravityview'),
134
+			'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
135
+		);
136
+
137
+		return $return;
138
+	}
139
+
140
+	/**
141
+	 * Manipulate the fields' options for the EDIT ENTRY screen
142
+	 * @param  [type] $field_options [description]
143
+	 * @param  [type] $template_id   [description]
144
+	 * @param  [type] $field_id      [description]
145
+	 * @param  [type] $context       [description]
146
+	 * @param  [type] $input_type    [description]
147
+	 * @return [type]                [description]
148
+	 */
149
+	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150
+
151
+		// We only want to modify the settings for the edit context
152
+		if( 'edit' !== $context ) {
153
+
154
+			/**
155
+			 * @since 1.8.4
156
+			 */
157
+			$field_options['new_window'] = array(
158
+				'type' => 'checkbox',
159
+				'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160
+				'value' => false,
161
+			);
162
+
163
+			return $field_options;
164
+		}
165
+
166
+		//  Entry field is only for logged in users
167
+		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
168
+
169
+		$add_options = array(
170
+			'allow_edit_cap' => array(
171
+				'type' => 'select',
172
+				'label' => __( 'Make field editable to:', 'gravityview' ),
173
+				'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
174
+				'tooltip' => 'allow_edit_cap',
175
+				'class' => 'widefat',
176
+				'value' => 'read', // Default: entry creator
177
+			),
178
+		);
179
+
180
+		return array_merge( $field_options, $add_options );
181
+	}
182 182
 
183 183
 
184 184
 } // end class
185 185
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     function load() {
26 26
 
27
-        if( !is_admin() ) {
27
+        if ( ! is_admin() ) {
28 28
             return;
29 29
         }
30 30
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
39 39
 
40 40
         // add tooltips
41
-        add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
41
+        add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) );
42 42
 
43 43
         // custom fields' options for zone EDIT
44 44
         add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
      */
53 53
     function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54 54
 
55
-        if( $zone !== 'edit' ) {
55
+        if ( $zone !== 'edit' ) {
56 56
 
57
-            $entry_default_fields['edit_link'] = array(
58
-                'label' => __('Edit Entry', 'gravityview'),
57
+            $entry_default_fields[ 'edit_link' ] = array(
58
+                'label' => __( 'Edit Entry', 'gravityview' ),
59 59
                 'type' => 'edit_link',
60
-                'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
60
+                'desc'	=> __( 'A link to edit the entry. Visible based on View settings.', 'gravityview' ),
61 61
             );
62 62
 
63 63
         }
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
         $caps = $visibility_caps;
82 82
 
83 83
         // If we're configuring fields in the edit context, we want a limited selection
84
-        if( $context === 'edit' ) {
84
+        if ( $context === 'edit' ) {
85 85
 
86 86
             // Remove other built-in caps.
87
-            unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
87
+            unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] );
88 88
 
89
-            $caps['read'] = _x('Entry Creator','User capability', 'gravityview');
89
+            $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' );
90 90
         }
91 91
 
92 92
         return $caps;
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
     function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105 105
 
106 106
         // Always a link, never a filter
107
-        unset( $field_options['show_as_link'], $field_options['search_filter'] );
107
+        unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] );
108 108
 
109 109
         // Edit Entry link should only appear to visitors capable of editing entries
110
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
110
+        unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] );
111 111
 
112
-        $add_option['edit_link'] = array(
112
+        $add_option[ 'edit_link' ] = array(
113 113
             'type' => 'text',
114 114
             'label' => __( 'Edit Link Text', 'gravityview' ),
115 115
             'desc' => NULL,
116
-            'value' => __('Edit Entry', 'gravityview'),
116
+            'value' => __( 'Edit Entry', 'gravityview' ),
117 117
             'merge_tags' => true,
118 118
         );
119 119
 
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
 
130 130
         $return = $tooltips;
131 131
 
132
-        $return['allow_edit_cap'] = array(
133
-            'title' => __('Limiting Edit Access', 'gravityview'),
134
-            'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
132
+        $return[ 'allow_edit_cap' ] = array(
133
+            'title' => __( 'Limiting Edit Access', 'gravityview' ),
134
+            'value' => __( 'Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview' ),
135 135
         );
136 136
 
137 137
         return $return;
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
     function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150 150
 
151 151
         // We only want to modify the settings for the edit context
152
-        if( 'edit' !== $context ) {
152
+        if ( 'edit' !== $context ) {
153 153
 
154 154
             /**
155 155
              * @since 1.8.4
156 156
              */
157
-            $field_options['new_window'] = array(
157
+            $field_options[ 'new_window' ] = array(
158 158
                 'type' => 'checkbox',
159 159
                 'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160 160
                 'value' => false,
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         }
165 165
 
166 166
         //  Entry field is only for logged in users
167
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
167
+        unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] );
168 168
 
169 169
         $add_options = array(
170 170
             'allow_edit_cap' => array(
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-render.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1249,7 +1249,7 @@
 block discarded – undo
1249 1249
     /**
1250 1250
      * Override GF Form field properties with the ones defined on the View
1251 1251
      * @param  GF_Field $field GF Form field object
1252
-     * @param  array $setting  GV field options
1252
+     * @param  array $field_setting  GV field options
1253 1253
      * @since  1.5
1254 1254
      * @return array
1255 1255
      */
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
             // Display the success message
537 537
             if( rgpost('action') === 'update' ) {
538 538
 
539
-                if( ! $this->is_valid ){
539
+                if( ! $this->is_valid ) {
540 540
 
541 541
                     // Keeping this compatible with Gravity Forms.
542 542
                     $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
@@ -1519,9 +1519,7 @@  discard block
 block discarded – undo
1519 1519
         // Verify
1520 1520
         else if( ! $this->is_edit_entry() ) {
1521 1521
             $valid = false;
1522
-        }
1523
-
1524
-        else {
1522
+        } else {
1525 1523
             $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
1526 1524
         }
1527 1525
 
Please login to merge, or discard this patch.
Indentation   +1214 added lines, -1214 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * GravityView Edit Entry - render frontend
4
- *
5
- * @package   GravityView
6
- * @license   GPL2+
7
- * @author    Katz Web Services, Inc.
8
- * @link      http://gravityview.co
9
- * @copyright Copyright 2014, Katz Web Services, Inc.
10
- */
3
+	 * GravityView Edit Entry - render frontend
4
+	 *
5
+	 * @package   GravityView
6
+	 * @license   GPL2+
7
+	 * @author    Katz Web Services, Inc.
8
+	 * @link      http://gravityview.co
9
+	 * @copyright Copyright 2014, Katz Web Services, Inc.
10
+	 */
11 11
 
12 12
 if ( ! defined( 'WPINC' ) ) {
13
-    die;
13
+	die;
14 14
 }
15 15
 
16 16
 
17 17
 class GravityView_Edit_Entry_Render {
18 18
 
19
-    protected $loader;
19
+	protected $loader;
20 20
 
21 21
 	/**
22 22
 	 * @var string String used to generate unique nonce for the entry/form/view combination. Allows access to edit page.
23 23
 	 */
24
-    static $nonce_key;
24
+	static $nonce_key;
25 25
 
26 26
 	/**
27 27
 	 * @since 1.9
@@ -41,124 +41,124 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	private static $supports_product_fields = false;
43 43
 
44
-    /**
45
-     * Gravity Forms entry array
46
-     *
47
-     * @var array
48
-     */
49
-    var $entry;
50
-
51
-    /**
52
-     * Gravity Forms form array
53
-     *
54
-     * @var array
55
-     */
56
-    var $form;
57
-
58
-    /**
59
-     * Gravity Forms form array after the form validation process
60
-     * @since 1.13
61
-     * @var array
62
-     */
63
-    var $form_after_validation = null;
64
-
65
-    /**
66
-     * Gravity Forms form id
67
-     *
68
-     * @var array
69
-     */
70
-    var $form_id;
71
-
72
-    /**
73
-     * ID of the current view
74
-     *
75
-     * @var int
76
-     */
77
-    var $view_id;
78
-
79
-
80
-    /**
81
-     * Updated entry is valid (GF Validation object)
82
-     *
83
-     * @var array
84
-     */
85
-    var $is_valid = NULL;
86
-
87
-    function __construct( GravityView_Edit_Entry $loader ) {
88
-        $this->loader = $loader;
89
-    }
90
-
91
-    function load() {
92
-
93
-        /** @define "GRAVITYVIEW_DIR" "../../../" */
94
-        include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
95
-
96
-        // Don't display an embedded form when editing an entry
97
-        add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
98
-        add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
99
-
100
-        // Stop Gravity Forms processing what is ours!
101
-        add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
102
-
103
-        add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
104
-
105
-        add_action( 'gravityview_edit_entry', array( $this, 'init' ) );
106
-
107
-        // Disable conditional logic if needed (since 1.9)
108
-        add_filter( 'gform_has_conditional_logic', array( $this, 'manage_conditional_logic' ), 10, 2 );
109
-
110
-        // Make sure GF doesn't validate max files (since 1.9)
111
-        add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
112
-
113
-        // Add fields expected by GFFormDisplay::validate()
114
-        add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
115
-
116
-    }
117
-
118
-    /**
119
-     * Don't show any forms embedded on a page when GravityView is in Edit Entry mode
120
-     *
121
-     * Adds a `__return_empty_string` filter on the Gravity Forms shortcode on the `wp_head` action
122
-     * And then removes it on the `wp_footer` action
123
-     *
124
-     * @since 1.16.1
125
-     *
126
-     * @return void
127
-     */
128
-    function prevent_render_form() {
129
-        if( $this->is_edit_entry() ) {
130
-            if( 'wp_head' === current_filter() ) {
131
-                add_filter( 'gform_shortcode_form', '__return_empty_string' );
132
-            } else {
133
-                remove_filter( 'gform_shortcode_form', '__return_empty_string' );
134
-            }
135
-        }
136
-    }
137
-
138
-    /**
139
-     * Because we're mimicking being a front-end Gravity Forms form while using a Gravity Forms
140
-     * backend form, we need to prevent them from saving twice.
141
-     * @return void
142
-     */
143
-    function prevent_maybe_process_form() {
144
-
145
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
146
-
147
-        if( $this->is_edit_entry_submission() && $this->verify_nonce() ) {
148
-            remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
149
-        }
150
-    }
151
-
152
-    /**
153
-     * Is the current page an Edit Entry page?
154
-     * @return boolean
155
-     */
156
-    public function is_edit_entry() {
157
-
158
-        $gf_page = ( 'entry' === RGForms::get( 'view' ) );
159
-
160
-        return ( $gf_page && isset( $_GET['edit'] ) || RGForms::post( 'action' ) === 'update' );
161
-    }
44
+	/**
45
+	 * Gravity Forms entry array
46
+	 *
47
+	 * @var array
48
+	 */
49
+	var $entry;
50
+
51
+	/**
52
+	 * Gravity Forms form array
53
+	 *
54
+	 * @var array
55
+	 */
56
+	var $form;
57
+
58
+	/**
59
+	 * Gravity Forms form array after the form validation process
60
+	 * @since 1.13
61
+	 * @var array
62
+	 */
63
+	var $form_after_validation = null;
64
+
65
+	/**
66
+	 * Gravity Forms form id
67
+	 *
68
+	 * @var array
69
+	 */
70
+	var $form_id;
71
+
72
+	/**
73
+	 * ID of the current view
74
+	 *
75
+	 * @var int
76
+	 */
77
+	var $view_id;
78
+
79
+
80
+	/**
81
+	 * Updated entry is valid (GF Validation object)
82
+	 *
83
+	 * @var array
84
+	 */
85
+	var $is_valid = NULL;
86
+
87
+	function __construct( GravityView_Edit_Entry $loader ) {
88
+		$this->loader = $loader;
89
+	}
90
+
91
+	function load() {
92
+
93
+		/** @define "GRAVITYVIEW_DIR" "../../../" */
94
+		include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
95
+
96
+		// Don't display an embedded form when editing an entry
97
+		add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
98
+		add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
99
+
100
+		// Stop Gravity Forms processing what is ours!
101
+		add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
102
+
103
+		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
104
+
105
+		add_action( 'gravityview_edit_entry', array( $this, 'init' ) );
106
+
107
+		// Disable conditional logic if needed (since 1.9)
108
+		add_filter( 'gform_has_conditional_logic', array( $this, 'manage_conditional_logic' ), 10, 2 );
109
+
110
+		// Make sure GF doesn't validate max files (since 1.9)
111
+		add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
112
+
113
+		// Add fields expected by GFFormDisplay::validate()
114
+		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
115
+
116
+	}
117
+
118
+	/**
119
+	 * Don't show any forms embedded on a page when GravityView is in Edit Entry mode
120
+	 *
121
+	 * Adds a `__return_empty_string` filter on the Gravity Forms shortcode on the `wp_head` action
122
+	 * And then removes it on the `wp_footer` action
123
+	 *
124
+	 * @since 1.16.1
125
+	 *
126
+	 * @return void
127
+	 */
128
+	function prevent_render_form() {
129
+		if( $this->is_edit_entry() ) {
130
+			if( 'wp_head' === current_filter() ) {
131
+				add_filter( 'gform_shortcode_form', '__return_empty_string' );
132
+			} else {
133
+				remove_filter( 'gform_shortcode_form', '__return_empty_string' );
134
+			}
135
+		}
136
+	}
137
+
138
+	/**
139
+	 * Because we're mimicking being a front-end Gravity Forms form while using a Gravity Forms
140
+	 * backend form, we need to prevent them from saving twice.
141
+	 * @return void
142
+	 */
143
+	function prevent_maybe_process_form() {
144
+
145
+		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
146
+
147
+		if( $this->is_edit_entry_submission() && $this->verify_nonce() ) {
148
+			remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
149
+		}
150
+	}
151
+
152
+	/**
153
+	 * Is the current page an Edit Entry page?
154
+	 * @return boolean
155
+	 */
156
+	public function is_edit_entry() {
157
+
158
+		$gf_page = ( 'entry' === RGForms::get( 'view' ) );
159
+
160
+		return ( $gf_page && isset( $_GET['edit'] ) || RGForms::post( 'action' ) === 'update' );
161
+	}
162 162
 
163 163
 	/**
164 164
 	 * Is the current page an Edit Entry page?
@@ -169,422 +169,422 @@  discard block
 block discarded – undo
169 169
 		return !empty( $_POST[ self::$nonce_field ] );
170 170
 	}
171 171
 
172
-    /**
173
-     * When Edit entry view is requested setup the vars
174
-     */
175
-    function setup_vars() {
176
-        $gravityview_view = GravityView_View::getInstance();
172
+	/**
173
+	 * When Edit entry view is requested setup the vars
174
+	 */
175
+	function setup_vars() {
176
+		$gravityview_view = GravityView_View::getInstance();
177 177
 
178 178
 
179
-        $entries = $gravityview_view->getEntries();
180
-        $this->entry = $entries[0];
179
+		$entries = $gravityview_view->getEntries();
180
+		$this->entry = $entries[0];
181 181
 
182 182
 
183
-        $this->form = $gravityview_view->getForm();
184
-        $this->form_id = $gravityview_view->getFormId();
185
-        $this->view_id = $gravityview_view->getViewId();
183
+		$this->form = $gravityview_view->getForm();
184
+		$this->form_id = $gravityview_view->getFormId();
185
+		$this->view_id = $gravityview_view->getViewId();
186 186
 
187
-        self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
188
-    }
187
+		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
188
+	}
189 189
 
190 190
 
191
-    /**
192
-     * Load required files and trigger edit flow
193
-     *
194
-     * Run when the is_edit_entry returns true.
195
-     *
196
-     * @param GravityView_View_Data $gv_data GravityView Data object
197
-     * @return void
198
-     */
199
-    function init( $gv_data ) {
191
+	/**
192
+	 * Load required files and trigger edit flow
193
+	 *
194
+	 * Run when the is_edit_entry returns true.
195
+	 *
196
+	 * @param GravityView_View_Data $gv_data GravityView Data object
197
+	 * @return void
198
+	 */
199
+	function init( $gv_data ) {
200 200
 
201
-        require_once( GFCommon::get_base_path() . '/form_display.php' );
202
-        require_once( GFCommon::get_base_path() . '/entry_detail.php' );
201
+		require_once( GFCommon::get_base_path() . '/form_display.php' );
202
+		require_once( GFCommon::get_base_path() . '/entry_detail.php' );
203 203
 
204
-        $this->setup_vars();
204
+		$this->setup_vars();
205 205
 
206
-        // Multiple Views embedded, don't proceed if nonce fails
207
-        if( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) {
208
-            return;
209
-        }
206
+		// Multiple Views embedded, don't proceed if nonce fails
207
+		if( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) {
208
+			return;
209
+		}
210 210
 
211
-        // Sorry, you're not allowed here.
212
-        if( false === $this->user_can_edit_entry( true ) ) {
213
-            return;
214
-        }
211
+		// Sorry, you're not allowed here.
212
+		if( false === $this->user_can_edit_entry( true ) ) {
213
+			return;
214
+		}
215 215
 
216
-        $this->print_scripts();
216
+		$this->print_scripts();
217 217
 
218
-        $this->process_save();
218
+		$this->process_save();
219 219
 
220
-        $this->edit_entry_form();
220
+		$this->edit_entry_form();
221 221
 
222
-    }
222
+	}
223 223
 
224 224
 
225
-    /**
226
-     * Force Gravity Forms to output scripts as if it were in the admin
227
-     * @return void
228
-     */
229
-    function print_scripts() {
230
-        $gravityview_view = GravityView_View::getInstance();
225
+	/**
226
+	 * Force Gravity Forms to output scripts as if it were in the admin
227
+	 * @return void
228
+	 */
229
+	function print_scripts() {
230
+		$gravityview_view = GravityView_View::getInstance();
231 231
 
232
-        wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
232
+		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
233 233
 
234
-        GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false);
234
+		GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false);
235 235
 
236
-        // Sack is required for images
237
-        wp_print_scripts( array( 'sack', 'gform_gravityforms' ) );
238
-    }
236
+		// Sack is required for images
237
+		wp_print_scripts( array( 'sack', 'gform_gravityforms' ) );
238
+	}
239 239
 
240 240
 
241
-    /**
242
-     * Process edit entry form save
243
-     */
244
-    function process_save() {
241
+	/**
242
+	 * Process edit entry form save
243
+	 */
244
+	function process_save() {
245 245
 
246
-        if( empty( $_POST ) ) {
247
-            return;
248
-        }
246
+		if( empty( $_POST ) ) {
247
+			return;
248
+		}
249 249
 
250
-        // Make sure the entry, view, and form IDs are all correct
251
-        $valid = $this->verify_nonce();
250
+		// Make sure the entry, view, and form IDs are all correct
251
+		$valid = $this->verify_nonce();
252 252
 
253
-        if( !$valid ) {
254
-            do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' );
255
-            return;
256
-        }
253
+		if( !$valid ) {
254
+			do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' );
255
+			return;
256
+		}
257 257
 
258
-        if( $this->entry['id'] !== $_POST['lid'] ) {
259
-            do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' );
260
-            return;
261
-        }
258
+		if( $this->entry['id'] !== $_POST['lid'] ) {
259
+			do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' );
260
+			return;
261
+		}
262 262
 
263
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
263
+		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
264 264
 
265
-        $this->process_save_process_files( $this->form_id );
265
+		$this->process_save_process_files( $this->form_id );
266 266
 
267
-        $this->validate();
267
+		$this->validate();
268 268
 
269
-        if( $this->is_valid ) {
269
+		if( $this->is_valid ) {
270 270
 
271
-            do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' );
271
+			do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' );
272 272
 
273
-            /**
274
-             * @hack This step is needed to unset the adminOnly from form fields
275
-             */
276
-            $form = $this->form_prepare_for_save();
273
+			/**
274
+			 * @hack This step is needed to unset the adminOnly from form fields
275
+			 */
276
+			$form = $this->form_prepare_for_save();
277 277
 
278
-            /**
279
-             * @hack to avoid the capability validation of the method save_lead for GF 1.9+
280
-             */
281
-            unset( $_GET['page'] );
278
+			/**
279
+			 * @hack to avoid the capability validation of the method save_lead for GF 1.9+
280
+			 */
281
+			unset( $_GET['page'] );
282 282
 
283
-            GFFormsModel::save_lead( $form, $this->entry );
283
+			GFFormsModel::save_lead( $form, $this->entry );
284 284
 
285
-            // If there's a post associated with the entry, process post fields
286
-            if( !empty( $this->entry['post_id'] ) ) {
287
-                $this->maybe_update_post_fields( $form );
288
-            }
285
+			// If there's a post associated with the entry, process post fields
286
+			if( !empty( $this->entry['post_id'] ) ) {
287
+				$this->maybe_update_post_fields( $form );
288
+			}
289 289
 
290
-            // Perform actions normally performed after updating a lead
291
-            $this->after_update();
290
+			// Perform actions normally performed after updating a lead
291
+			$this->after_update();
292 292
 
293
-            /**
294
-             * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry
295
-             * @param array $form Gravity Forms form array
296
-             * @param string $entry_id Numeric ID of the entry that was updated
297
-             */
298
-            do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] );
299
-        }
293
+			/**
294
+			 * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry
295
+			 * @param array $form Gravity Forms form array
296
+			 * @param string $entry_id Numeric ID of the entry that was updated
297
+			 */
298
+			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] );
299
+		}
300 300
 
301
-    } // process_save
301
+	} // process_save
302 302
 
303 303
 
304
-    /**
305
-     * Have GF handle file uploads
306
-     *
307
-     * Copy of code from GFFormDisplay::process_form()
308
-     *
309
-     * @param int $form_id
310
-     */
311
-    function process_save_process_files( $form_id ) {
304
+	/**
305
+	 * Have GF handle file uploads
306
+	 *
307
+	 * Copy of code from GFFormDisplay::process_form()
308
+	 *
309
+	 * @param int $form_id
310
+	 */
311
+	function process_save_process_files( $form_id ) {
312 312
 
313
-        //Loading files that have been uploaded to temp folder
314
-        $files = GFCommon::json_decode( stripslashes( RGForms::post( 'gform_uploaded_files' ) ) );
315
-        if ( ! is_array( $files ) ) {
316
-            $files = array();
317
-        }
313
+		//Loading files that have been uploaded to temp folder
314
+		$files = GFCommon::json_decode( stripslashes( RGForms::post( 'gform_uploaded_files' ) ) );
315
+		if ( ! is_array( $files ) ) {
316
+			$files = array();
317
+		}
318 318
 
319
-        RGFormsModel::$uploaded_files[ $form_id ] = $files;
320
-    }
319
+		RGFormsModel::$uploaded_files[ $form_id ] = $files;
320
+	}
321 321
 
322
-    /**
323
-     * Remove max_files validation (done on gravityforms.js) to avoid conflicts with GravityView
324
-     * Late validation done on self::custom_validation
325
-     *
326
-     * @param $plupload_init array Plupload settings
327
-     * @param $form_id
328
-     * @param $instance
329
-     * @return mixed
330
-     */
331
-    public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
332
-        if( ! $this->is_edit_entry() ) {
333
-            return $plupload_init;
334
-        }
322
+	/**
323
+	 * Remove max_files validation (done on gravityforms.js) to avoid conflicts with GravityView
324
+	 * Late validation done on self::custom_validation
325
+	 *
326
+	 * @param $plupload_init array Plupload settings
327
+	 * @param $form_id
328
+	 * @param $instance
329
+	 * @return mixed
330
+	 */
331
+	public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
332
+		if( ! $this->is_edit_entry() ) {
333
+			return $plupload_init;
334
+		}
335 335
 
336
-        $plupload_init['gf_vars']['max_files'] = 0;
336
+		$plupload_init['gf_vars']['max_files'] = 0;
337 337
 
338
-        return $plupload_init;
339
-    }
338
+		return $plupload_init;
339
+	}
340 340
 
341 341
 
342
-    /**
343
-     * Unset adminOnly and convert field input key to string
344
-     * @return array $form
345
-     */
346
-    private function form_prepare_for_save() {
347
-        $form = $this->form;
342
+	/**
343
+	 * Unset adminOnly and convert field input key to string
344
+	 * @return array $form
345
+	 */
346
+	private function form_prepare_for_save() {
347
+		$form = $this->form;
348 348
 
349
-        foreach( $form['fields'] as &$field ) {
349
+		foreach( $form['fields'] as &$field ) {
350 350
 
351
-            $field->adminOnly = false;
351
+			$field->adminOnly = false;
352 352
 
353
-            if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
354
-                foreach( $field->inputs as $key => $input ) {
355
-                    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
356
-                }
357
-            }
358
-        }
353
+			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
354
+				foreach( $field->inputs as $key => $input ) {
355
+					$field->inputs[ $key ][ 'id' ] = (string)$input['id'];
356
+				}
357
+			}
358
+		}
359 359
 
360
-        return $form;
361
-    }
360
+		return $form;
361
+	}
362 362
 
363 363
 
364
-    /**
365
-     * Loop through the fields being edited and if they include Post fields, update the Entry's post object
366
-     *
367
-     * @param array $form Gravity Forms form
368
-     *
369
-     * @return void
370
-     */
371
-    function maybe_update_post_fields( $form ) {
364
+	/**
365
+	 * Loop through the fields being edited and if they include Post fields, update the Entry's post object
366
+	 *
367
+	 * @param array $form Gravity Forms form
368
+	 *
369
+	 * @return void
370
+	 */
371
+	function maybe_update_post_fields( $form ) {
372 372
 
373
-        $post_id = $this->entry['post_id'];
373
+		$post_id = $this->entry['post_id'];
374 374
 
375
-        // Security check
376
-        if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
377
-            do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id );
378
-            return;
379
-        }
375
+		// Security check
376
+		if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
377
+			do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id );
378
+			return;
379
+		}
380 380
 
381
-        $update_entry = false;
381
+		$update_entry = false;
382 382
 
383
-        $updated_post = $original_post = get_post( $post_id );
383
+		$updated_post = $original_post = get_post( $post_id );
384 384
 
385
-        foreach ( $this->entry as $field_id => $value ) {
385
+		foreach ( $this->entry as $field_id => $value ) {
386 386
 
387
-            //todo: only run through the edit entry configured fields
387
+			//todo: only run through the edit entry configured fields
388 388
 
389
-            $field = RGFormsModel::get_field( $form, $field_id );
389
+			$field = RGFormsModel::get_field( $form, $field_id );
390 390
 
391
-            if( class_exists('GF_Fields') ) {
392
-                $field = GF_Fields::create( $field );
393
-            }
391
+			if( class_exists('GF_Fields') ) {
392
+				$field = GF_Fields::create( $field );
393
+			}
394 394
 
395
-            if( GFCommon::is_post_field( $field ) ) {
395
+			if( GFCommon::is_post_field( $field ) ) {
396 396
 
397
-                // Get the value of the field, including $_POSTed value
398
-                $value = RGFormsModel::get_field_value( $field );
397
+				// Get the value of the field, including $_POSTed value
398
+				$value = RGFormsModel::get_field_value( $field );
399 399
 
400
-                // Convert the field object in 1.9 to an array for backward compatibility
401
-                $field_array = GVCommon::get_field_array( $field );
400
+				// Convert the field object in 1.9 to an array for backward compatibility
401
+				$field_array = GVCommon::get_field_array( $field );
402 402
 
403
-                switch( $field_array['type'] ) {
403
+				switch( $field_array['type'] ) {
404 404
 
405
-                    case 'post_title':
406
-                    case 'post_content':
407
-                    case 'post_excerpt':
408
-                        $updated_post->{$field_array['type']} = $value;
409
-                        break;
410
-                    case 'post_tags':
411
-                        wp_set_post_tags( $post_id, $value, false );
412
-                        break;
413
-                    case 'post_category':
405
+					case 'post_title':
406
+					case 'post_content':
407
+					case 'post_excerpt':
408
+						$updated_post->{$field_array['type']} = $value;
409
+						break;
410
+					case 'post_tags':
411
+						wp_set_post_tags( $post_id, $value, false );
412
+						break;
413
+					case 'post_category':
414 414
 
415
-                        $categories = is_array( $value ) ? array_values( $value ) : (array)$value;
416
-                        $categories = array_filter( $categories );
415
+						$categories = is_array( $value ) ? array_values( $value ) : (array)$value;
416
+						$categories = array_filter( $categories );
417 417
 
418
-                        wp_set_post_categories( $post_id, $categories, false );
418
+						wp_set_post_categories( $post_id, $categories, false );
419 419
 
420
-                        // prepare value to be saved in the entry
421
-                        $field = GFCommon::add_categories_as_choices( $field, '' );
420
+						// prepare value to be saved in the entry
421
+						$field = GFCommon::add_categories_as_choices( $field, '' );
422 422
 
423
-                        // if post_category is type checkbox, then value is an array of inputs
424
-                        if( isset( $value[ strval( $field_id ) ] ) ) {
425
-                            foreach( $value as $input_id => $val ) {
426
-                                $input_name = 'input_' . str_replace( '.', '_', $input_id );
427
-                                $this->entry[ strval( $input_id ) ] = RGFormsModel::prepare_value( $form, $field, $val, $input_name, $this->entry['id'] );
428
-                            }
429
-                        } else {
430
-                            $input_name = 'input_' . str_replace( '.', '_', $field_id );
431
-                            $this->entry[ strval( $field_id ) ] = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $this->entry['id'] );
432
-                        }
423
+						// if post_category is type checkbox, then value is an array of inputs
424
+						if( isset( $value[ strval( $field_id ) ] ) ) {
425
+							foreach( $value as $input_id => $val ) {
426
+								$input_name = 'input_' . str_replace( '.', '_', $input_id );
427
+								$this->entry[ strval( $input_id ) ] = RGFormsModel::prepare_value( $form, $field, $val, $input_name, $this->entry['id'] );
428
+							}
429
+						} else {
430
+							$input_name = 'input_' . str_replace( '.', '_', $field_id );
431
+							$this->entry[ strval( $field_id ) ] = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $this->entry['id'] );
432
+						}
433 433
 
434
-                        break;
435
-                    case 'post_custom_field':
434
+						break;
435
+					case 'post_custom_field':
436 436
 
437
-                        $input_type = RGFormsModel::get_input_type( $field );
438
-                        $custom_field_name = $field_array['postCustomFieldName'];
437
+						$input_type = RGFormsModel::get_input_type( $field );
438
+						$custom_field_name = $field_array['postCustomFieldName'];
439 439
 
440
-                        // Only certain custom field types are supported
441
-                        if( !in_array( $input_type, array( 'list', 'fileupload' ) ) ) {
442
-                            update_post_meta( $post_id, $custom_field_name, $value );
443
-                        }
440
+						// Only certain custom field types are supported
441
+						if( !in_array( $input_type, array( 'list', 'fileupload' ) ) ) {
442
+							update_post_meta( $post_id, $custom_field_name, $value );
443
+						}
444 444
 
445
-                        break;
445
+						break;
446 446
 
447
-                    case 'post_image':
447
+					case 'post_image':
448 448
 
449
-                        $value = '';
450
-                        break;
449
+						$value = '';
450
+						break;
451 451
 
452
-                }
452
+				}
453 453
 
454
-                //ignore fields that have not changed
455
-                if ( $value === rgget( (string) $field_id, $this->entry ) ) {
456
-                    continue;
457
-                }
454
+				//ignore fields that have not changed
455
+				if ( $value === rgget( (string) $field_id, $this->entry ) ) {
456
+					continue;
457
+				}
458 458
 
459
-                // update entry
460
-                if( 'post_category' !== $field->type ) {
461
-                    $this->entry[ strval( $field_id ) ] = $value;
462
-                }
459
+				// update entry
460
+				if( 'post_category' !== $field->type ) {
461
+					$this->entry[ strval( $field_id ) ] = $value;
462
+				}
463 463
 
464
-                $update_entry = true;
464
+				$update_entry = true;
465 465
 
466
-            }
466
+			}
467 467
 
468
-        }
468
+		}
469 469
 
470
-        if( $update_entry ) {
470
+		if( $update_entry ) {
471 471
 
472
-            $return_entry = GFAPI::update_entry( $this->entry );
472
+			$return_entry = GFAPI::update_entry( $this->entry );
473 473
 
474
-            if( is_wp_error( $return_entry ) ) {
475
-                do_action( 'gravityview_log_error', 'Updating the entry post fields failed', $return_entry );
476
-            } else {
477
-                do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' );
478
-            }
474
+			if( is_wp_error( $return_entry ) ) {
475
+				do_action( 'gravityview_log_error', 'Updating the entry post fields failed', $return_entry );
476
+			} else {
477
+				do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' );
478
+			}
479 479
 
480
-        }
480
+		}
481 481
 
482
-        $return_post = wp_update_post( $updated_post, true );
482
+		$return_post = wp_update_post( $updated_post, true );
483 483
 
484
-        if( is_wp_error( $return_post ) ) {
485
-            do_action( 'gravityview_log_error', 'Updating the post content failed', $return_post );
486
-        } else {
487
-            do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded' );
488
-        }
484
+		if( is_wp_error( $return_post ) ) {
485
+			do_action( 'gravityview_log_error', 'Updating the post content failed', $return_post );
486
+		} else {
487
+			do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded' );
488
+		}
489 489
 
490
-    }
490
+	}
491 491
 
492
-    /**
493
-     * Perform actions normally performed after updating a lead
494
-     *
495
-     * @since 1.8
496
-     *
497
-     * @see GFEntryDetail::lead_detail_page()
498
-     *
499
-     * @return void
500
-     */
501
-    function after_update() {
492
+	/**
493
+	 * Perform actions normally performed after updating a lead
494
+	 *
495
+	 * @since 1.8
496
+	 *
497
+	 * @see GFEntryDetail::lead_detail_page()
498
+	 *
499
+	 * @return void
500
+	 */
501
+	function after_update() {
502 502
 
503
-        do_action( 'gform_after_update_entry', $this->form, $this->entry['id'] );
504
-        do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] );
503
+		do_action( 'gform_after_update_entry', $this->form, $this->entry['id'] );
504
+		do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] );
505 505
 
506
-        // Re-define the entry now that we've updated it.
507
-        $entry = RGFormsModel::get_lead( $this->entry['id'] );
506
+		// Re-define the entry now that we've updated it.
507
+		$entry = RGFormsModel::get_lead( $this->entry['id'] );
508 508
 
509
-        $entry = GFFormsModel::set_entry_meta( $entry, $this->form );
509
+		$entry = GFFormsModel::set_entry_meta( $entry, $this->form );
510 510
 
511
-        // We need to clear the cache because Gravity Forms caches the field values, which
512
-        // we have just updated.
513
-        foreach ($this->form['fields'] as $key => $field) {
514
-            GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
515
-        }
511
+		// We need to clear the cache because Gravity Forms caches the field values, which
512
+		// we have just updated.
513
+		foreach ($this->form['fields'] as $key => $field) {
514
+			GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
515
+		}
516 516
 
517
-        $this->entry = $entry;
518
-    }
517
+		$this->entry = $entry;
518
+	}
519 519
 
520 520
 
521
-    /**
522
-     * Display the Edit Entry form
523
-     *
524
-     * @return [type] [description]
525
-     */
526
-    public function edit_entry_form() {
521
+	/**
522
+	 * Display the Edit Entry form
523
+	 *
524
+	 * @return [type] [description]
525
+	 */
526
+	public function edit_entry_form() {
527 527
 
528
-        $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) );
528
+		$back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) );
529 529
 
530
-        ?>
530
+		?>
531 531
 
532 532
         <div class="gv-edit-entry-wrapper"><?php
533 533
 
534
-            $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
534
+			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
535 535
 
536
-            /**
537
-             * Fixes weird wpautop() issue
538
-             * @see https://github.com/katzwebservices/GravityView/issues/451
539
-             */
540
-            echo gravityview_strip_whitespace( $javascript );
536
+			/**
537
+			 * Fixes weird wpautop() issue
538
+			 * @see https://github.com/katzwebservices/GravityView/issues/451
539
+			 */
540
+			echo gravityview_strip_whitespace( $javascript );
541 541
 
542
-            ?><h2 class="gv-edit-entry-title">
542
+			?><h2 class="gv-edit-entry-title">
543 543
                 <span><?php
544 544
 
545
-                    /**
546
-                     * @filter `gravityview_edit_entry_title` Modify the edit entry title
547
-                     * @param string $edit_entry_title Modify the "Edit Entry" title
548
-                     * @param GravityView_Edit_Entry_Render $this This object
549
-                     */
550
-                    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
545
+					/**
546
+					 * @filter `gravityview_edit_entry_title` Modify the edit entry title
547
+					 * @param string $edit_entry_title Modify the "Edit Entry" title
548
+					 * @param GravityView_Edit_Entry_Render $this This object
549
+					 */
550
+					$edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
551 551
 
552
-                    echo esc_attr( $edit_entry_title );
553
-            ?></span>
552
+					echo esc_attr( $edit_entry_title );
553
+			?></span>
554 554
             </h2>
555 555
 
556 556
             <?php
557 557
 
558
-            // Display the success message
559
-            if( rgpost('action') === 'update' ) {
558
+			// Display the success message
559
+			if( rgpost('action') === 'update' ) {
560 560
 
561
-                if( ! $this->is_valid ){
561
+				if( ! $this->is_valid ){
562 562
 
563
-                    // Keeping this compatible with Gravity Forms.
564
-                    $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
565
-                    $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
563
+					// Keeping this compatible with Gravity Forms.
564
+					$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
565
+					$message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
566 566
 
567
-                    echo GVCommon::generate_notice( $message , 'gv-error' );
567
+					echo GVCommon::generate_notice( $message , 'gv-error' );
568 568
 
569
-                } else {
570
-                    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' );
569
+				} else {
570
+					$entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' );
571 571
 
572
-                    /**
573
-                     * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link)
574
-                     * @since 1.5.4
575
-                     * @param string $entry_updated_message Existing message
576
-                     * @param int $view_id View ID
577
-                     * @param array $entry Gravity Forms entry array
578
-                     * @param string $back_link URL to return to the original entry. @since 1.6
579
-                     */
580
-                    $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
572
+					/**
573
+					 * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link)
574
+					 * @since 1.5.4
575
+					 * @param string $entry_updated_message Existing message
576
+					 * @param int $view_id View ID
577
+					 * @param array $entry Gravity Forms entry array
578
+					 * @param string $back_link URL to return to the original entry. @since 1.6
579
+					 */
580
+					$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
581 581
 
582
-                    echo GVCommon::generate_notice( $message );
583
-                }
582
+					echo GVCommon::generate_notice( $message );
583
+				}
584 584
 
585
-            }
585
+			}
586 586
 
587
-            ?>
587
+			?>
588 588
 
589 589
             <?php // The ID of the form needs to be `gform_{form_id}` for the pluploader ?>
590 590
 
@@ -592,590 +592,590 @@  discard block
 block discarded – undo
592 592
 
593 593
                 <?php
594 594
 
595
-                wp_nonce_field( self::$nonce_key, self::$nonce_key );
595
+				wp_nonce_field( self::$nonce_key, self::$nonce_key );
596 596
 
597
-                wp_nonce_field( self::$nonce_field, self::$nonce_field, false );
597
+				wp_nonce_field( self::$nonce_field, self::$nonce_field, false );
598 598
 
599
-                // Most of this is needed for GFFormDisplay::validate(), but `gform_unique_id` is needed for file cleanup.
599
+				// Most of this is needed for GFFormDisplay::validate(), but `gform_unique_id` is needed for file cleanup.
600 600
 
601
-                ?>
601
+				?>
602 602
 
603 603
 
604 604
                 <?php
605 605
 
606
-                /**
607
-                 * By default, the lead_detail_edit method uses the `RGFormsModel::get_lead_field_value()` method, which doesn't fill in $_POST values when there is a validation error, because it was designed to work in the admin. We want to use the `RGFormsModel::get_field_value()` If the form has been submitted, use the values for the fields.
608
-                 */
609
-                //add_filter( 'gform_get_field_value', array( $this, 'get_field_value' ), 10, 3 );
606
+				/**
607
+				 * By default, the lead_detail_edit method uses the `RGFormsModel::get_lead_field_value()` method, which doesn't fill in $_POST values when there is a validation error, because it was designed to work in the admin. We want to use the `RGFormsModel::get_field_value()` If the form has been submitted, use the values for the fields.
608
+				 */
609
+				//add_filter( 'gform_get_field_value', array( $this, 'get_field_value' ), 10, 3 );
610 610
 
611
-                // Print the actual form HTML
612
-                $this->render_edit_form();
611
+				// Print the actual form HTML
612
+				$this->render_edit_form();
613 613
 
614
-                //echo $this->render_form_buttons();
614
+				//echo $this->render_form_buttons();
615 615
 
616
-                ?>
616
+				?>
617 617
             </form>
618 618
 
619 619
         </div>
620 620
 
621 621
     <?php
622
-    }
623
-
624
-    /**
625
-     * Display the Edit Entry form in the original Gravity Forms format
626
-     *
627
-     * @since 1.9
628
-     *
629
-     * @param $form
630
-     * @param $lead
631
-     * @param $view_id
632
-     *
633
-     * @return void
634
-     */
635
-    private function render_edit_form() {
636
-
637
-        add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
638
-        add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
639
-        add_filter( 'gform_disable_view_counter', '__return_true' );
640
-        add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
641
-
642
-        // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
643
-        unset( $_GET['page'] );
644
-
645
-        // TODO: Make sure validation isn't handled by GF
646
-        // TODO: Include CSS for file upload fields
647
-        // TODO: Verify multiple-page forms
648
-        // TODO: Product fields are not editable
649
-        // TODO: Check Updated and Error messages
650
-
651
-        $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
652
-
653
-	    remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
654
-        remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
655
-        remove_filter( 'gform_disable_view_counter', '__return_true' );
656
-        remove_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10 );
657
-
658
-        echo $html;
659
-    }
660
-
661
-    /**
662
-     * Display the Update/Cancel/Delete buttons for the Edit Entry form
663
-     * @since 1.8
664
-     * @return string
665
-     */
666
-    public function render_form_buttons() {
667
-        return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
668
-    }
669
-
670
-
671
-    /**
672
-     * Modify the form fields that are shown when using GFFormDisplay::get_form()
673
-     *
674
-     * By default, all fields will be shown. We only want the Edit Tab configured fields to be shown.
675
-     *
676
-     * @param array $form
677
-     * @param boolean $ajax Whether in AJAX mode
678
-     * @param array|string $field_values Passed parameters to the form
679
-     *
680
-     * @since 1.9
681
-     *
682
-     * @return array Modified form array
683
-     */
684
-    public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
685
-
686
-        // In case we have validated the form, use it to inject the validation results into the form render
687
-        if( isset( $this->form_after_validation ) ) {
688
-            $form = $this->form_after_validation;
689
-        } else {
690
-            $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
691
-        }
692
-
693
-        $form = $this->filter_conditional_logic( $form );
694
-
695
-        // for now we don't support Save and Continue feature.
696
-        if( ! self::$supports_save_and_continue ) {
697
-	        unset( $form['save'] );
698
-        }
699
-
700
-        return $form;
701
-    }
702
-
703
-
704
-    /**
705
-     *
706
-     * Fill-in the saved values into the form inputs
707
-     *
708
-     * @param string $field_content Always empty.
709
-     * @param GF_Field $field
710
-     * @param string|array $value If array, it's a field with multiple inputs. If string, single input.
711
-     * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.
712
-     * @param int $form_id Form ID
713
-     *
714
-     * @return mixed
715
-     */
716
-    function modify_edit_field_input( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
717
-
718
-        // If the form has been submitted, then we don't need to pre-fill the values,
719
-        // Except for fileupload type - run always!!
720
-        if(
721
-	        $this->is_edit_entry_submission() && 'fileupload' !== $field->type
722
-        ||  GFCommon::is_product_field( $field->type ) // Prevent product fields from appearing editable
723
-        ) {
724
-	        return $field_content;
725
-        }
726
-
727
-        // Turn on Admin-style display for file upload fields only
728
-        if( 'fileupload' === $field->type ) {
729
-            $_GET['page'] = 'gf_entries';
730
-        }
731
-
732
-        // SET SOME FIELD DEFAULTS TO PREVENT ISSUES
733
-        $field->adminOnly = false; /** @see GFFormDisplay::get_counter_init_script() need to prevent adminOnly */
734
-
735
-        // add categories as choices for Post Category field
736
-        if ( 'post_category' === $field->type ) {
737
-            $field = GFCommon::add_categories_as_choices( $field, $value );
738
-        }
739
-
740
-        /**
741
-         * @filter `gravityview/edit_entry/pre_populate/override` Allow the pre-populated value to override saved value in Edit Entry form. By default, pre-populate mechanism only kicks on empty fields.
742
-         * @param boolean True: override saved values; False: don't override (default)
743
-         * @param $field GF_Field object Gravity Forms field object
744
-         * @since 1.13
745
-         */
746
-        $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
747
-
748
-        // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
749
-        if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
750
-
751
-            $field_value = array();
752
-
753
-            // only accept pre-populated values if the field doesn't have any choice selected.
754
-            $allow_pre_populated = $field->allowsPrepopulate;
755
-
756
-	        foreach ( (array)$field->inputs as $input ) {
757
-
758
-	            $input_id = strval( $input['id'] );
759
-
760
-                if ( ! empty( $this->entry[ $input_id ] ) ) {
761
-                    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
762
-                    $allow_pre_populated = false;
763
-                }
764
-
765
-            }
766
-
767
-            $pre_value = $field->get_value_submission( array(), false );
768
-
769
-            $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !empty( $pre_value ) ) ? $field_value : $pre_value;
770
-
771
-        } else {
772
-
773
-            $id = intval( $field->id );
774
-
775
-            // get pre-populated value if exists
776
-            $pre_value = $field->allowsPrepopulate ? GFFormsModel::get_parameter_value( $field->inputName, array(), $field ) : '';
777
-
778
-            // saved field entry value (if empty, fallback to the pre-populated value, if exists)
779
-            // or pre-populated value if not empty and set to override saved value
780
-            $field_value = !empty( $this->entry[ $id ] ) && ! ( $override_saved_value && !empty( $pre_value ) ) ? $this->entry[ $id ] : $pre_value;
781
-
782
-            // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
783
-            if ( 'post_category' === $field->type && !empty( $field_value ) ) {
784
-                $categories = array();
785
-                foreach ( explode( ',', $field_value ) as $cat_string ) {
786
-                    $categories[] = GFCommon::format_post_category( $cat_string, true );
787
-                }
788
-                $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
789
-            }
622
+	}
790 623
 
791
-        }
624
+	/**
625
+	 * Display the Edit Entry form in the original Gravity Forms format
626
+	 *
627
+	 * @since 1.9
628
+	 *
629
+	 * @param $form
630
+	 * @param $lead
631
+	 * @param $view_id
632
+	 *
633
+	 * @return void
634
+	 */
635
+	private function render_edit_form() {
792 636
 
793
-        // if value is empty get the default value if defined
794
-        $field_value = $field->get_value_default_if_empty( $field_value );
795
-
796
-        /**
797
-         * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
798
-         * @since 1.11
799
-         * @param mixed $field_value field value used to populate the input
800
-         * @param object $field Gravity Forms field object ( Class GF_Field )
801
-         */
802
-        $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field );
803
-
804
-	    // Prevent any PHP warnings, like undefined index
805
-	    ob_start();
806
-
807
-	    $return = $field->get_field_input( $this->form, $field_value, $this->entry );
808
-
809
-	    // If there was output, it's an error
810
-	    $warnings = ob_get_clean();
637
+		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
638
+		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
639
+		add_filter( 'gform_disable_view_counter', '__return_true' );
640
+		add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
811 641
 
812
-	    if( !empty( $warnings ) ) {
813
-		    do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value );
814
-	    }
642
+		// We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
643
+		unset( $_GET['page'] );
815 644
 
816
-        /**
817
-         * Unset hack $_GET['page'] = 'gf_entries'
818
-         * We need the fileupload html field to render with the proper id
819
-         *  ( <li id="field_80_16" ... > )
820
-         */
821
-        unset( $_GET['page'] );
645
+		// TODO: Make sure validation isn't handled by GF
646
+		// TODO: Include CSS for file upload fields
647
+		// TODO: Verify multiple-page forms
648
+		// TODO: Product fields are not editable
649
+		// TODO: Check Updated and Error messages
822 650
 
823
-        return $return;
824
-    }
651
+		$html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
825 652
 
653
+		remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
654
+		remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
655
+		remove_filter( 'gform_disable_view_counter', '__return_true' );
656
+		remove_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10 );
826 657
 
827
-    /**
828
-     * Get the posted values from the edit form submission
829
-     *
830
-     * @hack
831
-     * @uses GFFormsModel::get_field_value()
832
-     * @param  mixed $value Existing field value, before edit
833
-     * @param  array $lead  Gravity Forms entry array
834
-     * @param  array $field Gravity Forms field array
835
-     * @return string        [description]
836
-     */
837
-    public function get_field_value( $value, $lead, $field ) {
658
+		echo $html;
659
+	}
838 660
 
839
-        // The form's not being edited; use the original value
840
-        if( ! $this->is_edit_entry_submission() ) {
841
-            return $value;
842
-        }
661
+	/**
662
+	 * Display the Update/Cancel/Delete buttons for the Edit Entry form
663
+	 * @since 1.8
664
+	 * @return string
665
+	 */
666
+	public function render_form_buttons() {
667
+		return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
668
+	}
843 669
 
844
-        return GFFormsModel::get_field_value( $field, $lead, true );
845
-    }
846 670
 
671
+	/**
672
+	 * Modify the form fields that are shown when using GFFormDisplay::get_form()
673
+	 *
674
+	 * By default, all fields will be shown. We only want the Edit Tab configured fields to be shown.
675
+	 *
676
+	 * @param array $form
677
+	 * @param boolean $ajax Whether in AJAX mode
678
+	 * @param array|string $field_values Passed parameters to the form
679
+	 *
680
+	 * @since 1.9
681
+	 *
682
+	 * @return array Modified form array
683
+	 */
684
+	public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
685
+
686
+		// In case we have validated the form, use it to inject the validation results into the form render
687
+		if( isset( $this->form_after_validation ) ) {
688
+			$form = $this->form_after_validation;
689
+		} else {
690
+			$form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
691
+		}
847 692
 
693
+		$form = $this->filter_conditional_logic( $form );
848 694
 
695
+		// for now we don't support Save and Continue feature.
696
+		if( ! self::$supports_save_and_continue ) {
697
+			unset( $form['save'] );
698
+		}
849 699
 
850
-    // ---- Entry validation
700
+		return $form;
701
+	}
851 702
 
852
-    /**
853
-     * Add field keys that Gravity Forms expects.
854
-     *
855
-     * @see GFFormDisplay::validate()
856
-     * @param  array $form GF Form
857
-     * @return array       Modified GF Form
858
-     */
859
-    function gform_pre_validation( $form ) {
860 703
 
861
-        if( ! $this->verify_nonce() ) {
862
-            return $form;
863
-        }
704
+	/**
705
+	 *
706
+	 * Fill-in the saved values into the form inputs
707
+	 *
708
+	 * @param string $field_content Always empty.
709
+	 * @param GF_Field $field
710
+	 * @param string|array $value If array, it's a field with multiple inputs. If string, single input.
711
+	 * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.
712
+	 * @param int $form_id Form ID
713
+	 *
714
+	 * @return mixed
715
+	 */
716
+	function modify_edit_field_input( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
717
+
718
+		// If the form has been submitted, then we don't need to pre-fill the values,
719
+		// Except for fileupload type - run always!!
720
+		if(
721
+			$this->is_edit_entry_submission() && 'fileupload' !== $field->type
722
+		||  GFCommon::is_product_field( $field->type ) // Prevent product fields from appearing editable
723
+		) {
724
+			return $field_content;
725
+		}
864 726
 
865
-        // Fix PHP warning regarding undefined index.
866
-        foreach ( $form['fields'] as &$field) {
727
+		// Turn on Admin-style display for file upload fields only
728
+		if( 'fileupload' === $field->type ) {
729
+			$_GET['page'] = 'gf_entries';
730
+		}
867 731
 
868
-            // This is because we're doing admin form pretending to be front-end, so Gravity Forms
869
-            // expects certain field array items to be set.
870
-            foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) {
871
-	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
872
-            }
732
+		// SET SOME FIELD DEFAULTS TO PREVENT ISSUES
733
+		$field->adminOnly = false; /** @see GFFormDisplay::get_counter_init_script() need to prevent adminOnly */
734
+
735
+		// add categories as choices for Post Category field
736
+		if ( 'post_category' === $field->type ) {
737
+			$field = GFCommon::add_categories_as_choices( $field, $value );
738
+		}
739
+
740
+		/**
741
+		 * @filter `gravityview/edit_entry/pre_populate/override` Allow the pre-populated value to override saved value in Edit Entry form. By default, pre-populate mechanism only kicks on empty fields.
742
+		 * @param boolean True: override saved values; False: don't override (default)
743
+		 * @param $field GF_Field object Gravity Forms field object
744
+		 * @since 1.13
745
+		 */
746
+		$override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
747
+
748
+		// We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
749
+		if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
750
+
751
+			$field_value = array();
752
+
753
+			// only accept pre-populated values if the field doesn't have any choice selected.
754
+			$allow_pre_populated = $field->allowsPrepopulate;
755
+
756
+			foreach ( (array)$field->inputs as $input ) {
757
+
758
+				$input_id = strval( $input['id'] );
759
+
760
+				if ( ! empty( $this->entry[ $input_id ] ) ) {
761
+					$field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
762
+					$allow_pre_populated = false;
763
+				}
764
+
765
+			}
766
+
767
+			$pre_value = $field->get_value_submission( array(), false );
768
+
769
+			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && !empty( $pre_value ) ) ? $field_value : $pre_value;
770
+
771
+		} else {
772
+
773
+			$id = intval( $field->id );
774
+
775
+			// get pre-populated value if exists
776
+			$pre_value = $field->allowsPrepopulate ? GFFormsModel::get_parameter_value( $field->inputName, array(), $field ) : '';
777
+
778
+			// saved field entry value (if empty, fallback to the pre-populated value, if exists)
779
+			// or pre-populated value if not empty and set to override saved value
780
+			$field_value = !empty( $this->entry[ $id ] ) && ! ( $override_saved_value && !empty( $pre_value ) ) ? $this->entry[ $id ] : $pre_value;
781
+
782
+			// in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
783
+			if ( 'post_category' === $field->type && !empty( $field_value ) ) {
784
+				$categories = array();
785
+				foreach ( explode( ',', $field_value ) as $cat_string ) {
786
+					$categories[] = GFCommon::format_post_category( $cat_string, true );
787
+				}
788
+				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
789
+			}
790
+
791
+		}
873 792
 
874
-            // unset emailConfirmEnabled for email type fields
875
-           /* if( 'email' === $field['type'] && !empty( $field['emailConfirmEnabled'] ) ) {
793
+		// if value is empty get the default value if defined
794
+		$field_value = $field->get_value_default_if_empty( $field_value );
795
+
796
+		/**
797
+		 * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
798
+		 * @since 1.11
799
+		 * @param mixed $field_value field value used to populate the input
800
+		 * @param object $field Gravity Forms field object ( Class GF_Field )
801
+		 */
802
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field );
803
+
804
+		// Prevent any PHP warnings, like undefined index
805
+		ob_start();
806
+
807
+		$return = $field->get_field_input( $this->form, $field_value, $this->entry );
808
+
809
+		// If there was output, it's an error
810
+		$warnings = ob_get_clean();
811
+
812
+		if( !empty( $warnings ) ) {
813
+			do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value );
814
+		}
815
+
816
+		/**
817
+		 * Unset hack $_GET['page'] = 'gf_entries'
818
+		 * We need the fileupload html field to render with the proper id
819
+		 *  ( <li id="field_80_16" ... > )
820
+		 */
821
+		unset( $_GET['page'] );
822
+
823
+		return $return;
824
+	}
825
+
826
+
827
+	/**
828
+	 * Get the posted values from the edit form submission
829
+	 *
830
+	 * @hack
831
+	 * @uses GFFormsModel::get_field_value()
832
+	 * @param  mixed $value Existing field value, before edit
833
+	 * @param  array $lead  Gravity Forms entry array
834
+	 * @param  array $field Gravity Forms field array
835
+	 * @return string        [description]
836
+	 */
837
+	public function get_field_value( $value, $lead, $field ) {
838
+
839
+		// The form's not being edited; use the original value
840
+		if( ! $this->is_edit_entry_submission() ) {
841
+			return $value;
842
+		}
843
+
844
+		return GFFormsModel::get_field_value( $field, $lead, true );
845
+	}
846
+
847
+
848
+
849
+
850
+	// ---- Entry validation
851
+
852
+	/**
853
+	 * Add field keys that Gravity Forms expects.
854
+	 *
855
+	 * @see GFFormDisplay::validate()
856
+	 * @param  array $form GF Form
857
+	 * @return array       Modified GF Form
858
+	 */
859
+	function gform_pre_validation( $form ) {
860
+
861
+		if( ! $this->verify_nonce() ) {
862
+			return $form;
863
+		}
864
+
865
+		// Fix PHP warning regarding undefined index.
866
+		foreach ( $form['fields'] as &$field) {
867
+
868
+			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
869
+			// expects certain field array items to be set.
870
+			foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) {
871
+				$field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
872
+			}
873
+
874
+			// unset emailConfirmEnabled for email type fields
875
+		   /* if( 'email' === $field['type'] && !empty( $field['emailConfirmEnabled'] ) ) {
876 876
                 $field['emailConfirmEnabled'] = '';
877 877
             }*/
878 878
 
879
-            switch( RGFormsModel::get_input_type( $field ) ) {
879
+			switch( RGFormsModel::get_input_type( $field ) ) {
880 880
 
881
-                /**
882
-                 * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend.
883
-                 *
884
-                 * What we have to do is set the value so that it doesn't get overwritten as empty on save and appears immediately in the Edit Entry screen again.
885
-                 *
886
-                 * @hack
887
-                 */
888
-                case 'fileupload':
889
-                case 'post_image':
881
+				/**
882
+				 * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend.
883
+				 *
884
+				 * What we have to do is set the value so that it doesn't get overwritten as empty on save and appears immediately in the Edit Entry screen again.
885
+				 *
886
+				 * @hack
887
+				 */
888
+				case 'fileupload':
889
+				case 'post_image':
890 890
 
891
-                    // Set the previous value
892
-                    $entry = $this->get_entry();
891
+					// Set the previous value
892
+					$entry = $this->get_entry();
893 893
 
894
-                    $input_name = 'input_'.$field->id;
895
-                    $form_id = $form['id'];
894
+					$input_name = 'input_'.$field->id;
895
+					$form_id = $form['id'];
896 896
 
897
-                    $value = NULL;
897
+					$value = NULL;
898 898
 
899
-                    // Use the previous entry value as the default.
900
-                    if( isset( $entry[ $field->id ] ) ) {
901
-                        $value = $entry[ $field->id ];
902
-                    }
899
+					// Use the previous entry value as the default.
900
+					if( isset( $entry[ $field->id ] ) ) {
901
+						$value = $entry[ $field->id ];
902
+					}
903 903
 
904
-                    // If this is a single upload file
905
-                    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
906
-                        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
907
-                        $value = $file_path['url'];
904
+					// If this is a single upload file
905
+					if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
906
+						$file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
907
+						$value = $file_path['url'];
908 908
 
909
-                    } else {
909
+					} else {
910 910
 
911
-                        // Fix PHP warning on line 1498 of form_display.php for post_image fields
912
-                        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
913
-                        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
911
+						// Fix PHP warning on line 1498 of form_display.php for post_image fields
912
+						// Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
913
+						$_FILES[ $input_name ] = array('name' => '', 'size' => '' );
914 914
 
915
-                    }
915
+					}
916 916
 
917
-                    if( rgar($field, "multipleFiles") ) {
917
+					if( rgar($field, "multipleFiles") ) {
918 918
 
919
-                        // If there are fresh uploads, process and merge them.
920
-                        // Otherwise, use the passed values, which should be json-encoded array of URLs
921
-                        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
919
+						// If there are fresh uploads, process and merge them.
920
+						// Otherwise, use the passed values, which should be json-encoded array of URLs
921
+						if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
922 922
 
923
-                            $value = empty( $value ) ? '[]' : $value;
924
-                            $value = stripslashes_deep( $value );
925
-                            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
926
-                        }
923
+							$value = empty( $value ) ? '[]' : $value;
924
+							$value = stripslashes_deep( $value );
925
+							$value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
926
+						}
927 927
 
928
-                    } else {
928
+					} else {
929 929
 
930
-                        // A file already exists when editing an entry
931
-                        // We set this to solve issue when file upload fields are required.
932
-                        GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
930
+						// A file already exists when editing an entry
931
+						// We set this to solve issue when file upload fields are required.
932
+						GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
933 933
 
934
-                    }
934
+					}
935 935
 
936
-                    $_POST[ $input_name ] = $value;
936
+					$_POST[ $input_name ] = $value;
937 937
 
938
-                    break;
939
-                case 'number':
940
-                    // Fix "undefined index" issue at line 1286 in form_display.php
941
-                    if( !isset( $_POST['input_'.$field->id ] ) ) {
942
-                        $_POST['input_'.$field->id ] = NULL;
943
-                    }
944
-                    break;
945
-                case 'captcha':
946
-                    // Fix issue with recaptcha_check_answer() on line 1458 in form_display.php
947
-                    $_POST['recaptcha_challenge_field'] = NULL;
948
-                    $_POST['recaptcha_response_field'] = NULL;
949
-                    break;
950
-            }
938
+					break;
939
+				case 'number':
940
+					// Fix "undefined index" issue at line 1286 in form_display.php
941
+					if( !isset( $_POST['input_'.$field->id ] ) ) {
942
+						$_POST['input_'.$field->id ] = NULL;
943
+					}
944
+					break;
945
+				case 'captcha':
946
+					// Fix issue with recaptcha_check_answer() on line 1458 in form_display.php
947
+					$_POST['recaptcha_challenge_field'] = NULL;
948
+					$_POST['recaptcha_response_field'] = NULL;
949
+					break;
950
+			}
951 951
 
952
-        }
952
+		}
953 953
 
954
-        return $form;
955
-    }
954
+		return $form;
955
+	}
956 956
 
957 957
 
958
-    /**
959
-     * Process validation for a edit entry submission
960
-     *
961
-     * Sets the `is_valid` object var
962
-     *
963
-     * @return void
964
-     */
965
-    function validate() {
958
+	/**
959
+	 * Process validation for a edit entry submission
960
+	 *
961
+	 * Sets the `is_valid` object var
962
+	 *
963
+	 * @return void
964
+	 */
965
+	function validate() {
966 966
 
967
-        // If using GF User Registration Add-on, remove the validation step, otherwise generates error when updating the entry
968
-        if ( class_exists( 'GFUser' ) ) {
969
-            remove_filter( 'gform_validation', array( 'GFUser', 'user_registration_validation' ) );
970
-        }
967
+		// If using GF User Registration Add-on, remove the validation step, otherwise generates error when updating the entry
968
+		if ( class_exists( 'GFUser' ) ) {
969
+			remove_filter( 'gform_validation', array( 'GFUser', 'user_registration_validation' ) );
970
+		}
971 971
 
972
-        /**
973
-         * For some crazy reason, Gravity Forms doesn't validate Edit Entry form submissions.
974
-         * You can enter whatever you want!
975
-         * We try validating, and customize the results using `self::custom_validation()`
976
-         */
977
-        add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
972
+		/**
973
+		 * For some crazy reason, Gravity Forms doesn't validate Edit Entry form submissions.
974
+		 * You can enter whatever you want!
975
+		 * We try validating, and customize the results using `self::custom_validation()`
976
+		 */
977
+		add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
978 978
 
979
-        // Needed by the validate funtion
980
-        $failed_validation_page = NULL;
981
-        $field_values = RGForms::post( 'gform_field_values' );
979
+		// Needed by the validate funtion
980
+		$failed_validation_page = NULL;
981
+		$field_values = RGForms::post( 'gform_field_values' );
982 982
 
983
-        // Prevent entry limit from running when editing an entry, also
984
-        // prevent form scheduling from preventing editing
985
-        unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
983
+		// Prevent entry limit from running when editing an entry, also
984
+		// prevent form scheduling from preventing editing
985
+		unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
986 986
 
987
-        // Hide fields depending on Edit Entry settings
988
-        $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
987
+		// Hide fields depending on Edit Entry settings
988
+		$this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
989 989
 
990
-        $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
990
+		$this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
991 991
 
992
-        remove_filter( 'gform_validation_'.$this->form_id, array( $this, 'custom_validation' ), 10 );
993
-    }
992
+		remove_filter( 'gform_validation_'.$this->form_id, array( $this, 'custom_validation' ), 10 );
993
+	}
994 994
 
995 995
 
996
-    /**
997
-     * Make validation work for Edit Entry
998
-     *
999
-     * Because we're calling the GFFormDisplay::validate() in an unusual way (as a front-end
1000
-     * form pretending to be a back-end form), validate() doesn't know we _can't_ edit post
1001
-     * fields. This goes through all the fields and if they're an invalid post field, we
1002
-     * set them as valid. If there are still issues, we'll return false.
1003
-     *
1004
-     * @param  [type] $validation_results [description]
1005
-     * @return [type]                     [description]
1006
-     */
1007
-    function custom_validation( $validation_results ) {
996
+	/**
997
+	 * Make validation work for Edit Entry
998
+	 *
999
+	 * Because we're calling the GFFormDisplay::validate() in an unusual way (as a front-end
1000
+	 * form pretending to be a back-end form), validate() doesn't know we _can't_ edit post
1001
+	 * fields. This goes through all the fields and if they're an invalid post field, we
1002
+	 * set them as valid. If there are still issues, we'll return false.
1003
+	 *
1004
+	 * @param  [type] $validation_results [description]
1005
+	 * @return [type]                     [description]
1006
+	 */
1007
+	function custom_validation( $validation_results ) {
1008 1008
 
1009
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results );
1009
+		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results );
1010 1010
 
1011
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
1011
+		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
1012 1012
 
1013
-        $gv_valid = true;
1013
+		$gv_valid = true;
1014 1014
 
1015
-        foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1015
+		foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1016 1016
 
1017
-            $value = RGFormsModel::get_field_value( $field );
1018
-            $field_type = RGFormsModel::get_input_type( $field );
1017
+			$value = RGFormsModel::get_field_value( $field );
1018
+			$field_type = RGFormsModel::get_input_type( $field );
1019 1019
 
1020
-            // Validate always
1021
-            switch ( $field_type ) {
1020
+			// Validate always
1021
+			switch ( $field_type ) {
1022 1022
 
1023 1023
 
1024
-                case 'fileupload' :
1024
+				case 'fileupload' :
1025 1025
 
1026
-                    // in case nothing is uploaded but there are already files saved
1027
-                    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1028
-                        $field->failed_validation = false;
1029
-                        unset( $field->validation_message );
1030
-                    }
1026
+					// in case nothing is uploaded but there are already files saved
1027
+					if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1028
+						$field->failed_validation = false;
1029
+						unset( $field->validation_message );
1030
+					}
1031 1031
 
1032
-                    // validate if multi file upload reached max number of files [maxFiles] => 2
1033
-                    if( rgar( $field, 'maxFiles') && rgar( $field, 'multipleFiles') ) {
1032
+					// validate if multi file upload reached max number of files [maxFiles] => 2
1033
+					if( rgar( $field, 'maxFiles') && rgar( $field, 'multipleFiles') ) {
1034 1034
 
1035
-                        $input_name = 'input_' . $field->id;
1036
-                        //uploaded
1037
-                        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1035
+						$input_name = 'input_' . $field->id;
1036
+						//uploaded
1037
+						$file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1038 1038
 
1039
-                        //existent
1040
-                        $entry = $this->get_entry();
1041
-                        $value = NULL;
1042
-                        if( isset( $entry[ $field->id ] ) ) {
1043
-                            $value = json_decode( $entry[ $field->id ], true );
1044
-                        }
1039
+						//existent
1040
+						$entry = $this->get_entry();
1041
+						$value = NULL;
1042
+						if( isset( $entry[ $field->id ] ) ) {
1043
+							$value = json_decode( $entry[ $field->id ], true );
1044
+						}
1045 1045
 
1046
-                        // count uploaded files and existent entry files
1047
-                        $count_files = count( $file_names ) + count( $value );
1046
+						// count uploaded files and existent entry files
1047
+						$count_files = count( $file_names ) + count( $value );
1048 1048
 
1049
-                        if( $count_files > $field->maxFiles ) {
1050
-                            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1051
-                            $field->failed_validation = 1;
1052
-                            $gv_valid = false;
1049
+						if( $count_files > $field->maxFiles ) {
1050
+							$field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1051
+							$field->failed_validation = 1;
1052
+							$gv_valid = false;
1053 1053
 
1054
-                            // in case of error make sure the newest upload files are removed from the upload input
1055
-                            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1056
-                        }
1054
+							// in case of error make sure the newest upload files are removed from the upload input
1055
+							GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1056
+						}
1057 1057
 
1058
-                    }
1058
+					}
1059 1059
 
1060 1060
 
1061
-                    break;
1061
+					break;
1062 1062
 
1063
-            }
1063
+			}
1064 1064
 
1065
-            // This field has failed validation.
1066
-            if( !empty( $field->failed_validation ) ) {
1065
+			// This field has failed validation.
1066
+			if( !empty( $field->failed_validation ) ) {
1067 1067
 
1068
-                do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) );
1068
+				do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) );
1069 1069
 
1070
-                switch ( $field_type ) {
1070
+				switch ( $field_type ) {
1071 1071
 
1072
-                    // Captchas don't need to be re-entered.
1073
-                    case 'captcha':
1072
+					// Captchas don't need to be re-entered.
1073
+					case 'captcha':
1074 1074
 
1075
-                        // Post Image fields aren't editable, so we un-fail them.
1076
-                    case 'post_image':
1077
-                        $field->failed_validation = false;
1078
-                        unset( $field->validation_message );
1079
-                        break;
1075
+						// Post Image fields aren't editable, so we un-fail them.
1076
+					case 'post_image':
1077
+						$field->failed_validation = false;
1078
+						unset( $field->validation_message );
1079
+						break;
1080 1080
 
1081
-                }
1081
+				}
1082 1082
 
1083
-                // You can't continue inside a switch, so we do it after.
1084
-                if( empty( $field->failed_validation ) ) {
1085
-                    continue;
1086
-                }
1083
+				// You can't continue inside a switch, so we do it after.
1084
+				if( empty( $field->failed_validation ) ) {
1085
+					continue;
1086
+				}
1087 1087
 
1088
-                // checks if the No Duplicates option is not validating entry against itself, since
1089
-                // we're editing a stored entry, it would also assume it's a duplicate.
1090
-                if( !empty( $field->noDuplicates ) ) {
1088
+				// checks if the No Duplicates option is not validating entry against itself, since
1089
+				// we're editing a stored entry, it would also assume it's a duplicate.
1090
+				if( !empty( $field->noDuplicates ) ) {
1091 1091
 
1092
-                    $entry = $this->get_entry();
1092
+					$entry = $this->get_entry();
1093 1093
 
1094
-                    // If the value of the entry is the same as the stored value
1095
-                    // Then we can assume it's not a duplicate, it's the same.
1096
-                    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1097
-                        //if value submitted was not changed, then don't validate
1098
-                        $field->failed_validation = false;
1094
+					// If the value of the entry is the same as the stored value
1095
+					// Then we can assume it's not a duplicate, it's the same.
1096
+					if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1097
+						//if value submitted was not changed, then don't validate
1098
+						$field->failed_validation = false;
1099 1099
 
1100
-                        unset( $field->validation_message );
1100
+						unset( $field->validation_message );
1101 1101
 
1102
-                        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry );
1102
+						do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry );
1103 1103
 
1104
-                        continue;
1105
-                    }
1106
-                }
1104
+						continue;
1105
+					}
1106
+				}
1107 1107
 
1108
-                // if here then probably we are facing the validation 'At least one field must be filled out'
1109
-                if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1110
-                    unset( $field->validation_message );
1111
-	                $field->validation_message = false;
1112
-                    continue;
1113
-                }
1108
+				// if here then probably we are facing the validation 'At least one field must be filled out'
1109
+				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1110
+					unset( $field->validation_message );
1111
+					$field->validation_message = false;
1112
+					continue;
1113
+				}
1114 1114
 
1115
-                $gv_valid = false;
1115
+				$gv_valid = false;
1116 1116
 
1117
-            }
1117
+			}
1118 1118
 
1119
-        }
1119
+		}
1120 1120
 
1121
-        $validation_results['is_valid'] = $gv_valid;
1121
+		$validation_results['is_valid'] = $gv_valid;
1122 1122
 
1123
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results );
1123
+		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results );
1124 1124
 
1125
-        // We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1126
-        $this->form_after_validation = $validation_results['form'];
1125
+		// We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1126
+		$this->form_after_validation = $validation_results['form'];
1127 1127
 
1128
-        return $validation_results;
1129
-    }
1128
+		return $validation_results;
1129
+	}
1130 1130
 
1131 1131
 
1132
-    /**
1133
-     * TODO: This seems to be hacky... we should remove it. Entry is set when updating the form using setup_vars()!
1134
-     * Get the current entry and set it if it's not yet set.
1135
-     * @return array Gravity Forms entry array
1136
-     */
1137
-    private function get_entry() {
1132
+	/**
1133
+	 * TODO: This seems to be hacky... we should remove it. Entry is set when updating the form using setup_vars()!
1134
+	 * Get the current entry and set it if it's not yet set.
1135
+	 * @return array Gravity Forms entry array
1136
+	 */
1137
+	private function get_entry() {
1138 1138
 
1139
-        if( empty( $this->entry ) ) {
1140
-            // Get the database value of the entry that's being edited
1141
-            $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1142
-        }
1139
+		if( empty( $this->entry ) ) {
1140
+			// Get the database value of the entry that's being edited
1141
+			$this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1142
+		}
1143 1143
 
1144
-        return $this->entry;
1145
-    }
1144
+		return $this->entry;
1145
+	}
1146 1146
 
1147 1147
 
1148 1148
 
1149
-    // --- Filters
1149
+	// --- Filters
1150 1150
 
1151
-    /**
1152
-     * Get the Edit Entry fields as configured in the View
1153
-     *
1154
-     * @since 1.8
1155
-     *
1156
-     * @param int $view_id
1157
-     *
1158
-     * @return array Array of fields that are configured in the Edit tab in the Admin
1159
-     */
1160
-    private function get_configured_edit_fields( $form, $view_id ) {
1151
+	/**
1152
+	 * Get the Edit Entry fields as configured in the View
1153
+	 *
1154
+	 * @since 1.8
1155
+	 *
1156
+	 * @param int $view_id
1157
+	 *
1158
+	 * @return array Array of fields that are configured in the Edit tab in the Admin
1159
+	 */
1160
+	private function get_configured_edit_fields( $form, $view_id ) {
1161 1161
 
1162
-        // Get all fields for form
1163
-        $properties = GravityView_View_Data::getInstance()->get_fields( $view_id );
1162
+		// Get all fields for form
1163
+		$properties = GravityView_View_Data::getInstance()->get_fields( $view_id );
1164 1164
 
1165
-        // If edit tab not yet configured, show all fields
1166
-        $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1165
+		// If edit tab not yet configured, show all fields
1166
+		$edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1167 1167
 
1168
-	    // Show hidden fields as text fields
1169
-	    $form = $this->fix_hidden_fields( $form );
1168
+		// Show hidden fields as text fields
1169
+		$form = $this->fix_hidden_fields( $form );
1170 1170
 
1171
-        // Hide fields depending on admin settings
1172
-        $fields = $this->filter_fields( $form['fields'], $edit_fields );
1171
+		// Hide fields depending on admin settings
1172
+		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1173 1173
 
1174
-	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1175
-	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1174
+		// If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1175
+		$fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1176 1176
 
1177
-        return $fields;
1178
-    }
1177
+		return $fields;
1178
+	}
1179 1179
 
1180 1180
 	/**
1181 1181
 	 * @since 1.9.2
@@ -1199,364 +1199,364 @@  discard block
 block discarded – undo
1199 1199
 	}
1200 1200
 
1201 1201
 
1202
-    /**
1203
-     * Filter area fields based on specified conditions
1204
-     *
1205
-     * @uses GravityView_Edit_Entry::user_can_edit_field() Check caps
1206
-     * @access private
1207
-     * @param GF_Field[] $fields
1208
-     * @param array $configured_fields
1209
-     * @since  1.5
1210
-     * @return array $fields
1211
-     */
1212
-    private function filter_fields( $fields, $configured_fields ) {
1213
-
1214
-        if( empty( $fields ) || !is_array( $fields ) ) {
1215
-            return $fields;
1216
-        }
1217
-
1218
-        $edit_fields = array();
1219
-
1220
-        $field_type_blacklist = array(
1221
-            'page',
1222
-        );
1223
-
1224
-	    /**
1225
-	     * @filter `gravityview/edit_entry/hide-product-fields` Hide product fields from being editable.
1226
-	     * @since 1.9.1
1227
-         * @param boolean $hide_product_fields Whether to hide product fields in the editor.  Default: false
1228
-	     */
1229
-	    $hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) );
1230
-
1231
-	    if( $hide_product_fields ) {
1232
-		    $field_type_blacklist[] = 'option';
1233
-		    $field_type_blacklist[] = 'quantity';
1234
-            $field_type_blacklist[] = 'product';
1235
-            $field_type_blacklist[] = 'total';
1236
-            $field_type_blacklist[] = 'shipping';
1237
-            $field_type_blacklist[] = 'calculation';
1238
-	    }
1239
-
1240
-        // First, remove blacklist
1241
-        foreach ( $fields as $key => $field ) {
1242
-            if( in_array( $field->type, $field_type_blacklist ) ) {
1243
-                unset( $fields[ $key ] );
1244
-            }
1245
-        }
1246
-
1247
-        // The Edit tab has not been configured, so we return all fields by default.
1248
-        if( empty( $configured_fields ) ) {
1249
-            return $fields;
1250
-        }
1251
-
1252
-        // The edit tab has been configured, so we loop through to configured settings
1253
-        foreach ( $configured_fields as $configured_field ) {
1254
-
1255
-	        /** @var GF_Field $field */
1256
-	        foreach ( $fields as $field ) {
1257
-
1258
-                if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1259
-                    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1260
-                    break;
1261
-                }
1262
-
1263
-            }
1264
-
1265
-        }
1266
-
1267
-        return $edit_fields;
1268
-
1269
-    }
1270
-
1271
-    /**
1272
-     * Override GF Form field properties with the ones defined on the View
1273
-     * @param  GF_Field $field GF Form field object
1274
-     * @param  array $setting  GV field options
1275
-     * @since  1.5
1276
-     * @return array
1277
-     */
1278
-    private function merge_field_properties( $field, $field_setting ) {
1279
-
1280
-        $return_field = $field;
1281
-
1282
-        if( empty( $field_setting['show_label'] ) ) {
1283
-            $return_field->label = '';
1284
-        } elseif ( !empty( $field_setting['custom_label'] ) ) {
1285
-            $return_field->label = $field_setting['custom_label'];
1286
-        }
1287
-
1288
-        if( !empty( $field_setting['custom_class'] ) ) {
1289
-            $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1290
-        }
1291
-
1292
-        /**
1293
-         * Normalize page numbers - avoid conflicts with page validation
1294
-         * @since 1.6
1295
-         */
1296
-        $return_field->pageNumber = 1;
1297
-
1298
-        return $return_field;
1299
-
1300
-    }
1301
-
1302
-    /**
1303
-     * Remove fields that shouldn't be visible based on the Gravity Forms adminOnly field property
1304
-     *
1305
-     * @since 1.9.1
1306
-     *
1307
-     * @param array|GF_Field[] $fields Gravity Forms form fields
1308
-     * @param array|null $edit_fields Fields for the Edit Entry tab configured in the View Configuration
1309
-     * @param array $form GF Form array
1310
-     * @param int $view_id View ID
1311
-     *
1312
-     * @return array Possibly modified form array
1313
-     */
1314
-    function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) {
1315
-
1316
-	    /**
1317
-         * @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
1318
-	     * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1319
-	     * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1320
-	     * @since 1.9.1
1321
-	     * @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.
1322
-	     * @param array $form GF Form array
1323
-	     * @param int $view_id View ID
1324
-	     */
1325
-	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1326
-
1327
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1328
-            return $fields;
1329
-        }
1330
-
1331
-	    foreach( $fields as &$field ) {
1332
-		    $field->adminOnly = false;
1333
-        }
1334
-
1335
-        return $fields;
1336
-    }
1337
-
1338
-    // --- Conditional Logic
1339
-
1340
-    /**
1341
-     * Remove the conditional logic rules from the form button and the form fields, if needed.
1342
-     *
1343
-     * @since 1.9
1344
-     *
1345
-     * @param array $form Gravity Forms form
1346
-     * @return array Modified form, if not using Conditional Logic
1347
-     */
1348
-    function filter_conditional_logic( $form ) {
1349
-
1350
-        /**
1351
-         * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields?
1352
-         * @since 1.9
1353
-         * @param bool $use_conditional_logic True: Gravity Forms will show/hide fields just like in the original form; False: conditional logic will be disabled and fields will be shown based on configuration. Default: true
1354
-         * @param array $form Gravity Forms form
1355
-         */
1356
-        $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
1357
-
1358
-        if( $use_conditional_logic ) {
1359
-            return $form;
1360
-        }
1361
-
1362
-        foreach( $form['fields'] as &$field ) {
1363
-            /* @var GF_Field $field */
1364
-            $field->conditionalLogic = null;
1365
-        }
1366
-
1367
-        unset( $form['button']['conditionalLogic'] );
1368
-
1369
-        return $form;
1370
-
1371
-    }
1372
-
1373
-    /**
1374
-     * Disable the Gravity Forms conditional logic script and features on the Edit Entry screen
1375
-     *
1376
-     * @since 1.9
1377
-     *
1378
-     * @param $has_conditional_logic
1379
-     * @param $form
1380
-     * @return mixed|void
1381
-     */
1382
-    function manage_conditional_logic( $has_conditional_logic, $form ) {
1383
-
1384
-        if( ! $this->is_edit_entry() ) {
1385
-            return $has_conditional_logic;
1386
-        }
1387
-
1388
-        return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );
1389
-
1390
-    }
1391
-
1392
-
1393
-    // --- User checks and nonces
1394
-
1395
-    /**
1396
-     * Check if the user can edit the entry
1397
-     *
1398
-     * - Is the nonce valid?
1399
-     * - Does the user have the right caps for the entry
1400
-     * - Is the entry in the trash?
1401
-     *
1402
-     * @todo Move to GVCommon
1403
-     *
1404
-     * @param  boolean $echo Show error messages in the form?
1405
-     * @return boolean        True: can edit form. False: nope.
1406
-     */
1407
-    function user_can_edit_entry( $echo = false ) {
1408
-
1409
-        $error = NULL;
1410
-
1411
-        /**
1412
-         *  1. Permalinks are turned off
1413
-         *  2. There are two entries embedded using oEmbed
1414
-         *  3. One of the entries has just been saved
1415
-         */
1416
-        if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
1417
-
1418
-            $error = true;
1419
-
1420
-        }
1202
+	/**
1203
+	 * Filter area fields based on specified conditions
1204
+	 *
1205
+	 * @uses GravityView_Edit_Entry::user_can_edit_field() Check caps
1206
+	 * @access private
1207
+	 * @param GF_Field[] $fields
1208
+	 * @param array $configured_fields
1209
+	 * @since  1.5
1210
+	 * @return array $fields
1211
+	 */
1212
+	private function filter_fields( $fields, $configured_fields ) {
1213
+
1214
+		if( empty( $fields ) || !is_array( $fields ) ) {
1215
+			return $fields;
1216
+		}
1217
+
1218
+		$edit_fields = array();
1219
+
1220
+		$field_type_blacklist = array(
1221
+			'page',
1222
+		);
1223
+
1224
+		/**
1225
+		 * @filter `gravityview/edit_entry/hide-product-fields` Hide product fields from being editable.
1226
+		 * @since 1.9.1
1227
+		 * @param boolean $hide_product_fields Whether to hide product fields in the editor.  Default: false
1228
+		 */
1229
+		$hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) );
1230
+
1231
+		if( $hide_product_fields ) {
1232
+			$field_type_blacklist[] = 'option';
1233
+			$field_type_blacklist[] = 'quantity';
1234
+			$field_type_blacklist[] = 'product';
1235
+			$field_type_blacklist[] = 'total';
1236
+			$field_type_blacklist[] = 'shipping';
1237
+			$field_type_blacklist[] = 'calculation';
1238
+		}
1239
+
1240
+		// First, remove blacklist
1241
+		foreach ( $fields as $key => $field ) {
1242
+			if( in_array( $field->type, $field_type_blacklist ) ) {
1243
+				unset( $fields[ $key ] );
1244
+			}
1245
+		}
1246
+
1247
+		// The Edit tab has not been configured, so we return all fields by default.
1248
+		if( empty( $configured_fields ) ) {
1249
+			return $fields;
1250
+		}
1251
+
1252
+		// The edit tab has been configured, so we loop through to configured settings
1253
+		foreach ( $configured_fields as $configured_field ) {
1254
+
1255
+			/** @var GF_Field $field */
1256
+			foreach ( $fields as $field ) {
1257
+
1258
+				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1259
+					$edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1260
+					break;
1261
+				}
1262
+
1263
+			}
1264
+
1265
+		}
1266
+
1267
+		return $edit_fields;
1268
+
1269
+	}
1270
+
1271
+	/**
1272
+	 * Override GF Form field properties with the ones defined on the View
1273
+	 * @param  GF_Field $field GF Form field object
1274
+	 * @param  array $setting  GV field options
1275
+	 * @since  1.5
1276
+	 * @return array
1277
+	 */
1278
+	private function merge_field_properties( $field, $field_setting ) {
1279
+
1280
+		$return_field = $field;
1281
+
1282
+		if( empty( $field_setting['show_label'] ) ) {
1283
+			$return_field->label = '';
1284
+		} elseif ( !empty( $field_setting['custom_label'] ) ) {
1285
+			$return_field->label = $field_setting['custom_label'];
1286
+		}
1287
+
1288
+		if( !empty( $field_setting['custom_class'] ) ) {
1289
+			$return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1290
+		}
1291
+
1292
+		/**
1293
+		 * Normalize page numbers - avoid conflicts with page validation
1294
+		 * @since 1.6
1295
+		 */
1296
+		$return_field->pageNumber = 1;
1297
+
1298
+		return $return_field;
1299
+
1300
+	}
1301
+
1302
+	/**
1303
+	 * Remove fields that shouldn't be visible based on the Gravity Forms adminOnly field property
1304
+	 *
1305
+	 * @since 1.9.1
1306
+	 *
1307
+	 * @param array|GF_Field[] $fields Gravity Forms form fields
1308
+	 * @param array|null $edit_fields Fields for the Edit Entry tab configured in the View Configuration
1309
+	 * @param array $form GF Form array
1310
+	 * @param int $view_id View ID
1311
+	 *
1312
+	 * @return array Possibly modified form array
1313
+	 */
1314
+	function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) {
1315
+
1316
+		/**
1317
+		 * @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
1318
+		 * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1319
+		 * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1320
+		 * @since 1.9.1
1321
+		 * @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.
1322
+		 * @param array $form GF Form array
1323
+		 * @param int $view_id View ID
1324
+		 */
1325
+		$use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1326
+
1327
+		if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1328
+			return $fields;
1329
+		}
1330
+
1331
+		foreach( $fields as &$field ) {
1332
+			$field->adminOnly = false;
1333
+		}
1334
+
1335
+		return $fields;
1336
+	}
1337
+
1338
+	// --- Conditional Logic
1339
+
1340
+	/**
1341
+	 * Remove the conditional logic rules from the form button and the form fields, if needed.
1342
+	 *
1343
+	 * @since 1.9
1344
+	 *
1345
+	 * @param array $form Gravity Forms form
1346
+	 * @return array Modified form, if not using Conditional Logic
1347
+	 */
1348
+	function filter_conditional_logic( $form ) {
1349
+
1350
+		/**
1351
+		 * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields?
1352
+		 * @since 1.9
1353
+		 * @param bool $use_conditional_logic True: Gravity Forms will show/hide fields just like in the original form; False: conditional logic will be disabled and fields will be shown based on configuration. Default: true
1354
+		 * @param array $form Gravity Forms form
1355
+		 */
1356
+		$use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
1357
+
1358
+		if( $use_conditional_logic ) {
1359
+			return $form;
1360
+		}
1361
+
1362
+		foreach( $form['fields'] as &$field ) {
1363
+			/* @var GF_Field $field */
1364
+			$field->conditionalLogic = null;
1365
+		}
1366
+
1367
+		unset( $form['button']['conditionalLogic'] );
1368
+
1369
+		return $form;
1370
+
1371
+	}
1372
+
1373
+	/**
1374
+	 * Disable the Gravity Forms conditional logic script and features on the Edit Entry screen
1375
+	 *
1376
+	 * @since 1.9
1377
+	 *
1378
+	 * @param $has_conditional_logic
1379
+	 * @param $form
1380
+	 * @return mixed|void
1381
+	 */
1382
+	function manage_conditional_logic( $has_conditional_logic, $form ) {
1383
+
1384
+		if( ! $this->is_edit_entry() ) {
1385
+			return $has_conditional_logic;
1386
+		}
1421 1387
 
1422
-        if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
1388
+		return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );
1423 1389
 
1424
-            $error = true;
1390
+	}
1425 1391
 
1426
-        } elseif( ! $this->verify_nonce() ) {
1427 1392
 
1428
-            /**
1429
-             * If the Entry is embedded, there may be two entries on the same page.
1430
-             * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
1431
-             */
1432
-            if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1433
-                $error = true;
1434
-            } else {
1435
-                $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
1436
-            }
1393
+	// --- User checks and nonces
1437 1394
 
1438
-        }
1395
+	/**
1396
+	 * Check if the user can edit the entry
1397
+	 *
1398
+	 * - Is the nonce valid?
1399
+	 * - Does the user have the right caps for the entry
1400
+	 * - Is the entry in the trash?
1401
+	 *
1402
+	 * @todo Move to GVCommon
1403
+	 *
1404
+	 * @param  boolean $echo Show error messages in the form?
1405
+	 * @return boolean        True: can edit form. False: nope.
1406
+	 */
1407
+	function user_can_edit_entry( $echo = false ) {
1439 1408
 
1440
-        if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1441
-            $error = __( 'You do not have permission to edit this entry.', 'gravityview');
1442
-        }
1409
+		$error = NULL;
1443 1410
 
1444
-        if( $this->entry['status'] === 'trash' ) {
1445
-            $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
1446
-        }
1411
+		/**
1412
+		 *  1. Permalinks are turned off
1413
+		 *  2. There are two entries embedded using oEmbed
1414
+		 *  3. One of the entries has just been saved
1415
+		 */
1416
+		if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
1447 1417
 
1448
-        // No errors; everything's fine here!
1449
-        if( empty( $error ) ) {
1450
-            return true;
1451
-        }
1418
+			$error = true;
1452 1419
 
1453
-        if( $echo && $error !== true ) {
1420
+		}
1454 1421
 
1455
-	        $error = esc_html( $error );
1422
+		if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
1456 1423
 
1457
-	        /**
1458
-	         * @since 1.9
1459
-	         */
1460
-	        if ( ! empty( $this->entry ) ) {
1461
-		        $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;" ) );
1462
-	        }
1424
+			$error = true;
1463 1425
 
1464
-            echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1465
-        }
1426
+		} elseif( ! $this->verify_nonce() ) {
1466 1427
 
1467
-        do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error );
1428
+			/**
1429
+			 * If the Entry is embedded, there may be two entries on the same page.
1430
+			 * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
1431
+			 */
1432
+			if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1433
+				$error = true;
1434
+			} else {
1435
+				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
1436
+			}
1468 1437
 
1469
-        return false;
1470
-    }
1438
+		}
1471 1439
 
1440
+		if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1441
+			$error = __( 'You do not have permission to edit this entry.', 'gravityview');
1442
+		}
1472 1443
 
1473
-    /**
1474
-     * Check whether a field is editable by the current user, and optionally display an error message
1475
-     * @uses  GravityView_Edit_Entry->check_user_cap_edit_field() Check user capabilities
1476
-     * @param  array  $field Field or field settings array
1477
-     * @param  boolean $echo  Whether to show error message telling user they aren't allowed
1478
-     * @return boolean         True: user can edit the current field; False: nope, they can't.
1479
-     */
1480
-    private function user_can_edit_field( $field, $echo = false ) {
1444
+		if( $this->entry['status'] === 'trash' ) {
1445
+			$error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
1446
+		}
1481 1447
 
1482
-        $error = NULL;
1448
+		// No errors; everything's fine here!
1449
+		if( empty( $error ) ) {
1450
+			return true;
1451
+		}
1483 1452
 
1484
-        if( ! $this->check_user_cap_edit_field( $field ) ) {
1485
-            $error = __( 'You do not have permission to edit this field.', 'gravityview');
1486
-        }
1453
+		if( $echo && $error !== true ) {
1487 1454
 
1488
-        // No errors; everything's fine here!
1489
-        if( empty( $error ) ) {
1490
-            return true;
1491
-        }
1455
+			$error = esc_html( $error );
1492 1456
 
1493
-        if( $echo ) {
1494
-            echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
1495
-        }
1496
-
1497
-        do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error );
1457
+			/**
1458
+			 * @since 1.9
1459
+			 */
1460
+			if ( ! empty( $this->entry ) ) {
1461
+				$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;" ) );
1462
+			}
1498 1463
 
1499
-        return false;
1464
+			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1465
+		}
1500 1466
 
1501
-    }
1467
+		do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error );
1502 1468
 
1469
+		return false;
1470
+	}
1503 1471
 
1504
-    /**
1505
-     * checks if user has permissions to edit a specific field
1506
-     *
1507
-     * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_field for maximum security!!
1508
-     *
1509
-     * @param  [type] $field [description]
1510
-     * @return bool
1511
-     */
1512
-    private function check_user_cap_edit_field( $field ) {
1513 1472
 
1514
-        // If they can edit any entries (as defined in Gravity Forms), we're good.
1515
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
1516
-            return true;
1517
-        }
1473
+	/**
1474
+	 * Check whether a field is editable by the current user, and optionally display an error message
1475
+	 * @uses  GravityView_Edit_Entry->check_user_cap_edit_field() Check user capabilities
1476
+	 * @param  array  $field Field or field settings array
1477
+	 * @param  boolean $echo  Whether to show error message telling user they aren't allowed
1478
+	 * @return boolean         True: user can edit the current field; False: nope, they can't.
1479
+	 */
1480
+	private function user_can_edit_field( $field, $echo = false ) {
1518 1481
 
1519
-        $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
1482
+		$error = NULL;
1520 1483
 
1521
-        // If the field has custom editing capaibilities set, check those
1522
-        if( $field_cap ) {
1523
-            return GVCommon::has_cap( $field['allow_edit_cap'] );
1524
-        }
1525
-
1526
-        return false;
1527
-    }
1484
+		if( ! $this->check_user_cap_edit_field( $field ) ) {
1485
+			$error = __( 'You do not have permission to edit this field.', 'gravityview');
1486
+		}
1528 1487
 
1488
+		// No errors; everything's fine here!
1489
+		if( empty( $error ) ) {
1490
+			return true;
1491
+		}
1529 1492
 
1530
-    /**
1531
-     * Is the current nonce valid for editing the entry?
1532
-     * @return boolean
1533
-     */
1534
-    public function verify_nonce() {
1493
+		if( $echo ) {
1494
+			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
1495
+		}
1535 1496
 
1536
-        // Verify form submitted for editing single
1537
-        if( $this->is_edit_entry_submission() ) {
1538
-            $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
1539
-        }
1497
+		do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error );
1540 1498
 
1541
-        // Verify
1542
-        else if( ! $this->is_edit_entry() ) {
1543
-            $valid = false;
1544
-        }
1499
+		return false;
1545 1500
 
1546
-        else {
1547
-            $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
1548
-        }
1501
+	}
1549 1502
 
1550
-        /**
1551
-         * @filter `gravityview/edit_entry/verify_nonce` Override Edit Entry nonce validation. Return true to declare nonce valid.
1552
-         * @since 1.13
1553
-         * @param int|boolean $valid False if invalid; 1 or 2 when nonce was generated
1554
-         * @param string $nonce_field Key used when validating submissions. Default: is_gv_edit_entry
1555
-         */
1556
-        $valid = apply_filters( 'gravityview/edit_entry/verify_nonce', $valid, self::$nonce_field );
1557 1503
 
1558
-        return $valid;
1559
-    }
1504
+	/**
1505
+	 * checks if user has permissions to edit a specific field
1506
+	 *
1507
+	 * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_field for maximum security!!
1508
+	 *
1509
+	 * @param  [type] $field [description]
1510
+	 * @return bool
1511
+	 */
1512
+	private function check_user_cap_edit_field( $field ) {
1513
+
1514
+		// If they can edit any entries (as defined in Gravity Forms), we're good.
1515
+		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
1516
+			return true;
1517
+		}
1518
+
1519
+		$field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
1520
+
1521
+		// If the field has custom editing capaibilities set, check those
1522
+		if( $field_cap ) {
1523
+			return GVCommon::has_cap( $field['allow_edit_cap'] );
1524
+		}
1525
+
1526
+		return false;
1527
+	}
1528
+
1529
+
1530
+	/**
1531
+	 * Is the current nonce valid for editing the entry?
1532
+	 * @return boolean
1533
+	 */
1534
+	public function verify_nonce() {
1535
+
1536
+		// Verify form submitted for editing single
1537
+		if( $this->is_edit_entry_submission() ) {
1538
+			$valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
1539
+		}
1540
+
1541
+		// Verify
1542
+		else if( ! $this->is_edit_entry() ) {
1543
+			$valid = false;
1544
+		}
1545
+
1546
+		else {
1547
+			$valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
1548
+		}
1549
+
1550
+		/**
1551
+		 * @filter `gravityview/edit_entry/verify_nonce` Override Edit Entry nonce validation. Return true to declare nonce valid.
1552
+		 * @since 1.13
1553
+		 * @param int|boolean $valid False if invalid; 1 or 2 when nonce was generated
1554
+		 * @param string $nonce_field Key used when validating submissions. Default: is_gv_edit_entry
1555
+		 */
1556
+		$valid = apply_filters( 'gravityview/edit_entry/verify_nonce', $valid, self::$nonce_field );
1557
+
1558
+		return $valid;
1559
+	}
1560 1560
 
1561 1561
 
1562 1562
 
Please login to merge, or discard this patch.
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
     function load() {
92 92
 
93 93
         /** @define "GRAVITYVIEW_DIR" "../../../" */
94
-        include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
94
+        include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' );
95 95
 
96 96
         // Don't display an embedded form when editing an entry
97 97
         add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
98 98
         add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
99 99
 
100 100
         // Stop Gravity Forms processing what is ours!
101
-        add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
101
+        add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 );
102 102
 
103
-        add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
103
+        add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) );
104 104
 
105 105
         add_action( 'gravityview_edit_entry', array( $this, 'init' ) );
106 106
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
112 112
 
113 113
         // Add fields expected by GFFormDisplay::validate()
114
-        add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
114
+        add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) );
115 115
 
116 116
     }
117 117
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
      * @return void
127 127
      */
128 128
     function prevent_render_form() {
129
-        if( $this->is_edit_entry() ) {
130
-            if( 'wp_head' === current_filter() ) {
129
+        if ( $this->is_edit_entry() ) {
130
+            if ( 'wp_head' === current_filter() ) {
131 131
                 add_filter( 'gform_shortcode_form', '__return_empty_string' );
132 132
             } else {
133 133
                 remove_filter( 'gform_shortcode_form', '__return_empty_string' );
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
      */
143 143
     function prevent_maybe_process_form() {
144 144
 
145
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
145
+        do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
146 146
 
147
-        if( $this->is_edit_entry_submission() && $this->verify_nonce() ) {
148
-            remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
147
+        if ( $this->is_edit_entry_submission() && $this->verify_nonce() ) {
148
+            remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 );
149 149
         }
150 150
     }
151 151
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
         $gf_page = ( 'entry' === RGForms::get( 'view' ) );
159 159
 
160
-        return ( $gf_page && isset( $_GET['edit'] ) || RGForms::post( 'action' ) === 'update' );
160
+        return ( $gf_page && isset( $_GET[ 'edit' ] ) || RGForms::post( 'action' ) === 'update' );
161 161
     }
162 162
 
163 163
 	/**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @return boolean
167 167
 	 */
168 168
 	public function is_edit_entry_submission() {
169
-		return !empty( $_POST[ self::$nonce_field ] );
169
+		return ! empty( $_POST[ self::$nonce_field ] );
170 170
 	}
171 171
 
172 172
     /**
@@ -177,14 +177,14 @@  discard block
 block discarded – undo
177 177
 
178 178
 
179 179
         $entries = $gravityview_view->getEntries();
180
-        $this->entry = $entries[0];
180
+        $this->entry = $entries[ 0 ];
181 181
 
182 182
 
183 183
         $this->form = $gravityview_view->getForm();
184 184
         $this->form_id = $gravityview_view->getFormId();
185 185
         $this->view_id = $gravityview_view->getViewId();
186 186
 
187
-        self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
187
+        self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] );
188 188
     }
189 189
 
190 190
 
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
         $this->setup_vars();
205 205
 
206 206
         // Multiple Views embedded, don't proceed if nonce fails
207
-        if( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) {
207
+        if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) {
208 208
             return;
209 209
         }
210 210
 
211 211
         // Sorry, you're not allowed here.
212
-        if( false === $this->user_can_edit_entry( true ) ) {
212
+        if ( false === $this->user_can_edit_entry( true ) ) {
213 213
             return;
214 214
         }
215 215
 
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
     function print_scripts() {
230 230
         $gravityview_view = GravityView_View::getInstance();
231 231
 
232
-        wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
232
+        wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
233 233
 
234
-        GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false);
234
+        GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false );
235 235
 
236 236
         // Sack is required for images
237 237
         wp_print_scripts( array( 'sack', 'gform_gravityforms' ) );
@@ -243,32 +243,32 @@  discard block
 block discarded – undo
243 243
      */
244 244
     function process_save() {
245 245
 
246
-        if( empty( $_POST ) ) {
246
+        if ( empty( $_POST ) ) {
247 247
             return;
248 248
         }
249 249
 
250 250
         // Make sure the entry, view, and form IDs are all correct
251 251
         $valid = $this->verify_nonce();
252 252
 
253
-        if( !$valid ) {
254
-            do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' );
253
+        if ( ! $valid ) {
254
+            do_action( 'gravityview_log_error', __METHOD__ . ' Nonce validation failed.' );
255 255
             return;
256 256
         }
257 257
 
258
-        if( $this->entry['id'] !== $_POST['lid'] ) {
259
-            do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' );
258
+        if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) {
259
+            do_action( 'gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' );
260 260
             return;
261 261
         }
262 262
 
263
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
263
+        do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
264 264
 
265 265
         $this->process_save_process_files( $this->form_id );
266 266
 
267 267
         $this->validate();
268 268
 
269
-        if( $this->is_valid ) {
269
+        if ( $this->is_valid ) {
270 270
 
271
-            do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' );
271
+            do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' );
272 272
 
273 273
             /**
274 274
              * @hack This step is needed to unset the adminOnly from form fields
@@ -278,12 +278,12 @@  discard block
 block discarded – undo
278 278
             /**
279 279
              * @hack to avoid the capability validation of the method save_lead for GF 1.9+
280 280
              */
281
-            unset( $_GET['page'] );
281
+            unset( $_GET[ 'page' ] );
282 282
 
283 283
             GFFormsModel::save_lead( $form, $this->entry );
284 284
 
285 285
             // If there's a post associated with the entry, process post fields
286
-            if( !empty( $this->entry['post_id'] ) ) {
286
+            if ( ! empty( $this->entry[ 'post_id' ] ) ) {
287 287
                 $this->maybe_update_post_fields( $form );
288 288
             }
289 289
 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
              * @param array $form Gravity Forms form array
296 296
              * @param string $entry_id Numeric ID of the entry that was updated
297 297
              */
298
-            do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] );
298
+            do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ] );
299 299
         }
300 300
 
301 301
     } // process_save
@@ -329,11 +329,11 @@  discard block
 block discarded – undo
329 329
      * @return mixed
330 330
      */
331 331
     public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
332
-        if( ! $this->is_edit_entry() ) {
332
+        if ( ! $this->is_edit_entry() ) {
333 333
             return $plupload_init;
334 334
         }
335 335
 
336
-        $plupload_init['gf_vars']['max_files'] = 0;
336
+        $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0;
337 337
 
338 338
         return $plupload_init;
339 339
     }
@@ -346,13 +346,13 @@  discard block
 block discarded – undo
346 346
     private function form_prepare_for_save() {
347 347
         $form = $this->form;
348 348
 
349
-        foreach( $form['fields'] as &$field ) {
349
+        foreach ( $form[ 'fields' ] as &$field ) {
350 350
 
351 351
             $field->adminOnly = false;
352 352
 
353
-            if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
354
-                foreach( $field->inputs as $key => $input ) {
355
-                    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
353
+            if ( isset( $field->inputs ) && is_array( $field->inputs ) ) {
354
+                foreach ( $field->inputs as $key => $input ) {
355
+                    $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ];
356 356
                 }
357 357
             }
358 358
         }
@@ -370,11 +370,11 @@  discard block
 block discarded – undo
370 370
      */
371 371
     function maybe_update_post_fields( $form ) {
372 372
 
373
-        $post_id = $this->entry['post_id'];
373
+        $post_id = $this->entry[ 'post_id' ];
374 374
 
375 375
         // Security check
376
-        if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
377
-            do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id );
376
+        if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
377
+            do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #' . $post_id );
378 378
             return;
379 379
         }
380 380
 
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
 
389 389
             $field = RGFormsModel::get_field( $form, $field_id );
390 390
 
391
-            if( class_exists('GF_Fields') ) {
391
+            if ( class_exists( 'GF_Fields' ) ) {
392 392
                 $field = GF_Fields::create( $field );
393 393
             }
394 394
 
395
-            if( GFCommon::is_post_field( $field ) ) {
395
+            if ( GFCommon::is_post_field( $field ) ) {
396 396
 
397 397
                 // Get the value of the field, including $_POSTed value
398 398
                 $value = RGFormsModel::get_field_value( $field );
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
                 // Convert the field object in 1.9 to an array for backward compatibility
401 401
                 $field_array = GVCommon::get_field_array( $field );
402 402
 
403
-                switch( $field_array['type'] ) {
403
+                switch ( $field_array[ 'type' ] ) {
404 404
 
405 405
                     case 'post_title':
406 406
                     case 'post_content':
407 407
                     case 'post_excerpt':
408
-                        $updated_post->{$field_array['type']} = $value;
408
+                        $updated_post->{$field_array[ 'type' ]} = $value;
409 409
                         break;
410 410
                     case 'post_tags':
411 411
                         wp_set_post_tags( $post_id, $value, false );
@@ -421,24 +421,24 @@  discard block
 block discarded – undo
421 421
                         $field = GFCommon::add_categories_as_choices( $field, '' );
422 422
 
423 423
                         // if post_category is type checkbox, then value is an array of inputs
424
-                        if( isset( $value[ strval( $field_id ) ] ) ) {
425
-                            foreach( $value as $input_id => $val ) {
424
+                        if ( isset( $value[ strval( $field_id ) ] ) ) {
425
+                            foreach ( $value as $input_id => $val ) {
426 426
                                 $input_name = 'input_' . str_replace( '.', '_', $input_id );
427
-                                $this->entry[ strval( $input_id ) ] = RGFormsModel::prepare_value( $form, $field, $val, $input_name, $this->entry['id'] );
427
+                                $this->entry[ strval( $input_id ) ] = RGFormsModel::prepare_value( $form, $field, $val, $input_name, $this->entry[ 'id' ] );
428 428
                             }
429 429
                         } else {
430 430
                             $input_name = 'input_' . str_replace( '.', '_', $field_id );
431
-                            $this->entry[ strval( $field_id ) ] = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $this->entry['id'] );
431
+                            $this->entry[ strval( $field_id ) ] = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $this->entry[ 'id' ] );
432 432
                         }
433 433
 
434 434
                         break;
435 435
                     case 'post_custom_field':
436 436
 
437 437
                         $input_type = RGFormsModel::get_input_type( $field );
438
-                        $custom_field_name = $field_array['postCustomFieldName'];
438
+                        $custom_field_name = $field_array[ 'postCustomFieldName' ];
439 439
 
440 440
                         // Only certain custom field types are supported
441
-                        if( !in_array( $input_type, array( 'list', 'fileupload' ) ) ) {
441
+                        if ( ! in_array( $input_type, array( 'list', 'fileupload' ) ) ) {
442 442
                             update_post_meta( $post_id, $custom_field_name, $value );
443 443
                         }
444 444
 
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
                 }
453 453
 
454 454
                 //ignore fields that have not changed
455
-                if ( $value === rgget( (string) $field_id, $this->entry ) ) {
455
+                if ( $value === rgget( (string)$field_id, $this->entry ) ) {
456 456
                     continue;
457 457
                 }
458 458
 
459 459
                 // update entry
460
-                if( 'post_category' !== $field->type ) {
460
+                if ( 'post_category' !== $field->type ) {
461 461
                     $this->entry[ strval( $field_id ) ] = $value;
462 462
                 }
463 463
 
@@ -467,24 +467,24 @@  discard block
 block discarded – undo
467 467
 
468 468
         }
469 469
 
470
-        if( $update_entry ) {
470
+        if ( $update_entry ) {
471 471
 
472 472
             $return_entry = GFAPI::update_entry( $this->entry );
473 473
 
474
-            if( is_wp_error( $return_entry ) ) {
474
+            if ( is_wp_error( $return_entry ) ) {
475 475
                 do_action( 'gravityview_log_error', 'Updating the entry post fields failed', $return_entry );
476 476
             } else {
477
-                do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' );
477
+                do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #' . $post_id . ' succeeded' );
478 478
             }
479 479
 
480 480
         }
481 481
 
482 482
         $return_post = wp_update_post( $updated_post, true );
483 483
 
484
-        if( is_wp_error( $return_post ) ) {
484
+        if ( is_wp_error( $return_post ) ) {
485 485
             do_action( 'gravityview_log_error', 'Updating the post content failed', $return_post );
486 486
         } else {
487
-            do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded' );
487
+            do_action( 'gravityview_log_debug', 'Updating the post content for post #' . $post_id . ' succeeded' );
488 488
         }
489 489
 
490 490
     }
@@ -500,18 +500,18 @@  discard block
 block discarded – undo
500 500
      */
501 501
     function after_update() {
502 502
 
503
-        do_action( 'gform_after_update_entry', $this->form, $this->entry['id'] );
504
-        do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] );
503
+        do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ] );
504
+        do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ] );
505 505
 
506 506
         // Re-define the entry now that we've updated it.
507
-        $entry = RGFormsModel::get_lead( $this->entry['id'] );
507
+        $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] );
508 508
 
509 509
         $entry = GFFormsModel::set_entry_meta( $entry, $this->form );
510 510
 
511 511
         // We need to clear the cache because Gravity Forms caches the field values, which
512 512
         // we have just updated.
513
-        foreach ($this->form['fields'] as $key => $field) {
514
-            GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
513
+        foreach ( $this->form[ 'fields' ] as $key => $field ) {
514
+            GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id );
515 515
         }
516 516
 
517 517
         $this->entry = $entry;
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 
532 532
         <div class="gv-edit-entry-wrapper"><?php
533 533
 
534
-            $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
534
+            $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this );
535 535
 
536 536
             /**
537 537
              * Fixes weird wpautop() issue
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
                      * @param string $edit_entry_title Modify the "Edit Entry" title
548 548
                      * @param GravityView_Edit_Entry_Render $this This object
549 549
                      */
550
-                    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
550
+                    $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this );
551 551
 
552 552
                     echo esc_attr( $edit_entry_title );
553 553
             ?></span>
@@ -556,18 +556,18 @@  discard block
 block discarded – undo
556 556
             <?php
557 557
 
558 558
             // Display the success message
559
-            if( rgpost('action') === 'update' ) {
559
+            if ( rgpost( 'action' ) === 'update' ) {
560 560
 
561
-                if( ! $this->is_valid ){
561
+                if ( ! $this->is_valid ) {
562 562
 
563 563
                     // Keeping this compatible with Gravity Forms.
564
-                    $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
565
-                    $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
564
+                    $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>";
565
+                    $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form );
566 566
 
567
-                    echo GVCommon::generate_notice( $message , 'gv-error' );
567
+                    echo GVCommon::generate_notice( $message, 'gv-error' );
568 568
 
569 569
                 } else {
570
-                    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' );
570
+                    $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' );
571 571
 
572 572
                     /**
573 573
                      * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link)
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
                      * @param array $entry Gravity Forms entry array
578 578
                      * @param string $back_link URL to return to the original entry. @since 1.6
579 579
                      */
580
-                    $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
580
+                    $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link );
581 581
 
582 582
                     echo GVCommon::generate_notice( $message );
583 583
                 }
@@ -634,13 +634,13 @@  discard block
 block discarded – undo
634 634
      */
635 635
     private function render_edit_form() {
636 636
 
637
-        add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
638
-        add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
637
+        add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 );
638
+        add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
639 639
         add_filter( 'gform_disable_view_counter', '__return_true' );
640 640
         add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
641 641
 
642 642
         // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
643
-        unset( $_GET['page'] );
643
+        unset( $_GET[ 'page' ] );
644 644
 
645 645
         // TODO: Make sure validation isn't handled by GF
646 646
         // TODO: Include CSS for file upload fields
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
         // TODO: Product fields are not editable
649 649
         // TODO: Check Updated and Error messages
650 650
 
651
-        $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
651
+        $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry );
652 652
 
653 653
 	    remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
654 654
         remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
      * @return string
665 665
      */
666 666
     public function render_form_buttons() {
667
-        return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
667
+        return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this );
668 668
     }
669 669
 
670 670
 
@@ -684,17 +684,17 @@  discard block
 block discarded – undo
684 684
     public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
685 685
 
686 686
         // In case we have validated the form, use it to inject the validation results into the form render
687
-        if( isset( $this->form_after_validation ) ) {
687
+        if ( isset( $this->form_after_validation ) ) {
688 688
             $form = $this->form_after_validation;
689 689
         } else {
690
-            $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
690
+            $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id );
691 691
         }
692 692
 
693 693
         $form = $this->filter_conditional_logic( $form );
694 694
 
695 695
         // for now we don't support Save and Continue feature.
696
-        if( ! self::$supports_save_and_continue ) {
697
-	        unset( $form['save'] );
696
+        if ( ! self::$supports_save_and_continue ) {
697
+	        unset( $form[ 'save' ] );
698 698
         }
699 699
 
700 700
         return $form;
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 
718 718
         // If the form has been submitted, then we don't need to pre-fill the values,
719 719
         // Except for fileupload type - run always!!
720
-        if(
720
+        if (
721 721
 	        $this->is_edit_entry_submission() && 'fileupload' !== $field->type
722 722
         ||  GFCommon::is_product_field( $field->type ) // Prevent product fields from appearing editable
723 723
         ) {
@@ -725,8 +725,8 @@  discard block
 block discarded – undo
725 725
         }
726 726
 
727 727
         // Turn on Admin-style display for file upload fields only
728
-        if( 'fileupload' === $field->type ) {
729
-            $_GET['page'] = 'gf_entries';
728
+        if ( 'fileupload' === $field->type ) {
729
+            $_GET[ 'page' ] = 'gf_entries';
730 730
         }
731 731
 
732 732
         // SET SOME FIELD DEFAULTS TO PREVENT ISSUES
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
         $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
747 747
 
748 748
         // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
749
-        if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
749
+        if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) {
750 750
 
751 751
             $field_value = array();
752 752
 
@@ -755,10 +755,10 @@  discard block
 block discarded – undo
755 755
 
756 756
 	        foreach ( (array)$field->inputs as $input ) {
757 757
 
758
-	            $input_id = strval( $input['id'] );
758
+	            $input_id = strval( $input[ 'id' ] );
759 759
 
760 760
                 if ( ! empty( $this->entry[ $input_id ] ) ) {
761
-                    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
761
+                    $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
762 762
                     $allow_pre_populated = false;
763 763
                 }
764 764
 
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 
767 767
             $pre_value = $field->get_value_submission( array(), false );
768 768
 
769
-            $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !empty( $pre_value ) ) ? $field_value : $pre_value;
769
+            $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! empty( $pre_value ) ) ? $field_value : $pre_value;
770 770
 
771 771
         } else {
772 772
 
@@ -777,13 +777,13 @@  discard block
 block discarded – undo
777 777
 
778 778
             // saved field entry value (if empty, fallback to the pre-populated value, if exists)
779 779
             // or pre-populated value if not empty and set to override saved value
780
-            $field_value = !empty( $this->entry[ $id ] ) && ! ( $override_saved_value && !empty( $pre_value ) ) ? $this->entry[ $id ] : $pre_value;
780
+            $field_value = ! empty( $this->entry[ $id ] ) && ! ( $override_saved_value && ! empty( $pre_value ) ) ? $this->entry[ $id ] : $pre_value;
781 781
 
782 782
             // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
783
-            if ( 'post_category' === $field->type && !empty( $field_value ) ) {
783
+            if ( 'post_category' === $field->type && ! empty( $field_value ) ) {
784 784
                 $categories = array();
785 785
                 foreach ( explode( ',', $field_value ) as $cat_string ) {
786
-                    $categories[] = GFCommon::format_post_category( $cat_string, true );
786
+                    $categories[ ] = GFCommon::format_post_category( $cat_string, true );
787 787
                 }
788 788
                 $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
789 789
             }
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 	    // If there was output, it's an error
810 810
 	    $warnings = ob_get_clean();
811 811
 
812
-	    if( !empty( $warnings ) ) {
812
+	    if ( ! empty( $warnings ) ) {
813 813
 		    do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value );
814 814
 	    }
815 815
 
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
          * We need the fileupload html field to render with the proper id
819 819
          *  ( <li id="field_80_16" ... > )
820 820
          */
821
-        unset( $_GET['page'] );
821
+        unset( $_GET[ 'page' ] );
822 822
 
823 823
         return $return;
824 824
     }
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
     public function get_field_value( $value, $lead, $field ) {
838 838
 
839 839
         // The form's not being edited; use the original value
840
-        if( ! $this->is_edit_entry_submission() ) {
840
+        if ( ! $this->is_edit_entry_submission() ) {
841 841
             return $value;
842 842
         }
843 843
 
@@ -858,12 +858,12 @@  discard block
 block discarded – undo
858 858
      */
859 859
     function gform_pre_validation( $form ) {
860 860
 
861
-        if( ! $this->verify_nonce() ) {
861
+        if ( ! $this->verify_nonce() ) {
862 862
             return $form;
863 863
         }
864 864
 
865 865
         // Fix PHP warning regarding undefined index.
866
-        foreach ( $form['fields'] as &$field) {
866
+        foreach ( $form[ 'fields' ] as &$field ) {
867 867
 
868 868
             // This is because we're doing admin form pretending to be front-end, so Gravity Forms
869 869
             // expects certain field array items to be set.
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
                 $field['emailConfirmEnabled'] = '';
877 877
             }*/
878 878
 
879
-            switch( RGFormsModel::get_input_type( $field ) ) {
879
+            switch ( RGFormsModel::get_input_type( $field ) ) {
880 880
 
881 881
                 /**
882 882
                  * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend.
@@ -891,38 +891,38 @@  discard block
 block discarded – undo
891 891
                     // Set the previous value
892 892
                     $entry = $this->get_entry();
893 893
 
894
-                    $input_name = 'input_'.$field->id;
895
-                    $form_id = $form['id'];
894
+                    $input_name = 'input_' . $field->id;
895
+                    $form_id = $form[ 'id' ];
896 896
 
897 897
                     $value = NULL;
898 898
 
899 899
                     // Use the previous entry value as the default.
900
-                    if( isset( $entry[ $field->id ] ) ) {
900
+                    if ( isset( $entry[ $field->id ] ) ) {
901 901
                         $value = $entry[ $field->id ];
902 902
                     }
903 903
 
904 904
                     // If this is a single upload file
905
-                    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
906
-                        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
907
-                        $value = $file_path['url'];
905
+                    if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
906
+                        $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] );
907
+                        $value = $file_path[ 'url' ];
908 908
 
909 909
                     } else {
910 910
 
911 911
                         // Fix PHP warning on line 1498 of form_display.php for post_image fields
912 912
                         // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
913
-                        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
913
+                        $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' );
914 914
 
915 915
                     }
916 916
 
917
-                    if( rgar($field, "multipleFiles") ) {
917
+                    if ( rgar( $field, "multipleFiles" ) ) {
918 918
 
919 919
                         // If there are fresh uploads, process and merge them.
920 920
                         // Otherwise, use the passed values, which should be json-encoded array of URLs
921
-                        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
921
+                        if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) {
922 922
 
923 923
                             $value = empty( $value ) ? '[]' : $value;
924 924
                             $value = stripslashes_deep( $value );
925
-                            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
925
+                            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() );
926 926
                         }
927 927
 
928 928
                     } else {
@@ -938,14 +938,14 @@  discard block
 block discarded – undo
938 938
                     break;
939 939
                 case 'number':
940 940
                     // Fix "undefined index" issue at line 1286 in form_display.php
941
-                    if( !isset( $_POST['input_'.$field->id ] ) ) {
942
-                        $_POST['input_'.$field->id ] = NULL;
941
+                    if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) {
942
+                        $_POST[ 'input_' . $field->id ] = NULL;
943 943
                     }
944 944
                     break;
945 945
                 case 'captcha':
946 946
                     // Fix issue with recaptcha_check_answer() on line 1458 in form_display.php
947
-                    $_POST['recaptcha_challenge_field'] = NULL;
948
-                    $_POST['recaptcha_response_field'] = NULL;
947
+                    $_POST[ 'recaptcha_challenge_field' ] = NULL;
948
+                    $_POST[ 'recaptcha_response_field' ] = NULL;
949 949
                     break;
950 950
             }
951 951
 
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
          * You can enter whatever you want!
975 975
          * We try validating, and customize the results using `self::custom_validation()`
976 976
          */
977
-        add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
977
+        add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 );
978 978
 
979 979
         // Needed by the validate funtion
980 980
         $failed_validation_page = NULL;
@@ -982,14 +982,14 @@  discard block
 block discarded – undo
982 982
 
983 983
         // Prevent entry limit from running when editing an entry, also
984 984
         // prevent form scheduling from preventing editing
985
-        unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
985
+        unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] );
986 986
 
987 987
         // Hide fields depending on Edit Entry settings
988
-        $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
988
+        $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id );
989 989
 
990 990
         $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
991 991
 
992
-        remove_filter( 'gform_validation_'.$this->form_id, array( $this, 'custom_validation' ), 10 );
992
+        remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 );
993 993
     }
994 994
 
995 995
 
@@ -1006,13 +1006,13 @@  discard block
 block discarded – undo
1006 1006
      */
1007 1007
     function custom_validation( $validation_results ) {
1008 1008
 
1009
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results );
1009
+        do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results );
1010 1010
 
1011
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
1011
+        do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
1012 1012
 
1013 1013
         $gv_valid = true;
1014 1014
 
1015
-        foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1015
+        foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) {
1016 1016
 
1017 1017
             $value = RGFormsModel::get_field_value( $field );
1018 1018
             $field_type = RGFormsModel::get_input_type( $field );
@@ -1024,35 +1024,35 @@  discard block
 block discarded – undo
1024 1024
                 case 'fileupload' :
1025 1025
 
1026 1026
                     // in case nothing is uploaded but there are already files saved
1027
-                    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1027
+                    if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) {
1028 1028
                         $field->failed_validation = false;
1029 1029
                         unset( $field->validation_message );
1030 1030
                     }
1031 1031
 
1032 1032
                     // validate if multi file upload reached max number of files [maxFiles] => 2
1033
-                    if( rgar( $field, 'maxFiles') && rgar( $field, 'multipleFiles') ) {
1033
+                    if ( rgar( $field, 'maxFiles' ) && rgar( $field, 'multipleFiles' ) ) {
1034 1034
 
1035 1035
                         $input_name = 'input_' . $field->id;
1036 1036
                         //uploaded
1037
-                        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1037
+                        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array();
1038 1038
 
1039 1039
                         //existent
1040 1040
                         $entry = $this->get_entry();
1041 1041
                         $value = NULL;
1042
-                        if( isset( $entry[ $field->id ] ) ) {
1042
+                        if ( isset( $entry[ $field->id ] ) ) {
1043 1043
                             $value = json_decode( $entry[ $field->id ], true );
1044 1044
                         }
1045 1045
 
1046 1046
                         // count uploaded files and existent entry files
1047 1047
                         $count_files = count( $file_names ) + count( $value );
1048 1048
 
1049
-                        if( $count_files > $field->maxFiles ) {
1049
+                        if ( $count_files > $field->maxFiles ) {
1050 1050
                             $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1051 1051
                             $field->failed_validation = 1;
1052 1052
                             $gv_valid = false;
1053 1053
 
1054 1054
                             // in case of error make sure the newest upload files are removed from the upload input
1055
-                            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1055
+                            GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null;
1056 1056
                         }
1057 1057
 
1058 1058
                     }
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
             }
1064 1064
 
1065 1065
             // This field has failed validation.
1066
-            if( !empty( $field->failed_validation ) ) {
1066
+            if ( ! empty( $field->failed_validation ) ) {
1067 1067
 
1068 1068
                 do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) );
1069 1069
 
@@ -1081,32 +1081,32 @@  discard block
 block discarded – undo
1081 1081
                 }
1082 1082
 
1083 1083
                 // You can't continue inside a switch, so we do it after.
1084
-                if( empty( $field->failed_validation ) ) {
1084
+                if ( empty( $field->failed_validation ) ) {
1085 1085
                     continue;
1086 1086
                 }
1087 1087
 
1088 1088
                 // checks if the No Duplicates option is not validating entry against itself, since
1089 1089
                 // we're editing a stored entry, it would also assume it's a duplicate.
1090
-                if( !empty( $field->noDuplicates ) ) {
1090
+                if ( ! empty( $field->noDuplicates ) ) {
1091 1091
 
1092 1092
                     $entry = $this->get_entry();
1093 1093
 
1094 1094
                     // If the value of the entry is the same as the stored value
1095 1095
                     // Then we can assume it's not a duplicate, it's the same.
1096
-                    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1096
+                    if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) {
1097 1097
                         //if value submitted was not changed, then don't validate
1098 1098
                         $field->failed_validation = false;
1099 1099
 
1100 1100
                         unset( $field->validation_message );
1101 1101
 
1102
-                        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry );
1102
+                        do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry );
1103 1103
 
1104 1104
                         continue;
1105 1105
                     }
1106 1106
                 }
1107 1107
 
1108 1108
                 // if here then probably we are facing the validation 'At least one field must be filled out'
1109
-                if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1109
+                if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) {
1110 1110
                     unset( $field->validation_message );
1111 1111
 	                $field->validation_message = false;
1112 1112
                     continue;
@@ -1118,12 +1118,12 @@  discard block
 block discarded – undo
1118 1118
 
1119 1119
         }
1120 1120
 
1121
-        $validation_results['is_valid'] = $gv_valid;
1121
+        $validation_results[ 'is_valid' ] = $gv_valid;
1122 1122
 
1123
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results );
1123
+        do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results );
1124 1124
 
1125 1125
         // We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1126
-        $this->form_after_validation = $validation_results['form'];
1126
+        $this->form_after_validation = $validation_results[ 'form' ];
1127 1127
 
1128 1128
         return $validation_results;
1129 1129
     }
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
      */
1137 1137
     private function get_entry() {
1138 1138
 
1139
-        if( empty( $this->entry ) ) {
1139
+        if ( empty( $this->entry ) ) {
1140 1140
             // Get the database value of the entry that's being edited
1141 1141
             $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1142 1142
         }
@@ -1163,13 +1163,13 @@  discard block
 block discarded – undo
1163 1163
         $properties = GravityView_View_Data::getInstance()->get_fields( $view_id );
1164 1164
 
1165 1165
         // If edit tab not yet configured, show all fields
1166
-        $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1166
+        $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL;
1167 1167
 
1168 1168
 	    // Show hidden fields as text fields
1169 1169
 	    $form = $this->fix_hidden_fields( $form );
1170 1170
 
1171 1171
         // Hide fields depending on admin settings
1172
-        $fields = $this->filter_fields( $form['fields'], $edit_fields );
1172
+        $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields );
1173 1173
 
1174 1174
 	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1175 1175
 	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
@@ -1187,11 +1187,11 @@  discard block
 block discarded – undo
1187 1187
 	private function fix_hidden_fields( $form ) {
1188 1188
 
1189 1189
 		/** @var GF_Field $field */
1190
-		foreach( $form['fields'] as $key => $field ) {
1191
-			if( 'hidden' === $field->type ) {
1190
+		foreach ( $form[ 'fields' ] as $key => $field ) {
1191
+			if ( 'hidden' === $field->type ) {
1192 1192
 				$text_field = new GF_Field_Text( $field );
1193 1193
 				$text_field->type = 'text';
1194
-				$form['fields'][ $key ] = $text_field;
1194
+				$form[ 'fields' ][ $key ] = $text_field;
1195 1195
 			}
1196 1196
 		}
1197 1197
 
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
      */
1212 1212
     private function filter_fields( $fields, $configured_fields ) {
1213 1213
 
1214
-        if( empty( $fields ) || !is_array( $fields ) ) {
1214
+        if ( empty( $fields ) || ! is_array( $fields ) ) {
1215 1215
             return $fields;
1216 1216
         }
1217 1217
 
@@ -1228,24 +1228,24 @@  discard block
 block discarded – undo
1228 1228
 	     */
1229 1229
 	    $hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) );
1230 1230
 
1231
-	    if( $hide_product_fields ) {
1232
-		    $field_type_blacklist[] = 'option';
1233
-		    $field_type_blacklist[] = 'quantity';
1234
-            $field_type_blacklist[] = 'product';
1235
-            $field_type_blacklist[] = 'total';
1236
-            $field_type_blacklist[] = 'shipping';
1237
-            $field_type_blacklist[] = 'calculation';
1231
+	    if ( $hide_product_fields ) {
1232
+		    $field_type_blacklist[ ] = 'option';
1233
+		    $field_type_blacklist[ ] = 'quantity';
1234
+            $field_type_blacklist[ ] = 'product';
1235
+            $field_type_blacklist[ ] = 'total';
1236
+            $field_type_blacklist[ ] = 'shipping';
1237
+            $field_type_blacklist[ ] = 'calculation';
1238 1238
 	    }
1239 1239
 
1240 1240
         // First, remove blacklist
1241 1241
         foreach ( $fields as $key => $field ) {
1242
-            if( in_array( $field->type, $field_type_blacklist ) ) {
1242
+            if ( in_array( $field->type, $field_type_blacklist ) ) {
1243 1243
                 unset( $fields[ $key ] );
1244 1244
             }
1245 1245
         }
1246 1246
 
1247 1247
         // The Edit tab has not been configured, so we return all fields by default.
1248
-        if( empty( $configured_fields ) ) {
1248
+        if ( empty( $configured_fields ) ) {
1249 1249
             return $fields;
1250 1250
         }
1251 1251
 
@@ -1255,8 +1255,8 @@  discard block
 block discarded – undo
1255 1255
 	        /** @var GF_Field $field */
1256 1256
 	        foreach ( $fields as $field ) {
1257 1257
 
1258
-                if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1259
-                    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1258
+                if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1259
+                    $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field );
1260 1260
                     break;
1261 1261
                 }
1262 1262
 
@@ -1279,14 +1279,14 @@  discard block
 block discarded – undo
1279 1279
 
1280 1280
         $return_field = $field;
1281 1281
 
1282
-        if( empty( $field_setting['show_label'] ) ) {
1282
+        if ( empty( $field_setting[ 'show_label' ] ) ) {
1283 1283
             $return_field->label = '';
1284
-        } elseif ( !empty( $field_setting['custom_label'] ) ) {
1285
-            $return_field->label = $field_setting['custom_label'];
1284
+        } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) {
1285
+            $return_field->label = $field_setting[ 'custom_label' ];
1286 1286
         }
1287 1287
 
1288
-        if( !empty( $field_setting['custom_class'] ) ) {
1289
-            $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1288
+        if ( ! empty( $field_setting[ 'custom_class' ] ) ) {
1289
+            $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] );
1290 1290
         }
1291 1291
 
1292 1292
         /**
@@ -1324,11 +1324,11 @@  discard block
 block discarded – undo
1324 1324
 	     */
1325 1325
 	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1326 1326
 
1327
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1327
+	    if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) {
1328 1328
             return $fields;
1329 1329
         }
1330 1330
 
1331
-	    foreach( $fields as &$field ) {
1331
+	    foreach ( $fields as &$field ) {
1332 1332
 		    $field->adminOnly = false;
1333 1333
         }
1334 1334
 
@@ -1355,16 +1355,16 @@  discard block
 block discarded – undo
1355 1355
          */
1356 1356
         $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
1357 1357
 
1358
-        if( $use_conditional_logic ) {
1358
+        if ( $use_conditional_logic ) {
1359 1359
             return $form;
1360 1360
         }
1361 1361
 
1362
-        foreach( $form['fields'] as &$field ) {
1362
+        foreach ( $form[ 'fields' ] as &$field ) {
1363 1363
             /* @var GF_Field $field */
1364 1364
             $field->conditionalLogic = null;
1365 1365
         }
1366 1366
 
1367
-        unset( $form['button']['conditionalLogic'] );
1367
+        unset( $form[ 'button' ][ 'conditionalLogic' ] );
1368 1368
 
1369 1369
         return $form;
1370 1370
 
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
      */
1382 1382
     function manage_conditional_logic( $has_conditional_logic, $form ) {
1383 1383
 
1384
-        if( ! $this->is_edit_entry() ) {
1384
+        if ( ! $this->is_edit_entry() ) {
1385 1385
             return $has_conditional_logic;
1386 1386
         }
1387 1387
 
@@ -1413,44 +1413,44 @@  discard block
 block discarded – undo
1413 1413
          *  2. There are two entries embedded using oEmbed
1414 1414
          *  3. One of the entries has just been saved
1415 1415
          */
1416
-        if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
1416
+        if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) {
1417 1417
 
1418 1418
             $error = true;
1419 1419
 
1420 1420
         }
1421 1421
 
1422
-        if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
1422
+        if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) {
1423 1423
 
1424 1424
             $error = true;
1425 1425
 
1426
-        } elseif( ! $this->verify_nonce() ) {
1426
+        } elseif ( ! $this->verify_nonce() ) {
1427 1427
 
1428 1428
             /**
1429 1429
              * If the Entry is embedded, there may be two entries on the same page.
1430 1430
              * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
1431 1431
              */
1432
-            if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1432
+            if ( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1433 1433
                 $error = true;
1434 1434
             } else {
1435
-                $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
1435
+                $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' );
1436 1436
             }
1437 1437
 
1438 1438
         }
1439 1439
 
1440
-        if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1441
-            $error = __( 'You do not have permission to edit this entry.', 'gravityview');
1440
+        if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1441
+            $error = __( 'You do not have permission to edit this entry.', 'gravityview' );
1442 1442
         }
1443 1443
 
1444
-        if( $this->entry['status'] === 'trash' ) {
1445
-            $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
1444
+        if ( $this->entry[ 'status' ] === 'trash' ) {
1445
+            $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' );
1446 1446
         }
1447 1447
 
1448 1448
         // No errors; everything's fine here!
1449
-        if( empty( $error ) ) {
1449
+        if ( empty( $error ) ) {
1450 1450
             return true;
1451 1451
         }
1452 1452
 
1453
-        if( $echo && $error !== true ) {
1453
+        if ( $echo && $error !== true ) {
1454 1454
 
1455 1455
 	        $error = esc_html( $error );
1456 1456
 
@@ -1458,13 +1458,13 @@  discard block
 block discarded – undo
1458 1458
 	         * @since 1.9
1459 1459
 	         */
1460 1460
 	        if ( ! empty( $this->entry ) ) {
1461
-		        $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;" ) );
1461
+		        $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;" ) );
1462 1462
 	        }
1463 1463
 
1464
-            echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1464
+            echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' );
1465 1465
         }
1466 1466
 
1467
-        do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error );
1467
+        do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error );
1468 1468
 
1469 1469
         return false;
1470 1470
     }
@@ -1481,20 +1481,20 @@  discard block
 block discarded – undo
1481 1481
 
1482 1482
         $error = NULL;
1483 1483
 
1484
-        if( ! $this->check_user_cap_edit_field( $field ) ) {
1485
-            $error = __( 'You do not have permission to edit this field.', 'gravityview');
1484
+        if ( ! $this->check_user_cap_edit_field( $field ) ) {
1485
+            $error = __( 'You do not have permission to edit this field.', 'gravityview' );
1486 1486
         }
1487 1487
 
1488 1488
         // No errors; everything's fine here!
1489
-        if( empty( $error ) ) {
1489
+        if ( empty( $error ) ) {
1490 1490
             return true;
1491 1491
         }
1492 1492
 
1493
-        if( $echo ) {
1494
-            echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
1493
+        if ( $echo ) {
1494
+            echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' );
1495 1495
         }
1496 1496
 
1497
-        do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error );
1497
+        do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error );
1498 1498
 
1499 1499
         return false;
1500 1500
 
@@ -1512,15 +1512,15 @@  discard block
 block discarded – undo
1512 1512
     private function check_user_cap_edit_field( $field ) {
1513 1513
 
1514 1514
         // If they can edit any entries (as defined in Gravity Forms), we're good.
1515
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
1515
+        if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
1516 1516
             return true;
1517 1517
         }
1518 1518
 
1519
-        $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
1519
+        $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false;
1520 1520
 
1521 1521
         // If the field has custom editing capaibilities set, check those
1522
-        if( $field_cap ) {
1523
-            return GVCommon::has_cap( $field['allow_edit_cap'] );
1522
+        if ( $field_cap ) {
1523
+            return GVCommon::has_cap( $field[ 'allow_edit_cap' ] );
1524 1524
         }
1525 1525
 
1526 1526
         return false;
@@ -1534,17 +1534,17 @@  discard block
 block discarded – undo
1534 1534
     public function verify_nonce() {
1535 1535
 
1536 1536
         // Verify form submitted for editing single
1537
-        if( $this->is_edit_entry_submission() ) {
1537
+        if ( $this->is_edit_entry_submission() ) {
1538 1538
             $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
1539 1539
         }
1540 1540
 
1541 1541
         // Verify
1542
-        else if( ! $this->is_edit_entry() ) {
1542
+        else if ( ! $this->is_edit_entry() ) {
1543 1543
             $valid = false;
1544 1544
         }
1545 1545
 
1546 1546
         else {
1547
-            $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
1547
+            $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key );
1548 1548
         }
1549 1549
 
1550 1550
         /**
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-user-registration.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
      * @since 1.11
58 58
      *
59 59
      * @param array $form Gravity Forms form array
60
-     * @param string $entry_id Gravity Forms entry ID
60
+     * @param integer $entry_id Gravity Forms entry ID
61 61
      * @return void
62 62
      */
63 63
     public function update_user( $form = array(), $entry_id = 0 ) {
Please login to merge, or discard this patch.
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 if ( ! defined( 'WPINC' ) ) {
14
-    die;
14
+	die;
15 15
 }
16 16
 
17 17
 /**
@@ -22,237 +22,237 @@  discard block
 block discarded – undo
22 22
 	/**
23 23
 	 * @var GravityView_Edit_Entry
24 24
 	 */
25
-    protected $loader;
25
+	protected $loader;
26 26
 
27
-    /**
28
-     * @var WP_User|null Temporary storage used by restore_user_details()
29
-     */
30
-    private $_user_before_update = null;
27
+	/**
28
+	 * @var WP_User|null Temporary storage used by restore_user_details()
29
+	 */
30
+	private $_user_before_update = null;
31 31
 
32
-    function __construct( GravityView_Edit_Entry $loader ) {
33
-        $this->loader = $loader;
34
-    }
32
+	function __construct( GravityView_Edit_Entry $loader ) {
33
+		$this->loader = $loader;
34
+	}
35 35
 
36 36
 	/**
37 37
 	 * @since 1.11
38 38
 	 */
39 39
 	public function load() {
40 40
 
41
-        /**
42
-	     * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated?
43
-	     * @since 1.11
44
-	     * @param boolean $boolean Whether to trigger update on user registration (default: true)
45
-	     */
46
-        if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
47
-            add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
48
-
49
-            // last resort in case the current user display name don't match any of the defaults
50
-            add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
51
-        }
52
-    }
53
-
54
-    /**
55
-     * Update the WordPress user profile based on the GF User Registration create feed
56
-     *
57
-     * @since 1.11
58
-     *
59
-     * @param array $form Gravity Forms form array
60
-     * @param string $entry_id Gravity Forms entry ID
61
-     * @return void
62
-     */
63
-    public function update_user( $form = array(), $entry_id = 0 ) {
64
-
65
-        if( !class_exists( 'GFAPI' ) || !class_exists( 'GFUser' ) || empty( $entry_id ) ) {
66
-            return;
67
-        }
68
-
69
-        $entry = GFAPI::get_entry( $entry_id );
70
-
71
-	    /**
72
-	     * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
73
-	     * @since 1.11
74
-	     * @param array $entry Gravity Forms entry
75
-	     * @param array $form Gravity Forms form
76
-	     */
77
-        $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form );
78
-
79
-        /**
80
-         * @since 1.14
81
-         */
82
-        $config = GFUser::get_active_config( $form, $entry );
83
-
84
-        /**
85
-         * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
86
-         * @since 1.15
87
-         * @param[in,out] boolean $preserve_role Preserve current user role Default: true
88
-         * @param[in] array $config Gravity Forms User Registration feed configuration for the form
89
-         * @param[in] array $form Gravity Forms form array
90
-         * @param[in] array $entry Gravity Forms entry being edited
91
-         */
92
-        $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
93
-
94
-        if( $preserve_role ) {
95
-            $config['meta']['role'] = 'gfur_preserve_role';
96
-        }
97
-
98
-        /**
99
-         * Make sure the current display name is not changed with the update user method.
100
-         * @since 1.15
101
-         */
102
-        $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
103
-
104
-
105
-        /**
106
-         * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
107
-         * @since 1.14
108
-         * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
109
-         * @param[in] array $form Gravity Forms form array
110
-         * @param[in] array $entry Gravity Forms entry being edited
111
-         */
112
-        $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
113
-
114
-        $is_create_feed = ( $config && rgars( $config, 'meta/feed_type') === 'create' );
115
-
116
-        // Only update if it's a create feed
117
-        if( ! $is_create_feed ) {
118
-            return;
119
-        }
120
-
121
-        // The priority is set to 3 so that default priority (10) will still override it
122
-        add_filter( 'send_password_change_email', '__return_false', 3 );
123
-        add_filter( 'send_email_change_email', '__return_false', 3 );
124
-
125
-        // Trigger the User Registration update user method
126
-        GFUser::update_user( $entry, $form, $config );
127
-
128
-        remove_filter( 'send_password_change_email', '__return_false', 3 );
129
-        remove_filter( 'send_email_change_email', '__return_false', 3 );
130
-
131
-    }
132
-
133
-    /**
134
-     * Calculate the user display name format
135
-     *
136
-     * @since 1.15
137
-     *
138
-     * @param int $user_id WP User ID
139
-     * @return string Display name format as used inside Gravity Forms User Registration
140
-     */
141
-    public function match_current_display_name( $user_id ) {
142
-
143
-        $user = get_userdata( $user_id );
144
-
145
-        $names = $this->generate_display_names( $user );
146
-
147
-        $format = array_search( $user->display_name, $names, true );
148
-
149
-        // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
150
-        //   trigger last resort method at the 'gform_user_updated' hook
151
-        if( false === $format || 'nickname' === $format ) {
152
-            $this->_user_before_update = $user;
153
-            $format = 'nickname';
154
-        }
155
-
156
-        return $format;
157
-
158
-    }
159
-
160
-    /**
161
-     * Generate an array of all the user display names possibilities
162
-     *
163
-     * @since 1.15
164
-     *
165
-     * @param object $profileuser WP_User object
166
-     * @return array List all the possible display names for a certain User object
167
-     */
168
-    public function generate_display_names( $profileuser ) {
169
-
170
-        $public_display = array();
171
-        $public_display['nickname']  = $profileuser->nickname;
172
-        $public_display['username']  = $profileuser->user_login;
173
-
174
-        if ( !empty($profileuser->first_name) )
175
-            $public_display['firstname'] = $profileuser->first_name;
176
-
177
-        if ( !empty($profileuser->last_name) )
178
-            $public_display['lastname'] = $profileuser->last_name;
179
-
180
-        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
181
-            $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
182
-            $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
183
-        }
184
-
185
-        $public_display = array_map( 'trim', $public_display );
186
-        $public_display = array_unique( $public_display );
187
-
188
-        return $public_display;
189
-    }
190
-
191
-
192
-    /**
193
-     * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon
194
-     *
195
-     * @see GFUser::update_user()
196
-     * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon
197
-     * @param array $config Gravity Forms User Registration Addon form feed configuration
198
-     * @param array $entry The Gravity Forms entry that was just updated
199
-     * @param string $password User password
200
-     * @return void
201
-     */
202
-    public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) {
203
-
204
-        /**
205
-         * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry.
206
-         * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed
207
-         * @since 1.14.4
208
-         * @param boolean $restore_display_name Restore Display Name? Default: true
209
-         */
210
-        $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
211
-
212
-        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
213
-
214
-        /**
215
-         * Don't restore display name:
216
-         *   - either disabled,
217
-         *   - or it is an Update feed (we only care about Create feed)
218
-         *   - or we don't need as we found the correct format before updating user.
219
-         * @since 1.14.4
220
-         */
221
-        if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
222
-            return;
223
-        }
224
-
225
-        $user_after_update = get_userdata( $user_id );
226
-
227
-        $restored_user = $user_after_update;
228
-
229
-	    // Restore previous display_name
230
-        $restored_user->display_name = $this->_user_before_update->display_name;
231
-
232
-	    // Don't have WP update the password.
233
-	    unset( $restored_user->data->user_pass, $restored_user->user_pass );
234
-
235
-        /**
236
-         * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView
237
-         * @since 1.14
238
-         * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user()
239
-         * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration
240
-         * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration
241
-         * @param array   $entry The Gravity Forms entry that was just updated
242
-         */
243
-        $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry );
244
-
245
-        $updated = wp_update_user( $restored_user );
246
-
247
-        if( is_wp_error( $updated ) ) {
248
-            do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
249
-        } else {
250
-            do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
251
-        }
252
-
253
-        $this->_user_before_update = null;
254
-
255
-        unset( $updated, $restored_user, $user_after_update );
256
-    }
41
+		/**
42
+		 * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated?
43
+		 * @since 1.11
44
+		 * @param boolean $boolean Whether to trigger update on user registration (default: true)
45
+		 */
46
+		if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
47
+			add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
48
+
49
+			// last resort in case the current user display name don't match any of the defaults
50
+			add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
51
+		}
52
+	}
53
+
54
+	/**
55
+	 * Update the WordPress user profile based on the GF User Registration create feed
56
+	 *
57
+	 * @since 1.11
58
+	 *
59
+	 * @param array $form Gravity Forms form array
60
+	 * @param string $entry_id Gravity Forms entry ID
61
+	 * @return void
62
+	 */
63
+	public function update_user( $form = array(), $entry_id = 0 ) {
64
+
65
+		if( !class_exists( 'GFAPI' ) || !class_exists( 'GFUser' ) || empty( $entry_id ) ) {
66
+			return;
67
+		}
68
+
69
+		$entry = GFAPI::get_entry( $entry_id );
70
+
71
+		/**
72
+		 * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
73
+		 * @since 1.11
74
+		 * @param array $entry Gravity Forms entry
75
+		 * @param array $form Gravity Forms form
76
+		 */
77
+		$entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form );
78
+
79
+		/**
80
+		 * @since 1.14
81
+		 */
82
+		$config = GFUser::get_active_config( $form, $entry );
83
+
84
+		/**
85
+		 * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
86
+		 * @since 1.15
87
+		 * @param[in,out] boolean $preserve_role Preserve current user role Default: true
88
+		 * @param[in] array $config Gravity Forms User Registration feed configuration for the form
89
+		 * @param[in] array $form Gravity Forms form array
90
+		 * @param[in] array $entry Gravity Forms entry being edited
91
+		 */
92
+		$preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
93
+
94
+		if( $preserve_role ) {
95
+			$config['meta']['role'] = 'gfur_preserve_role';
96
+		}
97
+
98
+		/**
99
+		 * Make sure the current display name is not changed with the update user method.
100
+		 * @since 1.15
101
+		 */
102
+		$config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
103
+
104
+
105
+		/**
106
+		 * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
107
+		 * @since 1.14
108
+		 * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
109
+		 * @param[in] array $form Gravity Forms form array
110
+		 * @param[in] array $entry Gravity Forms entry being edited
111
+		 */
112
+		$config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
113
+
114
+		$is_create_feed = ( $config && rgars( $config, 'meta/feed_type') === 'create' );
115
+
116
+		// Only update if it's a create feed
117
+		if( ! $is_create_feed ) {
118
+			return;
119
+		}
120
+
121
+		// The priority is set to 3 so that default priority (10) will still override it
122
+		add_filter( 'send_password_change_email', '__return_false', 3 );
123
+		add_filter( 'send_email_change_email', '__return_false', 3 );
124
+
125
+		// Trigger the User Registration update user method
126
+		GFUser::update_user( $entry, $form, $config );
127
+
128
+		remove_filter( 'send_password_change_email', '__return_false', 3 );
129
+		remove_filter( 'send_email_change_email', '__return_false', 3 );
130
+
131
+	}
132
+
133
+	/**
134
+	 * Calculate the user display name format
135
+	 *
136
+	 * @since 1.15
137
+	 *
138
+	 * @param int $user_id WP User ID
139
+	 * @return string Display name format as used inside Gravity Forms User Registration
140
+	 */
141
+	public function match_current_display_name( $user_id ) {
142
+
143
+		$user = get_userdata( $user_id );
144
+
145
+		$names = $this->generate_display_names( $user );
146
+
147
+		$format = array_search( $user->display_name, $names, true );
148
+
149
+		// In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
150
+		//   trigger last resort method at the 'gform_user_updated' hook
151
+		if( false === $format || 'nickname' === $format ) {
152
+			$this->_user_before_update = $user;
153
+			$format = 'nickname';
154
+		}
155
+
156
+		return $format;
157
+
158
+	}
159
+
160
+	/**
161
+	 * Generate an array of all the user display names possibilities
162
+	 *
163
+	 * @since 1.15
164
+	 *
165
+	 * @param object $profileuser WP_User object
166
+	 * @return array List all the possible display names for a certain User object
167
+	 */
168
+	public function generate_display_names( $profileuser ) {
169
+
170
+		$public_display = array();
171
+		$public_display['nickname']  = $profileuser->nickname;
172
+		$public_display['username']  = $profileuser->user_login;
173
+
174
+		if ( !empty($profileuser->first_name) )
175
+			$public_display['firstname'] = $profileuser->first_name;
176
+
177
+		if ( !empty($profileuser->last_name) )
178
+			$public_display['lastname'] = $profileuser->last_name;
179
+
180
+		if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
181
+			$public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
182
+			$public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
183
+		}
184
+
185
+		$public_display = array_map( 'trim', $public_display );
186
+		$public_display = array_unique( $public_display );
187
+
188
+		return $public_display;
189
+	}
190
+
191
+
192
+	/**
193
+	 * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon
194
+	 *
195
+	 * @see GFUser::update_user()
196
+	 * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon
197
+	 * @param array $config Gravity Forms User Registration Addon form feed configuration
198
+	 * @param array $entry The Gravity Forms entry that was just updated
199
+	 * @param string $password User password
200
+	 * @return void
201
+	 */
202
+	public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) {
203
+
204
+		/**
205
+		 * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry.
206
+		 * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed
207
+		 * @since 1.14.4
208
+		 * @param boolean $restore_display_name Restore Display Name? Default: true
209
+		 */
210
+		$restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
211
+
212
+		$is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
213
+
214
+		/**
215
+		 * Don't restore display name:
216
+		 *   - either disabled,
217
+		 *   - or it is an Update feed (we only care about Create feed)
218
+		 *   - or we don't need as we found the correct format before updating user.
219
+		 * @since 1.14.4
220
+		 */
221
+		if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
222
+			return;
223
+		}
224
+
225
+		$user_after_update = get_userdata( $user_id );
226
+
227
+		$restored_user = $user_after_update;
228
+
229
+		// Restore previous display_name
230
+		$restored_user->display_name = $this->_user_before_update->display_name;
231
+
232
+		// Don't have WP update the password.
233
+		unset( $restored_user->data->user_pass, $restored_user->user_pass );
234
+
235
+		/**
236
+		 * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView
237
+		 * @since 1.14
238
+		 * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user()
239
+		 * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration
240
+		 * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration
241
+		 * @param array   $entry The Gravity Forms entry that was just updated
242
+		 */
243
+		$restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry );
244
+
245
+		$updated = wp_update_user( $restored_user );
246
+
247
+		if( is_wp_error( $updated ) ) {
248
+			do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
249
+		} else {
250
+			do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
251
+		}
252
+
253
+		$this->_user_before_update = null;
254
+
255
+		unset( $updated, $restored_user, $user_after_update );
256
+	}
257 257
 
258 258
 } //end class
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -171,11 +171,13 @@
 block discarded – undo
171 171
         $public_display['nickname']  = $profileuser->nickname;
172 172
         $public_display['username']  = $profileuser->user_login;
173 173
 
174
-        if ( !empty($profileuser->first_name) )
175
-            $public_display['firstname'] = $profileuser->first_name;
174
+        if ( !empty($profileuser->first_name) ) {
175
+                    $public_display['firstname'] = $profileuser->first_name;
176
+        }
176 177
 
177
-        if ( !empty($profileuser->last_name) )
178
-            $public_display['lastname'] = $profileuser->last_name;
178
+        if ( !empty($profileuser->last_name) ) {
179
+                    $public_display['lastname'] = $profileuser->last_name;
180
+        }
179 181
 
180 182
         if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
181 183
             $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	     * @since 1.11
44 44
 	     * @param boolean $boolean Whether to trigger update on user registration (default: true)
45 45
 	     */
46
-        if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
47
-            add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
46
+        if ( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
47
+            add_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10, 2 );
48 48
 
49 49
             // last resort in case the current user display name don't match any of the defaults
50 50
             add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function update_user( $form = array(), $entry_id = 0 ) {
64 64
 
65
-        if( !class_exists( 'GFAPI' ) || !class_exists( 'GFUser' ) || empty( $entry_id ) ) {
65
+        if ( ! class_exists( 'GFAPI' ) || ! class_exists( 'GFUser' ) || empty( $entry_id ) ) {
66 66
             return;
67 67
         }
68 68
 
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
          */
92 92
         $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
93 93
 
94
-        if( $preserve_role ) {
95
-            $config['meta']['role'] = 'gfur_preserve_role';
94
+        if ( $preserve_role ) {
95
+            $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role';
96 96
         }
97 97
 
98 98
         /**
99 99
          * Make sure the current display name is not changed with the update user method.
100 100
          * @since 1.15
101 101
          */
102
-        $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
102
+        $config[ 'meta' ][ 'displayname' ] = $this->match_current_display_name( $entry[ 'created_by' ] );
103 103
 
104 104
 
105 105
         /**
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
          */
112 112
         $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
113 113
 
114
-        $is_create_feed = ( $config && rgars( $config, 'meta/feed_type') === 'create' );
114
+        $is_create_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'create' );
115 115
 
116 116
         // Only update if it's a create feed
117
-        if( ! $is_create_feed ) {
117
+        if ( ! $is_create_feed ) {
118 118
             return;
119 119
         }
120 120
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
         // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
150 150
         //   trigger last resort method at the 'gform_user_updated' hook
151
-        if( false === $format || 'nickname' === $format ) {
151
+        if ( false === $format || 'nickname' === $format ) {
152 152
             $this->_user_before_update = $user;
153 153
             $format = 'nickname';
154 154
         }
@@ -168,18 +168,18 @@  discard block
 block discarded – undo
168 168
     public function generate_display_names( $profileuser ) {
169 169
 
170 170
         $public_display = array();
171
-        $public_display['nickname']  = $profileuser->nickname;
172
-        $public_display['username']  = $profileuser->user_login;
171
+        $public_display[ 'nickname' ]  = $profileuser->nickname;
172
+        $public_display[ 'username' ]  = $profileuser->user_login;
173 173
 
174
-        if ( !empty($profileuser->first_name) )
175
-            $public_display['firstname'] = $profileuser->first_name;
174
+        if ( ! empty( $profileuser->first_name ) )
175
+            $public_display[ 'firstname' ] = $profileuser->first_name;
176 176
 
177
-        if ( !empty($profileuser->last_name) )
178
-            $public_display['lastname'] = $profileuser->last_name;
177
+        if ( ! empty( $profileuser->last_name ) )
178
+            $public_display[ 'lastname' ] = $profileuser->last_name;
179 179
 
180
-        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
181
-            $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
182
-            $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
180
+        if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
181
+            $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name;
182
+            $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name;
183 183
         }
184 184
 
185 185
         $public_display = array_map( 'trim', $public_display );
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
          */
210 210
         $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
211 211
 
212
-        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
212
+        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'update' );
213 213
 
214 214
         /**
215 215
          * Don't restore display name:
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
          *   - or we don't need as we found the correct format before updating user.
219 219
          * @since 1.14.4
220 220
          */
221
-        if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
221
+        if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
222 222
             return;
223 223
         }
224 224
 
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 
245 245
         $updated = wp_update_user( $restored_user );
246 246
 
247
-        if( is_wp_error( $updated ) ) {
248
-            do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
247
+        if ( is_wp_error( $updated ) ) {
248
+            do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
249 249
         } else {
250
-            do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
250
+            do_action( 'gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
251 251
         }
252 252
 
253 253
         $this->_user_before_update = null;
Please login to merge, or discard this patch.