Completed
Push — master ( a1257b...e47a6f )
by Zack
21:54 queued 12:13
created
includes/class-ajax.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @since 1.15
29 29
 	 * @param bool|false $mixed
30 30
 	 *
31
-	 * @return bool
31
+	 * @return boolean|null
32 32
 	 */
33 33
 	private function _exit( $mixed = NULL ) {
34 34
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * Import Gravity Form XML or JSON
201 201
 	 *
202 202
 	 * @param  string $xml_or_json_path Path to form XML or JSON file
203
-	 * @return int|bool       Imported form ID or false
203
+	 * @return false|string       Imported form ID or false
204 204
 	 */
205 205
 	function import_form( $xml_or_json_path = '' ) {
206 206
 
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 
139 139
 		// template areas
140 140
 		$template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' );
141
-        $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' );
141
+		$template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' );
142 142
 
143 143
 		// widget areas
144 144
 		$default_widget_areas = \GV\Widget::get_default_widget_areas();
@@ -331,40 +331,40 @@  discard block
 block discarded – undo
331 331
 		// load file
332 332
 		$xmlstr = file_get_contents( $form_file );
333 333
 
334
-        $options = array(
335
-            "page" => array("unserialize_as_array" => true),
336
-            "form"=> array("unserialize_as_array" => true),
337
-            "field"=> array("unserialize_as_array" => true),
338
-            "rule"=> array("unserialize_as_array" => true),
339
-            "choice"=> array("unserialize_as_array" => true),
340
-            "input"=> array("unserialize_as_array" => true),
341
-            "routing_item"=> array("unserialize_as_array" => true),
342
-            "creditCard"=> array("unserialize_as_array" => true),
343
-            "routin"=> array("unserialize_as_array" => true),
344
-            "confirmation" => array("unserialize_as_array" => true),
345
-            "notification" => array("unserialize_as_array" => true)
346
-        );
334
+		$options = array(
335
+			"page" => array("unserialize_as_array" => true),
336
+			"form"=> array("unserialize_as_array" => true),
337
+			"field"=> array("unserialize_as_array" => true),
338
+			"rule"=> array("unserialize_as_array" => true),
339
+			"choice"=> array("unserialize_as_array" => true),
340
+			"input"=> array("unserialize_as_array" => true),
341
+			"routing_item"=> array("unserialize_as_array" => true),
342
+			"creditCard"=> array("unserialize_as_array" => true),
343
+			"routin"=> array("unserialize_as_array" => true),
344
+			"confirmation" => array("unserialize_as_array" => true),
345
+			"notification" => array("unserialize_as_array" => true)
346
+		);
347 347
 
348 348
 		$xml = new RGXML($options);
349
-        $forms = $xml->unserialize($xmlstr);
349
+		$forms = $xml->unserialize($xmlstr);
350 350
 
351
-        if( !$forms ) {
352
-        	gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. Error importing file. (File) {path}', array( 'template_id' => $template_id, 'path' => $form_file ) );
353
-        	return false;
354
-        }
351
+		if( !$forms ) {
352
+			gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. Error importing file. (File) {path}', array( 'template_id' => $template_id, 'path' => $form_file ) );
353
+			return false;
354
+		}
355 355
 
356
-        if( !empty( $forms[0] ) && is_array( $forms[0] ) ) {
357
-        	$form = $forms[0];
358
-        }
356
+		if( !empty( $forms[0] ) && is_array( $forms[0] ) ) {
357
+			$form = $forms[0];
358
+		}
359 359
 
360
-        if( empty( $form ) ) {
361
-        	gravityview()->log->error( '$form not set.', array( 'data' => $forms ) );
362
-        	return false;
363
-        }
360
+		if( empty( $form ) ) {
361
+			gravityview()->log->error( '$form not set.', array( 'data' => $forms ) );
362
+			return false;
363
+		}
364 364
 
365
-        gravityview()->log->debug( '[pre_get_available_fields] Importing Form Fields for preset [{template_id}]. (Form)', array( 'template_id' => $template_id, 'data' => $form ) );
365
+		gravityview()->log->debug( '[pre_get_available_fields] Importing Form Fields for preset [{template_id}]. (Form)', array( 'template_id' => $template_id, 'data' => $form ) );
366 366
 
367
-        return $form;
367
+		return $form;
368 368
 
369 369
 	}
370 370
 
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		 * Don't exit if we're running test suite.
37 37
 		 * @since 1.15
38 38
 		 */
39
-		if( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) {
39
+		if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) {
40 40
 			return $mixed;
41 41
 		}
42 42
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @return void
51 51
 	 */
52 52
 	function check_ajax_nonce() {
53
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxviews' ) ) {
53
+		if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxviews' ) ) {
54 54
 			$this->_exit( false );
55 55
 		}
56 56
 	}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		$context = rgpost( 'context' );
70 70
 
71 71
 		// Return markup for a single or multiple contexts
72
-		if( $context ) {
72
+		if ( $context ) {
73 73
 			$data = array(
74 74
 				esc_attr( $context ) => ''
75 75
 			);
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 	function get_active_areas() {
114 114
 		$this->check_ajax_nonce();
115 115
 
116
-		if( empty( $_POST['template_id'] ) ) {
116
+		if ( empty( $_POST[ 'template_id' ] ) ) {
117 117
 			$this->_exit( false );
118 118
 		}
119 119
 
120 120
 		ob_start();
121
-		do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true );
122
-		$response['directory'] = ob_get_clean();
121
+		do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'directory', '', true );
122
+		$response[ 'directory' ] = ob_get_clean();
123 123
 
124 124
 		ob_start();
125
-		do_action( 'gravityview_render_directory_active_areas',  $_POST['template_id'], 'single', '', true );
126
-		$response['single'] = ob_get_clean();
125
+		do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'single', '', true );
126
+		$response[ 'single' ] = ob_get_clean();
127 127
 
128 128
 		$response = array_map( 'gravityview_strip_whitespace', $response );
129 129
 
@@ -138,20 +138,20 @@  discard block
 block discarded – undo
138 138
 
139 139
 		$this->check_ajax_nonce();
140 140
 
141
-		if( empty( $_POST['template_id'] ) ) {
141
+		if ( empty( $_POST[ 'template_id' ] ) ) {
142 142
 			$this->_exit( false );
143 143
 		}
144 144
 
145 145
 		// get the fields xml config file for this specific preset
146
-		$preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] );
146
+		$preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST[ 'template_id' ] );
147 147
 		// import fields
148
-		if( !empty( $preset_fields_path ) ) {
148
+		if ( ! empty( $preset_fields_path ) ) {
149 149
 			$presets = $this->import_fields( $preset_fields_path );
150 150
 		} else {
151 151
 			$presets = array( 'widgets' => array(), 'fields' => array() );
152 152
 		}
153 153
 
154
-		$template_id = esc_attr( $_POST['template_id'] );
154
+		$template_id = esc_attr( $_POST[ 'template_id' ] );
155 155
 
156 156
 		// template areas
157 157
 		$template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' );
@@ -161,20 +161,20 @@  discard block
 block discarded – undo
161 161
 		$default_widget_areas = \GV\Widget::get_default_widget_areas();
162 162
 
163 163
 		ob_start();
164
-		do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] );
165
-		$response['header'] = ob_get_clean();
164
+		do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets[ 'widgets' ] );
165
+		$response[ 'header' ] = ob_get_clean();
166 166
 
167 167
 		ob_start();
168
-		do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] );
169
-		$response['footer'] = ob_get_clean();
168
+		do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets[ 'widgets' ] );
169
+		$response[ 'footer' ] = ob_get_clean();
170 170
 
171 171
 		ob_start();
172
-		do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] );
173
-		$response['directory'] = ob_get_clean();
172
+		do_action( 'gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets[ 'fields' ] );
173
+		$response[ 'directory' ] = ob_get_clean();
174 174
 
175 175
 		ob_start();
176
-		do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] );
177
-		$response['single'] = ob_get_clean();
176
+		do_action( 'gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets[ 'fields' ] );
177
+		$response[ 'single' ] = ob_get_clean();
178 178
 
179 179
 		$response = array_map( 'gravityview_strip_whitespace', $response );
180 180
 
@@ -192,26 +192,26 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$this->check_ajax_nonce();
194 194
 
195
-		if( empty( $_POST['template_id'] ) ) {
195
+		if ( empty( $_POST[ 'template_id' ] ) ) {
196 196
 			gravityview()->log->error( 'Cannot create preset form; the template_id is empty.' );
197 197
 			$this->_exit( false );
198 198
 		}
199 199
 
200 200
 		// get the xml for this specific template_id
201
-		$preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] );
201
+		$preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST[ 'template_id' ] );
202 202
 
203 203
 		// import form
204 204
 		$form = $this->import_form( $preset_form_xml_path );
205 205
 
206 206
 		// get the form ID
207
-		if( false === $form ) {
207
+		if ( false === $form ) {
208 208
 			// send error to user
209
-			gravityview()->log->error( 'Error importing form for template id: {template_id}', array( 'template_id' => (int) $_POST['template_id'] ) );
209
+			gravityview()->log->error( 'Error importing form for template id: {template_id}', array( 'template_id' => (int)$_POST[ 'template_id' ] ) );
210 210
 
211 211
 			$this->_exit( false );
212 212
 		}
213 213
 
214
-		$this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' );
214
+		$this->_exit( '<option value="' . esc_attr( $form[ 'id' ] ) . '" selected="selected">' . esc_html( $form[ 'title' ] ) . '</option>' );
215 215
 
216 216
 	}
217 217
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
 		gravityview()->log->debug( '[import_form] Import Preset Form. (File) {path}', array( 'path' => $xml_or_json_path ) );
227 227
 
