Completed
Pull Request — master (#963)
by Zack
07: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
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
 		// template areas
138 138
 		$template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' );
139
-        $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' );
139
+		$template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' );
140 140
 
141 141
 		// widget areas
142 142
 		$default_widget_areas = GravityView_Plugin::get_default_widget_areas();
@@ -328,40 +328,40 @@  discard block
 block discarded – undo
328 328
 		// load file
329 329
 		$xmlstr = file_get_contents( $form_file );
330 330
 
331
-        $options = array(
332
-            "page" => array("unserialize_as_array" => true),
333
-            "form"=> array("unserialize_as_array" => true),
334
-            "field"=> array("unserialize_as_array" => true),
335
-            "rule"=> array("unserialize_as_array" => true),
336
-            "choice"=> array("unserialize_as_array" => true),
337
-            "input"=> array("unserialize_as_array" => true),
338
-            "routing_item"=> array("unserialize_as_array" => true),
339
-            "creditCard"=> array("unserialize_as_array" => true),
340
-            "routin"=> array("unserialize_as_array" => true),
341
-            "confirmation" => array("unserialize_as_array" => true),
342
-            "notification" => array("unserialize_as_array" => true)
343
-        );
331
+		$options = array(
332
+			"page" => array("unserialize_as_array" => true),
333
+			"form"=> array("unserialize_as_array" => true),
334
+			"field"=> array("unserialize_as_array" => true),
335
+			"rule"=> array("unserialize_as_array" => true),
336
+			"choice"=> array("unserialize_as_array" => true),
337
+			"input"=> array("unserialize_as_array" => true),
338
+			"routing_item"=> array("unserialize_as_array" => true),
339
+			"creditCard"=> array("unserialize_as_array" => true),
340
+			"routin"=> array("unserialize_as_array" => true),
341
+			"confirmation" => array("unserialize_as_array" => true),
342
+			"notification" => array("unserialize_as_array" => true)
343
+		);
344 344
 
345 345
 		$xml = new RGXML($options);
346
-        $forms = $xml->unserialize($xmlstr);
346
+		$forms = $xml->unserialize($xmlstr);
347 347
 
348
-        if( !$forms ) {
349
-        	do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file );
350
-        	return false;
351
-        }
348
+		if( !$forms ) {
349
+			do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file );
350
+			return false;
351
+		}
352 352
 
353
-        if( !empty( $forms[0] ) && is_array( $forms[0] ) ) {
354
-        	$form = $forms[0];
355
-        }
353
+		if( !empty( $forms[0] ) && is_array( $forms[0] ) ) {
354
+			$form = $forms[0];
355
+		}
356 356
 
357
-        if( empty( $form ) ) {
358
-        	do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms );
359
-        	return false;
360
-        }
357
+		if( empty( $form ) ) {
358
+			do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms );
359
+			return false;
360
+		}
361 361
 
362
-        do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form );
362
+		do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form );
363 363
 
364
-        return $form;
364
+		return $form;
365 365
 
366 366
 	}
367 367
 
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 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
 	}
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 		//check nonce
68 68
 		$this->check_ajax_nonce();
69 69
 
70
-		$context = isset($_POST['context']) ? esc_attr( $_POST['context'] ) : 'directory';
70
+		$context = isset( $_POST[ 'context' ] ) ? esc_attr( $_POST[ 'context' ] ) : 'directory';
71 71
 
72 72
 		// If Form was changed, JS sends form ID, if start fresh, JS sends template_id
73
-		if( !empty( $_POST['form_id'] ) ) {
74
-			do_action( 'gravityview_render_available_fields', (int) $_POST['form_id'], $context );
73
+		if ( ! empty( $_POST[ 'form_id' ] ) ) {
74
+			do_action( 'gravityview_render_available_fields', (int)$_POST[ 'form_id' ], $context );
75 75
 			$this->_exit();
76
-		} elseif( !empty( $_POST['template_id'] ) ) {
77
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
76
+		} elseif ( ! empty( $_POST[ 'template_id' ] ) ) {
77
+			$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
78 78
 
79 79
 			/** @see GravityView_Admin_Views::render_available_fields */
80 80
 			do_action( 'gravityview_render_available_fields', $form, $context );
@@ -96,17 +96,17 @@  discard block
 block discarded – undo
96 96
 	function get_active_areas() {
97 97
 		$this->check_ajax_nonce();
98 98
 
99
-		if( empty( $_POST['template_id'] ) ) {
99
+		if ( empty( $_POST[ 'template_id' ] ) ) {
100 100
 			$this->_exit( false );
101 101
 		}
102 102
 
103 103
 		ob_start();
104
-		do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true );
105
-		$response['directory'] = ob_get_clean();
104
+		do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'directory', '', true );
105
+		$response[ 'directory' ] = ob_get_clean();
106 106
 
107 107
 		ob_start();
108
-		do_action( 'gravityview_render_directory_active_areas',  $_POST['template_id'], 'single', '', true );
109
-		$response['single'] = ob_get_clean();
108
+		do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'single', '', true );
109
+		$response[ 'single' ] = ob_get_clean();
110 110
 
111 111
 		$response = array_map( 'gravityview_strip_whitespace', $response );
112 112
 
@@ -121,20 +121,20 @@  discard block
 block discarded – undo
121 121
 
122 122
 		$this->check_ajax_nonce();
123 123
 
124
-		if( empty( $_POST['template_id'] ) ) {
124
+		if ( empty( $_POST[ 'template_id' ] ) ) {
125 125
 			$this->_exit( false );
126 126
 		}
127 127
 
128 128
 		// get the fields xml config file for this specific preset
129
-		$preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] );
129
+		$preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST[ 'template_id' ] );
130 130
 		// import fields
131
-		if( !empty( $preset_fields_path ) ) {
131
+		if ( ! empty( $preset_fields_path ) ) {
132 132
 			$presets = $this->import_fields( $preset_fields_path );
133 133
 		} else {
134 134
 			$presets = array( 'widgets' => array(), 'fields' => array() );
135 135
 		}
136 136
 
137
-		$template_id = esc_attr( $_POST['template_id'] );
137
+		$template_id = esc_attr( $_POST[ 'template_id' ] );
138 138
 
139 139
 		// template areas
140 140
 		$template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' );
@@ -144,20 +144,20 @@  discard block
 block discarded – undo
144 144
 		$default_widget_areas = GravityView_Plugin::get_default_widget_areas();
145 145
 
146 146
 		ob_start();
147
-		do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] );
148
-		$response['header'] = ob_get_clean();
147
+		do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets[ 'widgets' ] );
148
+		$response[ 'header' ] = ob_get_clean();
149 149
 
150 150
 		ob_start();
151
-		do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] );
152
-		$response['footer'] = ob_get_clean();
151
+		do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets[ 'widgets' ] );
152
+		$response[ 'footer' ] = ob_get_clean();
153 153
 
154 154
 		ob_start();
155
-		do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] );
156
-		$response['directory'] = ob_get_clean();
155
+		do_action( 'gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets[ 'fields' ] );
156
+		$response[ 'directory' ] = ob_get_clean();
157 157
 
158 158
 		ob_start();
159
-		do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] );
160
-		$response['single'] = ob_get_clean();
159
+		do_action( 'gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets[ 'fields' ] );
160
+		$response[ 'single' ] = ob_get_clean();
161 161
 
162 162
 		$response = array_map( 'gravityview_strip_whitespace', $response );
163 163
 
@@ -175,26 +175,26 @@  discard block
 block discarded – undo
175 175
 
176 176
 		$this->check_ajax_nonce();
177 177
 
178
-		if( empty( $_POST['template_id'] ) ) {
178
+		if ( empty( $_POST[ 'template_id' ] ) ) {
179 179
 			do_action( 'gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.' );
180 180
 			$this->_exit( false );
181 181
 		}
182 182
 
183 183
 		// get the xml for this specific template_id
184
-		$preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] );
184
+		$preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST[ 'template_id' ] );
185 185
 
186 186
 		// import form
187 187
 		$form = $this->import_form( $preset_form_xml_path );
188 188
 
189 189
 		// get the form ID
190
-		if( false === $form ) {
190
+		if ( false === $form ) {
191 191
 			// send error to user
192
-			do_action( 'gravityview_log_error', '[create_preset_form] Error importing form for template id: ' . (int) $_POST['template_id'] );
192
+			do_action( 'gravityview_log_error', '[create_preset_form] Error importing form for template id: ' . (int)$_POST[ 'template_id' ] );
193 193
 
194 194
 			$this->_exit( false );
195 195
 		}
196 196
 
197
-		$this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' );
197
+		$this->_exit( '<option value="' . esc_attr( $form[ 'id' ] ) . '" selected="selected">' . esc_html( $form[ 'title' ] ) . '</option>' );
198 198
 
199 199
 	}
200 200
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 
209 209
 		do_action( 'gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path );
210 210
 
211
-		if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) {
211
+		if ( empty( $xml_or_json_path ) || ! class_exists( 'GFExport' ) || ! file_exists( $xml_or_json_path ) ) {
212 212
 			do_action( 'gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path );
213 213
 			return false;
214 214
 		}
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 		do_action( 'gravityview_log_debug', '[import_form] Importing form (Result)', $count );
221 221
 		do_action( 'gravityview_log_debug', '[import_form] Importing form (Form) ', $forms );
222 222
 
223
-		if( $count != 1 || empty( $forms[0]['id'] ) ) {
223
+		if ( $count != 1 || empty( $forms[ 0 ][ 'id' ] ) ) {
224 224
 			do_action( 'gravityview_log_error', '[import_form] Form Import Failed!' );
225 225
 			return false;
226 226
 		}
227 227
 
228 228
 		// import success - return form id
229
-		return $forms[0];
229
+		return $forms[ 0 ];
230 230
 	}
231 231
 
232 232
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	function get_field_options() {
241 241
 		$this->check_ajax_nonce();
242 242
 
243
-		if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) {
243
+		if ( empty( $_POST[ 'template' ] ) || empty( $_POST[ 'area' ] ) || empty( $_POST[ 'field_id' ] ) || empty( $_POST[ 'field_type' ] ) ) {
244 244
 			do_action( 'gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. ' );
245 245
 			$this->_exit( false );
246 246
 		}
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
 		$_post = array_map( 'esc_attr', $_post );
253 253
 
254 254
 		// The GF type of field: `product`, `name`, `creditcard`, `id`, `text`
255
-		$input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL;
256
-		$context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL;
255
+		$input_type = isset( $_post[ 'input_type' ] ) ? esc_attr( $_post[ 'input_type' ] ) : NULL;
256
+		$context = isset( $_post[ 'context' ] ) ? esc_attr( $_post[ 'context' ] ) : NULL;
257 257
 
258
-		$response = GravityView_Render_Settings::render_field_options( $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context  );
258
+		$response = GravityView_Render_Settings::render_field_options( $_post[ 'field_type' ], $_post[ 'template' ], $_post[ 'field_id' ], $_post[ 'field_label' ], $_post[ 'area' ], $input_type, '', '', $context );
259 259
 
260 260
 		$response = gravityview_strip_whitespace( $response );
261 261
 
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
 		$form = '';
277 277
 
278 278
 		// if form id is set, use it, else, get form from preset
279
-		if( !empty( $_POST['form_id'] ) ) {
279
+		if ( ! empty( $_POST[ 'form_id' ] ) ) {
280 280
 
281
-			$form = (int) $_POST['form_id'];
281
+			$form = (int)$_POST[ 'form_id' ];
282 282
 
283 283
 		}
284 284
 		// get form from preset
285
-		elseif( !empty( $_POST['template_id'] ) ) {
285
+		elseif ( ! empty( $_POST[ 'template_id' ] ) ) {
286 286
 
287
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
287
+			$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
288 288
 
289 289
 		}
290 290
 
@@ -300,27 +300,27 @@  discard block
 block discarded – undo
300 300
 	 * @param  string $template_id Preset template
301 301
 	 *
302 302
 	 */
303
-	static function pre_get_form_fields( $template_id = '') {
303
+	static function pre_get_form_fields( $template_id = '' ) {
304 304
 
305
-		if( empty( $template_id ) ) {
305
+		if ( empty( $template_id ) ) {
306 306
 			do_action( 'gravityview_log_error', __METHOD__ . ' - Template ID not set.' );
307 307
 			return false;
308 308
 		} else {
309 309
 			$form_file = apply_filters( 'gravityview_template_formxml', '', $template_id );
310
-			if( !file_exists( $form_file )  ) {
311
-				do_action( 'gravityview_log_error', __METHOD__ . ' - Importing Form Fields for preset ['. $template_id .']. File not found. file: ' . $form_file );
310
+			if ( ! file_exists( $form_file ) ) {
311
+				do_action( 'gravityview_log_error', __METHOD__ . ' - Importing Form Fields for preset [' . $template_id . ']. File not found. file: ' . $form_file );
312 312
 				return false;
313 313
 			}
314 314
 		}
315 315
 
316 316
 		// Load xml parser (from GravityForms)
317
-		if( class_exists( 'GFCommon' ) ) {
317
+		if ( class_exists( 'GFCommon' ) ) {
318 318
 			$xml_parser = GFCommon::get_base_path() . '/xml.php';
319 319
 		} else {
320 320
 			$xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php';
321 321
 		}
322 322
 
323
-		if( file_exists( $xml_parser ) ) {
323
+		if ( file_exists( $xml_parser ) ) {
324 324
 			require_once( $xml_parser );
325 325
 		} else {
326 326
 			do_action( 'gravityview_log_debug', __METHOD__ . ' - Gravity Forms XML Parser not found.', $xml_parser );
@@ -331,37 +331,37 @@  discard block
 block discarded – undo
331 331
 		$xmlstr = file_get_contents( $form_file );
332 332
 
333 333
         $options = array(
334
-            "page" => array("unserialize_as_array" => true),
335
-            "form"=> array("unserialize_as_array" => true),
336
-            "field"=> array("unserialize_as_array" => true),
337
-            "rule"=> array("unserialize_as_array" => true),
338
-            "choice"=> array("unserialize_as_array" => true),
339
-            "input"=> array("unserialize_as_array" => true),
340
-            "routing_item"=> array("unserialize_as_array" => true),
341
-            "creditCard"=> array("unserialize_as_array" => true),
342
-            "routin"=> array("unserialize_as_array" => true),
343
-            "confirmation" => array("unserialize_as_array" => true),
344
-            "notification" => array("unserialize_as_array" => true)
334
+            "page" => array( "unserialize_as_array" => true ),
335
+            "form"=> array( "unserialize_as_array" => true ),
336
+            "field"=> array( "unserialize_as_array" => true ),
337
+            "rule"=> array( "unserialize_as_array" => true ),
338
+            "choice"=> array( "unserialize_as_array" => true ),
339
+            "input"=> array( "unserialize_as_array" => true ),
340
+            "routing_item"=> array( "unserialize_as_array" => true ),
341
+            "creditCard"=> array( "unserialize_as_array" => true ),
342
+            "routin"=> array( "unserialize_as_array" => true ),
343
+            "confirmation" => array( "unserialize_as_array" => true ),
344
+            "notification" => array( "unserialize_as_array" => true )
345 345
         );
346 346
 
347
-		$xml = new RGXML($options);
348
-        $forms = $xml->unserialize($xmlstr);
347
+		$xml = new RGXML( $options );
348
+        $forms = $xml->unserialize( $xmlstr );
349 349
 
350
-        if( !$forms ) {
351
-        	do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file );
350
+        if ( ! $forms ) {
351
+        	do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset [' . $template_id . ']. Error importing file. (File)', $form_file );
352 352
         	return false;
353 353
         }
354 354
 
355
-        if( !empty( $forms[0] ) && is_array( $forms[0] ) ) {
356
-        	$form = $forms[0];
355
+        if ( ! empty( $forms[ 0 ] ) && is_array( $forms[ 0 ] ) ) {
356
+        	$form = $forms[ 0 ];
357 357
         }
358 358
 
359
-        if( empty( $form ) ) {
359
+        if ( empty( $form ) ) {
360 360
         	do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms );
361 361
         	return false;
362 362
         }
363 363
 
364
-        do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form );
364
+        do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset [' . $template_id . ']. (Form)', $form );
365 365
 
366 366
         return $form;
367 367
 
@@ -375,38 +375,38 @@  discard block
 block discarded – undo
375 375
 	 */
376 376
 	function import_fields( $file ) {
377 377
 
378
-		if( empty( $file ) || !file_exists(  $file ) ) {
378
+		if ( empty( $file ) || ! file_exists( $file ) ) {
379 379
 			do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file );
380 380
 			return false;
381 381
 		}
382 382
 
383
-		if( !class_exists('WXR_Parser') ) {
383
+		if ( ! class_exists( 'WXR_Parser' ) ) {
384 384
 			include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php';
385 385
 		}
386 386
 
387 387
 		$parser = new WXR_Parser();
388 388
 		$presets = $parser->parse( $file );
389 389
 
390
-		if(is_wp_error( $presets )) {
390
+		if ( is_wp_error( $presets ) ) {
391 391
 			do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets );
392 392
 			return false;
393 393
 		}
394 394
 
395
-		if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) {
395
+		if ( empty( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) && ! is_array( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) ) {
396 396
 			do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file );
397 397
 			return false;
398 398
 		}
399 399
 
400
-		do_action( 'gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta'] );
400
+		do_action( 'gravityview_log_debug', '[import_fields] postmeta', $presets[ 'posts' ][ 0 ][ 'postmeta' ] );
401 401
 
402 402
 		$fields = $widgets = array();
403
-		foreach( $presets['posts'][0]['postmeta'] as $meta ) {
404
-			switch ($meta['key']) {
403
+		foreach ( $presets[ 'posts' ][ 0 ][ 'postmeta' ] as $meta ) {
404
+			switch ( $meta[ 'key' ] ) {
405 405
 				case '_gravityview_directory_fields':
406
-					$fields = maybe_unserialize( $meta['value'] );
406
+					$fields = maybe_unserialize( $meta[ 'value' ] );
407 407
 					break;
408 408
 				case '_gravityview_directory_widgets':
409
-					$widgets = maybe_unserialize( $meta['value'] );
409
+					$widgets = maybe_unserialize( $meta[ 'value' ] );
410 410
 					break;
411 411
 			}
412 412
 		}
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
 		}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		 * @param string|null If string, the status to set for the new View. If empty, use existing View status.
120 120
 		 * @param WP_Post $post View being cloned
121 121
 		 */
122
-		$new_view_status = apply_filters('gravityview/duplicate-view/status', $status, $post );
122
+		$new_view_status = apply_filters( 'gravityview/duplicate-view/status', $status, $post );
123 123
 
124 124
 		$new_view = array(
125 125
 			'menu_order'     => $post->menu_order,
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 		 * @param boolean $copy_date Whether the copy the date from the existing View. Default: `false`
143 143
 		 * @param WP_Post $post View being cloned
144 144
 		 */
145
-		$copy_date = apply_filters('gravityview/duplicate-view/copy-date', false, $post );
145
+		$copy_date = apply_filters( 'gravityview/duplicate-view/copy-date', false, $post );
146 146
 
147 147
 		if ( $copy_date ) {
148
-			$new_view['post_date']     = $new_post_date = $post->post_date;
149
-			$new_view['post_date_gmt'] = get_gmt_from_date( $new_post_date );
148
+			$new_view[ 'post_date' ]     = $new_post_date = $post->post_date;
149
+			$new_view[ 'post_date_gmt' ] = get_gmt_from_date( $new_post_date );
150 150
 		}
151 151
 
152 152
 		/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		 * @param array $new_view Array of settings to be passed to wp_insert_post()
156 156
 		 * @param WP_Post $post View being cloned
157 157
 		 */
158
-		$new_view = apply_filters('gravityview/duplicate-view/new-view', $new_view, $post );
158
+		$new_view = apply_filters( 'gravityview/duplicate-view/new-view', $new_view, $post );
159 159
 
160 160
 		// Magic happens here.
161 161
 		$new_view_id = wp_insert_post( $new_view );
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
 			$clone_text = __( 'Clone', 'gravityview' );
238 238
 			$clone_title = __( 'Clone this View', 'gravityview' );
239 239
 
240
-			$actions['clone'] = gravityview_get_link( $clone_link, $clone_text, 'title='.$clone_title );
240
+			$actions[ 'clone' ] = gravityview_get_link( $clone_link, $clone_text, 'title=' . $clone_title );
241 241
 
242 242
 			$clone_draft_link = $this->get_clone_view_link( $post->ID );
243 243
 			$clone_draft_text = $this->is_all_views_page() ? __( 'New Draft', 'gravityview' ) : __( 'Clone View', 'gravityview' );
244 244
 			$clone_draft_title = __( 'Copy as a new draft View', 'gravityview' );
245 245
 
246
-			$actions['edit_as_new_draft'] = gravityview_get_link( $clone_draft_link, esc_html( $clone_draft_text ), 'title='.$clone_draft_title );
246
+			$actions[ 'edit_as_new_draft' ] = gravityview_get_link( $clone_draft_link, esc_html( $clone_draft_text ), 'title=' . $clone_draft_title );
247 247
 		}
248 248
 
249 249
 		return $actions;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 		}
268 268
 
269 269
 		// Verify the View exists
270
-		if ( !$view = get_post( $id ) ) {
270
+		if ( ! $view = get_post( $id ) ) {
271 271
 			return '';
272 272
 		}
273 273
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		$post_type_object = get_post_type_object( $view->post_type );
283 283
 
284 284
 		/** If there's no gravityview post type for some reason, abort! */
285
-		if ( !$post_type_object ) {
285
+		if ( ! $post_type_object ) {
286 286
 			do_action( 'gravityview_log_error', __METHOD__ . ' No gravityview post type exists when trying to clone the View.', $view );
287 287
 			return '';
288 288
 		}
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		 * @param int $view_id View ID
295 295
 		 * @param string $context How to display the link. If "display", the URL is run through esc_html(). Default: `display`
296 296
 		 */
297
-		$clone_view_link = apply_filters( 'gravityview/duplicate-view/get_clone_view_link', admin_url( "admin.php". $action ), $view->ID, $context );
297
+		$clone_view_link = apply_filters( 'gravityview/duplicate-view/get_clone_view_link', admin_url( "admin.php" . $action ), $view->ID, $context );
298 298
 
299 299
 		return $clone_view_link;
300 300
 	}
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
 	 */
322 322
 	public function save_as_new_view( $status = '' ) {
323 323
 
324
-		if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) ) ) {
324
+		if ( ! ( isset( $_GET[ 'post' ] ) || isset( $_POST[ 'post' ] ) ) ) {
325 325
 			wp_die( __( 'No post to duplicate has been supplied!', 'gravityview' ) );
326 326
 		}
327 327
 
328 328
 		// Get the original post
329
-		$id   = ( isset( $_GET['post'] ) ? $_GET['post'] : $_POST['post'] );
329
+		$id = ( isset( $_GET[ 'post' ] ) ? $_GET[ 'post' ] : $_POST[ 'post' ] );
330 330
 
331
-		if( ! $this->current_user_can_copy( $id ) ) {
331
+		if ( ! $this->current_user_can_copy( $id ) ) {
332 332
 			wp_die( __( 'You don\'t have permission to copy this View.', 'gravityview' ) );
333 333
 		}
334 334
 
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   +37 added lines, -37 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;
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 		// If Gravity Forms doesn't exist or is outdated, load the admin view class to
155 155
 		// show the notice, but not load any post types or process shortcodes.
156 156
 		// Without Gravity Forms, there is no GravityView. Beautiful, really.
157
-		if( ! self::is_valid() ) {
157
+		if ( ! self::is_valid() ) {
158 158
 
159 159
 			// If the plugin's not loaded, might as well hide the shortcode for people.
160
-			add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice') );
160
+			add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice' ) );
161 161
 
162 162
 		}
163 163
 	}
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	public function _shortcode_gf_notice( $atts = array(), $content = null, $shortcode = 'gravityview' ) {
185 185
 
186
-		if( ! GVCommon::has_cap( 'activate_plugins' ) ) {
186
+		if ( ! GVCommon::has_cap( 'activate_plugins' ) ) {
187 187
 			return null;
188 188
 		}
189 189
 
190 190
 		$notices = self::get_notices();
191 191
 
192
-		$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>';
193
-		foreach( (array)$notices as $notice ) {
194
-			$message .= wpautop( $notice['message'] );
192
+		$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>';
193
+		foreach ( (array)$notices as $notice ) {
194
+			$message .= wpautop( $notice[ 'message' ] );
195 195
 		}
196 196
 		$message .= '</div>';
197 197
 
@@ -211,12 +211,12 @@  discard block
 block discarded – undo
211 211
 
212 212
 		if (
213 213
 			( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && ! gravityview()->plugin->is_compatible_php() )
214
-			|| ( false === version_compare( phpversion(), GV_MIN_PHP_VERSION , '>=' ) )
214
+			|| ( false === version_compare( phpversion(), GV_MIN_PHP_VERSION, '>=' ) )
215 215
 		) {
216 216
 
217
-			self::$notices['php_version'] = array(
217
+			self::$notices[ 'php_version' ] = array(
218 218
 				'class' => 'error',
219
-				'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>' ),
219
+				'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>' ),
220 220
 				'cap' => 'manage_options',
221 221
 				'dismiss' => 'php_version',
222 222
 			);
@@ -224,14 +224,14 @@  discard block
 block discarded – undo
224 224
 			return false;
225 225
 		}
226 226
 
227
-		if( false === version_compare( phpversion(), GV_FUTURE_MIN_PHP_VERSION , '>=' ) ) {
227
+		if ( false === version_compare( phpversion(), GV_FUTURE_MIN_PHP_VERSION, '>=' ) ) {
228 228
 
229 229
 			// Show the notice on every update. Yes, annoying, but not as annoying as a plugin breaking.
230
-			$key = sprintf('php_%s_%s', GV_FUTURE_MIN_PHP_VERSION, GravityView_Plugin::version );
230
+			$key = sprintf( 'php_%s_%s', GV_FUTURE_MIN_PHP_VERSION, GravityView_Plugin::version );
231 231
 
232 232
 			self::$notices[ $key ] = array(
233 233
 				'class' => 'error',
234
-				'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>' ),
234
+				'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>' ),
235 235
 				'cap' => 'manage_options',
236 236
 				'dismiss' => $key,
237 237
 			);
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
 			|| ( false === version_compare( $wp_version, GV_MIN_WP_VERSION, '>=' ) )
256 256
 		) {
257 257
 
258
-			self::$notices['wp_version'] = array(
258
+			self::$notices[ 'wp_version' ] = array(
259 259
 				'class' => 'error',
260
-				'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>' ),
260
+				'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>' ),
261 261
 			    'cap' => 'update_core',
262 262
 				'dismiss' => 'wp_version',
263 263
 			);
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 	public static function check_gravityforms() {
281 281
 
282 282
 		// Bypass other checks: if the class exists
283
-		if( class_exists( 'GFCommon' ) ) {
283
+		if ( class_exists( 'GFCommon' ) ) {
284 284
 
285 285
 			// Does the version meet future requirements?
286
-			if( true === version_compare( GFCommon::$version, GV_FUTURE_MIN_GF_VERSION, ">=" ) ) {
286
+			if ( true === version_compare( GFCommon::$version, GV_FUTURE_MIN_GF_VERSION, ">=" ) ) {
287 287
 				return true;
288 288
 			}
289 289
 
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 			$class = $meets_minimum ? 'notice-warning' : 'error';
298 298
 
299 299
 			// Show the notice even if the future version requirements aren't met
300
-			self::$notices['gf_version'] = array(
300
+			self::$notices[ 'gf_version' ] = array(
301 301
 				'class' => $class,
302
-				'message' => sprintf( __( "%sGravityView requires Gravity Forms Version %s or newer.%s \n\nYou're using Version %s. Please update your Gravity Forms or purchase a license. %sGet Gravity Forms%s - starting at $39%s%s", 'gravityview' ), '<h3>', GV_FUTURE_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>', "\n\n".'<a href="https://gravityview.co/gravityforms/" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'),
302
+				'message' => sprintf( __( "%sGravityView requires Gravity Forms Version %s or newer.%s \n\nYou're using Version %s. Please update your Gravity Forms or purchase a license. %sGet Gravity Forms%s - starting at $39%s%s", 'gravityview' ), '<h3>', GV_FUTURE_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . GFCommon::$version . '</span>', "\n\n" . '<a href="https://gravityview.co/gravityforms/" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>' ),
303 303
 				'cap' => 'update_plugins',
304 304
 				'dismiss' => 'gf_version_' . GV_FUTURE_MIN_GF_VERSION,
305 305
 			);
@@ -315,42 +315,42 @@  discard block
 block discarded – undo
315 315
 		 * OR
316 316
 		 * It's the Network Admin and we just don't know whether the sites have GF activated themselves.
317 317
 		 */
318
-		if( true === $gf_status || is_network_admin() ) {
318
+		if ( true === $gf_status || is_network_admin() ) {
319 319
 			return true;
320 320
 		}
321 321
 
322 322
 		// If GFCommon doesn't exist, assume GF not active
323 323
 		$return = false;
324 324
 
325
-		switch( $gf_status ) {
325
+		switch ( $gf_status ) {
326 326
 			case 'inactive':
327 327
 
328 328
 				// Required for multisite
329
-				if( ! function_exists('wp_create_nonce') ) {
329
+				if ( ! function_exists( 'wp_create_nonce' ) ) {
330 330
 					require_once ABSPATH . WPINC . '/pluggable.php';
331 331
 				}
332 332
 
333 333
 				// Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE"
334
-				if( is_multisite() ) {
334
+				if ( is_multisite() ) {
335 335
 					wp_cookie_constants();
336 336
 				}
337 337
 
338 338
 				$return = false;
339 339
 
340
-				$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">';
340
+				$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">';
341 341
 
342
-				self::$notices['gf_inactive'] = array(
342
+				self::$notices[ 'gf_inactive' ] = array(
343 343
 					'class' => 'error',
344
-					'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>' ),
344
+					'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>' ),
345 345
 					'cap' => 'activate_plugins',
346 346
 					'dismiss' => 'gf_inactive',
347 347
 				);
348 348
 
349 349
 				break;
350 350
 			default:
351
-				self::$notices['gf_installed'] = array(
351
+				self::$notices[ 'gf_installed' ] = array(
352 352
 					'class' => 'error',
353
-					'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $39%s%s', 'gravityview' ), '<h3>', "</h3>\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'),
353
+					'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $39%s%s', 'gravityview' ), '<h3>', "</h3>\n\n" . '<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>' ),
354 354
 					'cap' => 'install_plugins',
355 355
 					'dismiss' => 'gf_installed',
356 356
 				);
@@ -367,10 +367,10 @@  discard block
 block discarded – undo
367 367
 	 */
368 368
 	private static function check_gf_directory() {
369 369
 
370
-		if( class_exists( 'GFDirectory' ) ) {
371
-			self::$notices['gf_directory'] = array(
370
+		if ( class_exists( 'GFDirectory' ) ) {
371
+			self::$notices[ 'gf_directory' ] = array(
372 372
 				'class' => 'error is-dismissible',
373
-				'title' => __('Potential Conflict', 'gravityview' ),
373
+				'title' => __( 'Potential Conflict', 'gravityview' ),
374 374
 				'message' => __( 'GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview' ),
375 375
 				'dismiss' => 'gf_directory',
376 376
 				'cap' => 'activate_plugins',
@@ -389,21 +389,21 @@  discard block
 block discarded – undo
389 389
 	 */
390 390
 	public static function get_plugin_status( $location = '' ) {
391 391
 
392
-		if( ! function_exists('is_plugin_active') ) {
392
+		if ( ! function_exists( 'is_plugin_active' ) ) {
393 393
 			include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
394 394
 		}
395 395
 
396
-		if( is_network_admin() && is_plugin_active_for_network( $location ) ) {
396
+		if ( is_network_admin() && is_plugin_active_for_network( $location ) ) {
397 397
 			return true;
398 398
 		}
399 399
 
400
-		if( !is_network_admin() && is_plugin_active( $location ) ) {
400
+		if ( ! is_network_admin() && is_plugin_active( $location ) ) {
401 401
 			return true;
402 402
 		}
403 403
 
404
-		if(
405
-			!file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) &&
406
-			!file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location )
404
+		if (
405
+			! file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) &&
406
+			! file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location )
407 407
 		) {
408 408
 			return false;
409 409
 		}
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   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @copydoc GravityView_Entry_Link_Shortcode::shortcode
73 73
 	 */
74 74
 	public function edit_shortcode( $atts, $content = null, $context = 'gv_edit_entry_link' ) {
75
-		$atts['action'] = 'edit';
75
+		$atts[ 'action' ] = 'edit';
76 76
 
77 77
 		return $this->shortcode( $atts, $content, $context );
78 78
 	}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @copydoc GravityView_Entry_Link_Shortcode::shortcode
86 86
 	 */
87 87
 	public function delete_shortcode( $atts, $content = null, $context = 'gv_delete_entry_link' ) {
88
-		$atts['action'] = 'delete';
88
+		$atts[ 'action' ] = 'delete';
89 89
 
90 90
 		return $this->shortcode( $atts, $content, $context );
91 91
 	}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
 		$this->settings = shortcode_atts( self::$defaults, $atts, $context );
128 128
 
129
-		$this->view_id = empty( $this->settings['view_id'] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings['view_id'] );
129
+		$this->view_id = empty( $this->settings[ 'view_id' ] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings[ 'view_id' ] );
130 130
 
131 131
 		if ( empty( $this->view_id ) ) {
132 132
 			do_action( 'gravityview_log_error', __METHOD__ . ' A View ID was not defined and we are not inside a View' );
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 			return null;
135 135
 		}
136 136
 
137
-		$this->entry = $this->get_entry( $this->settings['entry_id'] );
137
+		$this->entry = $this->get_entry( $this->settings[ 'entry_id' ] );
138 138
 
139 139
 		do_action( 'gravityview_log_debug', __METHOD__ . ' ' . $context . ' $atts: ', $atts );
140 140
 
141 141
 		if ( ! $this->has_cap() ) {
142
-			do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the capability to ' . esc_attr( $this->settings['action'] ) . ' this entry: ' . $this->entry['id'] );
142
+			do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the capability to ' . esc_attr( $this->settings[ 'action' ] ) . ' this entry: ' . $this->entry[ 'id' ] );
143 143
 
144 144
 			return null;
145 145
 		}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		}
154 154
 
155 155
 		// Get just the URL, not the tag
156
-		if ( 'url' === $this->settings['return'] ) {
156
+		if ( 'url' === $this->settings[ 'return' ] ) {
157 157
 			return $url;
158 158
 		}
159 159
 
@@ -174,13 +174,13 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	private function get_link_atts() {
176 176
 
177
-		wp_parse_str( $this->settings['link_atts'], $link_atts );
177
+		wp_parse_str( $this->settings[ 'link_atts' ], $link_atts );
178 178
 
179
-		if ( 'delete' === $this->settings['action'] ) {
180
-			$link_atts['onclick'] = isset( $link_atts['onclick'] ) ? $link_atts['onclick'] : GravityView_Delete_Entry::get_confirm_dialog();
179
+		if ( 'delete' === $this->settings[ 'action' ] ) {
180
+			$link_atts[ 'onclick' ] = isset( $link_atts[ 'onclick' ] ) ? $link_atts[ 'onclick' ] : GravityView_Delete_Entry::get_confirm_dialog();
181 181
 		}
182 182
 
183
-		return (array) $link_atts;
183
+		return (array)$link_atts;
184 184
 	}
185 185
 
186 186
 	/**
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			return $content;
201 201
 		}
202 202
 
203
-		switch ( $this->settings['action'] ) {
203
+		switch ( $this->settings[ 'action' ] ) {
204 204
 			case 'edit':
205 205
 				$anchor_text = __( 'Edit Entry', 'gravityview' );
206 206
 				break;
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 	private function get_url() {
229 229
 
230 230
 		// if post_id is not defined, default to view_id
231
-		$post_id = empty( $this->settings['post_id'] ) ? $this->view_id : absint( $this->settings['post_id'] );
231
+		$post_id = empty( $this->settings[ 'post_id' ] ) ? $this->view_id : absint( $this->settings[ 'post_id' ] );
232 232
 
233
-		switch ( $this->settings['action'] ) {
233
+		switch ( $this->settings[ 'action' ] ) {
234 234
 			case 'edit':
235 235
 				$url = GravityView_Edit_Entry::get_edit_link( $this->entry, $this->view_id, $post_id );
236 236
 				break;
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 */
256 256
 	private function has_cap() {
257 257
 
258
-		switch ( $this->settings['action'] ) {
258
+		switch ( $this->settings[ 'action' ] ) {
259 259
 			case 'edit':
260 260
 				$has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry, $this->view_id );
261 261
 				break;
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	private function maybe_add_field_values_query_args( $url ) {
322 322
 
323
-		if ( $url && ! empty( $this->settings['field_values'] ) ) {
323
+		if ( $url && ! empty( $this->settings[ 'field_values' ] ) ) {
324 324
 
325
-			wp_parse_str( $this->settings['field_values'], $field_values );
325
+			wp_parse_str( $this->settings[ 'field_values' ], $field_values );
326 326
 
327 327
 			$url = add_query_arg( $field_values, $url );
328 328
 		}
Please login to merge, or discard this patch.
includes/class-gravityview-extension.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -278,7 +278,7 @@
 block discarded – undo
278 278
 
279 279
 	/**
280 280
 	 * Add a notice to be displayed in the admin.
281
-	 * @param array $notice Array with `class` and `message` keys. The message is not escaped.
281
+	 * @param string $notice Array with `class` and `message` keys. The message is not escaped.
282 282
 	 */
283 283
 	public static function add_notice( $notice = array() ) {
284 284
 
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -244,13 +244,13 @@
 block discarded – undo
244 244
 			$this->_remote_update_url,
245 245
 			$this->_path,
246 246
 			array(
247
-            	'version'	=> $this->_version, // current version number
248
-            	'license'	=> $license['license'],
249
-	            'item_id'   => $this->_item_id, // The ID of the download on _remote_update_url
250
-            	'item_name' => $this->_title,  // name of this plugin
251
-            	'author' 	=> strip_tags( $this->_author )  // author of this plugin
252
-          	)
253
-        );
247
+				'version'	=> $this->_version, // current version number
248
+				'license'	=> $license['license'],
249
+				'item_id'   => $this->_item_id, // The ID of the download on _remote_update_url
250
+				'item_name' => $this->_title,  // name of this plugin
251
+				'author' 	=> strip_tags( $this->_author )  // author of this plugin
252
+		  	)
253
+		);
254 254
 	}
255 255
 
256 256
 	/**
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
 
72 72
 		add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
73 73
 
74
-		add_action( 'admin_init', array( $this, 'settings') );
74
+		add_action( 'admin_init', array( $this, 'settings' ) );
75 75
 
76 76
 		add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 );
77 77
 
78 78
 		add_action( 'gravityview/metaboxes/before_render', array( $this, 'add_metabox_tab' ) );
79 79
 
80
-		if( false === $this->is_extension_supported() ) {
80
+		if ( false === $this->is_extension_supported() ) {
81 81
 			return;
82 82
 		}
83 83
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		$tab_settings = $this->tab_settings();
117 117
 
118 118
 		// Don't add a tab if it's empty.
119
-		if( empty( $tab_settings ) ) {
119
+		if ( empty( $tab_settings ) ) {
120 120
 			return;
121 121
 		}
122 122
 
@@ -134,17 +134,17 @@  discard block
 block discarded – undo
134 134
 		$tab = wp_parse_args( $tab_settings, $tab_defaults );
135 135
 
136 136
 		// Force the screen to be GravityView
137
-		$tab['screen'] = 'gravityview';
137
+		$tab[ 'screen' ] = 'gravityview';
138 138
 
139
-		if( class_exists('GravityView_Metabox_Tab') ) {
139
+		if ( class_exists( 'GravityView_Metabox_Tab' ) ) {
140 140
 
141
-			$metabox = new GravityView_Metabox_Tab( $tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args'] );
141
+			$metabox = new GravityView_Metabox_Tab( $tab[ 'id' ], $tab[ 'title' ], $tab[ 'file' ], $tab[ 'icon-class' ], $tab[ 'callback' ], $tab[ 'callback_args' ] );
142 142
 
143 143
 			GravityView_Metabox_Tabs::add( $metabox );
144 144
 
145 145
 		} else {
146 146
 
147
-			add_meta_box( 'gravityview_'.$tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority'] );
147
+			add_meta_box( 'gravityview_' . $tab[ 'id' ], $tab[ 'title' ], $tab[ 'callback' ], $tab[ 'screen' ], $tab[ 'context' ], $tab[ 'priority' ] );
148 148
 
149 149
 		}
150 150
 	}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function load_plugin_textdomain() {
162 162
 
163
-		if( empty( $this->_text_domain ) ) {
163
+		if ( empty( $this->_text_domain ) ) {
164 164
 			do_action( 'gravityview_log_debug', __METHOD__ . ': Extension translation cannot be loaded; the `_text_domain` variable is not defined', $this );
165 165
 			return;
166 166
 		}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		$lang_dir = dirname( plugin_basename( $path ) ) . '/languages/';
173 173
 
174 174
 		// Traditional WordPress plugin locale filter
175
-		$locale = apply_filters( 'plugin_locale',  get_locale(), $this->_text_domain );
175
+		$locale = apply_filters( 'plugin_locale', get_locale(), $this->_text_domain );
176 176
 
177 177
 		$mofile = sprintf( '%1$s-%2$s.mo', $this->_text_domain, $locale );
178 178
 
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	protected function get_license() {
204 204
 
205
-		if( !class_exists( 'GravityView_Settings' ) ) {
205
+		if ( ! class_exists( 'GravityView_Settings' ) ) {
206 206
 			return false;
207 207
 		}
208 208
 
209
-		$license = GravityView_Settings::getSetting('license');
209
+		$license = GravityView_Settings::getSetting( 'license' );
210 210
 
211 211
 		return $license;
212 212
 	}
@@ -219,16 +219,16 @@  discard block
 block discarded – undo
219 219
 	public function settings() {
220 220
 
221 221
 		// If doing ajax, get outta here
222
-		if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )  {
222
+		if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
223 223
 			return;
224 224
 		}
225 225
 
226
-		if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) {
226
+		if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
227 227
 
228 228
 			$file_path = plugin_dir_path( __FILE__ ) . 'lib/EDD_SL_Plugin_Updater.php';
229 229
 
230 230
 			// This file may be in the lib/ directory already
231
-			if( ! file_exists( $file_path ) ) {
231
+			if ( ! file_exists( $file_path ) ) {
232 232
 				$file_path = plugin_dir_path( __FILE__ ) . '/EDD_SL_Plugin_Updater.php';
233 233
 			}
234 234
 
@@ -238,16 +238,16 @@  discard block
 block discarded – undo
238 238
 		$license = $this->get_license();
239 239
 
240 240
 		// Don't update if invalid license.
241
-		if( false === $license || empty( $license['status'] ) || strtolower( $license['status'] ) !== 'valid' ) { return; }
241
+		if ( false === $license || empty( $license[ 'status' ] ) || strtolower( $license[ 'status' ] ) !== 'valid' ) { return; }
242 242
 
243 243
 		new EDD_SL_Plugin_Updater(
244 244
 			$this->_remote_update_url,
245 245
 			$this->_path,
246 246
 			array(
247 247
             	'version'	=> $this->_version, // current version number
248
-            	'license'	=> $license['license'],
248
+            	'license'	=> $license[ 'license' ],
249 249
 	            'item_id'   => $this->_item_id, // The ID of the download on _remote_update_url
250
-            	'item_name' => $this->_title,  // name of this plugin
250
+            	'item_name' => $this->_title, // name of this plugin
251 251
             	'author' 	=> strip_tags( $this->_author )  // author of this plugin
252 252
           	)
253 253
         );
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
 	 */
261 261
 	public function admin_notice() {
262 262
 
263
-		if( empty( self::$admin_notices ) ) {
263
+		if ( empty( self::$admin_notices ) ) {
264 264
 			return;
265 265
 		}
266 266
 
267
-		foreach( self::$admin_notices as $key => $notice ) {
267
+		foreach ( self::$admin_notices as $key => $notice ) {
268 268
 
269
-			echo '<div id="message" class="'. esc_attr( $notice['class'] ).'">';
270
-			echo wpautop( $notice['message'] );
269
+			echo '<div id="message" class="' . esc_attr( $notice[ 'class' ] ) . '">';
270
+			echo wpautop( $notice[ 'message' ] );
271 271
 			echo '<div class="clear"></div>';
272 272
 			echo '</div>';
273 273
 		}
@@ -282,16 +282,16 @@  discard block
 block discarded – undo
282 282
 	 */
283 283
 	public static function add_notice( $notice = array() ) {
284 284
 
285
-		if( is_array( $notice ) && !isset( $notice['message'] ) ) {
286
-			do_action( 'gravityview_log_error', __CLASS__.'[add_notice] Notice not set', $notice );
285
+		if ( is_array( $notice ) && ! isset( $notice[ 'message' ] ) ) {
286
+			do_action( 'gravityview_log_error', __CLASS__ . '[add_notice] Notice not set', $notice );
287 287
 			return;
288
-		} else if( is_string( $notice ) ) {
288
+		} else if ( is_string( $notice ) ) {
289 289
 			$notice = array( 'message' => $notice );
290 290
 		}
291 291
 
292
-		$notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class'];
292
+		$notice[ 'class' ] = empty( $notice[ 'class' ] ) ? 'error' : $notice[ 'class' ];
293 293
 
294
-		self::$admin_notices[] = $notice;
294
+		self::$admin_notices[ ] = $notice;
295 295
 	}
296 296
 
297 297
 	/**
@@ -346,17 +346,17 @@  discard block
 block discarded – undo
346 346
 
347 347
 		$message = '';
348 348
 
349
-		if( !class_exists( 'GravityView_Plugin' ) ) {
349
+		if ( ! class_exists( 'GravityView_Plugin' ) ) {
350 350
 
351
-			$message = sprintf( __('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), $this->_title );
351
+			$message = sprintf( __( 'Could not activate the %s Extension; GravityView is not active.', 'gravityview' ), $this->_title );
352 352
 
353
-		} else if( false === version_compare(GravityView_Plugin::version, $this->_min_gravityview_version , ">=") ) {
353
+		} else if ( false === version_compare( GravityView_Plugin::version, $this->_min_gravityview_version, ">=" ) ) {
354 354
 
355
-			$message = sprintf( __('The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), $this->_title, '<tt>'.$this->_min_gravityview_version.'</tt>' );
355
+			$message = sprintf( __( 'The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), $this->_title, '<tt>' . $this->_min_gravityview_version . '</tt>' );
356 356
 
357
-		} else if( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version , ">=") ) {
357
+		} else if ( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version, ">=" ) ) {
358 358
 
359
-			$message = sprintf( __('The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), $this->_title, '<tt>'.$this->_min_php_version.'</tt>' );
359
+			$message = sprintf( __( 'The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), $this->_title, '<tt>' . $this->_min_php_version . '</tt>' );
360 360
 
361 361
 		} else {
362 362
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 
369 369
 			self::add_notice( $message );
370 370
 
371
-			do_action( 'gravityview_log_error', __METHOD__. ' ' . $message );
371
+			do_action( 'gravityview_log_error', __METHOD__ . ' ' . $message );
372 372
 
373 373
 			self::$is_compatible = false;
374 374
 		}
Please login to merge, or discard this patch.
Braces   +3 added lines, -5 removed lines patch added patch discarded remove patch
@@ -183,12 +183,10 @@  discard block
 block discarded – undo
183 183
 		if ( file_exists( $mofile_global ) ) {
184 184
 			// Look in global /wp-content/languages/[plugin-dir]/ folder
185 185
 			load_textdomain( $this->_text_domain, $mofile_global );
186
-		}
187
-		elseif ( file_exists( $mofile_local ) ) {
186
+		} elseif ( file_exists( $mofile_local ) ) {
188 187
 			// Look in local /wp-content/plugins/[plugin-dir]/languages/ folder
189 188
 			load_textdomain( $this->_text_domain, $mofile_local );
190
-		}
191
-		else {
189
+		} else {
192 190
 			// Load the default language files
193 191
 			load_plugin_textdomain( $this->_text_domain, false, $lang_dir );
194 192
 		}
@@ -219,7 +217,7 @@  discard block
 block discarded – undo
219 217
 	public function settings() {
220 218
 
221 219
 		// If doing ajax, get outta here
222
-		if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )  {
220
+		if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
223 221
 			return;
224 222
 		}
225 223
 
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/delete-entry/class-delete-entry.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -170,7 +170,6 @@
 block discarded – undo
170 170
 	 *
171 171
 	 * @since 1.5.1
172 172
 	 * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
173
-	 * @param  string      $field_type  Type of field options to render (`field` or `widget`)
174 173
 	 * @param  string      $template_id Table slug
175 174
 	 * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
176 175
 	 * @param  string      $context     What context are we in? Example: `single` or `directory`
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 
235 235
 		self::getInstance()->set_entry( $entry );
236 236
 
237
-        $base = GravityView_API::directory_link( $post_id, true );
237
+		$base = GravityView_API::directory_link( $post_id, true );
238 238
 
239 239
 		if( empty( $base ) ) {
240 240
 			do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id );
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 		// Use the slug instead of the ID for consistent security
245 245
 		$entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry );
246 246
 
247
-        $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id;
247
+		$view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id;
248 248
 
249 249
 		$actionurl = add_query_arg( array(
250 250
 			'action'	=> 'delete',
251 251
 			'entry_id'		=> $entry_slug,
252 252
 			'gvid' => $view_id,
253
-            'view_id' => $view_id,
253
+			'view_id' => $view_id,
254 254
 		), $base );
255 255
 
256 256
 		$url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' );
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 				 * @since 1.16.4
425 425
 				 * @param  int $entry_id ID of the Gravity Forms entry
426 426
 				 * @param  array $entry Deleted entry array
427
-				*/
427
+				 */
428 428
 				do_action( 'gravityview/delete-entry/deleted', $entry_id, $entry );
429 429
 			}
430 430
 
Please login to merge, or discard this patch.
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 
43 43
 		add_action( 'wp', array( $this, 'process_delete' ), 10000 );
44 44
 
45
-		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field'), 10, 3 );
45
+		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
46 46
 
47 47
 		add_action( 'gravityview_before', array( $this, 'display_message' ) );
48 48
 
49 49
 		// For the Delete Entry Link, you don't want visible to all users.
50
-		add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps'), 10, 5 );
50
+		add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
51 51
 
52 52
 		// Modify the field options based on the name of the field type
53 53
 		add_filter( 'gravityview_template_delete_link_options', array( $this, 'delete_link_field_options' ), 10, 5 );
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 		// add template path to check for field
56 56
 		add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
57 57
 
58
-		add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button'), 10, 3 );
58
+		add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button' ), 10, 3 );
59 59
 
60
-		add_action ( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 );
61
-		add_action ( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 );
60
+		add_action( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 );
61
+		add_action( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 );
62 62
 	}
63 63
 
64 64
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	static function getInstance() {
71 71
 
72
-		if( empty( self::$instance ) ) {
72
+		if ( empty( self::$instance ) ) {
73 73
 			self::$instance = new self;
74 74
 		}
75 75
 
@@ -105,20 +105,20 @@  discard block
 block discarded – undo
105 105
 	function delete_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
106 106
 
107 107
 		// Always a link, never a filter
108
-		unset( $field_options['show_as_link'], $field_options['search_filter'] );
108
+		unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] );
109 109
 
110 110
 		// Delete Entry link should only appear to visitors capable of editing entries
111
-		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
111
+		unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] );
112 112
 
113
-		$add_option['delete_link'] = array(
113
+		$add_option[ 'delete_link' ] = array(
114 114
 			'type' => 'text',
115 115
 			'label' => __( 'Delete Link Text', 'gravityview' ),
116 116
 			'desc' => NULL,
117
-			'value' => __('Delete Entry', 'gravityview'),
117
+			'value' => __( 'Delete Entry', 'gravityview' ),
118 118
 			'merge_tags' => true,
119 119
 		);
120 120
 
121
-		$field_options['allow_edit_cap'] = array(
121
+		$field_options[ 'allow_edit_cap' ] = array(
122 122
 			'type' => 'select',
123 123
 			'label' => __( 'Allow the following users to delete the entry:', 'gravityview' ),
124 124
 			'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
144 144
 
145
-		if( 'edit' !== $zone ) {
146
-			$entry_default_fields['delete_link'] = array(
145
+		if ( 'edit' !== $zone ) {
146
+			$entry_default_fields[ 'delete_link' ] = array(
147 147
 				'label' => __( 'Delete Entry', 'gravityview' ),
148 148
 				'type'  => 'delete_link',
149 149
 				'desc'  => __( 'A link to delete the entry. Respects the Delete Entry permissions.', 'gravityview' ),
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	function add_available_field( $available_fields = array() ) {
162 162
 
163
-		$available_fields['delete_link'] = array(
163
+		$available_fields[ 'delete_link' ] = array(
164 164
 			'label_text' => __( 'Delete Entry', 'gravityview' ),
165 165
 			'field_id' => 'delete_link',
166 166
 			'label_type' => 'field',
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
 		$caps = $visibility_caps;
189 189
 
190 190
 		// If we're configuring fields in the edit context, we want a limited selection
191
-		if( $field_id === 'delete_link' ) {
191
+		if ( $field_id === 'delete_link' ) {
192 192
 
193 193
 			// Remove other built-in caps.
194
-			unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
194
+			unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] );
195 195
 
196
-			$caps['read'] = _x('Entry Creator', 'User capability', 'gravityview');
196
+			$caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' );
197 197
 		}
198 198
 
199 199
 		return $caps;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 * @param [type] $entry [description]
207 207
 	 */
208 208
 	function set_entry( $entry = null ) {
209
-		$this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[0] : $entry;
209
+		$this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[ 0 ] : $entry;
210 210
 	}
211 211
 
212 212
 	/**
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
 
237 237
         $base = GravityView_API::directory_link( $post_id, true );
238 238
 
239
-		if( empty( $base ) ) {
240
-			do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id );
239
+		if ( empty( $base ) ) {
240
+			do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: ' . $post_id );
241 241
 			return NULL;
242 242
 		}
243 243
 
244 244
 		// Use the slug instead of the ID for consistent security
245
-		$entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry );
245
+		$entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry );
246 246
 
247 247
         $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id;
248 248
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
             'view_id' => $view_id,
254 254
 		), $base );
255 255
 
256
-		$url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' );
256
+		$url = wp_nonce_url( $actionurl, 'delete_' . $entry_slug, 'delete' );
257 257
 
258 258
 		return $url;
259 259
 	}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	function add_delete_button( $form = array(), $entry = array(), $view_id = NULL ) {
271 271
 
272 272
 		// Only show the link to those who are allowed to see it.
273
-		if( !self::check_user_cap_delete_entry( $entry ) ) {
273
+		if ( ! self::check_user_cap_delete_entry( $entry ) ) {
274 274
 			return;
275 275
 		}
276 276
 
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 		$show_delete_button = apply_filters( 'gravityview/delete-entry/show-delete-button', true );
282 282
 
283 283
 		// If the button is hidden by the filter, don't show.
284
-		if( !$show_delete_button ) {
284
+		if ( ! $show_delete_button ) {
285 285
 			return;
286 286
 		}
287 287
 
288 288
 		$attributes = array(
289 289
 			'class' => 'btn btn-sm button button-small alignright pull-right btn-danger gv-button-delete',
290
-			'tabindex' => ( GFCommon::$tab_index ++ ),
290
+			'tabindex' => ( GFCommon::$tab_index++ ),
291 291
 			'onclick' => self::get_confirm_dialog(),
292 292
 		);
293 293
 
@@ -311,27 +311,27 @@  discard block
 block discarded – undo
311 311
 	function process_delete() {
312 312
 
313 313
 		// If the form is submitted
314
-		if( isset( $_GET['action'] ) && 'delete' === $_GET['action'] && isset( $_GET['entry_id'] ) ) {
314
+		if ( isset( $_GET[ 'action' ] ) && 'delete' === $_GET[ 'action' ] && isset( $_GET[ 'entry_id' ] ) ) {
315 315
 
316 316
 			// Make sure it's a GravityView request
317
-			$valid_nonce_key = wp_verify_nonce( $_GET['delete'], self::get_nonce_key( $_GET['entry_id'] ) );
317
+			$valid_nonce_key = wp_verify_nonce( $_GET[ 'delete' ], self::get_nonce_key( $_GET[ 'entry_id' ] ) );
318 318
 
319
-			if( ! $valid_nonce_key ) {
320
-				do_action('gravityview_log_debug', __METHOD__ . ' Delete entry not processed: nonce validation failed.' );
319
+			if ( ! $valid_nonce_key ) {
320
+				do_action( 'gravityview_log_debug', __METHOD__ . ' Delete entry not processed: nonce validation failed.' );
321 321
 				return;
322 322
 			}
323 323
 
324 324
 			// Get the entry slug
325
-			$entry_slug = esc_attr( $_GET['entry_id'] );
325
+			$entry_slug = esc_attr( $_GET[ 'entry_id' ] );
326 326
 
327 327
 			// See if there's an entry there
328 328
 			$entry = gravityview_get_entry( $entry_slug, true, false );
329 329
 
330
-			if( $entry ) {
330
+			if ( $entry ) {
331 331
 
332 332
 				$has_permission = $this->user_can_delete_entry( $entry );
333 333
 
334
-				if( is_wp_error( $has_permission ) ) {
334
+				if ( is_wp_error( $has_permission ) ) {
335 335
 
336 336
 					$messages = array(
337 337
 						'message' => urlencode( $has_permission->get_error_message() ),
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 					// Delete the entry
344 344
 					$delete_response = $this->delete_or_trash_entry( $entry );
345 345
 
346
-					if( is_wp_error( $delete_response ) ) {
346
+					if ( is_wp_error( $delete_response ) ) {
347 347
 
348 348
 						$messages = array(
349 349
 							'message' => urlencode( $delete_response->get_error_message() ),
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
 
363 363
 			} else {
364 364
 
365
-				do_action('gravityview_log_debug', __METHOD__ . ' Delete entry failed: there was no entry with the entry slug '. $entry_slug );
365
+				do_action( 'gravityview_log_debug', __METHOD__ . ' Delete entry failed: there was no entry with the entry slug ' . $entry_slug );
366 366
 
367 367
 				$messages = array(
368
-					'message' => urlencode( __('The entry does not exist.', 'gravityview') ),
368
+					'message' => urlencode( __( 'The entry does not exist.', 'gravityview' ) ),
369 369
 					'status' => 'error',
370 370
 				);
371 371
 			}
@@ -405,18 +405,18 @@  discard block
 block discarded – undo
405 405
 	 */
406 406
 	private function delete_or_trash_entry( $entry ) {
407 407
 
408
-		$entry_id = $entry['id'];
408
+		$entry_id = $entry[ 'id' ];
409 409
 		
410 410
 		$mode = $this->get_delete_mode();
411 411
 
412
-		if( 'delete' === $mode ) {
412
+		if ( 'delete' === $mode ) {
413 413
 
414 414
 			do_action( 'gravityview_log_debug', __METHOD__ . ' Starting delete entry: ', $entry_id );
415 415
 
416 416
 			// Delete the entry
417 417
 			$delete_response = GFAPI::delete_entry( $entry_id );
418 418
 
419
-			if( ! is_wp_error( $delete_response ) ) {
419
+			if ( ! is_wp_error( $delete_response ) ) {
420 420
 				$delete_response = 'deleted';
421 421
 
422 422
 				/**
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 			$trashed = GFAPI::update_entry_property( $entry_id, 'status', 'trash' );
438 438
 			new GravityView_Cache;
439 439
 
440
-			if( ! $trashed ) {
441
-				$delete_response = new WP_Error( 'trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview' ) );
440
+			if ( ! $trashed ) {
441
+				$delete_response = new WP_Error( 'trash_entry_failed', __( 'Moving the entry to the trash failed.', 'gravityview' ) );
442 442
 			} else {
443 443
 
444 444
 				/**
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 	public function process_connected_posts( $entry_id = 0, $entry = array() ) {
470 470
 
471 471
 		// The entry had no connected post
472
-		if( empty( $entry['post_id'] ) ) {
472
+		if ( empty( $entry[ 'post_id' ] ) ) {
473 473
 			return;
474 474
 		}
475 475
 
@@ -480,22 +480,22 @@  discard block
 block discarded – undo
480 480
 		 */
481 481
 		$delete_post = apply_filters( 'gravityview/delete-entry/delete-connected-post', true );
482 482
 		
483
-		if( false === $delete_post ) {
483
+		if ( false === $delete_post ) {
484 484
 			return;
485 485
 		}
486 486
 
487 487
 		$action = current_action();
488 488
 
489
-		if( 'gravityview/delete-entry/deleted' === $action ) {
490
-			$result = wp_delete_post( $entry['post_id'], true );
489
+		if ( 'gravityview/delete-entry/deleted' === $action ) {
490
+			$result = wp_delete_post( $entry[ 'post_id' ], true );
491 491
 		} else {
492
-			$result = wp_trash_post( $entry['post_id'] );
492
+			$result = wp_trash_post( $entry[ 'post_id' ] );
493 493
 		}
494 494
 
495
-		if( false === $result ) {
496
-			do_action( 'gravityview_log_error', __METHOD__ . ' (called by '.$action.'): Error processing the Post connected to the entry.', $entry );
495
+		if ( false === $result ) {
496
+			do_action( 'gravityview_log_error', __METHOD__ . ' (called by ' . $action . '): Error processing the Post connected to the entry.', $entry );
497 497
 		} else {
498
-			do_action( 'gravityview_log_debug', __METHOD__ . ' (called by '.$action.'): Successfully processed Post connected to the entry.', $entry );
498
+			do_action( 'gravityview_log_debug', __METHOD__ . ' (called by ' . $action . '): Successfully processed Post connected to the entry.', $entry );
499 499
 		}
500 500
 	}
501 501
 
@@ -508,13 +508,13 @@  discard block
 block discarded – undo
508 508
 	public function verify_nonce() {
509 509
 
510 510
 		// No delete entry request was made
511
-		if( empty( $_GET['entry_id'] ) || empty( $_GET['delete'] ) ) {
511
+		if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'delete' ] ) ) {
512 512
 			return false;
513 513
 		}
514 514
 
515
-		$nonce_key = self::get_nonce_key( $_GET['entry_id'] );
515
+		$nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] );
516 516
 
517
-		$valid = wp_verify_nonce( $_GET['delete'], $nonce_key );
517
+		$valid = wp_verify_nonce( $_GET[ 'delete' ], $nonce_key );
518 518
 
519 519
 		/**
520 520
 		 * @filter `gravityview/delete-entry/verify_nonce` Override Delete Entry nonce validation. Return true to declare nonce valid.
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	 */
537 537
 	public static function get_confirm_dialog() {
538 538
 
539
-		$confirm = __('Are you sure you want to delete this entry? This cannot be undone.', 'gravityview');
539
+		$confirm = __( 'Are you sure you want to delete this entry? This cannot be undone.', 'gravityview' );
540 540
 
541 541
 		/**
542 542
 		 * @filter `gravityview/delete-entry/confirm-text` Modify the Delete Entry Javascript confirmation text
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		 */
545 545
 		$confirm = apply_filters( 'gravityview/delete-entry/confirm-text', $confirm );
546 546
 
547
-		return 'return window.confirm(\''. esc_js( $confirm ) .'\');';
547
+		return 'return window.confirm(\'' . esc_js( $confirm ) . '\');';
548 548
 	}
549 549
 
550 550
 	/**
@@ -562,16 +562,16 @@  discard block
 block discarded – undo
562 562
 
563 563
 		$error = NULL;
564 564
 
565
-		if( ! $this->verify_nonce() ) {
566
-			$error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview');
565
+		if ( ! $this->verify_nonce() ) {
566
+			$error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview' );
567 567
 		}
568 568
 
569
-		if( ! self::check_user_cap_delete_entry( $entry ) ) {
570
-			$error = __( 'You do not have permission to delete this entry.', 'gravityview');
569
+		if ( ! self::check_user_cap_delete_entry( $entry ) ) {
570
+			$error = __( 'You do not have permission to delete this entry.', 'gravityview' );
571 571
 		}
572 572
 
573
-		if( $entry['status'] === 'trash' ) {
574
-			if( 'trash' === $this->get_delete_mode() ) {
573
+		if ( $entry[ 'status' ] === 'trash' ) {
574
+			if ( 'trash' === $this->get_delete_mode() ) {
575 575
 				$error = __( 'The entry is already in the trash.', 'gravityview' );
576 576
 			} else {
577 577
 				$error = __( 'You cannot delete the entry; it is already in the trash.', 'gravityview' );
@@ -579,11 +579,11 @@  discard block
 block discarded – undo
579 579
 		}
580 580
 
581 581
 		// No errors; everything's fine here!
582
-		if( empty( $error ) ) {
582
+		if ( empty( $error ) ) {
583 583
 			return true;
584 584
 		}
585 585
 
586
-		do_action('gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]' . $error );
586
+		do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]' . $error );
587 587
 
588 588
 		return new WP_Error( 'gravityview-delete-entry-permissions', $error );
589 589
 	}
@@ -605,32 +605,32 @@  discard block
 block discarded – undo
605 605
 
606 606
 		$current_user = wp_get_current_user();
607 607
 
608
-		$entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL;
608
+		$entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL;
609 609
 
610 610
 		// Or if they can delete any entries (as defined in Gravity Forms), we're good.
611
-		if( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) {
611
+		if ( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) {
612 612
 
613
-			do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' );
613
+			do_action( 'gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' );
614 614
 
615 615
 			return true;
616 616
 		}
617 617
 
618 618
 
619 619
 		// If field options are passed, check if current user can view the link
620
-		if( !empty( $field ) ) {
620
+		if ( ! empty( $field ) ) {
621 621
 
622 622
 			// If capability is not defined, something is not right!
623
-			if( empty( $field['allow_edit_cap'] ) ) {
623
+			if ( empty( $field[ 'allow_edit_cap' ] ) ) {
624 624
 
625 625
 				do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Cannot read delete entry field caps', $field );
626 626
 
627 627
 				return false;
628 628
 			}
629 629
 
630
-			if( GVCommon::has_cap( $field['allow_edit_cap'] ) ) {
630
+			if ( GVCommon::has_cap( $field[ 'allow_edit_cap' ] ) ) {
631 631
 
632 632
 				// Do not return true if cap is read, as we need to check if the current user created the entry
633
-				if( $field['allow_edit_cap'] !== 'read' ) {
633
+				if ( $field[ 'allow_edit_cap' ] !== 'read' ) {
634 634
 					return true;
635 635
 				}
636 636
 
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 
644 644
 		}
645 645
 
646
-		if( !isset( $entry['created_by'] ) ) {
646
+		if ( ! isset( $entry[ 'created_by' ] ) ) {
647 647
 
648
-			do_action('gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.');
648
+			do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.' );
649 649
 
650 650
 			return false;
651 651
 		}
@@ -653,24 +653,24 @@  discard block
 block discarded – undo
653 653
 		$view_id = empty( $view_id ) ? $gravityview_view->getViewId() : $view_id;
654 654
 
655 655
 		// Only checks user_delete view option if view is already set
656
-		if( $view_id ) {
656
+		if ( $view_id ) {
657 657
 
658 658
 			$current_view = gravityview_get_current_view_data( $view_id );
659 659
 
660
-			$user_delete = isset( $current_view['atts']['user_delete'] ) ? $current_view['atts']['user_delete'] : false;
660
+			$user_delete = isset( $current_view[ 'atts' ][ 'user_delete' ] ) ? $current_view[ 'atts' ][ 'user_delete' ] : false;
661 661
 
662
-			if( empty( $user_delete ) ) {
662
+			if ( empty( $user_delete ) ) {
663 663
 
664
-				do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.' );
664
+				do_action( 'gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.' );
665 665
 
666 666
 				return false;
667 667
 			}
668 668
 		}
669 669
 
670 670
 		// If the logged-in user is the same as the user who created the entry, we're good.
671
-		if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
671
+		if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) {
672 672
 
673
-			do_action('gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID ) );
673
+			do_action( 'gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID ) );
674 674
 
675 675
 			return true;
676 676
 		}
@@ -693,31 +693,31 @@  discard block
 block discarded – undo
693 693
 	 */
694 694
 	public function display_message( $current_view_id = 0 ) {
695 695
 
696
-		if( empty( $_GET['status'] ) || ! self::verify_nonce() ) {
696
+		if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) {
697 697
 			return;
698 698
 		}
699 699
 
700 700
 		// Entry wasn't deleted from current View
701
-		if( isset( $_GET['view_id'] ) && intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) {
701
+		if ( isset( $_GET[ 'view_id' ] ) && intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) {
702 702
 			return;
703 703
 		}
704 704
 
705
-		$status = esc_attr( $_GET['status'] );
706
-		$message_from_url = rgget('message');
705
+		$status = esc_attr( $_GET[ 'status' ] );
706
+		$message_from_url = rgget( 'message' );
707 707
 		$message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) );
708 708
 		$class = '';
709 709
 
710 710
 		switch ( $status ) {
711 711
 			case 'error':
712 712
 				$class = ' gv-error error';
713
-				$error_message = __('There was an error deleting the entry: %s', 'gravityview');
713
+				$error_message = __( 'There was an error deleting the entry: %s', 'gravityview' );
714 714
 				$message = sprintf( $error_message, $message_from_url );
715 715
 				break;
716 716
 			case 'trashed':
717
-				$message = __('The entry was successfully moved to the trash.', 'gravityview');
717
+				$message = __( 'The entry was successfully moved to the trash.', 'gravityview' );
718 718
 				break;
719 719
 			default:
720
-				$message = __('The entry was successfully deleted.', 'gravityview');
720
+				$message = __( 'The entry was successfully deleted.', 'gravityview' );
721 721
 				break;
722 722
 		}
723 723
 
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 		$message = apply_filters( 'gravityview/delete-entry/message', esc_attr( $message ), $status, $message_from_url );
732 732
 
733 733
 		// DISPLAY ERROR/SUCCESS MESSAGE
734
-		echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>';
734
+		echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>';
735 735
 	}
736 736
 
737 737
 
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-admin.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,6 @@
 block discarded – undo
69 69
      * Change wording for the Edit context to read Entry Creator
70 70
      *
71 71
      * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
-     * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73 72
      * @param  string      $template_id Table slug
74 73
      * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75 74
      * @param  string      $context     What context are we in? Example: `single` or `directory`
Please login to merge, or discard this patch.
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -10,175 +10,175 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 if ( ! defined( 'WPINC' ) ) {
13
-    die;
13
+	die;
14 14
 }
15 15
 
16 16
 
17 17
 class GravityView_Edit_Entry_Admin {
18 18
 
19
-    protected $loader;
19
+	protected $loader;
20 20
 
21
-    function __construct( GravityView_Edit_Entry $loader ) {
22
-        $this->loader = $loader;
23
-    }
21
+	function __construct( GravityView_Edit_Entry $loader ) {
22
+		$this->loader = $loader;
23
+	}
24 24
 
25
-    function load() {
26
-
27
-        if( !is_admin() ) {
28
-            return;
29
-        }
30
-
31
-        // Add Edit Link as a default field, outside those set in the Gravity Form form
32
-        add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
33
-
34
-        // For the Edit Entry Link, you don't want visible to all users.
35
-        add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
25
+	function load() {
26
+
27
+		if( !is_admin() ) {
28
+			return;
29
+		}
30
+
31
+		// Add Edit Link as a default field, outside those set in the Gravity Form form
32
+		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
33
+
34
+		// For the Edit Entry Link, you don't want visible to all users.
35
+		add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
36 36
 
37
-        // Modify the field options based on the name of the field type
38
-        add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
37
+		// Modify the field options based on the name of the field type
38
+		add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
39 39
 
40
-        // add tooltips
41
-        add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
42
-
43
-        // custom fields' options for zone EDIT
44
-        add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
45
-    }
46
-
47
-    /**
48
-     * Add Edit Link as a default field, outside those set in the Gravity Form form
49
-     * @param array $entry_default_fields Existing fields
50
-     * @param  string|array $form form_ID or form object
51
-     * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
52
-     */
53
-    function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54
-
55
-        if( $zone !== 'edit' ) {
56
-
57
-            $entry_default_fields['edit_link'] = array(
58
-                'label' => __('Edit Entry', 'gravityview'),
59
-                'type' => 'edit_link',
60
-                'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
61
-            );
62
-
63
-        }
64
-
65
-        return $entry_default_fields;
66
-    }
67
-
68
-    /**
69
-     * Change wording for the Edit context to read Entry Creator
70
-     *
71
-     * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
-     * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73
-     * @param  string      $template_id Table slug
74
-     * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75
-     * @param  string      $context     What context are we in? Example: `single` or `directory`
76
-     * @param  string      $input_type  (textarea, list, select, etc.)
77
-     * @return array                   Array of field options with `label`, `value`, `type`, `default` keys
78
-     */
79
-    function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
80
-
81
-        $caps = $visibility_caps;
82
-
83
-        // If we're configuring fields in the edit context, we want a limited selection
84
-        if( $context === 'edit' ) {
85
-
86
-            // Remove other built-in caps.
87
-            unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
88
-
89
-            $caps['read'] = _x('Entry Creator','User capability', 'gravityview');
90
-        }
91
-
92
-        return $caps;
93
-    }
94
-
95
-    /**
96
-     * Add "Edit Link Text" setting to the edit_link field settings
97
-     * @param  [type] $field_options [description]
98
-     * @param  [type] $template_id   [description]
99
-     * @param  [type] $field_id      [description]
100
-     * @param  [type] $context       [description]
101
-     * @param  [type] $input_type    [description]
102
-     * @return [type]                [description]
103
-     */
104
-    function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105
-
106
-        // Always a link, never a filter
107
-        unset( $field_options['show_as_link'], $field_options['search_filter'] );
108
-
109
-        // Edit Entry link should only appear to visitors capable of editing entries
110
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
111
-
112
-        $add_option['edit_link'] = array(
113
-            'type' => 'text',
114
-            'label' => __( 'Edit Link Text', 'gravityview' ),
115
-            'desc' => NULL,
116
-            'value' => __('Edit Entry', 'gravityview'),
117
-            'merge_tags' => true,
118
-        );
119
-
120
-        return array_merge( $add_option, $field_options );
121
-    }
122
-
123
-    /**
124
-     * Add tooltips
125
-     * @param  array $tooltips Existing tooltips
126
-     * @return array           Modified tooltips
127
-     */
128
-    function tooltips( $tooltips ) {
129
-
130
-        $return = $tooltips;
131
-
132
-        $return['allow_edit_cap'] = array(
133
-            'title' => __('Limiting Edit Access', 'gravityview'),
134
-            'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
135
-        );
136
-
137
-        return $return;
138
-    }
139
-
140
-    /**
141
-     * Manipulate the fields' options for the EDIT ENTRY screen
142
-     * @param  [type] $field_options [description]
143
-     * @param  [type] $template_id   [description]
144
-     * @param  [type] $field_id      [description]
145
-     * @param  [type] $context       [description]
146
-     * @param  [type] $input_type    [description]
147
-     * @return [type]                [description]
148
-     */
149
-    function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150
-
151
-        // We only want to modify the settings for the edit context
152
-        if( 'edit' !== $context ) {
153
-
154
-            /**
155
-             * @since 1.8.4
156
-             */
157
-            $field_options['new_window'] = array(
158
-                'type' => 'checkbox',
159
-                'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160
-                'value' => false,
161
-            );
162
-
163
-            return $field_options;
164
-        }
165
-
166
-        //  Entry field is only for logged in users
167
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
168
-
169
-        $add_options = array(
170
-            'allow_edit_cap' => array(
171
-                'type' => 'select',
172
-                'label' => __( 'Make field editable to:', 'gravityview' ),
173
-                'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
174
-                'tooltip' => 'allow_edit_cap',
175
-                'class' => 'widefat',
176
-                'value' => 'read', // Default: entry creator
177
-            ),
178
-        );
179
-
180
-        return array_merge( $field_options, $add_options );
181
-    }
40
+		// add tooltips
41
+		add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
42
+
43
+		// custom fields' options for zone EDIT
44
+		add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
45
+	}
46
+
47
+	/**
48
+	 * Add Edit Link as a default field, outside those set in the Gravity Form form
49
+	 * @param array $entry_default_fields Existing fields
50
+	 * @param  string|array $form form_ID or form object
51
+	 * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
52
+	 */
53
+	function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54
+
55
+		if( $zone !== 'edit' ) {
56
+
57
+			$entry_default_fields['edit_link'] = array(
58
+				'label' => __('Edit Entry', 'gravityview'),
59
+				'type' => 'edit_link',
60
+				'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
61
+			);
62
+
63
+		}
64
+
65
+		return $entry_default_fields;
66
+	}
67
+
68
+	/**
69
+	 * Change wording for the Edit context to read Entry Creator
70
+	 *
71
+	 * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
+	 * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73
+	 * @param  string      $template_id Table slug
74
+	 * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75
+	 * @param  string      $context     What context are we in? Example: `single` or `directory`
76
+	 * @param  string      $input_type  (textarea, list, select, etc.)
77
+	 * @return array                   Array of field options with `label`, `value`, `type`, `default` keys
78
+	 */
79
+	function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
80
+
81
+		$caps = $visibility_caps;
82
+
83
+		// If we're configuring fields in the edit context, we want a limited selection
84
+		if( $context === 'edit' ) {
85
+
86
+			// Remove other built-in caps.
87
+			unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
88
+
89
+			$caps['read'] = _x('Entry Creator','User capability', 'gravityview');
90
+		}
91
+
92
+		return $caps;
93
+	}
94
+
95
+	/**
96
+	 * Add "Edit Link Text" setting to the edit_link field settings
97
+	 * @param  [type] $field_options [description]
98
+	 * @param  [type] $template_id   [description]
99
+	 * @param  [type] $field_id      [description]
100
+	 * @param  [type] $context       [description]
101
+	 * @param  [type] $input_type    [description]
102
+	 * @return [type]                [description]
103
+	 */
104
+	function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105
+
106
+		// Always a link, never a filter
107
+		unset( $field_options['show_as_link'], $field_options['search_filter'] );
108
+
109
+		// Edit Entry link should only appear to visitors capable of editing entries
110
+		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
111
+
112
+		$add_option['edit_link'] = array(
113
+			'type' => 'text',
114
+			'label' => __( 'Edit Link Text', 'gravityview' ),
115
+			'desc' => NULL,
116
+			'value' => __('Edit Entry', 'gravityview'),
117
+			'merge_tags' => true,
118
+		);
119
+
120
+		return array_merge( $add_option, $field_options );
121
+	}
122
+
123
+	/**
124
+	 * Add tooltips
125
+	 * @param  array $tooltips Existing tooltips
126
+	 * @return array           Modified tooltips
127
+	 */
128
+	function tooltips( $tooltips ) {
129
+
130
+		$return = $tooltips;
131
+
132
+		$return['allow_edit_cap'] = array(
133
+			'title' => __('Limiting Edit Access', 'gravityview'),
134
+			'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
135
+		);
136
+
137
+		return $return;
138
+	}
139
+
140
+	/**
141
+	 * Manipulate the fields' options for the EDIT ENTRY screen
142
+	 * @param  [type] $field_options [description]
143
+	 * @param  [type] $template_id   [description]
144
+	 * @param  [type] $field_id      [description]
145
+	 * @param  [type] $context       [description]
146
+	 * @param  [type] $input_type    [description]
147
+	 * @return [type]                [description]
148
+	 */
149
+	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150
+
151
+		// We only want to modify the settings for the edit context
152
+		if( 'edit' !== $context ) {
153
+
154
+			/**
155
+			 * @since 1.8.4
156
+			 */
157
+			$field_options['new_window'] = array(
158
+				'type' => 'checkbox',
159
+				'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160
+				'value' => false,
161
+			);
162
+
163
+			return $field_options;
164
+		}
165
+
166
+		//  Entry field is only for logged in users
167
+		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
168
+
169
+		$add_options = array(
170
+			'allow_edit_cap' => array(
171
+				'type' => 'select',
172
+				'label' => __( 'Make field editable to:', 'gravityview' ),
173
+				'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
174
+				'tooltip' => 'allow_edit_cap',
175
+				'class' => 'widefat',
176
+				'value' => 'read', // Default: entry creator
177
+			),
178
+		);
179
+
180
+		return array_merge( $field_options, $add_options );
181
+	}
182 182
 
183 183
 
184 184
 } // end class
185 185
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     function load() {
26 26
 
27
-        if( !is_admin() ) {
27
+        if ( ! is_admin() ) {
28 28
             return;
29 29
         }
30 30
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
39 39
 
40 40
         // add tooltips
41
-        add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
41
+        add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) );
42 42
 
43 43
         // custom fields' options for zone EDIT
44 44
         add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
      */
53 53
     function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54 54
 
55
-        if( $zone !== 'edit' ) {
55
+        if ( $zone !== 'edit' ) {
56 56
 
57
-            $entry_default_fields['edit_link'] = array(
58
-                'label' => __('Edit Entry', 'gravityview'),
57
+            $entry_default_fields[ 'edit_link' ] = array(
58
+                'label' => __( 'Edit Entry', 'gravityview' ),
59 59
                 'type' => 'edit_link',
60
-                'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
60
+                'desc'	=> __( 'A link to edit the entry. Visible based on View settings.', 'gravityview' ),
61 61
             );
62 62
 
63 63
         }
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
         $caps = $visibility_caps;
82 82
 
83 83
         // If we're configuring fields in the edit context, we want a limited selection
84
-        if( $context === 'edit' ) {
84
+        if ( $context === 'edit' ) {
85 85
 
86 86
             // Remove other built-in caps.
87
-            unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
87
+            unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] );
88 88
 
89
-            $caps['read'] = _x('Entry Creator','User capability', 'gravityview');
89
+            $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' );
90 90
         }
91 91
 
92 92
         return $caps;
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
     function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105 105
 
106 106
         // Always a link, never a filter
107
-        unset( $field_options['show_as_link'], $field_options['search_filter'] );
107
+        unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] );
108 108
 
109 109
         // Edit Entry link should only appear to visitors capable of editing entries
110
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
110
+        unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] );
111 111
 
112
-        $add_option['edit_link'] = array(
112
+        $add_option[ 'edit_link' ] = array(
113 113
             'type' => 'text',
114 114
             'label' => __( 'Edit Link Text', 'gravityview' ),
115 115
             'desc' => NULL,
116
-            'value' => __('Edit Entry', 'gravityview'),
116
+            'value' => __( 'Edit Entry', 'gravityview' ),
117 117
             'merge_tags' => true,
118 118
         );
119 119
 
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
 
130 130
         $return = $tooltips;
131 131
 
132
-        $return['allow_edit_cap'] = array(
133
-            'title' => __('Limiting Edit Access', 'gravityview'),
134
-            'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
132
+        $return[ 'allow_edit_cap' ] = array(
133
+            'title' => __( 'Limiting Edit Access', 'gravityview' ),
134
+            'value' => __( 'Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview' ),
135 135
         );
136 136
 
137 137
         return $return;
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
     function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150 150
 
151 151
         // We only want to modify the settings for the edit context
152
-        if( 'edit' !== $context ) {
152
+        if ( 'edit' !== $context ) {
153 153
 
154 154
             /**
155 155
              * @since 1.8.4
156 156
              */
157
-            $field_options['new_window'] = array(
157
+            $field_options[ 'new_window' ] = array(
158 158
                 'type' => 'checkbox',
159 159
                 'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160 160
                 'value' => false,
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         }
165 165
 
166 166
         //  Entry field is only for logged in users
167
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
167
+        unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] );
168 168
 
169 169
         $add_options = array(
170 170
             'allow_edit_cap' => array(
Please login to merge, or discard this patch.