228
-		if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) {
228
+		if ( empty( $xml_or_json_path ) || ! class_exists( 'GFExport' ) || ! file_exists( $xml_or_json_path ) ) {
229 229
 			gravityview()->log->error( 'Class GFExport or file not found. file: {path}', array( 'path' => $xml_or_json_path ) );
230 230
 			return false;
231 231
 		}
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
 		gravityview()->log->debug( '[import_form] Importing form (Result) {count}', array( 'count' => $count ) );
238 238
 		gravityview()->log->debug( '[import_form] Importing form (Form) ', array( 'data' => $forms ) );
239 239
 
240
-		if( $count != 1 || empty( $forms[0]['id'] ) ) {
240
+		if ( $count != 1 || empty( $forms[ 0 ][ 'id' ] ) ) {
241 241
 			gravityview()->log->error( 'Form Import Failed!' );
242 242
 			return false;
243 243
 		}
244 244
 
245 245
 		// import success - return form id
246
-		return $forms[0];
246
+		return $forms[ 0 ];
247 247
 	}
248 248
 
249 249
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	function get_field_options() {
258 258
 		$this->check_ajax_nonce();
259 259
 
260
-		if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) {
260
+		if ( empty( $_POST[ 'template' ] ) || empty( $_POST[ 'area' ] ) || empty( $_POST[ 'field_id' ] ) || empty( $_POST[ 'field_type' ] ) ) {
261 261
 			gravityview()->log->error( 'Required fields were not set in the $_POST request. ' );
262 262
 			$this->_exit( false );
263 263
 		}
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 		$_post = array_map( 'esc_attr', $_post );
270 270
 
271 271
 		// The GF type of field: `product`, `name`, `creditcard`, `id`, `text`
272
-		$input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL;
273
-		$context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL;
272
+		$input_type = isset( $_post[ 'input_type' ] ) ? esc_attr( $_post[ 'input_type' ] ) : NULL;
273
+		$context = isset( $_post[ 'context' ] ) ? esc_attr( $_post[ 'context' ] ) : NULL;
274 274
 
275
-		$form_id = empty( $_post['form_id'] ) ? null : $_post['form_id'];
276
-		$response = GravityView_Render_Settings::render_field_options( $form_id, $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context  );
275
+		$form_id = empty( $_post[ 'form_id' ] ) ? null : $_post[ 'form_id' ];
276
+		$response = GravityView_Render_Settings::render_field_options( $form_id, $_post[ 'field_type' ], $_post[ 'template' ], $_post[ 'field_id' ], $_post[ 'field_label' ], $_post[ 'area' ], $input_type, '', '', $context );
277 277
 
278 278
 		$response = gravityview_strip_whitespace( $response );
279 279
 
@@ -294,15 +294,15 @@  discard block
 block discarded – undo
294 294
 		$form = '';
295 295
 
296 296
 		// if form id is set, use it, else, get form from preset
297
-		if( !empty( $_POST['form_id'] ) ) {
297
+		if ( ! empty( $_POST[ 'form_id' ] ) ) {
298 298
 
299
-			$form = (int) $_POST['form_id'];
299
+			$form = (int)$_POST[ 'form_id' ];
300 300
 
301 301
 		}
302 302
 		// get form from preset
303
-		elseif( !empty( $_POST['template_id'] ) ) {
303
+		elseif ( ! empty( $_POST[ 'template_id' ] ) ) {
304 304
 
305
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
305
+			$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
306 306
 
307 307
 		}
308 308
 
@@ -318,27 +318,27 @@  discard block
 block discarded – undo
318 318
 	 * @param  string $template_id Preset template
319 319
 	 *
320 320
 	 */
321
-	static function pre_get_form_fields( $template_id = '') {
321
+	static function pre_get_form_fields( $template_id = '' ) {
322 322
 
323
-		if( empty( $template_id ) ) {
323
+		if ( empty( $template_id ) ) {
324 324
 			gravityview()->log->error( 'Template ID not set.' );
325 325
 			return false;
326 326
 		} else {
327 327
 			$form_file = apply_filters( 'gravityview_template_formxml', '', $template_id );
328
-			if( !file_exists( $form_file )  ) {
328
+			if ( ! file_exists( $form_file ) ) {
329 329
 				gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. File not found. file: {path}', array( 'template_id' => $template_id, 'path' => $form_file ) );
330 330
 				return false;
331 331
 			}
332 332
 		}
333 333
 
334 334
 		// Load xml parser (from GravityForms)
335
-		if( class_exists( 'GFCommon' ) ) {
335
+		if ( class_exists( 'GFCommon' ) ) {
336 336
 			$xml_parser = GFCommon::get_base_path() . '/xml.php';
337 337
 		} else {
338 338
 			$xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php';
339 339
 		}
340 340
 
341
-		if( file_exists( $xml_parser ) ) {
341
+		if ( file_exists( $xml_parser ) ) {
342 342
 			require_once( $xml_parser );
343 343
 		} else {
344 344
 			gravityview()->log->debug( ' - Gravity Forms XML Parser not found {path}.', array( 'path' => $xml_parser ) );
@@ -349,32 +349,32 @@  discard block
 block discarded – undo
349 349
 		$xmlstr = file_get_contents( $form_file );
350 350
 
351 351
         $options = array(
352
-            "page" => array("unserialize_as_array" => true),
353
-            "form"=> array("unserialize_as_array" => true),
354
-            "field"=> array("unserialize_as_array" => true),
355
-            "rule"=> array("unserialize_as_array" => true),
356
-            "choice"=> array("unserialize_as_array" => true),
357
-            "input"=> array("unserialize_as_array" => true),
358
-            "routing_item"=> array("unserialize_as_array" => true),
359
-            "creditCard"=> array("unserialize_as_array" => true),
360
-            "routin"=> array("unserialize_as_array" => true),
361
-            "confirmation" => array("unserialize_as_array" => true),
362
-            "notification" => array("unserialize_as_array" => true)
352
+            "page" => array( "unserialize_as_array" => true ),
353
+            "form"=> array( "unserialize_as_array" => true ),
354
+            "field"=> array( "unserialize_as_array" => true ),
355
+            "rule"=> array( "unserialize_as_array" => true ),
356
+            "choice"=> array( "unserialize_as_array" => true ),
357
+            "input"=> array( "unserialize_as_array" => true ),
358
+            "routing_item"=> array( "unserialize_as_array" => true ),
359
+            "creditCard"=> array( "unserialize_as_array" => true ),
360
+            "routin"=> array( "unserialize_as_array" => true ),
361
+            "confirmation" => array( "unserialize_as_array" => true ),
362
+            "notification" => array( "unserialize_as_array" => true )
363 363
         );
364 364
 
365
-		$xml = new RGXML($options);
366
-        $forms = $xml->unserialize($xmlstr);
365
+		$xml = new RGXML( $options );
366
+        $forms = $xml->unserialize( $xmlstr );
367 367
 
368
-        if( !$forms ) {
368
+        if ( ! $forms ) {
369 369
         	gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. Error importing file. (File) {path}', array( 'template_id' => $template_id, 'path' => $form_file ) );
370 370
         	return false;
371 371
         }
372 372
 
373
-        if( !empty( $forms[0] ) && is_array( $forms[0] ) ) {
374
-        	$form = $forms[0];
373
+        if ( ! empty( $forms[ 0 ] ) && is_array( $forms[ 0 ] ) ) {
374
+        	$form = $forms[ 0 ];
375 375
         }
376 376
 
377
-        if( empty( $form ) ) {
377
+        if ( empty( $form ) ) {
378 378
         	gravityview()->log->error( '$form not set.', array( 'data' => $forms ) );
379 379
         	return false;
380 380
         }
@@ -393,38 +393,38 @@  discard block
 block discarded – undo
393 393
 	 */
394 394
 	function import_fields( $file ) {
395 395
 
396
-		if( empty( $file ) || !file_exists(  $file ) ) {
396
+		if ( empty( $file ) || ! file_exists( $file ) ) {
397 397
 			gravityview()->log->error( 'Importing Preset Fields. File not found. (File) {path}', array( 'path' => $file ) );
398 398
 			return false;
399 399
 		}
400 400
 
401
-		if( !class_exists('WXR_Parser') ) {
401
+		if ( ! class_exists( 'WXR_Parser' ) ) {
402 402
 			include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php';
403 403
 		}
404 404
 
405 405
 		$parser = new WXR_Parser();
406 406
 		$presets = $parser->parse( $file );
407 407
 
408
-		if(is_wp_error( $presets )) {
408
+		if ( is_wp_error( $presets ) ) {
409 409
 			gravityview()->log->error( 'Importing Preset Fields failed. Threw WP_Error.', array( 'data' => $presets ) );
410 410
 			return false;
411 411
 		}
412 412
 
413
-		if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) {
413
+		if ( empty( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) && ! is_array( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) ) {
414 414
 			gravityview()->log->error( 'Importing Preset Fields failed. Meta not found in file. {path}', array( 'path' => $file ) );
415 415
 			return false;
416 416
 		}
417 417
 
418
-		gravityview()->log->debug( '[import_fields] postmeta', array( 'data' => $presets['posts'][0]['postmeta'] ) );
418
+		gravityview()->log->debug( '[import_fields] postmeta', array( 'data' => $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) );
419 419
 
420 420
 		$fields = $widgets = array();
421
-		foreach( $presets['posts'][0]['postmeta'] as $meta ) {
422
-			switch ($meta['key']) {
421
+		foreach ( $presets[ 'posts' ][ 0 ][ 'postmeta' ] as $meta ) {
422
+			switch ( $meta[ 'key' ] ) {
423 423
 				case '_gravityview_directory_fields':
424
-					$fields = maybe_unserialize( $meta['value'] );
424
+					$fields = maybe_unserialize( $meta[ 'value' ] );
425 425
 					break;
426 426
 				case '_gravityview_directory_widgets':
427
-					$widgets = maybe_unserialize( $meta['value'] );
427
+					$widgets = maybe_unserialize( $meta[ 'value' ] );
428 428
 					break;
429 429
 			}
430 430
 		}
Please login to merge, or discard this patch.
includes/class-gravityview-admin-duplicate-view.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -195,7 +195,7 @@
 block discarded – undo
195 195
 	 *
196 196
 	 * @since 1.6
197 197
 	 *
198
-	 * @param int $new_view_id The ID of the newly created View
198
+	 * @param int $new_id The ID of the newly created View
199 199
 	 * @param WP_Post $post The View that was just cloned
200 200
 	 *
201 201
 	 * @return void
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 	function __construct() {
16 16
 
17 17
 		// Only run on Admin
18
-		if ( !is_admin() ) {
18
+		if ( ! is_admin() ) {
19 19
 			return;
20 20
 		}
21 21
 
22 22
 		// If the Duplicate Post plugin is active, don't run.
23
-		if( defined('DUPLICATE_POST_CURRENT_VERSION') ) {
23
+		if ( defined( 'DUPLICATE_POST_CURRENT_VERSION' ) ) {
24 24
 			return;
25 25
 		}
26 26
 
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 		global $post;
61 61
 
62 62
 		// We only want to add Clone links to the Edit View metabox
63
-		if( !$this->is_all_views_page() ) {
63
+		if ( ! $this->is_all_views_page() ) {
64 64
 
65
-			if( $duplicate_links = $this->make_duplicate_link_row( array(), $post ) ) {
66
-				$links[] = '<span>' . $duplicate_links['edit_as_new_draft'] . '</span>';
65
+			if ( $duplicate_links = $this->make_duplicate_link_row( array(), $post ) ) {
66
+				$links[ ] = '<span>' . $duplicate_links[ 'edit_as_new_draft' ] . '</span>';
67 67
 			}
68 68
 
69 69
 		}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		 * @param string|null If string, the status to set for the new View. If empty, use existing View status.
124 124
 		 * @param WP_Post $post View being cloned
125 125
 		 */
126
-		$new_view_status = apply_filters('gravityview/duplicate-view/status', $status, $post );
126
+		$new_view_status = apply_filters( 'gravityview/duplicate-view/status', $status, $post );
127 127
 
128 128
 		$new_view = array(
129 129
 			'menu_order'     => $post->menu_order,
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
 		 * @param boolean $copy_date Whether the copy the date from the existing View. Default: `false`
147 147
 		 * @param WP_Post $post View being cloned
148 148
 		 */
149
-		$copy_date = apply_filters('gravityview/duplicate-view/copy-date', false, $post );
149
+		$copy_date = apply_filters( 'gravityview/duplicate-view/copy-date', false, $post );
150 150
 
151 151
 		if ( $copy_date ) {
152
-			$new_view['post_date']     = $new_post_date = $post->post_date;
153
-			$new_view['post_date_gmt'] = get_gmt_from_date( $new_post_date );
152
+			$new_view[ 'post_date' ]     = $new_post_date = $post->post_date;
153
+			$new_view[ 'post_date_gmt' ] = get_gmt_from_date( $new_post_date );
154 154
 		}
155 155
 
156 156
 		/**
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		 * @param array $new_view Array of settings to be passed to wp_insert_post()
160 160
 		 * @param WP_Post $post View being cloned
161 161
 		 */
162
-		$new_view = apply_filters('gravityview/duplicate-view/new-view', $new_view, $post );
162
+		$new_view = apply_filters( 'gravityview/duplicate-view/new-view', $new_view, $post );
163 163
 
164 164
 		// Magic happens here.
165 165
 		$new_view_id = wp_insert_post( $new_view );
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
 			$clone_text = __( 'Clone', 'gravityview' );
242 242
 			$clone_title = __( 'Clone this View', 'gravityview' );
243 243
 
244
-			$actions['clone'] = gravityview_get_link( $clone_link, $clone_text, 'title='.$clone_title );
244
+			$actions[ 'clone' ] = gravityview_get_link( $clone_link, $clone_text, 'title=' . $clone_title );
245 245
 
246 246
 			$clone_draft_link = $this->get_clone_view_link( $post->ID );
247 247
 			$clone_draft_text = $this->is_all_views_page() ? __( 'New Draft', 'gravityview' ) : __( 'Clone View', 'gravityview' );
248 248
 			$clone_draft_title = __( 'Copy as a new draft View', 'gravityview' );
249 249
 
250
-			$actions['edit_as_new_draft'] = gravityview_get_link( $clone_draft_link, esc_html( $clone_draft_text ), 'title='.$clone_draft_title );
250
+			$actions[ 'edit_as_new_draft' ] = gravityview_get_link( $clone_draft_link, esc_html( $clone_draft_text ), 'title=' . $clone_draft_title );
251 251
 		}
252 252
 
253 253
 		return $actions;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 		}
272 272
 
273 273
 		// Verify the View exists
274
-		if ( !$view = get_post( $id ) ) {
274
+		if ( ! $view = get_post( $id ) ) {
275 275
 			return '';
276 276
 		}
277 277
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		$post_type_object = get_post_type_object( $view->post_type );
287 287
 
288 288
 		/** If there's no gravityview post type for some reason, abort! */
289
-		if ( !$post_type_object ) {
289
+		if ( ! $post_type_object ) {
290 290
 			gravityview()->log->error( 'No gravityview post type exists when trying to clone the View.', array( 'data' => $view ) );
291 291
 			return '';
292 292
 		}
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 		 * @param int $view_id View ID
299 299
 		 * @param string $context How to display the link. If "display", the URL is run through esc_html(). Default: `display`
300 300
 		 */
301
-		$clone_view_link = apply_filters( 'gravityview/duplicate-view/get_clone_view_link', admin_url( "admin.php". $action ), $view->ID, $context );
301
+		$clone_view_link = apply_filters( 'gravityview/duplicate-view/get_clone_view_link', admin_url( "admin.php" . $action ), $view->ID, $context );
302 302
 
303 303
 		return $clone_view_link;
304 304
 	}
@@ -325,14 +325,14 @@  discard block
 block discarded – undo
325 325
 	 */
326 326
 	public function save_as_new_view( $status = '' ) {
327 327
 
328
-		if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) ) ) {
328
+		if ( ! ( isset( $_GET[ 'post' ] ) || isset( $_POST[ 'post' ] ) ) ) {
329 329
 			wp_die( __( 'No post to duplicate has been supplied!', 'gravityview' ) );
330 330
 		}
331 331
 
332 332
 		// Get the original post
333
-		$id   = ( isset( $_GET['post'] ) ? $_GET['post'] : $_POST['post'] );
333
+		$id = ( isset( $_GET[ 'post' ] ) ? $_GET[ 'post' ] : $_POST[ 'post' ] );
334 334
 
335
-		if( ! $this->current_user_can_copy( $id ) ) {
335
+		if ( ! $this->current_user_can_copy( $id ) ) {
336 336
 			wp_die( __( 'You don\'t have permission to copy this View.', 'gravityview' ) );
337 337
 		}
338 338
 
Please login to merge, or discard this patch.
includes/class-gravityview-compatibility.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@
 block discarded – undo
116 116
 
117 117
 	/**
118 118
 	 * @since 1.12
119
-	 * @return bool
119
+	 * @return boolean|null
120 120
 	 */
121 121
 	private function add_fallback_shortcode() {
122 122
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -204,7 +204,7 @@
 block discarded – undo
204 204
 			self::$notices['wp_version'] = array(
205 205
 				'class' => 'error',
206 206
 				'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ),
207
-			    'cap' => 'update_core',
207
+				'cap' => 'update_core',
208 208
 				'dismiss' => 'wp_version',
209 209
 			);
210 210
 
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @return GravityView_Compatibility
77 77
 	 */
78 78
 	public static function getInstance() {
79
-		if( self::$instance ) {
79
+		if ( self::$instance ) {
80 80
 			return self::$instance;
81 81
 		}
82 82
 		return new self;
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
 		// If Gravity Forms doesn't exist or is outdated, load the admin view class to
139 139
 		// show the notice, but not load any post types or process shortcodes.
140 140
 		// Without Gravity Forms, there is no GravityView. Beautiful, really.
141
-		if( ! self::is_valid() ) {
141
+		if ( ! self::is_valid() ) {
142 142
 
143 143
 			// If the plugin's not loaded, might as well hide the shortcode for people.
144
-			add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice') );
144
+			add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice' ) );
145 145
 
146 146
 		}
147 147
 	}
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public function _shortcode_gf_notice( $atts = array(), $content = null, $shortcode = 'gravityview' ) {
169 169
 
170
-		if( ! GVCommon::has_cap( 'activate_plugins' ) ) {
170
+		if ( ! GVCommon::has_cap( 'activate_plugins' ) ) {
171 171
 			return null;
172 172
 		}
173 173
 
174 174
 		$notices = self::get_notices();
175 175
 
176
-		$message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>' . esc_html__( 'You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview') . '</em></p>';
177
-		foreach( (array)$notices as $notice ) {
178
-			$message .= wpautop( $notice['message'] );
176
+		$message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>' . esc_html__( 'You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview' ) . '</em></p>';
177
+		foreach ( (array)$notices as $notice ) {
178
+			$message .= wpautop( $notice[ 'message' ] );
179 179
 		}
180 180
 		$message .= '</div>';
181 181
 
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 
196 196
 		if ( ! gravityview()->plugin->is_compatible_php() ) {
197 197
 
198
-			self::$notices['php_version'] = array(
198
+			self::$notices[ 'php_version' ] = array(
199 199
 				'class' => 'error',
200
-				'message' => sprintf( __( "%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' ),
200
+				'message' => sprintf( __( "%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . phpversion() . '</span>' ),
201 201
 				'cap' => 'manage_options',
202 202
 				'dismiss' => 'php_version',
203 203
 			);
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
 		if ( ! gravityview()->plugin->is_compatible_future_php() ) {
209 209
 
210 210
 			// Show the notice on every update. Yes, annoying, but not as annoying as a plugin breaking.
211
-			$key = sprintf('php_%s_%s', GV_FUTURE_MIN_PHP_VERSION, GravityView_Plugin::version );
211
+			$key = sprintf( 'php_%s_%s', GV_FUTURE_MIN_PHP_VERSION, GravityView_Plugin::version );
212 212
 
213 213
 			self::$notices[ $key ] = array(
214 214
 				'class' => 'error',
215
-				'message' => sprintf( __( "%sGravityView will soon require PHP Version %s.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_FUTURE_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' ),
215
+				'message' => sprintf( __( "%sGravityView will soon require PHP Version %s.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_FUTURE_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . phpversion() . '</span>' ),
216 216
 				'cap' => 'manage_options',
217 217
 				'dismiss' => $key,
218 218
 			);
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
 
234 234
 		if ( ! gravityview()->plugin->is_compatible_wordpress() ) {
235 235
 
236
-			self::$notices['wp_version'] = array(
236
+			self::$notices[ 'wp_version' ] = array(
237 237
 				'class' => 'error',
238
-				'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ),
238
+				'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . $wp_version . '</span>' ),
239 239
 			    'cap' => 'update_core',
240 240
 				'dismiss' => 'wp_version',
241 241
 			);
@@ -258,17 +258,17 @@  discard block
 block discarded – undo
258 258
 	public static function check_gravityforms() {
259 259
 
260 260
 		// Bypass other checks: if the class exists
261
-		if( class_exists( 'GFCommon' ) ) {
261
+		if ( class_exists( 'GFCommon' ) ) {
262 262
 
263 263
 			// Does the version meet future requirements?
264
-			if( true === version_compare( GFCommon::$version, GV_FUTURE_MIN_GF_VERSION, ">=" ) ) {
264
+			if ( true === version_compare( GFCommon::$version, GV_FUTURE_MIN_GF_VERSION, ">=" ) ) {
265 265
 				return true;
266 266
 			}
267 267
 
268 268
 			// Does it meet minimum requirements?
269 269
 			$meets_minimum = gravityview()->plugin->is_compatible_gravityforms();
270 270
 
271
-			if( $meets_minimum ) {
271
+			if ( $meets_minimum ) {
272 272
 				/* translators: first placeholder is the future required version of Gravity Forms. The second placeholder is the current version of Gravity Forms. */
273 273
 				$title = __( 'In the future, GravityView will require Gravity Forms Version %s or newer.', 'gravityview' );
274 274
 				$version = GV_FUTURE_MIN_GF_VERSION;
@@ -283,14 +283,14 @@  discard block
 block discarded – undo
283 283
 			$message = '<h3>' . esc_html( sprintf( $title, $version ) ) . '</h3>';
284 284
 
285 285
 			/* translators: the placeholder is the current version of Gravity Forms. */
286
-			$message .= '<p>' . sprintf( esc_html__( "You're using Version %s. Please update your Gravity Forms or purchase a license.", 'gravityview' ), '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>' ) . '</p>';
286
+			$message .= '<p>' . sprintf( esc_html__( "You're using Version %s. Please update your Gravity Forms or purchase a license.", 'gravityview' ), '<span style="font-family: Consolas, Courier, monospace;">' . GFCommon::$version . '</span>' ) . '</p>';
287 287
 
288 288
 			/* translators: In this context, "get" means purchase */
289 289
 			$message .= '<p><a href="https://gravityview.co/gravityforms/" class="button button-secondary button-large button-hero">' . esc_html__( 'Get the Latest Gravity Forms', 'gravityview' ) . '</a></p>';
290 290
 
291 291
 
292 292
 			// Show the notice even if the future version requirements aren't met
293
-			self::$notices['gf_version'] = array(
293
+			self::$notices[ 'gf_version' ] = array(
294 294
 				'class' => $class,
295 295
 				'message' => $message,
296 296
 				'cap' => 'update_plugins',
@@ -308,42 +308,42 @@  discard block
 block discarded – undo
308 308
 		 * OR
309 309
 		 * It's the Network Admin and we just don't know whether the sites have GF activated themselves.
310 310
 		 */
311
-		if( true === $gf_status || is_network_admin() ) {
311
+		if ( true === $gf_status || is_network_admin() ) {
312 312
 			return true;
313 313
 		}
314 314
 
315 315
 		// If GFCommon doesn't exist, assume GF not active
316 316
 		$return = false;
317 317
 
318
-		switch( $gf_status ) {
318
+		switch ( $gf_status ) {
319 319
 			case 'inactive':
320 320
 
321 321
 				// Required for multisite
322
-				if( ! function_exists('wp_create_nonce') ) {
322
+				if ( ! function_exists( 'wp_create_nonce' ) ) {
323 323
 					require_once ABSPATH . WPINC . '/pluggable.php';
324 324
 				}
325 325
 
326 326
 				// Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE"
327
-				if( is_multisite() ) {
327
+				if ( is_multisite() ) {
328 328
 					wp_cookie_constants();
329 329
 				}
330 330
 
331 331
 				$return = false;
332 332
 
333
-				$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="'. wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=gravityforms/gravityforms.php' ), 'activate-plugin_gravityforms/gravityforms.php') . '" class="button button-large">';
333
+				$button = function_exists( 'is_network_admin' ) && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="' . wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=gravityforms/gravityforms.php' ), 'activate-plugin_gravityforms/gravityforms.php' ) . '" class="button button-large">';
334 334
 
335
-				self::$notices['gf_inactive'] = array(
335
+				self::$notices[ 'gf_inactive' ] = array(
336 336
 					'class' => 'error',
337
-					'message' => sprintf( __( '%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview' ), '<h3>', "</h3>\n\n". $button, '</a></strong>' ),
337
+					'message' => sprintf( __( '%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview' ), '<h3>', "</h3>\n\n" . $button, '</a></strong>' ),
338 338
 					'cap' => 'activate_plugins',
339 339
 					'dismiss' => 'gf_inactive',
340 340
 				);
341 341
 
342 342
 				break;
343 343
 			default:
344
-				self::$notices['gf_installed'] = array(
344
+				self::$notices[ 'gf_installed' ] = array(
345 345
 					'class' => 'error',
346
-					'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $59%s%s', 'gravityview' ), '<h3>', "</h3>\n\n".'<a href="https://gravityview.co/gravityforms/" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'),
346
+					'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $59%s%s', 'gravityview' ), '<h3>', "</h3>\n\n" . '<a href="https://gravityview.co/gravityforms/" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>' ),
347 347
 					'cap' => 'install_plugins',
348 348
 					'dismiss' => 'gf_installed',
349 349
 				);
@@ -360,10 +360,10 @@  discard block
 block discarded – undo
360 360
 	 */
361 361
 	private static function check_gf_directory() {
362 362
 
363
-		if( class_exists( 'GFDirectory' ) ) {
364
-			self::$notices['gf_directory'] = array(
363
+		if ( class_exists( 'GFDirectory' ) ) {
364
+			self::$notices[ 'gf_directory' ] = array(
365 365
 				'class' => 'error is-dismissible',
366
-				'title' => __('Potential Conflict', 'gravityview' ),
366
+				'title' => __( 'Potential Conflict', 'gravityview' ),
367 367
 				'message' => __( 'GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview' ),
368 368
 				'dismiss' => 'gf_directory',
369 369
 				'cap' => 'activate_plugins',
@@ -382,21 +382,21 @@  discard block
 block discarded – undo
382 382
 	 */
383 383
 	public static function get_plugin_status( $location = '' ) {
384 384
 
385
-		if( ! function_exists('is_plugin_active') ) {
385
+		if ( ! function_exists( 'is_plugin_active' ) ) {
386 386
 			include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
387 387
 		}
388 388
 
389
-		if( is_network_admin() && is_plugin_active_for_network( $location ) ) {
389
+		if ( is_network_admin() && is_plugin_active_for_network( $location ) ) {
390 390
 			return true;
391 391
 		}
392 392
 
393
-		if( !is_network_admin() && is_plugin_active( $location ) ) {
393
+		if ( ! is_network_admin() && is_plugin_active( $location ) ) {
394 394
 			return true;
395 395
 		}
396 396
 
397
-		if(
398
-			!file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) &&
399
-			!file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location )
397
+		if (
398
+			! file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) &&
399
+			! file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location )
400 400
 		) {
401 401
 			return false;
402 402
 		}
Please login to merge, or discard this patch.
includes/class-gravityview-entry-link-shortcode.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -221,7 +221,6 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @since 1.15
223 223
 	 *
224
-	 * @param string|null $content Content inside shortcode, if defined
225 224
 	 *
226 225
 	 * @return string|boolean If URL is fetched, the URL to the entry link. If not found, returns false.
227 226
 	 */
@@ -316,7 +315,7 @@  discard block
 block discarded – undo
316 315
 	 *
317 316
 	 * @since 1.15
318 317
 	 *
319
-	 * @param string $href URL
318
+	 * @param string|null $url
320 319
 	 */
321 320
 	private function maybe_add_field_values_query_args( $url ) {
322 321
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 
76 76
 		$atts = shortcode_atts( self::$defaults, $atts );
77 77
 
78
-		$atts['action'] = 'edit';
78
+		$atts[ 'action' ] = 'edit';
79 79
 
80 80
 		return $this->shortcode( $atts, $content, $context );
81 81
 	}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 		$atts = shortcode_atts( self::$defaults, $atts );
93 93
 
94
-		$atts['action'] = 'delete';
94
+		$atts[ 'action' ] = 'delete';
95 95
 
96 96
 		return $this->shortcode( $atts, $content, $context );
97 97
 	}
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
 		$this->settings = shortcode_atts( self::$defaults, $atts, $context );
133 133
 
134
-		$this->view_id = empty( $this->settings['view_id'] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings['view_id'] );
134
+		$this->view_id = empty( $this->settings[ 'view_id' ] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings[ 'view_id' ] );
135 135
 
136 136
 		if ( empty( $this->view_id ) ) {
137 137
 			gravityview()->log->error( 'A View ID was not defined and we are not inside a View' );
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 			return null;
140 140
 		}
141 141
 
142
-		$this->entry = $this->get_entry( $this->settings['entry_id'] );
142
+		$this->entry = $this->get_entry( $this->settings[ 'entry_id' ] );
143 143
 
144 144
 		if ( empty( $this->entry ) ) {
145
-			gravityview()->log->error( 'An Entry ID was not defined or found. Entry ID: {entry_id}', array( 'entry_id' => $this->settings['entry_id'] ) );
145
+			gravityview()->log->error( 'An Entry ID was not defined or found. Entry ID: {entry_id}', array( 'entry_id' => $this->settings[ 'entry_id' ] ) );
146 146
 
147 147
 			return null;
148 148
 		}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		gravityview()->log->debug( '{context} atts:', array( 'context' => $context, 'data' => $atts ) );
151 151
 
152 152
 		if ( ! $this->has_cap() ) {
153
-			gravityview()->log->error( 'User does not have the capability to {action} this entry: {entry_id}', array( 'action' => esc_attr( $this->settings['action'] ), 'entry_id' => $this->entry['id'] ) );
153
+			gravityview()->log->error( 'User does not have the capability to {action} this entry: {entry_id}', array( 'action' => esc_attr( $this->settings[ 'action' ] ), 'entry_id' => $this->entry[ 'id' ] ) );
154 154
 
155 155
 			return null;
156 156
 		}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		}
165 165
 
166 166
 		// Get just the URL, not the tag
167
-		if ( 'url' === $this->settings['return'] ) {
167
+		if ( 'url' === $this->settings[ 'return' ] ) {
168 168
 			return $url;
169 169
 		}
170 170
 
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
 	 */
186 186
 	private function get_link_atts() {
187 187
 
188
-		wp_parse_str( $this->settings['link_atts'], $link_atts );
188
+		wp_parse_str( $this->settings[ 'link_atts' ], $link_atts );
189 189
 
190
-		if ( 'delete' === $this->settings['action'] ) {
191
-			$link_atts['onclick'] = isset( $link_atts['onclick'] ) ? $link_atts['onclick'] : GravityView_Delete_Entry::get_confirm_dialog();
190
+		if ( 'delete' === $this->settings[ 'action' ] ) {
191
+			$link_atts[ 'onclick' ] = isset( $link_atts[ 'onclick' ] ) ? $link_atts[ 'onclick' ] : GravityView_Delete_Entry::get_confirm_dialog();
192 192
 		}
193 193
 
194
-		return (array) $link_atts;
194
+		return (array)$link_atts;
195 195
 	}
196 196
 
197 197
 	/**
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 			return do_shortcode( $content );
212 212
 		}
213 213
 
214
-		switch ( $this->settings['action'] ) {
214
+		switch ( $this->settings[ 'action' ] ) {
215 215
 			case 'edit':
216 216
 				$anchor_text = __( 'Edit Entry', 'gravityview' );
217 217
 				break;
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 	private function get_url() {
240 240
 
241 241
 		// if post_id is not defined, default to view_id
242
-		$post_id = empty( $this->settings['post_id'] ) ? $this->view_id : $this->settings['post_id'];
242
+		$post_id = empty( $this->settings[ 'post_id' ] ) ? $this->view_id : $this->settings[ 'post_id' ];
243 243
 
244
-		switch ( $this->settings['action'] ) {
244
+		switch ( $this->settings[ 'action' ] ) {
245 245
 			case 'edit':
246 246
 				$url = GravityView_Edit_Entry::get_edit_link( $this->entry, $this->view_id, $post_id );
247 247
 				break;
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	private function has_cap() {
268 268
 
269
-		switch ( $this->settings['action'] ) {
269
+		switch ( $this->settings[ 'action' ] ) {
270 270
 			case 'edit':
271 271
 				$has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry, $this->view_id );
272 272
 				break;
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 	 */
332 332
 	private function maybe_add_field_values_query_args( $url ) {
333 333
 
334
-		if ( $url && ! empty( $this->settings['field_values'] ) ) {
334
+		if ( $url && ! empty( $this->settings[ 'field_values' ] ) ) {
335 335
 
336
-			wp_parse_str( $this->settings['field_values'], $field_values );
336
+			wp_parse_str( $this->settings[ 'field_values' ], $field_values );
337 337
 
338 338
 			$url = add_query_arg( $field_values, $url );
339 339
 		}
Please login to merge, or discard this patch.
includes/class-gravityview-roles-capabilities.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,6 @@
 block discarded – undo
67 67
 	 *
68 68
 	 * @since 1.15
69 69
 	 *
70
-	 * @param array   $allcaps An array of all the user's capabilities.
71 70
 	 * @param array   $caps    Actual capabilities for meta capability.
72 71
 	 * @param array   $args    Optional parameters passed to has_cap(), typically object ID.
73 72
 	 * @param WP_User|null $user    The user object, in WordPress 3.7.0 or higher
Please login to merge, or discard this patch.
Indentation   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) );
57 57
 		add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 );
58 58
 		add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 );
59
-        add_action( 'admin_init', array( $this, 'add_caps') );
59
+		add_action( 'admin_init', array( $this, 'add_caps') );
60 60
 	}
61 61
 
62 62
 
@@ -360,7 +360,6 @@  discard block
 block discarded – undo
360 360
 	 * Add Gravity Forms and GravityView's "full access" caps when any other caps are checked against.
361 361
 	 *
362 362
 	 * @since 1.15
363
-
364 363
 	 * @param array $caps_to_check
365 364
 	 *
366 365
 	 * @return array
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 */
34 34
 	public static function get_instance() {
35 35
 
36
-		if( ! self::$instance ) {
36
+		if ( ! self::$instance ) {
37 37
 			self::$instance = new self;
38 38
 		}
39 39
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) );
57 57
 		add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 );
58 58
 		add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 );
59
-        add_action( 'admin_init', array( $this, 'add_caps') );
59
+        add_action( 'admin_init', array( $this, 'add_caps' ) );
60 60
 	}
61 61
 
62 62
 
@@ -77,18 +77,18 @@  discard block
 block discarded – undo
77 77
 	public function filter_user_has_cap( $usercaps = array(), $caps = array(), $args = array(), $user = NULL ) {
78 78
 
79 79
 		// Empty caps_to_check array
80
-		if( ! $usercaps || ! $caps ) {
80
+		if ( ! $usercaps || ! $caps ) {
81 81
 			return $usercaps;
82 82
 		}
83 83
 
84 84
 		/**
85 85
 		 * Enable all GravityView caps_to_check if `gravityview_full_access` is enabled
86 86
 		 */
87
-		if( ! empty( $usercaps['gravityview_full_access'] ) ) {
87
+		if ( ! empty( $usercaps[ 'gravityview_full_access' ] ) ) {
88 88
 
89 89
 			$all_gravityview_caps = self::all_caps();
90 90
 
91
-			foreach( $all_gravityview_caps as $gv_cap ) {
91
+			foreach ( $all_gravityview_caps as $gv_cap ) {
92 92
 				$usercaps[ $gv_cap ] = true;
93 93
 			}
94 94
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		$all = $administrator;
307 307
 
308 308
 		// If role is set, return caps_to_check for just that role.
309
-		if( $single_role ) {
309
+		if ( $single_role ) {
310 310
 			$caps = isset( ${$single_role} ) ? ${$single_role} : false;
311 311
 			return $flat_array ? $caps : array( $single_role => $caps );
312 312
 		}
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 
356 356
 		if ( true === $allow_logged_out ) {
357 357
 
358
-			$all_caps = self::all_caps('editor');
358
+			$all_caps = self::all_caps( 'editor' );
359 359
 
360
-			if( array_intersect( $all_caps, (array) $caps_to_check ) ) {
360
+			if ( array_intersect( $all_caps, (array)$caps_to_check ) ) {
361 361
 				return true;
362 362
 			}
363 363
 		}
@@ -378,13 +378,13 @@  discard block
 block discarded – undo
378 378
 		$caps_to_check = self::maybe_add_full_access_caps( $caps_to_check );
379 379
 
380 380
 		foreach ( $caps_to_check as $cap ) {
381
-			if( ! is_null( $object_id ) ) {
381
+			if ( ! is_null( $object_id ) ) {
382 382
 				$has_cap = $user_id ? user_can( $user_id, $cap, $object_id ) : current_user_can( $cap, $object_id );
383 383
 			} else {
384 384
 				$has_cap = $user_id ? user_can( $user_id, $cap ) : current_user_can( $cap );
385 385
 			}
386 386
 			// At the first successful response, stop checking
387
-			if( $has_cap ) {
387
+			if ( $has_cap ) {
388 388
 				break;
389 389
 			}
390 390
 		}
@@ -408,15 +408,15 @@  discard block
 block discarded – undo
408 408
 		$all_gravityview_caps = self::all_caps();
409 409
 
410 410
 		// Are there any $caps_to_check that are from GravityView?
411
-		if( $has_gravityview_caps = array_intersect( $caps_to_check, $all_gravityview_caps ) ) {
412
-			$caps_to_check[] = 'gravityview_full_access';
411
+		if ( $has_gravityview_caps = array_intersect( $caps_to_check, $all_gravityview_caps ) ) {
412
+			$caps_to_check[ ] = 'gravityview_full_access';
413 413
 		}
414 414
 
415 415
 		$all_gravity_forms_caps = class_exists( 'GFCommon' ) ? GFCommon::all_caps() : array();
416 416
 
417 417
 		// Are there any $caps_to_check that are from Gravity Forms?
418
-		if( $all_gravity_forms_caps = array_intersect( $caps_to_check, $all_gravity_forms_caps ) ) {
419
-			$caps_to_check[] = 'gform_full_access';
418
+		if ( $all_gravity_forms_caps = array_intersect( $caps_to_check, $all_gravity_forms_caps ) ) {
419
+			$caps_to_check[ ] = 'gform_full_access';
420 420
 		}
421 421
 
422 422
 		return array_unique( $caps_to_check );
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 			$capabilities = self::all_caps();
439 439
 
440 440
 			// Loop through each role and remove GV caps_to_check
441
-			foreach( $wp_roles->get_names() as $role_slug => $role_name ) {
441
+			foreach ( $wp_roles->get_names() as $role_slug => $role_name ) {
442 442
 				foreach ( $capabilities as $cap ) {
443 443
 					$wp_roles->remove_cap( $role_slug, $cap );
444 444
 				}
Please login to merge, or discard this patch.
includes/class-gravityview-template.php 2 patches
Doc Comments   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,6 +37,9 @@  discard block
 block discarded – undo
37 37
 	public $active_areas;
38 38
 
39 39
 
40
+	/**
41
+	 * @param string $id
42
+	 */
40 43
 	function __construct( $id, $settings = array(), $field_options = array(), $areas = array() ) {
41 44
 
42 45
 		if ( empty( $id ) ) {
@@ -144,6 +147,9 @@  discard block
 block discarded – undo
144 147
 		return $areas;
145 148
 	}
146 149
 
150
+	/**
151
+	 * @param string $context
152
+	 */
147 153
 	public function get_active_areas( $context ) {
148 154
 		if ( isset( $this->active_areas[ $context ] ) ) {
149 155
 			return $this->active_areas[ $context ];
@@ -156,8 +162,8 @@  discard block
 block discarded – undo
156 162
 	/**
157 163
 	 * Assign template specific field options
158 164
 	 *
159
-	 * @param array $options (default: array())
160
-	 * @param string $template (default: '')
165
+	 * @param array $field_options (default: array())
166
+	 * @param string $template_id (default: '')
161 167
 	 * @param string $field_id key for the field
162 168
 	 * @param  string|array $context Context for the field; `directory` or `single` for example.
163 169
 	 *
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
 	 * @return string                Path to XML file
194 194
 	 */
195 195
 	public function assign_form_xml( $xml = '', $template = '' ) {
196
-		if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_form'] ) && $this->template_id === $template ) {
197
-			return $this->settings['preset_form'];
196
+		if ( $this->settings[ 'type' ] === 'preset' && ! empty( $this->settings[ 'preset_form' ] ) && $this->template_id === $template ) {
197
+			return $this->settings[ 'preset_form' ];
198 198
 		}
199 199
 
200 200
 		return $xml;
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 * @return string                Path to XML file
208 208
 	 */
209 209
 	public function assign_fields_xml( $xml = '', $template = '' ) {
210
-		if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_fields'] ) && $this->template_id === $template ) {
211
-			return $this->settings['preset_fields'];
210
+		if ( $this->settings[ 'type' ] === 'preset' && ! empty( $this->settings[ 'preset_fields' ] ) && $this->template_id === $template ) {
211
+			return $this->settings[ 'preset_fields' ];
212 212
 		}
213 213
 
214 214
 		return $xml;
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 */
227 227
 	public function assign_view_slug( $default, $context ) {
228 228
 
229
-		if ( ! empty( $this->settings['slug'] ) ) {
230
-			return $this->settings['slug'];
229
+		if ( ! empty( $this->settings[ 'slug' ] ) ) {
230
+			return $this->settings[ 'slug' ];
231 231
 		}
232 232
 		if ( ! empty( $default ) ) {
233 233
 			return $default;
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 	 * @return void
245 245
 	 */
246 246
 	public function register_styles() {
247
-		if ( ! empty( $this->settings['css_source'] ) ) {
248
-			wp_register_style( 'gravityview_style_' . $this->template_id, $this->settings['css_source'], array(), GravityView_Plugin::version, 'all' );
247
+		if ( ! empty( $this->settings[ 'css_source' ] ) ) {
248
+			wp_register_style( 'gravityview_style_' . $this->template_id, $this->settings[ 'css_source' ], array(), GravityView_Plugin::version, 'all' );
249 249
 		}
250 250
 	}
251 251
 
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   +158 added lines, -158 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/metaboxes/tooltips', array( $this, 'tooltips') );
42
-
43
-        // custom fields' options for zone EDIT
44
-        add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 6 );
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
-     */
40
+		// add tooltips
41
+		add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips') );
42
+
43
+		// custom fields' options for zone EDIT
44
+		add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 6 );
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 149
 	public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) {
150 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
-    }
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/metaboxes/tooltips', array( $this, 'tooltips') );
41
+        add_filter( 'gravityview/metaboxes/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, 6 );
@@ -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
 	public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) {
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-user-registration.php 3 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   +259 added lines, -259 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,104 +22,104 @@  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
 		add_action( 'wp', array( $this, 'add_hooks' ), 10 );
41
-    }
41
+	}
42 42
 
43 43
 	/**
44 44
 	 * Add hooks to trigger updating the user
45 45
 	 *
46 46
 	 * @since 1.18
47 47
 	 */
48
-    public function add_hooks() {
49
-
50
-	    /**
51
-	     * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated?
52
-	     * @since 1.11
53
-	     * @param boolean $boolean Whether to trigger update on user registration (default: true)
54
-	     */
55
-	    if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
56
-
57
-	    	add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
58
-
59
-		    // last resort in case the current user display name don't match any of the defaults
60
-		    add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
61
-	    }
62
-    }
63
-
64
-    /**
65
-     * Update the WordPress user profile based on the GF User Registration create feed
66
-     *
67
-     * @since 1.11
68
-     *
69
-     * @param array $form Gravity Forms form array
70
-     * @param string $entry_id Gravity Forms entry ID
71
-     * @return void
72
-     */
73
-    public function update_user( $form = array(), $entry_id = 0 ) {
74
-
75
-        if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) {
76
-	        gravityview()->log->error( 'GFAPI or User Registration class not found; not updating the user' );
77
-	        return;
78
-        } elseif( empty( $entry_id ) ) {
79
-        	gravityview()->log->error( 'Entry ID is empty [{entry_id}]; not updating the user', array( 'entry_id' => $entry_id ) );
80
-	        return;
81
-        }
82
-
83
-        /** @var GF_User_Registration $gf_user_registration */
84
-        $gf_user_registration = GF_User_Registration::get_instance();
85
-
86
-        $entry = GFAPI::get_entry( $entry_id );
87
-
88
-	    /**
89
-	     * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
90
-	     * @since 1.11
91
-	     * @param array $entry Gravity Forms entry
92
-	     * @param array $form Gravity Forms form
93
-	     */
94
-        $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form );
95
-
96
-	    $config = $this->get_feed_configuration( $entry, $form );
97
-
98
-        // Make sure the feed is active
99
-	    if ( ! \GV\Utils::get( $config, 'is_active', false ) ) {
48
+	public function add_hooks() {
49
+
50
+		/**
51
+		 * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated?
52
+		 * @since 1.11
53
+		 * @param boolean $boolean Whether to trigger update on user registration (default: true)
54
+		 */
55
+		if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
56
+
57
+			add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
58
+
59
+			// last resort in case the current user display name don't match any of the defaults
60
+			add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
61
+		}
62
+	}
63
+
64
+	/**
65
+	 * Update the WordPress user profile based on the GF User Registration create feed
66
+	 *
67
+	 * @since 1.11
68
+	 *
69
+	 * @param array $form Gravity Forms form array
70
+	 * @param string $entry_id Gravity Forms entry ID
71
+	 * @return void
72
+	 */
73
+	public function update_user( $form = array(), $entry_id = 0 ) {
74
+
75
+		if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) {
76
+			gravityview()->log->error( 'GFAPI or User Registration class not found; not updating the user' );
100 77
 			return;
101
-	    }
78
+		} elseif( empty( $entry_id ) ) {
79
+			gravityview()->log->error( 'Entry ID is empty [{entry_id}]; not updating the user', array( 'entry_id' => $entry_id ) );
80
+			return;
81
+		}
82
+
83
+		/** @var GF_User_Registration $gf_user_registration */
84
+		$gf_user_registration = GF_User_Registration::get_instance();
85
+
86
+		$entry = GFAPI::get_entry( $entry_id );
102 87
 
103
-	    // If an Update feed, make sure the conditions are met.
104
-	    if ( \GV\Utils::get( $config, 'meta/feedType' ) === 'update' ) {
105
-	    	if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
106
-			    return;
107
-		    }
108
-	    }
88
+		/**
89
+		 * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
90
+		 * @since 1.11
91
+		 * @param array $entry Gravity Forms entry
92
+		 * @param array $form Gravity Forms form
93
+		 */
94
+		$entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form );
95
+
96
+		$config = $this->get_feed_configuration( $entry, $form );
97
+
98
+		// Make sure the feed is active
99
+		if ( ! \GV\Utils::get( $config, 'is_active', false ) ) {
100
+			return;
101
+		}
109 102
 
110
-        // The priority is set to 3 so that default priority (10) will still override it
111
-        add_filter( 'send_password_change_email', '__return_false', 3 );
112
-        add_filter( 'send_email_change_email', '__return_false', 3 );
103
+		// If an Update feed, make sure the conditions are met.
104
+		if ( \GV\Utils::get( $config, 'meta/feedType' ) === 'update' ) {
105
+			if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
106
+				return;
107
+			}
108
+		}
113 109
 
114
-        // Trigger the User Registration update user method
115
-        $gf_user_registration->update_user( $entry, $form, $config );
110
+		// The priority is set to 3 so that default priority (10) will still override it
111
+		add_filter( 'send_password_change_email', '__return_false', 3 );
112
+		add_filter( 'send_email_change_email', '__return_false', 3 );
116 113
 
117
-        remove_filter( 'send_password_change_email', '__return_false', 3 );
118
-        remove_filter( 'send_email_change_email', '__return_false', 3 );
114
+		// Trigger the User Registration update user method
115
+		$gf_user_registration->update_user( $entry, $form, $config );
119 116
 
120
-        // Prevent double-triggering by removing the hook
121
-	    remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 );
122
-    }
117
+		remove_filter( 'send_password_change_email', '__return_false', 3 );
118
+		remove_filter( 'send_email_change_email', '__return_false', 3 );
119
+
120
+		// Prevent double-triggering by removing the hook
121
+		remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 );
122
+	}
123 123
 
124 124
 	/**
125 125
 	 * Get the User Registration feed configuration for the entry & form
@@ -134,185 +134,185 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @return array
136 136
 	 */
137
-    public function get_feed_configuration( $entry, $form ) {
138
-
139
-	    /** @var GF_User_Registration $gf_user_registration */
140
-	    $gf_user_registration = GF_User_Registration::get_instance();
141
-
142
-	    $config = $gf_user_registration->get_single_submission_feed( $entry, $form );
143
-
144
-	    /**
145
-	     * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
146
-	     * @since 1.15
147
-	     * @param[in,out] boolean $preserve_role Preserve current user role Default: true
148
-	     * @param[in] array $config Gravity Forms User Registration feed configuration for the form
149
-	     * @param[in] array $form Gravity Forms form array
150
-	     * @param[in] array $entry Gravity Forms entry being edited
151
-	     */
152
-	    $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
153
-
154
-	    if( $preserve_role ) {
155
-		    $config['meta']['role'] = 'gfur_preserve_role';
156
-	    }
157
-
158
-	    $displayname = $this->match_current_display_name( $entry['created_by'] );
159
-
160
-	    /**
161
-	     * Make sure the current display name is not changed with the update user method.
162
-	     * @since 1.15
163
-	     */
164
-	    $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname'];
165
-
166
-	    /**
167
-	     * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
168
-	     * @since 1.14
169
-	     * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
170
-	     * @param[in] array $form Gravity Forms form array
171
-	     * @param[in] array $entry Gravity Forms entry being edited
172
-	     */
173
-	    $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
174
-
175
-	    return $config;
176
-    }
177
-
178
-    /**
179
-     * Calculate the user display name format
180
-     *
181
-     * @since 1.15
182
-     * @since 1.20 Returns false if user not found at $user_id
183
-     *
184
-     * @param int $user_id WP User ID
185
-     * @return false|string Display name format as used inside Gravity Forms User Registration. Returns false if user not found.
186
-     */
187
-    public function match_current_display_name( $user_id ) {
188
-
189
-        $user = get_userdata( $user_id );
190
-
191
-        if( ! $user ) {
192
-        	return false;
193
-        }
194
-
195
-        $names = $this->generate_display_names( $user );
196
-
197
-        $format = array_search( $user->display_name, $names, true );
198
-
199
-        /**
200
-         * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook
201
-         * @see restore_display_name
202
-         */
203
-        if( false === $format ) {
204
-            $this->_user_before_update = $user;
205
-        }
206
-
207
-        return $format;
208
-    }
209
-
210
-    /**
211
-     * Generate an array of all the user display names possibilities
212
-     *
213
-     * @since 1.15
214
-     *
215
-     * @param object $profileuser WP_User object
216
-     * @return array List all the possible display names for a certain User object
217
-     */
218
-    public function generate_display_names( $profileuser ) {
219
-
220
-        $public_display = array();
221
-        $public_display['nickname']  = $profileuser->nickname;
222
-        $public_display['username']  = $profileuser->user_login;
223
-
224
-        if ( !empty($profileuser->first_name) ) {
225
-	        $public_display['firstname'] = $profileuser->first_name;
226
-        }
227
-
228
-        if ( !empty($profileuser->last_name) ) {
229
-	        $public_display['lastname'] = $profileuser->last_name;
230
-        }
231
-
232
-        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
233
-            $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
234
-            $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
235
-        }
236
-
237
-        $public_display = array_map( 'trim', $public_display );
238
-        $public_display = array_unique( $public_display );
239
-
240
-        return $public_display;
241
-    }
242
-
243
-
244
-    /**
245
-     * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon
246
-     *
247
-     * @see GFUser::update_user()
248
-     * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon
249
-     * @param array $config Gravity Forms User Registration Addon form feed configuration
250
-     * @param array $entry The Gravity Forms entry that was just updated
251
-     * @param string $password User password
252
-     * @return int|false|WP_Error|null True: User updated; False: $user_id not a valid User ID; WP_Error: User update error; Null: Method didn't process
253
-     */
254
-    public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) {
255
-
256
-        /**
257
-         * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry.
258
-         * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed
259
-         * @since 1.14.4
260
-         * @param boolean $restore_display_name Restore Display Name? Default: true
261
-         */
262
-        $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
263
-
264
-        $is_update_feed = ( $config && \GV\Utils::get( $config, 'meta/feed_type' ) === 'update' );
265
-
266
-        /**
267
-         * Don't restore display name:
268
-         *   - either disabled,
269
-         *   - or it is an Update feed (we only care about Create feed)
270
-         *   - or we don't need as we found the correct format before updating user.
271
-         * @since 1.14.4
272
-         */
273
-        if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
274
-            return null;
275
-        }
276
-
277
-        $user_after_update = get_userdata( $user_id );
278
-
279
-        // User not found
280
-	    if ( ! $user_after_update ) {
281
-	    	gravityview()->log->error( 'User not found at $user_id #{user_id}', array( 'user_id' => $user_id ) );
282
-		    return false;
283
-	    }
284
-
285
-        $restored_user = $user_after_update;
286
-
287
-	    // Restore previous display_name
288
-        $restored_user->display_name = $this->_user_before_update->display_name;
289
-
290
-	    // Don't have WP update the password.
291
-	    unset( $restored_user->data->user_pass, $restored_user->user_pass );
292
-
293
-        /**
294
-         * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView
295
-         * @since 1.14
296
-         * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user()
297
-         * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration
298
-         * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration
299
-         * @param array   $entry The Gravity Forms entry that was just updated
300
-         */
301
-        $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry );
302
-
303
-        $updated = wp_update_user( $restored_user );
304
-
305
-        if( is_wp_error( $updated ) ) {
306
-            gravityview()->log->error( 'There was an error updating user #{user_id} details', array( 'user_id' => $user_id, 'data' => $updated ) );
307
-        } else {
308
-            gravityview()->log->debug( 'User #{user_id} details restored', array( 'user_id' => $user_id ) );
309
-        }
310
-
311
-        $this->_user_before_update = null;
312
-
313
-        unset( $restored_user, $user_after_update );
314
-
315
-        return $updated;
316
-    }
137
+	public function get_feed_configuration( $entry, $form ) {
138
+
139
+		/** @var GF_User_Registration $gf_user_registration */
140
+		$gf_user_registration = GF_User_Registration::get_instance();
141
+
142
+		$config = $gf_user_registration->get_single_submission_feed( $entry, $form );
143
+
144
+		/**
145
+		 * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
146
+		 * @since 1.15
147
+		 * @param[in,out] boolean $preserve_role Preserve current user role Default: true
148
+		 * @param[in] array $config Gravity Forms User Registration feed configuration for the form
149
+		 * @param[in] array $form Gravity Forms form array
150
+		 * @param[in] array $entry Gravity Forms entry being edited
151
+		 */
152
+		$preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
153
+
154
+		if( $preserve_role ) {
155
+			$config['meta']['role'] = 'gfur_preserve_role';
156
+		}
157
+
158
+		$displayname = $this->match_current_display_name( $entry['created_by'] );
159
+
160
+		/**
161
+		 * Make sure the current display name is not changed with the update user method.
162
+		 * @since 1.15
163
+		 */
164
+		$config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname'];
165
+
166
+		/**
167
+		 * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
168
+		 * @since 1.14
169
+		 * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
170
+		 * @param[in] array $form Gravity Forms form array
171
+		 * @param[in] array $entry Gravity Forms entry being edited
172
+		 */
173
+		$config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
174
+
175
+		return $config;
176
+	}
177
+
178
+	/**
179
+	 * Calculate the user display name format
180
+	 *
181
+	 * @since 1.15
182
+	 * @since 1.20 Returns false if user not found at $user_id
183
+	 *
184
+	 * @param int $user_id WP User ID
185
+	 * @return false|string Display name format as used inside Gravity Forms User Registration. Returns false if user not found.
186
+	 */
187
+	public function match_current_display_name( $user_id ) {
188
+
189
+		$user = get_userdata( $user_id );
190
+
191
+		if( ! $user ) {
192
+			return false;
193
+		}
194
+
195
+		$names = $this->generate_display_names( $user );
196
+
197
+		$format = array_search( $user->display_name, $names, true );
198
+
199
+		/**
200
+		 * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook
201
+		 * @see restore_display_name
202
+		 */
203
+		if( false === $format ) {
204
+			$this->_user_before_update = $user;
205
+		}
206
+
207
+		return $format;
208
+	}
209
+
210
+	/**
211
+	 * Generate an array of all the user display names possibilities
212
+	 *
213
+	 * @since 1.15
214
+	 *
215
+	 * @param object $profileuser WP_User object
216
+	 * @return array List all the possible display names for a certain User object
217
+	 */
218
+	public function generate_display_names( $profileuser ) {
219
+
220
+		$public_display = array();
221
+		$public_display['nickname']  = $profileuser->nickname;
222
+		$public_display['username']  = $profileuser->user_login;
223
+
224
+		if ( !empty($profileuser->first_name) ) {
225
+			$public_display['firstname'] = $profileuser->first_name;
226
+		}
227
+
228
+		if ( !empty($profileuser->last_name) ) {
229
+			$public_display['lastname'] = $profileuser->last_name;
230
+		}
231
+
232
+		if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
233
+			$public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
234
+			$public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
235
+		}
236
+
237
+		$public_display = array_map( 'trim', $public_display );
238
+		$public_display = array_unique( $public_display );
239
+
240
+		return $public_display;
241
+	}
242
+
243
+
244
+	/**
245
+	 * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon
246
+	 *
247
+	 * @see GFUser::update_user()
248
+	 * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon
249
+	 * @param array $config Gravity Forms User Registration Addon form feed configuration
250
+	 * @param array $entry The Gravity Forms entry that was just updated
251
+	 * @param string $password User password
252
+	 * @return int|false|WP_Error|null True: User updated; False: $user_id not a valid User ID; WP_Error: User update error; Null: Method didn't process
253
+	 */
254
+	public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) {
255
+
256
+		/**
257
+		 * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry.
258
+		 * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed
259
+		 * @since 1.14.4
260
+		 * @param boolean $restore_display_name Restore Display Name? Default: true
261
+		 */
262
+		$restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
263
+
264
+		$is_update_feed = ( $config && \GV\Utils::get( $config, 'meta/feed_type' ) === 'update' );
265
+
266
+		/**
267
+		 * Don't restore display name:
268
+		 *   - either disabled,
269
+		 *   - or it is an Update feed (we only care about Create feed)
270
+		 *   - or we don't need as we found the correct format before updating user.
271
+		 * @since 1.14.4
272
+		 */
273
+		if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
274
+			return null;
275
+		}
276
+
277
+		$user_after_update = get_userdata( $user_id );
278
+
279
+		// User not found
280
+		if ( ! $user_after_update ) {
281
+			gravityview()->log->error( 'User not found at $user_id #{user_id}', array( 'user_id' => $user_id ) );
282
+			return false;
283
+		}
284
+
285
+		$restored_user = $user_after_update;
286
+
287
+		// Restore previous display_name
288
+		$restored_user->display_name = $this->_user_before_update->display_name;
289
+
290
+		// Don't have WP update the password.
291
+		unset( $restored_user->data->user_pass, $restored_user->user_pass );
292
+
293
+		/**
294
+		 * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView
295
+		 * @since 1.14
296
+		 * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user()
297
+		 * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration
298
+		 * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration
299
+		 * @param array   $entry The Gravity Forms entry that was just updated
300
+		 */
301
+		$restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry );
302
+
303
+		$updated = wp_update_user( $restored_user );
304
+
305
+		if( is_wp_error( $updated ) ) {
306
+			gravityview()->log->error( 'There was an error updating user #{user_id} details', array( 'user_id' => $user_id, 'data' => $updated ) );
307
+		} else {
308
+			gravityview()->log->debug( 'User #{user_id} details restored', array( 'user_id' => $user_id ) );
309
+		}
310
+
311
+		$this->_user_before_update = null;
312
+
313
+		unset( $restored_user, $user_after_update );
314
+
315
+		return $updated;
316
+	}
317 317
 
318 318
 } //end class
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	     * @since 1.11
53 53
 	     * @param boolean $boolean Whether to trigger update on user registration (default: true)
54 54
 	     */
55
-	    if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
55
+	    if ( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
56 56
 
57
-	    	add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
57
+	    	add_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10, 2 );
58 58
 
59 59
 		    // last resort in case the current user display name don't match any of the defaults
60 60
 		    add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function update_user( $form = array(), $entry_id = 0 ) {
74 74
 
75
-        if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) {
75
+        if ( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) {
76 76
 	        gravityview()->log->error( 'GFAPI or User Registration class not found; not updating the user' );
77 77
 	        return;
78
-        } elseif( empty( $entry_id ) ) {
78
+        } elseif ( empty( $entry_id ) ) {
79 79
         	gravityview()->log->error( 'Entry ID is empty [{entry_id}]; not updating the user', array( 'entry_id' => $entry_id ) );
80 80
 	        return;
81 81
         }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
 	    // If an Update feed, make sure the conditions are met.
104 104
 	    if ( \GV\Utils::get( $config, 'meta/feedType' ) === 'update' ) {
105
-	    	if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
105
+	    	if ( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
106 106
 			    return;
107 107
 		    }
108 108
 	    }
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
         remove_filter( 'send_email_change_email', '__return_false', 3 );
119 119
 
120 120
         // Prevent double-triggering by removing the hook
121
-	    remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 );
121
+	    remove_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10 );
122 122
     }
123 123
 
124 124
 	/**
@@ -151,17 +151,17 @@  discard block
 block discarded – undo
151 151
 	     */
152 152
 	    $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
153 153
 
154
-	    if( $preserve_role ) {
155
-		    $config['meta']['role'] = 'gfur_preserve_role';
154
+	    if ( $preserve_role ) {
155
+		    $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role';
156 156
 	    }
157 157
 
158
-	    $displayname = $this->match_current_display_name( $entry['created_by'] );
158
+	    $displayname = $this->match_current_display_name( $entry[ 'created_by' ] );
159 159
 
160 160
 	    /**
161 161
 	     * Make sure the current display name is not changed with the update user method.
162 162
 	     * @since 1.15
163 163
 	     */
164
-	    $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname'];
164
+	    $config[ 'meta' ][ 'displayname' ] = $displayname ? $displayname : $config[ 'meta' ][ 'displayname' ];
165 165
 
166 166
 	    /**
167 167
 	     * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
         $user = get_userdata( $user_id );
190 190
 
191
-        if( ! $user ) {
191
+        if ( ! $user ) {
192 192
         	return false;
193 193
         }
194 194
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
          * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook
201 201
          * @see restore_display_name
202 202
          */
203
-        if( false === $format ) {
203
+        if ( false === $format ) {
204 204
             $this->_user_before_update = $user;
205 205
         }
206 206
 
@@ -218,20 +218,20 @@  discard block
 block discarded – undo
218 218
     public function generate_display_names( $profileuser ) {
219 219
 
220 220
         $public_display = array();
221
-        $public_display['nickname']  = $profileuser->nickname;
222
-        $public_display['username']  = $profileuser->user_login;
221
+        $public_display[ 'nickname' ]  = $profileuser->nickname;
222
+        $public_display[ 'username' ]  = $profileuser->user_login;
223 223
 
224
-        if ( !empty($profileuser->first_name) ) {
225
-	        $public_display['firstname'] = $profileuser->first_name;
224
+        if ( ! empty( $profileuser->first_name ) ) {
225
+	        $public_display[ 'firstname' ] = $profileuser->first_name;
226 226
         }
227 227
 
228
-        if ( !empty($profileuser->last_name) ) {
229
-	        $public_display['lastname'] = $profileuser->last_name;
228
+        if ( ! empty( $profileuser->last_name ) ) {
229
+	        $public_display[ 'lastname' ] = $profileuser->last_name;
230 230
         }
231 231
 
232
-        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
233
-            $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
234
-            $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
232
+        if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
233
+            $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name;
234
+            $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name;
235 235
         }
236 236
 
237 237
         $public_display = array_map( 'trim', $public_display );
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
          *   - or we don't need as we found the correct format before updating user.
271 271
          * @since 1.14.4
272 272
          */
273
-        if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
273
+        if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
274 274
             return null;
275 275
         }
276 276
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
         $updated = wp_update_user( $restored_user );
304 304
 
305
-        if( is_wp_error( $updated ) ) {
305
+        if ( is_wp_error( $updated ) ) {
306 306
             gravityview()->log->error( 'There was an error updating user #{user_id} details', array( 'user_id' => $user_id, 'data' => $updated ) );
307 307
         } else {
308 308
             gravityview()->log->debug( 'User #{user_id} details restored', array( 'user_id' => $user_id ) );
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,6 +65,9 @@  discard block
 block discarded – undo
65 65
     }
66 66
 
67 67
 
68
+    /**
69
+     * @param string $component
70
+     */
68 71
     private function load_components( $component ) {
69 72
 
70 73
         $dir = trailingslashit( self::$file );
@@ -141,7 +144,7 @@  discard block
 block discarded – undo
141 144
      * "You can edit this post from the post page" fields, for example.
142 145
      *
143 146
      * @param $entry array Gravity Forms entry object
144
-     * @param $view_id int GravityView view id
147
+     * @param integer $view_id int GravityView view id
145 148
      * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
146 149
      * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
147 150
      * @return string
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
         self::$file = plugin_dir_path( __FILE__ );
38 38
 
39
-        if( is_admin() ) {
39
+        if ( is_admin() ) {
40 40
             $this->load_components( 'admin' );
41 41
         }
42 42
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     static function getInstance() {
57 57
 
58
-        if( empty( self::$instance ) ) {
58
+        if ( empty( self::$instance ) ) {
59 59
             self::$instance = new GravityView_Edit_Entry;
60 60
         }
61 61
 
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
     private function add_hooks() {
82 82
 
83 83
         // Add front-end access to Gravity Forms delete file action
84
-        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') );
84
+        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file' ) );
85 85
 
86 86
         // Make sure this hook is run for non-admins
87
-        add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') );
87
+        add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file' ) );
88 88
 
89 89
         add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
90 90
 
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	private function addon_specific_hooks() {
103 103
 
104
-		if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) {
105
-			add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script'));
104
+		if ( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) {
105
+			add_filter( 'gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script' ) );
106 106
 		}
107 107
 
108 108
 	}
@@ -192,15 +192,15 @@  discard block
 block discarded – undo
192 192
      */
193 193
     public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
194 194
 
195
-        $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
195
+        $nonce_key = self::get_nonce_key( $view_id, $entry[ 'form_id' ], $entry[ 'id' ] );
196 196
 
197
-        $base = gv_entry_link( $entry, $post_id ? : $view_id  );
197
+        $base = gv_entry_link( $entry, $post_id ?: $view_id );
198 198
 
199 199
         $url = add_query_arg( array(
200 200
             'edit' => wp_create_nonce( $nonce_key )
201 201
         ), $base );
202 202
 
203
-        if( $post_id ) {
203
+        if ( $post_id ) {
204 204
 	        $url = add_query_arg( array( 'gvid' => $view_id ), $url );
205 205
         }
206 206
 
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 	     * Allow passing params to dynamically populate entry with values
209 209
 	     * @since 1.9.2
210 210
 	     */
211
-	    if( !empty( $field_values ) ) {
211
+	    if ( ! empty( $field_values ) ) {
212 212
 
213
-		    if( is_array( $field_values ) ) {
213
+		    if ( is_array( $field_values ) ) {
214 214
 			    // If already an array, no parse_str() needed
215 215
 			    $params = $field_values;
216 216
 		    } else {
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		 * @param array $entry The entry.
227 227
 		 * @param \GV\View $view The View.
228 228
 		 */
229
-		return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id  ) );
229
+		return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id ) );
230 230
     }
231 231
 
232 232
 	/**
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	public function modify_field_blacklist( $fields = array(), $context = NULL ) {
239 239
 
240
-		if( empty( $context ) || $context !== 'edit' ) {
240
+		if ( empty( $context ) || $context !== 'edit' ) {
241 241
 			return $fields;
242 242
 		}
243 243
 
@@ -315,15 +315,15 @@  discard block
 block discarded – undo
315 315
         // If they can edit any entries (as defined in Gravity Forms)
316 316
         // Or if they can edit other people's entries
317 317
         // Then we're good.
318
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
318
+        if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry[ 'id' ] ) ) {
319 319
 
320 320
             gravityview()->log->debug( 'User has ability to edit all entries.' );
321 321
 
322 322
             $user_can_edit = true;
323 323
 
324
-        } else if( !isset( $entry['created_by'] ) ) {
324
+        } else if ( ! isset( $entry[ 'created_by' ] ) ) {
325 325
 
326
-            gravityview()->log->error( 'Entry `created_by` doesn\'t exist.');
326
+            gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' );
327 327
 
328 328
             $user_can_edit = false;
329 329
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
             $current_user = wp_get_current_user();
334 334
 
335 335
             // User edit is disabled
336
-            if( empty( $user_edit ) ) {
336
+            if ( empty( $user_edit ) ) {
337 337
 
338 338
                 gravityview()->log->debug( 'User Edit is disabled. Returning false.' );
339 339
 
@@ -341,13 +341,13 @@  discard block
 block discarded – undo
341 341
             }
342 342
 
343 343
             // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
344
-            else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
344
+            else if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) {
345 345
 
346 346
                 gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) );
347 347
 
348 348
                 $user_can_edit = true;
349 349
 
350
-            } else if( ! is_user_logged_in() ) {
350
+            } else if ( ! is_user_logged_in() ) {
351 351
 
352 352
                 gravityview()->log->debug( 'No user defined; edit entry requires logged in user' );
353 353
             }
Please login to merge, or discard this patch.
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -18,83 +18,83 @@  discard block
 block discarded – undo
18 18
 
19 19
 class GravityView_Edit_Entry {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
21
+	/**
22
+	 * @var string
23
+	 */
24 24
 	static $file;
25 25
 
26 26
 	static $instance;
27 27
 
28
-    /**
29
-     * Component instances.
30
-     * @var array
31
-     */
32
-    public $instances = array();
28
+	/**
29
+	 * Component instances.
30
+	 * @var array
31
+	 */
32
+	public $instances = array();
33 33
 
34 34
 
35 35
 	function __construct() {
36 36
 
37
-        self::$file = plugin_dir_path( __FILE__ );
37
+		self::$file = plugin_dir_path( __FILE__ );
38 38
 
39
-        if( is_admin() ) {
40
-            $this->load_components( 'admin' );
41
-        }
39
+		if( is_admin() ) {
40
+			$this->load_components( 'admin' );
41
+		}
42 42
 
43 43
 		$this->load_components( 'locking' );
44 44
 
45
-        $this->load_components( 'render' );
45
+		$this->load_components( 'render' );
46 46
 
47
-        // If GF User Registration Add-on exists
48
-        $this->load_components( 'user-registration' );
47
+		// If GF User Registration Add-on exists
48
+		$this->load_components( 'user-registration' );
49 49
 
50
-        $this->add_hooks();
50
+		$this->add_hooks();
51 51
 
52 52
 		// Process hooks for addons that may or may not be present
53 53
 		$this->addon_specific_hooks();
54 54
 	}
55 55
 
56 56
 
57
-    static function getInstance() {
57
+	static function getInstance() {
58 58
 
59
-        if( empty( self::$instance ) ) {
60
-            self::$instance = new GravityView_Edit_Entry;
61
-        }
59
+		if( empty( self::$instance ) ) {
60
+			self::$instance = new GravityView_Edit_Entry;
61
+		}
62 62
 
63
-        return self::$instance;
64
-    }
63
+		return self::$instance;
64
+	}
65 65
 
66 66
 
67
-    private function load_components( $component ) {
67
+	private function load_components( $component ) {
68 68
 
69
-        $dir = trailingslashit( self::$file );
69
+		$dir = trailingslashit( self::$file );
70 70
 
71
-        $filename  = $dir . 'class-edit-entry-' . $component . '.php';
72
-        $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
71
+		$filename  = $dir . 'class-edit-entry-' . $component . '.php';
72
+		$classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
73 73
 
74
-        // Loads component and pass extension's instance so that component can
75
-        // talk each other.
76
-        require_once $filename;
77
-        $this->instances[ $component ] = new $classname( $this );
78
-        $this->instances[ $component ]->load();
74
+		// Loads component and pass extension's instance so that component can
75
+		// talk each other.
76
+		require_once $filename;
77
+		$this->instances[ $component ] = new $classname( $this );
78
+		$this->instances[ $component ]->load();
79 79
 
80
-    }
80
+	}
81 81
 
82
-    private function add_hooks() {
82
+	private function add_hooks() {
83 83
 
84
-        // Add front-end access to Gravity Forms delete file action
85
-        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') );
84
+		// Add front-end access to Gravity Forms delete file action
85
+		add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') );
86 86
 
87
-        // Make sure this hook is run for non-admins
88
-        add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') );
87
+		// Make sure this hook is run for non-admins
88
+		add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') );
89 89
 
90
-        add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
90
+		add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
91 91
 
92
-        // add template path to check for field
93
-        add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
92
+		// add template path to check for field
93
+		add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
94 94
 
95 95
 		add_filter( 'gravityview/field/is_visible', array( $this, 'maybe_not_visible' ), 10, 3 );
96 96
 
97
-    }
97
+	}
98 98
 
99 99
 	/**
100 100
 	 * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin
@@ -152,74 +152,74 @@  discard block
 block discarded – undo
152 152
 		return false;
153 153
 	}
154 154
 
155
-    /**
156
-     * Include this extension templates path
157
-     * @param array $file_paths List of template paths ordered
158
-     */
159
-    public function add_template_path( $file_paths ) {
160
-
161
-        // Index 100 is the default GravityView template path.
162
-        $file_paths[ 110 ] = self::$file;
163
-
164
-        return $file_paths;
165
-    }
166
-
167
-    /**
168
-     *
169
-     * Return a well formatted nonce key according to GravityView Edit Entry protocol
170
-     *
171
-     * @param $view_id int GravityView view id
172
-     * @param $form_id int Gravity Forms form id
173
-     * @param $entry_id int Gravity Forms entry id
174
-     * @return string
175
-     */
176
-    public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
177
-        return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
178
-    }
179
-
180
-
181
-    /**
182
-     * The edit entry link creates a secure link with a nonce
183
-     *
184
-     * It also mimics the URL structure Gravity Forms expects to have so that
185
-     * it formats the display of the edit form like it does in the backend, like
186
-     * "You can edit this post from the post page" fields, for example.
187
-     *
188
-     * @param $entry array Gravity Forms entry object
189
-     * @param $view_id int GravityView view id
190
-     * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
191
-     * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
192
-     * @return string
193
-     */
194
-    public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
195
-
196
-        $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
197
-
198
-        $base = gv_entry_link( $entry, $post_id ? : $view_id  );
199
-
200
-        $url = add_query_arg( array(
201
-            'edit' => wp_create_nonce( $nonce_key )
202
-        ), $base );
203
-
204
-        if( $post_id ) {
205
-	        $url = add_query_arg( array( 'gvid' => $view_id ), $url );
206
-        }
207
-
208
-	    /**
209
-	     * Allow passing params to dynamically populate entry with values
210
-	     * @since 1.9.2
211
-	     */
212
-	    if( !empty( $field_values ) ) {
213
-
214
-		    if( is_array( $field_values ) ) {
215
-			    // If already an array, no parse_str() needed
216
-			    $params = $field_values;
217
-		    } else {
218
-			    parse_str( $field_values, $params );
219
-		    }
220
-
221
-		    $url = add_query_arg( $params, $url );
222
-	    }
155
+	/**
156
+	 * Include this extension templates path
157
+	 * @param array $file_paths List of template paths ordered
158
+	 */
159
+	public function add_template_path( $file_paths ) {
160
+
161
+		// Index 100 is the default GravityView template path.
162
+		$file_paths[ 110 ] = self::$file;
163
+
164
+		return $file_paths;
165
+	}
166
+
167
+	/**
168
+	 *
169
+	 * Return a well formatted nonce key according to GravityView Edit Entry protocol
170
+	 *
171
+	 * @param $view_id int GravityView view id
172
+	 * @param $form_id int Gravity Forms form id
173
+	 * @param $entry_id int Gravity Forms entry id
174
+	 * @return string
175
+	 */
176
+	public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
177
+		return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
178
+	}
179
+
180
+
181
+	/**
182
+	 * The edit entry link creates a secure link with a nonce
183
+	 *
184
+	 * It also mimics the URL structure Gravity Forms expects to have so that
185
+	 * it formats the display of the edit form like it does in the backend, like
186
+	 * "You can edit this post from the post page" fields, for example.
187
+	 *
188
+	 * @param $entry array Gravity Forms entry object
189
+	 * @param $view_id int GravityView view id
190
+	 * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
191
+	 * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
192
+	 * @return string
193
+	 */
194
+	public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
195
+
196
+		$nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
197
+
198
+		$base = gv_entry_link( $entry, $post_id ? : $view_id  );
199
+
200
+		$url = add_query_arg( array(
201
+			'edit' => wp_create_nonce( $nonce_key )
202
+		), $base );
203
+
204
+		if( $post_id ) {
205
+			$url = add_query_arg( array( 'gvid' => $view_id ), $url );
206
+		}
207
+
208
+		/**
209
+		 * Allow passing params to dynamically populate entry with values
210
+		 * @since 1.9.2
211
+		 */
212
+		if( !empty( $field_values ) ) {
213
+
214
+			if( is_array( $field_values ) ) {
215
+				// If already an array, no parse_str() needed
216
+				$params = $field_values;
217
+			} else {
218
+				parse_str( $field_values, $params );
219
+			}
220
+
221
+			$url = add_query_arg( $params, $url );
222
+		}
223 223
 
224 224
 		/**
225 225
 		 * @filter `gravityview/edit/link` Filter the edit URL link.
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 		 * @param \GV\View $view The View.
229 229
 		 */
230 230
 		return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id  ) );
231
-    }
231
+	}
232 232
 
233 233
 	/**
234 234
 	 * Edit mode doesn't allow certain field types.
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
 	}
284 284
 
285 285
 
286
-    /**
287
-     * checks if user has permissions to edit a specific entry
288
-     *
289
-     * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
290
-     *
291
-     * @param  array $entry Gravity Forms entry array
292
-     * @param \GV\View int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0
293
-     * @return bool
294
-     */
295
-    public static function check_user_cap_edit_entry( $entry, $view = 0 ) {
286
+	/**
287
+	 * checks if user has permissions to edit a specific entry
288
+	 *
289
+	 * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
290
+	 *
291
+	 * @param  array $entry Gravity Forms entry array
292
+	 * @param \GV\View int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0
293
+	 * @return bool
294
+	 */
295
+	public static function check_user_cap_edit_entry( $entry, $view = 0 ) {
296 296
 
297
-        // No permission by default
298
-        $user_can_edit = false;
297
+		// No permission by default
298
+		$user_can_edit = false;
299 299
 
300 300
 		// get user_edit setting
301 301
 		if ( empty( $view ) ) {
@@ -313,59 +313,59 @@  discard block
 block discarded – undo
313 313
 			$user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
314 314
 		}
315 315
 
316
-        // If they can edit any entries (as defined in Gravity Forms)
317
-        // Or if they can edit other people's entries
318
-        // Then we're good.
319
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
316
+		// If they can edit any entries (as defined in Gravity Forms)
317
+		// Or if they can edit other people's entries
318
+		// Then we're good.
319
+		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
320 320
 
321
-            gravityview()->log->debug( 'User has ability to edit all entries.' );
321
+			gravityview()->log->debug( 'User has ability to edit all entries.' );
322 322
 
323
-            $user_can_edit = true;
323
+			$user_can_edit = true;
324 324
 
325
-        } else if( !isset( $entry['created_by'] ) ) {
325
+		} else if( !isset( $entry['created_by'] ) ) {
326 326
 
327
-            gravityview()->log->error( 'Entry `created_by` doesn\'t exist.');
327
+			gravityview()->log->error( 'Entry `created_by` doesn\'t exist.');
328 328
 
329
-            $user_can_edit = false;
329
+			$user_can_edit = false;
330 330
 
331
-        } else {
331
+		} else {
332 332
 
333 333
 
334
-            $current_user = wp_get_current_user();
334
+			$current_user = wp_get_current_user();
335 335
 
336
-            // User edit is disabled
337
-            if( empty( $user_edit ) ) {
336
+			// User edit is disabled
337
+			if( empty( $user_edit ) ) {
338 338
 
339
-                gravityview()->log->debug( 'User Edit is disabled. Returning false.' );
339
+				gravityview()->log->debug( 'User Edit is disabled. Returning false.' );
340 340
 
341
-                $user_can_edit = false;
342
-            }
341
+				$user_can_edit = false;
342
+			}
343 343
 
344
-            // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
345
-            else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
344
+			// User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
345
+			else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
346 346
 
347
-                gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) );
347
+				gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) );
348 348
 
349
-                $user_can_edit = true;
349
+				$user_can_edit = true;
350 350
 
351
-            } else if( ! is_user_logged_in() ) {
351
+			} else if( ! is_user_logged_in() ) {
352 352
 
353
-                gravityview()->log->debug( 'No user defined; edit entry requires logged in user' );
354
-            }
353
+				gravityview()->log->debug( 'No user defined; edit entry requires logged in user' );
354
+			}
355 355
 
356
-        }
356
+		}
357 357
 
358
-        /**
359
-         * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
360
-         * @since 1.15 Added `$entry` and `$view_id` parameters
361
-         * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
362
-         * @param[in] array $entry Gravity Forms entry array {@since 1.15}
363
-         * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
364
-         */
365
-        $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
358
+		/**
359
+		 * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
360
+		 * @since 1.15 Added `$entry` and `$view_id` parameters
361
+		 * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
362
+		 * @param[in] array $entry Gravity Forms entry array {@since 1.15}
363
+		 * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
364
+		 */
365
+		$user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
366 366
 
367
-        return (bool)$user_can_edit;
368
-    }
367
+		return (bool)$user_can_edit;
368
+	}
369 369
 
370 370
 
371 371
 
Please login to merge, or discard this patch.