Completed
Branch master (3ac4b1)
by Zack
04:30
created
includes/class-data.php 2 patches
Doc Comments   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -113,6 +113,9 @@  discard block
 block discarded – undo
113 113
 		return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids;
114 114
 	}
115 115
 
116
+	/**
117
+	 * @return GravityView_View_Data
118
+	 */
116 119
 	public static function getInstance( $passed_post = NULL ) {
117 120
 
118 121
 		if( empty( self::$instance ) ) {
@@ -152,7 +155,7 @@  discard block
 block discarded – undo
152 155
 	 * within the WordPress database.
153 156
 	 *
154 157
 	 * @see http://tommcfarlin.com/wordpress-post-exists-by-id/ Fastest check available
155
-	 * @param    int    $id    The ID of the post to check
158
+	 * @param integer $view_id
156 159
 	 * @return   bool          True if the post exists; otherwise, false.
157 160
 	 * @since    1.0.0
158 161
 	 */
@@ -299,7 +302,7 @@  discard block
 block discarded – undo
299 302
 	 *
300 303
 	 * @access public
301 304
 	 * @param array $properties
302
-	 * @return void|boolean (field should be hidden) or false (field should be presented)
305
+	 * @return boolean (field should be hidden) or false (field should be presented)
303 306
 	 */
304 307
 	private function hide_field_check_conditions( $properties ) {
305 308
 
Please login to merge, or discard this patch.
Spacing   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /** If this file is called directly, abort. */
4
-if ( ! defined( 'ABSPATH' ) ) {
4
+if (!defined('ABSPATH')) {
5 5
 	die;
6 6
 }
7 7
 
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 	 *
16 16
 	 * @param null $passed_post
17 17
 	 */
18
-	private function __construct( $passed_post = NULL ) {
18
+	private function __construct($passed_post = NULL) {
19 19
 
20
-		if( !empty( $passed_post ) ) {
20
+		if (!empty($passed_post)) {
21 21
 
22
-			$id_or_id_array = $this->maybe_get_view_id( $passed_post );
22
+			$id_or_id_array = $this->maybe_get_view_id($passed_post);
23 23
 
24
-			if( !empty( $id_or_id_array ) ) {
25
-				$this->add_view( $id_or_id_array );
24
+			if (!empty($id_or_id_array)) {
25
+				$this->add_view($id_or_id_array);
26 26
 			}
27 27
 		}
28 28
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	public function has_multiple_views() {
35 35
 
36 36
 		//multiple views
37
-		return count( $this->get_views() ) > 1 ? true : false;
37
+		return count($this->get_views()) > 1 ? true : false;
38 38
 	}
39 39
 
40 40
 
@@ -52,37 +52,37 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return int|null|array ID of the View. If there are multiple views in the content, array of IDs parsed.
54 54
 	 */
55
-	public function maybe_get_view_id( $passed_post ) {
55
+	public function maybe_get_view_id($passed_post) {
56 56
 
57 57
 		$ids = array();
58 58
 
59
-		if( ! empty( $passed_post ) ) {
59
+		if (!empty($passed_post)) {
60 60
 
61
-			if( is_numeric( $passed_post ) ) {
62
-				$passed_post = get_post( $passed_post );
61
+			if (is_numeric($passed_post)) {
62
+				$passed_post = get_post($passed_post);
63 63
 			}
64 64
 
65 65
 			// Convert WP_Posts into WP_Posts[] array
66
-			if( $passed_post instanceof WP_Post ) {
67
-				$passed_post = array( $passed_post );
66
+			if ($passed_post instanceof WP_Post) {
67
+				$passed_post = array($passed_post);
68 68
 			}
69 69
 
70
-			if( is_array( $passed_post ) ) {
70
+			if (is_array($passed_post)) {
71 71
 
72
-				foreach ( $passed_post as &$post) {
73
-					if( ( get_post_type( $post ) === 'gravityview' ) ) {
72
+				foreach ($passed_post as &$post) {
73
+					if ((get_post_type($post) === 'gravityview')) {
74 74
 						$ids[] = $post->ID;
75
-					} else{
75
+					} else {
76 76
 						// Parse the Post Content
77
-						$id = $this->parse_post_content( $post->post_content );
78
-						if( $id ) {
79
-							$ids = array_merge( $ids, (array) $id );
77
+						$id = $this->parse_post_content($post->post_content);
78
+						if ($id) {
79
+							$ids = array_merge($ids, (array)$id);
80 80
 						}
81 81
 
82 82
 						// Parse the Post Meta
83
-						$id = $this->parse_post_meta( $post->ID );
84
-						if( $id ) {
85
-							$ids = array_merge( $ids, (array) $id );
83
+						$id = $this->parse_post_meta($post->ID);
84
+						if ($id) {
85
+							$ids = array_merge($ids, (array)$id);
86 86
 						}
87 87
 					}
88 88
 
@@ -90,33 +90,33 @@  discard block
 block discarded – undo
90 90
 
91 91
 			} else {
92 92
 
93
-				if ( is_string( $passed_post ) ) {
93
+				if (is_string($passed_post)) {
94 94
 
95
-					$id = $this->parse_post_content( $passed_post );
96
-					if( $id ) {
97
-						$ids = array_merge( $ids, (array) $id );
95
+					$id = $this->parse_post_content($passed_post);
96
+					if ($id) {
97
+						$ids = array_merge($ids, (array)$id);
98 98
 					}
99 99
 
100 100
 				} else {
101
-					$id = $this->get_id_from_atts( $passed_post );
102
-					$ids[] = intval( $id );
101
+					$id = $this->get_id_from_atts($passed_post);
102
+					$ids[] = intval($id);
103 103
 				}
104 104
 			}
105 105
 		}
106 106
 
107
-		if( empty($ids) ) {
107
+		if (empty($ids)) {
108 108
 			return NULL;
109 109
 		}
110 110
 
111 111
 		// If it's just one ID, return that.
112 112
 		// Otherwise, return array of IDs
113
-		return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids;
113
+		return (sizeof($ids) === 1) ? $ids[0] : $ids;
114 114
 	}
115 115
 
116
-	public static function getInstance( $passed_post = NULL ) {
116
+	public static function getInstance($passed_post = NULL) {
117 117
 
118
-		if( empty( self::$instance ) ) {
119
-			self::$instance = new GravityView_View_Data( $passed_post );
118
+		if (empty(self::$instance)) {
119
+			self::$instance = new GravityView_View_Data($passed_post);
120 120
 		}
121 121
 
122 122
 		return self::$instance;
@@ -126,25 +126,25 @@  discard block
 block discarded – undo
126 126
 		return $this->views;
127 127
 	}
128 128
 
129
-	function get_view( $view_id, $atts = NULL ) {
129
+	function get_view($view_id, $atts = NULL) {
130 130
 
131
-		if( ! is_numeric( $view_id) ) {
132
-			do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) );
131
+		if (!is_numeric($view_id)) {
132
+			do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id));
133 133
 			return false;
134 134
 		}
135 135
 
136 136
 		// Backup: the view hasn't been fetched yet. Doing it now.
137
-		if ( ! isset( $this->views[ $view_id ] ) ) {
138
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) );
139
-			return $this->add_view( $view_id, $atts );
137
+		if (!isset($this->views[$view_id])) {
138
+			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id));
139
+			return $this->add_view($view_id, $atts);
140 140
 		}
141 141
 
142
-		if ( empty( $this->views[ $view_id ] ) ) {
143
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) );
142
+		if (empty($this->views[$view_id])) {
143
+			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id));
144 144
 			return false;
145 145
 		}
146 146
 
147
-		return $this->views[ $view_id ];
147
+		return $this->views[$view_id];
148 148
 	}
149 149
 
150 150
 	/**
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 	 * @return   bool          True if the post exists; otherwise, false.
157 157
 	 * @since    1.0.0
158 158
 	 */
159
-	function view_exists( $view_id ) {
160
-		return is_string( get_post_status( $view_id ) );
159
+	function view_exists($view_id) {
160
+		return is_string(get_post_status($view_id));
161 161
 	}
162 162
 
163 163
 	/**
@@ -168,56 +168,56 @@  discard block
 block discarded – undo
168 168
 	 * @param array|string $atts Combine other attributes (eg. from shortcode) with the view settings (optional)
169 169
 	 * @return type
170 170
 	 */
171
-	function add_view( $view_id, $atts = NULL ) {
171
+	function add_view($view_id, $atts = NULL) {
172 172
 
173 173
 		// Handle array of IDs
174
-		if( is_array( $view_id ) ) {
175
-			foreach( $view_id as $id ) {
174
+		if (is_array($view_id)) {
175
+			foreach ($view_id as $id) {
176 176
 
177
-				$this->add_view( $id, $atts );
177
+				$this->add_view($id, $atts);
178 178
 			}
179 179
 
180 180
 			return $this->views;
181 181
 		}
182 182
 
183 183
 		// The view has been set already; returning stored view.
184
-		if ( !empty( $this->views[ $view_id ] ) ) {
185
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) );
186
-			return $this->views[ $view_id ];
184
+		if (!empty($this->views[$view_id])) {
185
+			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id));
186
+			return $this->views[$view_id];
187 187
 		}
188 188
 
189
-		if( ! $this->view_exists( $view_id ) ) {
190
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) );
189
+		if (!$this->view_exists($view_id)) {
190
+			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id));
191 191
 			return false;
192 192
 		}
193 193
 
194
-		$form_id = gravityview_get_form_id( $view_id );
194
+		$form_id = gravityview_get_form_id($view_id);
195 195
 
196
-		if( empty( $form_id ) ) {
196
+		if (empty($form_id)) {
197 197
 
198
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) );
198
+			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id));
199 199
 
200 200
 			return false;
201 201
 		}
202 202
 
203 203
 		// Get the settings for the View ID
204
-		$view_settings = gravityview_get_template_settings( $view_id );
204
+		$view_settings = gravityview_get_template_settings($view_id);
205 205
 
206
-		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings );
206
+		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings);
207 207
 
208 208
 		// Merge the view settings with the defaults
209
-		$view_defaults = wp_parse_args( $view_settings, self::get_default_args() );
209
+		$view_defaults = wp_parse_args($view_settings, self::get_default_args());
210 210
 
211
-		do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults );
211
+		do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults);
212 212
 
213
-		if( ! empty( $atts ) && is_array( $atts ) ) {
213
+		if (!empty($atts) && is_array($atts)) {
214 214
 
215
-			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging  with the $view_defaults', $atts );
215
+			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging  with the $view_defaults', $atts);
216 216
 
217 217
 			// Get the settings from the shortcode and merge them with defaults.
218
-			$atts = shortcode_atts( $view_defaults, $atts );
218
+			$atts = shortcode_atts($view_defaults, $atts);
219 219
 
220
-			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging  with the $view_defaults', $atts );
220
+			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging  with the $view_defaults', $atts);
221 221
 
222 222
 		} else {
223 223
 
@@ -226,24 +226,24 @@  discard block
 block discarded – undo
226 226
 
227 227
 		}
228 228
 
229
-		unset( $atts['id'], $view_defaults, $view_settings );
229
+		unset($atts['id'], $view_defaults, $view_settings);
230 230
 
231 231
 		$data = array(
232 232
 			'id' => $view_id,
233 233
 			'view_id' => $view_id,
234 234
 			'form_id' => $form_id,
235
-			'template_id' => gravityview_get_template_id( $view_id ),
235
+			'template_id' => gravityview_get_template_id($view_id),
236 236
 			'atts' => $atts,
237
-			'fields' => $this->get_fields( $view_id ),
238
-			'widgets' => get_post_meta( $view_id, '_gravityview_directory_widgets', true ),
239
-			'form' => gravityview_get_form( $form_id ),
237
+			'fields' => $this->get_fields($view_id),
238
+			'widgets' => get_post_meta($view_id, '_gravityview_directory_widgets', true),
239
+			'form' => gravityview_get_form($form_id),
240 240
 		);
241 241
 
242
-		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data );
242
+		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data);
243 243
 
244
-		$this->views[ $view_id ] = $data;
244
+		$this->views[$view_id] = $data;
245 245
 
246
-		return $this->views[ $view_id ];
246
+		return $this->views[$view_id];
247 247
 	}
248 248
 
249 249
 	/**
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
 	 * @param  int $view_id View ID
254 254
 	 * @return array          Array of fields as passed by `gravityview_get_directory_fields()`
255 255
 	 */
256
-	function get_fields( $view_id ) {
256
+	function get_fields($view_id) {
257 257
 
258
-		$dir_fields = gravityview_get_directory_fields( $view_id );
259
-		do_action( 'gravityview_log_debug', '[render_view] Fields: ', $dir_fields );
258
+		$dir_fields = gravityview_get_directory_fields($view_id);
259
+		do_action('gravityview_log_debug', '[render_view] Fields: ', $dir_fields);
260 260
 
261 261
 		// remove fields according to visitor visibility permissions (if logged-in)
262
-		$dir_fields = $this->filter_fields( $dir_fields );
263
-		do_action( 'gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields );
262
+		$dir_fields = $this->filter_fields($dir_fields);
263
+		do_action('gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields);
264 264
 
265 265
 		return $dir_fields;
266 266
 	}
@@ -272,18 +272,18 @@  discard block
 block discarded – undo
272 272
 	 * @param array $dir_fields
273 273
 	 * @return array
274 274
 	 */
275
-	private function filter_fields( $dir_fields ) {
275
+	private function filter_fields($dir_fields) {
276 276
 
277
-		if( empty( $dir_fields ) || !is_array( $dir_fields ) ) {
277
+		if (empty($dir_fields) || !is_array($dir_fields)) {
278 278
 			return $dir_fields;
279 279
 		}
280 280
 
281
-		foreach( $dir_fields as $area => $fields ) {
281
+		foreach ($dir_fields as $area => $fields) {
282 282
 
283
-			foreach( (array)$fields as $uniqid => $properties ) {
283
+			foreach ((array)$fields as $uniqid => $properties) {
284 284
 
285
-				if( $this->hide_field_check_conditions( $properties ) ) {
286
-					unset( $dir_fields[ $area ][ $uniqid ] );
285
+				if ($this->hide_field_check_conditions($properties)) {
286
+					unset($dir_fields[$area][$uniqid]);
287 287
 				}
288 288
 
289 289
 			}
@@ -301,31 +301,31 @@  discard block
 block discarded – undo
301 301
 	 * @param array $properties
302 302
 	 * @return void|boolean (field should be hidden) or false (field should be presented)
303 303
 	 */
304
-	private function hide_field_check_conditions( $properties ) {
304
+	private function hide_field_check_conditions($properties) {
305 305
 
306 306
 		// logged-in visibility
307
-		if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) {
307
+		if (!empty($properties['only_loggedin']) && !GVCommon::has_cap($properties['only_loggedin_cap'])) {
308 308
 			return true;
309 309
 		}
310 310
 
311 311
 		return false;
312 312
 	}
313 313
 
314
-	function get_id_from_atts( $atts ) {
314
+	function get_id_from_atts($atts) {
315 315
 
316
-		$atts = is_array( $atts ) ? $atts : shortcode_parse_atts( $atts );
316
+		$atts = is_array($atts) ? $atts : shortcode_parse_atts($atts);
317 317
 
318 318
 		// Get the settings from the shortcode and merge them with defaults.
319
-		$atts = wp_parse_args( $atts, self::get_default_args() );
319
+		$atts = wp_parse_args($atts, self::get_default_args());
320 320
 
321
-		$view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL;
321
+		$view_id = !empty($atts['view_id']) ? (int)$atts['view_id'] : NULL;
322 322
 
323
-		if( empty( $view_id ) && !empty( $atts['id'] ) ) {
323
+		if (empty($view_id) && !empty($atts['id'])) {
324 324
 			$view_id = (int)$atts['id'];
325 325
 		}
326 326
 
327
-		if( empty( $view_id ) ) {
328
-			do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts );
327
+		if (empty($view_id)) {
328
+			do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts);
329 329
 			return;
330 330
 		}
331 331
 
@@ -341,50 +341,50 @@  discard block
 block discarded – undo
341 341
 	 * @param  string $content $post->post_content content
342 342
 	 * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, NULL
343 343
 	 */
344
-	function parse_post_content( $content ) {
344
+	function parse_post_content($content) {
345 345
 
346 346
 		/**
347 347
 		 * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin
348 348
 		 * @since 1.6
349 349
 		 */
350
-		if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) {
350
+		if (!shortcode_exists('gravityview') && class_exists('GravityView_Shortcode')) {
351 351
 			new GravityView_Shortcode;
352 352
 		}
353 353
 
354
-		$shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' );
354
+		$shortcodes = gravityview_has_shortcode_r($content, 'gravityview');
355 355
 
356
-		if( empty( $shortcodes ) ) {
356
+		if (empty($shortcodes)) {
357 357
 			return NULL;
358 358
 		}
359 359
 
360
-		do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes );
360
+		do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes);
361 361
 
362 362
 		$ids = array();
363 363
 
364 364
 		foreach ($shortcodes as $key => $shortcode) {
365 365
 
366
-			$args = shortcode_parse_atts( $shortcode[3] );
366
+			$args = shortcode_parse_atts($shortcode[3]);
367 367
 
368
-			if( empty( $args['id'] ) ) {
369
-				do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode );
368
+			if (empty($args['id'])) {
369
+				do_action('gravityview_log_error', sprintf('GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID), $shortcode);
370 370
 				continue;
371 371
 			}
372 372
 
373
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args );
373
+			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args);
374 374
 
375 375
 			// Store the View to the object for later fetching.
376
-			$this->add_view( $args['id'], $args );
376
+			$this->add_view($args['id'], $args);
377 377
 
378 378
 			$ids[] = $args['id'];
379 379
 		}
380 380
 
381
-		if( empty($ids) ) {
381
+		if (empty($ids)) {
382 382
 			return NULL;
383 383
 		}
384 384
 
385 385
 		// If it's just one ID, return that.
386 386
 		// Otherwise, return array of IDs
387
-		return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids;
387
+		return (sizeof($ids) === 1) ? $ids[0] : $ids;
388 388
 
389 389
 	}
390 390
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	 * @param int $post_id WP_Post ID
396 396
 	 * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, or meta not parsed, NULL
397 397
 	 */
398
-	private function parse_post_meta( $post_id ) {
398
+	private function parse_post_meta($post_id) {
399 399
 
400 400
 		/**
401 401
 		 * @filter `gravityview/data/parse/meta_keys` Define meta keys to parse to check for GravityView shortcode content
@@ -403,32 +403,32 @@  discard block
 block discarded – undo
403 403
 		 * @param[in,out] array $meta_keys Array of key values to check. If empty, do not check. Default: empty array
404 404
 		 * @param[in] int $post_id ID of the post being checked
405 405
 		 */
406
-		$meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id );
406
+		$meta_keys = (array)apply_filters('gravityview/data/parse/meta_keys', array(), $post_id);
407 407
 
408
-		if( empty( $meta_keys ) ) {
408
+		if (empty($meta_keys)) {
409 409
 			return NULL;
410 410
 		}
411 411
 
412
-		do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys );
412
+		do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys);
413 413
 
414 414
 		$meta_content = '';
415 415
 
416
-		foreach( $meta_keys as $key ) {
417
-			$meta = get_post_meta( $post_id, $key , true );
418
-			if( ! is_string( $meta ) ) {
416
+		foreach ($meta_keys as $key) {
417
+			$meta = get_post_meta($post_id, $key, true);
418
+			if (!is_string($meta)) {
419 419
 				continue;
420 420
 			}
421
-			$meta_content .= $meta . ' ';
421
+			$meta_content .= $meta.' ';
422 422
 		}
423 423
 
424
-		if( empty( $meta_content ) ) {
425
-			do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys );
424
+		if (empty($meta_content)) {
425
+			do_action('gravityview_log_error', sprintf('GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id), $meta_keys);
426 426
 			return NULL;
427 427
 		}
428 428
 
429
-		do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content );
429
+		do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content);
430 430
 
431
-		return $this->parse_post_content( $meta_content );
431
+		return $this->parse_post_content($meta_content);
432 432
 
433 433
 	}
434 434
 
@@ -444,61 +444,61 @@  discard block
 block discarded – undo
444 444
 	 *
445 445
 	 * @return bool|WP_Error If valid, returns true. If invalid, returns WP_Error containing error message.
446 446
 	 */
447
-	public static function is_valid_embed_id( $post_id = '', $view_id = '', $empty_is_valid = true ) {
447
+	public static function is_valid_embed_id($post_id = '', $view_id = '', $empty_is_valid = true) {
448 448
 
449 449
 		$message = NULL;
450 450
 
451 451
 		// Not invalid if not set!
452
-		if( empty( $post_id ) || empty( $view_id ) ) {
452
+		if (empty($post_id) || empty($view_id)) {
453 453
 
454
-			if( $empty_is_valid ) {
454
+			if ($empty_is_valid) {
455 455
 				return true;
456 456
 			}
457 457
 
458
-			$message = esc_html__( 'The ID is required.', 'gravityview' );
458
+			$message = esc_html__('The ID is required.', 'gravityview');
459 459
 		}
460 460
 
461
-		if( ! $message ) {
462
-			$status = get_post_status( $post_id );
461
+		if (!$message) {
462
+			$status = get_post_status($post_id);
463 463
 
464 464
 			// Nothing exists with that post ID.
465
-			if ( ! is_numeric( $post_id ) ) {
466
-				$message = esc_html__( 'You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview' );
465
+			if (!is_numeric($post_id)) {
466
+				$message = esc_html__('You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview');
467 467
 
468 468
 				// @todo Convert to generic article about Embed IDs
469
-				$message .= ' ' . gravityview_get_link( 'http://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more&hellip;', 'gravityview' ), 'target=_blank' );
469
+				$message .= ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more&hellip;', 'gravityview'), 'target=_blank');
470 470
 			}
471 471
 		}
472 472
 
473
-		if( ! $message ) {
473
+		if (!$message) {
474 474
 
475 475
 			// Nothing exists with that post ID.
476
-			if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) {
477
-				$message = esc_html__( 'There is no post or page with that ID.', 'gravityview' );
476
+			if (empty($status) || in_array($status, array('revision', 'attachment'))) {
477
+				$message = esc_html__('There is no post or page with that ID.', 'gravityview');
478 478
 			}
479 479
 
480 480
 		}
481 481
 
482
-		if( ! $message ) {
483
-			$view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id );
482
+		if (!$message) {
483
+			$view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id($post_id);
484 484
 
485 485
 			// The post or page specified does not contain the shortcode.
486
-			if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) {
487
-				$message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' );
486
+			if (false === in_array($view_id, (array)$view_ids_in_post)) {
487
+				$message = sprintf(esc_html__('The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview'), '<br /><code>[gravityview id="'.intval($view_id).'"]</code>');
488 488
 			}
489 489
 		}
490 490
 
491
-		if( ! $message ) {
491
+		if (!$message) {
492 492
 
493 493
 			// It's a View
494
-			if( 'gravityview' === get_post_type( $post_id ) ) {
495
-				$message = esc_html__( 'The ID is already a View.', 'gravityview' );;
494
+			if ('gravityview' === get_post_type($post_id)) {
495
+				$message = esc_html__('The ID is already a View.', 'gravityview'); ;
496 496
 			}
497 497
 
498 498
 		}
499 499
 
500
-		if( $message ) {
501
-			return new WP_Error( 'invalid_embed_id', $message );
500
+		if ($message) {
501
+			return new WP_Error('invalid_embed_id', $message);
502 502
 		}
503 503
 
504 504
 		return true;
@@ -510,13 +510,13 @@  discard block
 block discarded – undo
510 510
 	 * @param  boolean $with_details Include details
511 511
 	 * @return mixed|array                If using $with_details, return array. Otherwise, mixed.
512 512
 	 */
513
-	public static function get_default_arg( $key, $with_details = false ) {
513
+	public static function get_default_arg($key, $with_details = false) {
514 514
 
515
-		$args = self::get_default_args( $with_details );
515
+		$args = self::get_default_args($with_details);
516 516
 
517
-		if( !isset( $args[ $key ] ) ) { return NULL; }
517
+		if (!isset($args[$key])) { return NULL; }
518 518
 
519
-		return $args[ $key ];
519
+		return $args[$key];
520 520
 	}
521 521
 
522 522
 	/**
@@ -535,13 +535,13 @@  discard block
 block discarded – undo
535 535
 	 *      @param[out] array  $options Array of values to use when generating select, multiselect, radio, or checkboxes fields
536 536
 	 *      @param[out] boolean $full_width True: Display the input and label together when rendering. False: Display label and input in separate columns when rendering.
537 537
 	 */
538
-	public static function get_default_args( $with_details = false, $group = NULL ) {
538
+	public static function get_default_args($with_details = false, $group = NULL) {
539 539
 
540 540
 		/**
541 541
 		 * @filter `gravityview_default_args` Modify the default settings for new Views
542 542
 		 * @param[in,out] array $default_args Array of default args.
543 543
 		 */
544
-		$default_settings = apply_filters( 'gravityview_default_args', array(
544
+		$default_settings = apply_filters('gravityview_default_args', array(
545 545
 			'id' => array(
546 546
 				'label' => __('View ID', 'gravityview'),
547 547
 				'type' => 'number',
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 				'show_in_shortcode' => true,
560 560
 			),
561 561
 			'lightbox' => array(
562
-				'label' => __( 'Enable lightbox for images', 'gravityview' ),
562
+				'label' => __('Enable lightbox for images', 'gravityview'),
563 563
 				'type' => 'checkbox',
564 564
 				'group'	=> 'default',
565 565
 				'value' => 1,
@@ -567,29 +567,29 @@  discard block
 block discarded – undo
567 567
 				'show_in_shortcode' => true,
568 568
 			),
569 569
 			'show_only_approved' => array(
570
-				'label' => __( 'Show only approved entries', 'gravityview' ),
570
+				'label' => __('Show only approved entries', 'gravityview'),
571 571
 				'type' => 'checkbox',
572 572
 				'group'	=> 'default',
573 573
 				'value' => 0,
574 574
 				'show_in_shortcode' => false,
575 575
 			),
576 576
 			'hide_until_searched' => array(
577
-				'label' => __( 'Hide View data until search is performed', 'gravityview' ),
577
+				'label' => __('Hide View data until search is performed', 'gravityview'),
578 578
 				'type' => 'checkbox',
579 579
 				'group'	=> 'default',
580
-				'tooltip' => __( 'When enabled it will only show any View entries after a search is performed.', 'gravityview' ),
580
+				'tooltip' => __('When enabled it will only show any View entries after a search is performed.', 'gravityview'),
581 581
 				'value' => 0,
582 582
 				'show_in_shortcode' => false,
583 583
 			),
584 584
 			'hide_empty' => array(
585
-				'label' 	=> __( 'Hide empty fields', 'gravityview' ),
585
+				'label' 	=> __('Hide empty fields', 'gravityview'),
586 586
 				'group'	=> 'default',
587 587
 				'type'	=> 'checkbox',
588 588
 				'value' => 1,
589 589
 				'show_in_shortcode' => false,
590 590
 			),
591 591
 			'user_edit' => array(
592
-				'label'	=> __( 'Allow User Edit', 'gravityview' ),
592
+				'label'	=> __('Allow User Edit', 'gravityview'),
593 593
 				'group'	=> 'default',
594 594
 				'desc'	=> __('Allow logged-in users to edit entries they created.', 'gravityview'),
595 595
 				'value'	=> 0,
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 				'show_in_shortcode' => true,
599 599
 			),
600 600
 			'user_delete' => array(
601
-				'label'	=> __( 'Allow User Delete', 'gravityview' ),
601
+				'label'	=> __('Allow User Delete', 'gravityview'),
602 602
 				'group'	=> 'default',
603 603
 				'desc'	=> __('Allow logged-in users to delete entries they created.', 'gravityview'),
604 604
 				'value'	=> 0,
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
 				'value' => '',
613 613
 				'group'	=> 'sort',
614 614
 				'options' => array(
615
-					'' => __( 'Default', 'gravityview'),
616
-					'date_created' => __( 'Date Created', 'gravityview'),
615
+					'' => __('Default', 'gravityview'),
616
+					'date_created' => __('Date Created', 'gravityview'),
617 617
 				),
618 618
 				'show_in_shortcode' => true,
619 619
 			),
@@ -630,19 +630,19 @@  discard block
 block discarded – undo
630 630
 				'show_in_shortcode' => true,
631 631
 			),
632 632
 			'sort_columns' => array(
633
-				'label' 	=> __( 'Enable sorting by column', 'gravityview' ),
634
-				'left_label' => __( 'Column Sorting', 'gravityview' ),
633
+				'label' 	=> __('Enable sorting by column', 'gravityview'),
634
+				'left_label' => __('Column Sorting', 'gravityview'),
635 635
 				'type' => 'checkbox',
636 636
 				'value' => false,
637 637
 				'group'	=> 'sort',
638 638
 				'tooltip' => NULL,
639 639
 				'show_in_shortcode' => true,
640
-				'show_in_template' => array( 'default_table' ),
640
+				'show_in_template' => array('default_table'),
641 641
 			),
642 642
 			'start_date' => array(
643 643
 				'label' 	=> __('Filter by Start Date', 'gravityview'),
644 644
 				'class'	=> 'gv-datepicker',
645
-				'desc'	=> __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ),
645
+				'desc'	=> __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview'),
646 646
 				'type' => 'text',
647 647
 				'value' => '',
648 648
 				'group'	=> 'filter',
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 			'end_date' => array(
652 652
 				'label' 	=> __('Filter by End Date', 'gravityview'),
653 653
 				'class'	=> 'gv-datepicker',
654
-				'desc'	=> __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ),
654
+				'desc'	=> __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview'),
655 655
 				'type' => 'text',
656 656
 				'value' => '',
657 657
 				'group'	=> 'filter',
@@ -711,12 +711,12 @@  discard block
 block discarded – undo
711 711
 		));
712 712
 
713 713
 		// By default, we only want the key => value pairing, not the whole array.
714
-		if( empty( $with_details ) ) {
714
+		if (empty($with_details)) {
715 715
 
716 716
 			$defaults = array();
717 717
 
718
-			foreach( $default_settings as $key => $value ) {
719
-				$defaults[ $key ] = $value['value'];
718
+			foreach ($default_settings as $key => $value) {
719
+				$defaults[$key] = $value['value'];
720 720
 			}
721 721
 
722 722
 			return $defaults;
@@ -729,9 +729,9 @@  discard block
 block discarded – undo
729 729
 
730 730
 				// If the $group argument is set for the method,
731 731
 				// ignore any settings that aren't in that group.
732
-				if( !empty( $group ) && is_string( $group ) ) {
733
-					if( empty( $value['group'] ) || $value['group'] !== $group ) {
734
-						unset( $default_settings[ $key ] );
732
+				if (!empty($group) && is_string($group)) {
733
+					if (empty($value['group']) || $value['group'] !== $group) {
734
+						unset($default_settings[$key]);
735 735
 					}
736 736
 				}
737 737
 
Please login to merge, or discard this patch.
includes/class-debug-bar.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 
49 49
 	/**
50 50
 	 * Should the panel be shown? If there are notices or warnings, yes.
51
-	 * @return boolean true: show panel; false: hide panel
51
+	 * @return boolean|null true: show panel; false: hide panel
52 52
 	 */
53 53
 	function set_visible( $visible = '' ) {
54 54
 		$this->_visible = ( count( $this->get_notices() ) || count( $this->get_warnings() ) );
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
 	function init() {
22 22
 
23 23
 		$icon = is_admin() ? '<i class="icon gv-icon-astronaut-head"></i>&nbsp;' : NULL;
24
-		$this->title( $icon . __('GravityView', 'gravityview') );
24
+		$this->title($icon.__('GravityView', 'gravityview'));
25 25
 	}
26 26
 
27 27
 	function get_warnings() {
28 28
 
29
-		if( is_null( $this->warnings ) ) {
29
+		if (is_null($this->warnings)) {
30 30
 			$this->warnings = GravityView_Logging::get_errors();
31 31
 		}
32 32
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 	function get_notices() {
37 37
 
38
-		if( is_null( $this->notices ) ) {
38
+		if (is_null($this->notices)) {
39 39
 			$this->notices = GravityView_Logging::get_notices();
40 40
 		}
41 41
 
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 * Should the panel be shown? If there are notices or warnings, yes.
51 51
 	 * @return boolean true: show panel; false: hide panel
52 52
 	 */
53
-	function set_visible( $visible = '' ) {
54
-		$this->_visible = ( count( $this->get_notices() ) || count( $this->get_warnings() ) );
53
+	function set_visible($visible = '') {
54
+		$this->_visible = (count($this->get_notices()) || count($this->get_warnings()));
55 55
 	}
56 56
 
57 57
 	/**
@@ -83,42 +83,42 @@  discard block
 block discarded – undo
83 83
 		</style>
84 84
 		<div id='debug-bar-gravityview'>";
85 85
 
86
-		$output .= '<img src="'.plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ).'" class="alignright" alt="" width="100" height="132" />';
86
+		$output .= '<img src="'.plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE).'" class="alignright" alt="" width="100" height="132" />';
87 87
 
88 88
 
89 89
 		$warnings = $this->get_warnings();
90 90
 		$notices = $this->get_notices();
91 91
 
92
-		if(count($warnings)) {
92
+		if (count($warnings)) {
93 93
 			$output .= '<h3><span>'.__('Warnings', 'gravityview').'</span></h3>';
94 94
 			$output .= '<ol>';
95
-			foreach ( $warnings as $key => $notice) {
96
-				if(empty($notice['message'])) { continue; }
97
-				$output .= '<li><a href="#'.sanitize_html_class( 'gv-warning-' . $key ).'">'.strip_tags($notice['message']).'</a></li>';
95
+			foreach ($warnings as $key => $notice) {
96
+				if (empty($notice['message'])) { continue; }
97
+				$output .= '<li><a href="#'.sanitize_html_class('gv-warning-'.$key).'">'.strip_tags($notice['message']).'</a></li>';
98 98
 			}
99 99
 			$output .= '</ol><hr />';
100 100
 		}
101
-		if(count($notices)) {
101
+		if (count($notices)) {
102 102
 			$output .= '<h3><span>'.__('Logs', 'gravityview').'</span></h3>';
103 103
 			$output .= '<ol>';
104
-			foreach ( $notices as $key => $notice) {
105
-				if(empty($notice['message'])) { continue; }
106
-				$output .= '<li><a href="#'.sanitize_html_class( 'gv-notice-' . $key ).'">'.strip_tags($notice['message']).'</a></li>';
104
+			foreach ($notices as $key => $notice) {
105
+				if (empty($notice['message'])) { continue; }
106
+				$output .= '<li><a href="#'.sanitize_html_class('gv-notice-'.$key).'">'.strip_tags($notice['message']).'</a></li>';
107 107
 			}
108 108
 			$output .= '</ol><hr />';
109 109
 		}
110 110
 
111
-		if ( count( $warnings ) ) {
111
+		if (count($warnings)) {
112 112
 			$output .= '<h3>Warnings</h3>';
113 113
 			$output .= '<ol class="debug-bar-php-list">';
114
-			foreach ( $warnings as $key => $notice) { $output .= $this->render_item( $notice, 'gv-warning-'  . $key ); }
114
+			foreach ($warnings as $key => $notice) { $output .= $this->render_item($notice, 'gv-warning-'.$key); }
115 115
 			$output .= '</ol>';
116 116
 		}
117 117
 
118
-		if ( count( $notices ) ) {
118
+		if (count($notices)) {
119 119
 			$output .= '<h3>Notices</h3>';
120 120
 			$output .= '<ol class="debug-bar-php-list">';
121
-			foreach ( $notices as $key => $notice) { $output .= $this->render_item( $notice, 'gv-notice-' . $key ); }
121
+			foreach ($notices as $key => $notice) { $output .= $this->render_item($notice, 'gv-notice-'.$key); }
122 122
 			$output .= '</ol>';
123 123
 		}
124 124
 
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
 	 * @return string       Escaped HTML
134 134
 	 */
135 135
 	function esc_html_recursive($item) {
136
-		if(is_object($item)) {
137
-			foreach($item as $key => $value) {
136
+		if (is_object($item)) {
137
+			foreach ($item as $key => $value) {
138 138
 				$item->{$key} = $this->esc_html_recursive($value);
139 139
 			}
140
-		} else if(is_array($item)) {
141
-			foreach($item as $key => $value) {
140
+		} else if (is_array($item)) {
141
+			foreach ($item as $key => $value) {
142 142
 				$item[$key] = $this->esc_html_recursive($value);
143 143
 			}
144 144
 		} else {
@@ -154,31 +154,31 @@  discard block
 block discarded – undo
154 154
 	 * @param  string $anchor The anchor ID for the item
155 155
 	 * @return string         HTML output
156 156
 	 */
157
-	function render_item( $notice, $anchor = '' ) {
157
+	function render_item($notice, $anchor = '') {
158 158
 
159 159
 		$output = '';
160 160
 
161
-		if(!empty($notice['message'])) {
162
-			$output .= '<a id="'.sanitize_html_class( $anchor ).'"></a>';
161
+		if (!empty($notice['message'])) {
162
+			$output .= '<a id="'.sanitize_html_class($anchor).'"></a>';
163 163
 			$output .= "<li class='debug-bar-php-notice'>";
164 164
 		}
165 165
 
166 166
 		$output .= '<div class="clear"></div>';
167 167
 
168 168
 		// Title
169
-		$output .= '<div class="gravityview-debug-bar-title">'.esc_attr( $notice['message'] ).'</div>';
169
+		$output .= '<div class="gravityview-debug-bar-title">'.esc_attr($notice['message']).'</div>';
170 170
 
171 171
 		// Debugging Output
172
-		if( empty( $notice['data'] ) ) {
173
-			if( !is_null( $notice['data'] ) ) {
174
-				$output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview' ).'</em>';
172
+		if (empty($notice['data'])) {
173
+			if (!is_null($notice['data'])) {
174
+				$output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview').'</em>';
175 175
 			}
176 176
 		}
177 177
 		else {
178
-			$output .= sprintf( '<pre>%s</pre>', print_r($this->esc_html_recursive( $notice['data'] ), true) );
178
+			$output .= sprintf('<pre>%s</pre>', print_r($this->esc_html_recursive($notice['data']), true));
179 179
 		}
180 180
 
181
-		if(!empty($notice['message'])) {
181
+		if (!empty($notice['message'])) {
182 182
 			$output .= '</li>';
183 183
 		}
184 184
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -173,8 +173,7 @@
 block discarded – undo
173 173
 			if( !is_null( $notice['data'] ) ) {
174 174
 				$output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview' ).'</em>';
175 175
 			}
176
-		}
177
-		else {
176
+		} else {
178 177
 			$output .= sprintf( '<pre>%s</pre>', print_r($this->esc_html_recursive( $notice['data'] ), true) );
179 178
 		}
180 179
 
Please login to merge, or discard this patch.
includes/class-frontend-views.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
 	/**
152 152
 	 * Sets the single entry ID and also the entry
153
-	 * @param bool|int $single_entry
153
+	 * @param boolean|string $single_entry
154 154
 	 */
155 155
 	public function setSingleEntry( $single_entry ) {
156 156
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
 	/**
169 169
 	 * Set the current entry
170
-	 * @param array|int $entry Entry array or entry ID
170
+	 * @param boolean|string $entry Entry array or entry ID
171 171
 	 */
172 172
 	public function setEntry( $entry ) {
173 173
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 *
226 226
 	 *
227 227
 	 *
228
-	 * @param null $view_id
228
+	 * @param string $view_id
229 229
 	 */
230 230
 	public function set_context_view_id( $view_id = null ) {
231 231
 
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 	 *
935 935
 	 * @uses  gravityview_get_entries()
936 936
 	 * @access public
937
-	 * @param array $args\n
937
+	 * @param array $args
938 938
 	 *   - $id - View id
939 939
 	 *   - $page_size - Page
940 940
 	 *   - $sort_field - form field id to sort
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
 	/**
1365 1365
 	 * Checks if field (column) is sortable
1366 1366
 	 *
1367
-	 * @param string $field Field settings
1367
+	 * @param string $field_id Field settings
1368 1368
 	 * @param array $form Gravity Forms form array
1369 1369
 	 *
1370 1370
 	 * @since 1.7
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * GravityView Frontend functions
4
- *
5
- * @package   GravityView
6
- * @license   GPL2+
7
- * @author    Katz Web Services, Inc.
8
- * @link      http://gravityview.co
9
- * @copyright Copyright 2014, Katz Web Services, Inc.
10
- *
11
- * @since 1.0.0
12
- */
3
+	 * GravityView Frontend functions
4
+	 *
5
+	 * @package   GravityView
6
+	 * @license   GPL2+
7
+	 * @author    Katz Web Services, Inc.
8
+	 * @link      http://gravityview.co
9
+	 * @copyright Copyright 2014, Katz Web Services, Inc.
10
+	 *
11
+	 * @since 1.0.0
12
+	 */
13 13
 
14 14
 
15 15
 class GravityView_frontend {
Please login to merge, or discard this patch.
Spacing   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @since 1.7.4.1
21 21
 	 * @var array
22 22
 	 */
23
-	private static $search_parameters = array( 'gv_search', 'gv_start', 'gv_end', 'gv_id', 'gv_by', 'filter_*' );
23
+	private static $search_parameters = array('gv_search', 'gv_start', 'gv_end', 'gv_id', 'gv_by', 'filter_*');
24 24
 
25 25
 	/**
26 26
 	 * Is the currently viewed post a `gravityview` post type?
@@ -85,18 +85,18 @@  discard block
 block discarded – undo
85 85
 	private function __construct() {}
86 86
 
87 87
 	private function initialize() {
88
-		add_action( 'wp', array( $this, 'parse_content'), 11 );
89
-		add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 );
88
+		add_action('wp', array($this, 'parse_content'), 11);
89
+		add_action('template_redirect', array($this, 'set_entry_data'), 1);
90 90
 
91 91
 		// Enqueue scripts and styles after GravityView_Template::register_styles()
92
-		add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 );
92
+		add_action('wp_enqueue_scripts', array($this, 'add_scripts_and_styles'), 20);
93 93
 
94 94
 		// Enqueue and print styles in the footer. Added 1 priorty so stuff gets printed at 10 priority.
95
-		add_action( 'wp_print_footer_scripts', array( $this, 'add_scripts_and_styles' ), 1 );
95
+		add_action('wp_print_footer_scripts', array($this, 'add_scripts_and_styles'), 1);
96 96
 
97
-		add_filter( 'the_title', array( $this, 'single_entry_title' ), 1, 2 );
98
-		add_filter( 'the_content', array( $this, 'insert_view_in_content' ) );
99
-		add_filter( 'comments_open', array( $this, 'comments_open' ), 10, 2 );
97
+		add_filter('the_title', array($this, 'single_entry_title'), 1, 2);
98
+		add_filter('the_content', array($this, 'insert_view_in_content'));
99
+		add_filter('comments_open', array($this, 'comments_open'), 10, 2);
100 100
 	}
101 101
 
102 102
 	/**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public static function getInstance() {
107 107
 
108
-		if ( empty( self::$instance ) ) {
108
+		if (empty(self::$instance)) {
109 109
 			self::$instance = new self;
110 110
 			self::$instance->initialize();
111 111
 		}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	/**
124 124
 	 * @param GravityView_View_Data $gv_output_data
125 125
 	 */
126
-	public function setGvOutputData( $gv_output_data ) {
126
+	public function setGvOutputData($gv_output_data) {
127 127
 		$this->gv_output_data = $gv_output_data;
128 128
 	}
129 129
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	/**
138 138
 	 * @param boolean $is_search
139 139
 	 */
140
-	public function setIsSearch( $is_search ) {
140
+	public function setIsSearch($is_search) {
141 141
 		$this->is_search = $is_search;
142 142
 	}
143 143
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * Sets the single entry ID and also the entry
153 153
 	 * @param bool|int $single_entry
154 154
 	 */
155
-	public function setSingleEntry( $single_entry ) {
155
+	public function setSingleEntry($single_entry) {
156 156
 
157 157
 		$this->single_entry = $single_entry;
158 158
 
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 	 * Set the current entry
170 170
 	 * @param array|int $entry Entry array or entry ID
171 171
 	 */
172
-	public function setEntry( $entry ) {
172
+	public function setEntry($entry) {
173 173
 
174
-		if ( ! is_array( $entry ) ) {
175
-			$entry = GVCommon::get_entry( $entry );
174
+		if (!is_array($entry)) {
175
+			$entry = GVCommon::get_entry($entry);
176 176
 		}
177 177
 
178 178
 		$this->entry = $entry;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	/**
189 189
 	 * @param int $post_id
190 190
 	 */
191
-	public function setPostId( $post_id ) {
191
+	public function setPostId($post_id) {
192 192
 		$this->post_id = $post_id;
193 193
 	}
194 194
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	/**
203 203
 	 * @param boolean $post_has_shortcode
204 204
 	 */
205
-	public function setPostHasShortcode( $post_has_shortcode ) {
205
+	public function setPostHasShortcode($post_has_shortcode) {
206 206
 		$this->post_has_shortcode = $post_has_shortcode;
207 207
 	}
208 208
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	/**
217 217
 	 * @param boolean $is_gravityview_post_type
218 218
 	 */
219
-	public function setIsGravityviewPostType( $is_gravityview_post_type ) {
219
+	public function setIsGravityviewPostType($is_gravityview_post_type) {
220 220
 		$this->is_gravityview_post_type = $is_gravityview_post_type;
221 221
 	}
222 222
 
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @param null $view_id
229 229
 	 */
230
-	public function set_context_view_id( $view_id = null ) {
230
+	public function set_context_view_id($view_id = null) {
231 231
 
232
-		if ( ! empty( $view_id ) ) {
232
+		if (!empty($view_id)) {
233 233
 
234 234
 			$this->context_view_id = $view_id;
235 235
 
236
-		} elseif ( isset( $_GET['gvid'] ) && $this->getGvOutputData()->has_multiple_views() ) {
236
+		} elseif (isset($_GET['gvid']) && $this->getGvOutputData()->has_multiple_views()) {
237 237
 			/**
238 238
 			 * used on a has_multiple_views context
239 239
 			 * @see GravityView_API::entry_link
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
 			 */
242 242
 			$this->context_view_id = $_GET['gvid'];
243 243
 
244
-		} elseif ( ! $this->getGvOutputData()->has_multiple_views() )  {
245
-			$array_keys = array_keys( $this->getGvOutputData()->get_views() );
246
-			$this->context_view_id = array_pop( $array_keys );
247
-			unset( $array_keys );
244
+		} elseif (!$this->getGvOutputData()->has_multiple_views()) {
245
+			$array_keys = array_keys($this->getGvOutputData()->get_views());
246
+			$this->context_view_id = array_pop($array_keys);
247
+			unset($array_keys);
248 248
 		}
249 249
 
250 250
 	}
@@ -265,31 +265,31 @@  discard block
 block discarded – undo
265 265
 	 * @param  array  $wp Passed in the `wp` hook. Not used.
266 266
 	 * @return void
267 267
 	 */
268
-	function parse_content( $wp = array() ) {
268
+	function parse_content($wp = array()) {
269 269
 		global $post;
270 270
 
271 271
 		// If in admin and NOT AJAX request, get outta here.
272
-		if ( GravityView_Plugin::is_admin() )  {
272
+		if (GravityView_Plugin::is_admin()) {
273 273
 			return;
274 274
 		}
275 275
 
276 276
 		// Calculate requested Views
277
-		$this->setGvOutputData( GravityView_View_Data::getInstance( $post ) );
277
+		$this->setGvOutputData(GravityView_View_Data::getInstance($post));
278 278
 
279 279
 		// !important: we need to run this before getting single entry (to kick the advanced filter)
280 280
 		$this->set_context_view_id();
281 281
 
282
-		$this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' );
282
+		$this->setIsGravityviewPostType(get_post_type($post) === 'gravityview');
283 283
 
284
-		$post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null );
285
-		$this->setPostId( $post_id );
286
-		$post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false;
287
-		$this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) );
284
+		$post_id = $this->getPostId() ? $this->getPostId() : (isset($post) ? $post->ID : null);
285
+		$this->setPostId($post_id);
286
+		$post_has_shortcode = !empty($post->post_content) ? gravityview_has_shortcode_r($post->post_content, 'gravityview') : false;
287
+		$this->setPostHasShortcode($this->isGravityviewPostType() ? null : !empty($post_has_shortcode));
288 288
 
289 289
 		// check if the View is showing search results (only for multiple entries View)
290
-		$this->setIsSearch( $this->is_searching() );
290
+		$this->setIsSearch($this->is_searching());
291 291
 
292
-		unset( $entry, $post_id, $post_has_shortcode );
292
+		unset($entry, $post_id, $post_has_shortcode);
293 293
 	}
294 294
 
295 295
 	/**
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	function set_entry_data() {
299 299
 		$entry_id = self::is_single_entry();
300
-		$this->setSingleEntry( $entry_id );
301
-		$this->setEntry( $entry_id );
300
+		$this->setSingleEntry($entry_id);
301
+		$this->setEntry($entry_id);
302 302
 	}
303 303
 
304 304
 	/**
@@ -311,31 +311,31 @@  discard block
 block discarded – undo
311 311
 	function is_searching() {
312 312
 
313 313
 		// It's a single entry, not search
314
-		if ( $this->getSingleEntry() ) {
314
+		if ($this->getSingleEntry()) {
315 315
 			return false;
316 316
 		}
317 317
 
318 318
 		// No $_GET parameters
319
-		if ( empty( $_GET ) || ! is_array( $_GET ) ) {
319
+		if (empty($_GET) || !is_array($_GET)) {
320 320
 			return false;
321 321
 		}
322 322
 
323 323
 		// Remove empty values
324
-		$get = array_filter( $_GET );
324
+		$get = array_filter($_GET);
325 325
 
326 326
 		// If the $_GET parameters are empty, it's no search.
327
-		if ( empty( $get ) ) {
327
+		if (empty($get)) {
328 328
 			return false;
329 329
 		}
330 330
 
331
-		$search_keys = array_keys( $get );
331
+		$search_keys = array_keys($get);
332 332
 
333
-		$search_match = implode( '|', self::$search_parameters );
333
+		$search_match = implode('|', self::$search_parameters);
334 334
 
335
-		foreach ( $search_keys as $search_key ) {
335
+		foreach ($search_keys as $search_key) {
336 336
 
337 337
 			// Analyze the search key $_GET parameter and see if it matches known GV args
338
-			if ( preg_match( '/(' . $search_match . ')/i', $search_key ) ) {
338
+			if (preg_match('/('.$search_match.')/i', $search_key)) {
339 339
 				return true;
340 340
 			}
341 341
 		}
@@ -350,11 +350,11 @@  discard block
 block discarded – undo
350 350
 	 * @param  int $passed_post_id Post ID
351 351
 	 * @return string          (modified) title
352 352
 	 */
353
-	public function single_entry_title( $title, $passed_post_id = null ) {
353
+	public function single_entry_title($title, $passed_post_id = null) {
354 354
 		global $post;
355 355
 
356 356
 		// If this is the directory view, return.
357
-		if ( ! $this->getSingleEntry() ) {
357
+		if (!$this->getSingleEntry()) {
358 358
 			return $title;
359 359
 		}
360 360
 
@@ -365,44 +365,44 @@  discard block
 block discarded – undo
365 365
 		 * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop
366 366
 		 * @param array $entry Current entry
367 367
 		 */
368
-		$apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry );
368
+		$apply_outside_loop = apply_filters('gravityview/single/title/out_loop', in_the_loop(), $entry);
369 369
 
370
-		if ( ! $apply_outside_loop ) {
370
+		if (!$apply_outside_loop) {
371 371
 			return $title;
372 372
 		}
373 373
 
374 374
 		// User reported WooCommerce doesn't pass two args.
375
-		if ( empty( $passed_post_id ) )  {
375
+		if (empty($passed_post_id)) {
376 376
 			return $title;
377 377
 		}
378 378
 
379 379
 		// Don't modify the title for anything other than the current view/post.
380 380
 		// This is true for embedded shortcodes and Views.
381
-		if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) {
381
+		if (is_object($post) && (int)$post->ID !== (int)$passed_post_id) {
382 382
 			return $title;
383 383
 		}
384 384
 
385 385
 		$context_view_id = $this->get_context_view_id();
386 386
 
387
-		if ( $this->getGvOutputData()->has_multiple_views() && ! empty( $context_view_id ) ) {
388
-			$view_meta = $this->getGvOutputData()->get_view( $context_view_id );
387
+		if ($this->getGvOutputData()->has_multiple_views() && !empty($context_view_id)) {
388
+			$view_meta = $this->getGvOutputData()->get_view($context_view_id);
389 389
 		} else {
390
-			foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) {
391
-				if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) {
390
+			foreach ($this->getGvOutputData()->get_views() as $view_id => $view_data) {
391
+				if (intval($view_data['form_id']) === intval($entry['form_id'])) {
392 392
 					$view_meta = $view_data;
393 393
 					break;
394 394
 				}
395 395
 			}
396 396
 		}
397 397
 
398
-		if ( ! empty( $view_meta['atts']['single_title'] ) ) {
398
+		if (!empty($view_meta['atts']['single_title'])) {
399 399
 
400 400
 			$title = $view_meta['atts']['single_title'];
401 401
 
402 402
 			// We are allowing HTML in the fields, so no escaping the output
403
-			$title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry );
403
+			$title = GravityView_API::replace_variables($title, $view_meta['form'], $entry);
404 404
 
405
-			$title = do_shortcode( $title );
405
+			$title = do_shortcode($title);
406 406
 		}
407 407
 
408 408
 		return $title;
@@ -417,38 +417,38 @@  discard block
 block discarded – undo
417 417
 	 * @param mixed $content
418 418
 	 * @return string Add the View output into View CPT content
419 419
 	 */
420
-	public function insert_view_in_content( $content ) {
420
+	public function insert_view_in_content($content) {
421 421
 
422 422
 		// Plugins may run through the content in the header. WP SEO does this for its OpenGraph functionality.
423
-		if ( ! did_action( 'loop_start' ) ) {
423
+		if (!did_action('loop_start')) {
424 424
 
425
-			do_action( 'gravityview_log_debug', '[insert_view_in_content] Not processing yet: loop_start hasn\'t run yet. Current action:', current_filter() );
425
+			do_action('gravityview_log_debug', '[insert_view_in_content] Not processing yet: loop_start hasn\'t run yet. Current action:', current_filter());
426 426
 
427 427
 			return $content;
428 428
 		}
429 429
 
430 430
 		//	We don't want this filter to run infinite loop on any post content fields
431
-		remove_filter( 'the_content', array( $this, 'insert_view_in_content' ) );
431
+		remove_filter('the_content', array($this, 'insert_view_in_content'));
432 432
 
433 433
 		// Otherwise, this is called on the Views page when in Excerpt mode.
434
-		if ( is_admin() ) {
434
+		if (is_admin()) {
435 435
 			return $content;
436 436
 		}
437 437
 
438
-		if ( $this->isGravityviewPostType() ) {
438
+		if ($this->isGravityviewPostType()) {
439 439
 
440 440
 			/** @since 1.7.4 */
441
-			if ( is_preview() && ! gravityview_get_form_id( $this->post_id ) ) {
442
-				$content .= __( 'When using a Start Fresh template, you must save the View before a Preview is available.', 'gravityview' );
441
+			if (is_preview() && !gravityview_get_form_id($this->post_id)) {
442
+				$content .= __('When using a Start Fresh template, you must save the View before a Preview is available.', 'gravityview');
443 443
 			} else {
444
-				foreach ( $this->getGvOutputData()->get_views() as $view_id => $data ) {
445
-					$content .= $this->render_view( array( 'id' => $view_id ) );
444
+				foreach ($this->getGvOutputData()->get_views() as $view_id => $data) {
445
+					$content .= $this->render_view(array('id' => $view_id));
446 446
 				}
447 447
 			}
448 448
 		}
449 449
 
450 450
 		//	Add the filter back in
451
-		add_filter( 'the_content', array( $this, 'insert_view_in_content' ) );
451
+		add_filter('the_content', array($this, 'insert_view_in_content'));
452 452
 
453 453
 		return $content;
454 454
 	}
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
 	 * @param  int $post_id Post ID
460 460
 	 * @return boolean
461 461
 	 */
462
-	public function comments_open( $open, $post_id ) {
462
+	public function comments_open($open, $post_id) {
463 463
 
464
-		if ( $this->isGravityviewPostType() ) {
464
+		if ($this->isGravityviewPostType()) {
465 465
 			$open = false;
466 466
 		}
467 467
 
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 		 * @param  boolean $open Open or closed status
472 472
 		 * @param  int $post_id Post ID to set comment status for
473 473
 		 */
474
-		$open = apply_filters( 'gravityview/comments_open', $open, $post_id );
474
+		$open = apply_filters('gravityview/comments_open', $open, $post_id);
475 475
 
476 476
 		return $open;
477 477
 	}
@@ -498,55 +498,55 @@  discard block
 block discarded – undo
498 498
 	 *
499 499
 	 * @return string|null HTML output of a View, NULL if View isn't found
500 500
 	 */
501
-	public function render_view( $passed_args ) {
501
+	public function render_view($passed_args) {
502 502
 
503 503
 		// validate attributes
504
-		if ( empty( $passed_args['id'] ) ) {
505
-			do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args );
504
+		if (empty($passed_args['id'])) {
505
+			do_action('gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args);
506 506
 			return null;
507 507
 		}
508 508
 
509 509
 		// Solve problem when loading content via admin-ajax.php
510 510
 		// @hack
511
-		if ( ! $this->getGvOutputData() ) {
511
+		if (!$this->getGvOutputData()) {
512 512
 
513
-			do_action( 'gravityview_log_error', '[render_view] gv_output_data not defined; parsing content.', $passed_args );
513
+			do_action('gravityview_log_error', '[render_view] gv_output_data not defined; parsing content.', $passed_args);
514 514
 
515 515
 			$this->parse_content();
516 516
 		}
517 517
 
518 518
 		// Make 100% sure that we're dealing with a properly called situation
519
-		if ( ! is_object( $this->getGvOutputData() ) || ! is_callable( array( $this->getGvOutputData(), 'get_view' ) ) ) {
519
+		if (!is_object($this->getGvOutputData()) || !is_callable(array($this->getGvOutputData(), 'get_view'))) {
520 520
 
521
-			do_action( 'gravityview_log_error', '[render_view] gv_output_data not an object or get_view not callable.', $this->getGvOutputData() );
521
+			do_action('gravityview_log_error', '[render_view] gv_output_data not an object or get_view not callable.', $this->getGvOutputData());
522 522
 
523 523
 			return null;
524 524
 		}
525 525
 
526 526
 		$view_id = $passed_args['id'];
527 527
 
528
-		$view_data = $this->getGvOutputData()->get_view( $view_id, $passed_args );
528
+		$view_data = $this->getGvOutputData()->get_view($view_id, $passed_args);
529 529
 
530
-		do_action( 'gravityview_log_debug', '[render_view] View Data: ', $view_data );
530
+		do_action('gravityview_log_debug', '[render_view] View Data: ', $view_data);
531 531
 
532
-		do_action( 'gravityview_log_debug', '[render_view] Init View. Arguments: ', $passed_args );
532
+		do_action('gravityview_log_debug', '[render_view] Init View. Arguments: ', $passed_args);
533 533
 
534 534
 		// The passed args were always winning, even if they were NULL.
535 535
 		// This prevents that. Filters NULL, FALSE, and empty strings.
536
-		$passed_args = array_filter( $passed_args, 'strlen' );
536
+		$passed_args = array_filter($passed_args, 'strlen');
537 537
 
538 538
 		//Override shortcode args over View template settings
539
-		$atts = wp_parse_args( $passed_args, $view_data['atts'] );
539
+		$atts = wp_parse_args($passed_args, $view_data['atts']);
540 540
 
541
-		do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts );
541
+		do_action('gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts);
542 542
 
543 543
 		// It's password protected and you need to log in.
544
-		if ( post_password_required( $view_id ) ) {
544
+		if (post_password_required($view_id)) {
545 545
 
546
-			do_action( 'gravityview_log_error', sprintf( '[render_view] Returning: View %d is password protected.', $view_id ) );
546
+			do_action('gravityview_log_error', sprintf('[render_view] Returning: View %d is password protected.', $view_id));
547 547
 
548 548
 			// If we're in an embed or on an archive page, show the password form
549
-			if ( get_the_ID() !== $view_id ) {
549
+			if (get_the_ID() !== $view_id) {
550 550
 				return get_the_password_form();
551 551
 			}
552 552
 
@@ -558,11 +558,11 @@  discard block
 block discarded – undo
558 558
 		 * Don't render View if user isn't allowed to see it
559 559
 		 * @since 1.15
560 560
 		 */
561
-		if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
561
+		if (is_user_logged_in() && false === GVCommon::has_cap('read_gravityview', $view_id)) {
562 562
 			return null;
563 563
 		}
564 564
 
565
-		if( $this->isGravityviewPostType() ) {
565
+		if ($this->isGravityviewPostType()) {
566 566
 
567 567
 			/**
568 568
 			 * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode?
@@ -572,12 +572,12 @@  discard block
 block discarded – undo
572 572
 			 * @param[in,out] boolean `true`: allow Views to be accessible directly. `false`: Only allow Views to be embedded via shortcode. Default: `true`
573 573
 			 * @param int $view_id The ID of the View currently being requested. `0` for general setting
574 574
 			 */
575
-			$direct_access = apply_filters( 'gravityview_direct_access', true, $view_id );
575
+			$direct_access = apply_filters('gravityview_direct_access', true, $view_id);
576 576
 
577
-			$embed_only = ! empty( $atts['embed_only'] );
577
+			$embed_only = !empty($atts['embed_only']);
578 578
 
579
-			if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) {
580
-				return __( 'You are not allowed to view this content.', 'gravityview' );
579
+			if (!$direct_access || ($embed_only && !GVCommon::has_cap('read_private_gravityviews'))) {
580
+				return __('You are not allowed to view this content.', 'gravityview');
581 581
 			}
582 582
 		}
583 583
 
@@ -589,137 +589,137 @@  discard block
 block discarded – undo
589 589
 		 */
590 590
 		global $gravityview_view;
591 591
 
592
-		$gravityview_view = new GravityView_View( $view_data );
592
+		$gravityview_view = new GravityView_View($view_data);
593 593
 
594
-		$post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : $this->getPostId();
594
+		$post_id = !empty($atts['post_id']) ? intval($atts['post_id']) : $this->getPostId();
595 595
 
596
-		$gravityview_view->setPostId( $post_id );
596
+		$gravityview_view->setPostId($post_id);
597 597
 
598
-		if ( ! $this->getSingleEntry() ) {
598
+		if (!$this->getSingleEntry()) {
599 599
 
600 600
 			// user requested Directory View
601
-			do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' );
601
+			do_action('gravityview_log_debug', '[render_view] Executing Directory View');
602 602
 
603 603
 			//fetch template and slug
604
-			$view_slug = apply_filters( 'gravityview_template_slug_'. $view_data['template_id'], 'table', 'directory' );
604
+			$view_slug = apply_filters('gravityview_template_slug_'.$view_data['template_id'], 'table', 'directory');
605 605
 
606
-			do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug );
606
+			do_action('gravityview_log_debug', '[render_view] View template slug: ', $view_slug);
607 607
 
608 608
 			/**
609 609
 			 * Disable fetching initial entries for views that don't need it (DataTables)
610 610
 			 */
611
-			$get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true );
611
+			$get_entries = apply_filters('gravityview_get_view_entries_'.$view_slug, true);
612 612
 
613 613
 			/**
614 614
 			 * Hide View data until search is performed
615 615
 			 * @since 1.5.4
616 616
 			 */
617
-			if ( ! empty( $atts['hide_until_searched'] ) && ! $this->isSearch() ) {
618
-				$gravityview_view->setHideUntilSearched( true );
617
+			if (!empty($atts['hide_until_searched']) && !$this->isSearch()) {
618
+				$gravityview_view->setHideUntilSearched(true);
619 619
 				$get_entries = false;
620 620
 			}
621 621
 
622 622
 
623
-			if ( $get_entries ) {
623
+			if ($get_entries) {
624 624
 
625
-				if ( ! empty( $atts['sort_columns'] ) ) {
625
+				if (!empty($atts['sort_columns'])) {
626 626
 					// add filter to enable column sorting
627
-					add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 );
627
+					add_filter('gravityview/template/field_label', array($this, 'add_columns_sort_links'), 100, 3);
628 628
 				}
629 629
 
630
-				$view_entries = self::get_view_entries( $atts, $view_data['form_id'] );
630
+				$view_entries = self::get_view_entries($atts, $view_data['form_id']);
631 631
 
632
-				do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) );
632
+				do_action('gravityview_log_debug', sprintf('[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof($view_entries['entries'])));
633 633
 
634 634
 			} else {
635 635
 
636
-				$view_entries = array( 'count' => null, 'entries' => null, 'paging' => null );
636
+				$view_entries = array('count' => null, 'entries' => null, 'paging' => null);
637 637
 
638
-				do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' );
638
+				do_action('gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false');
639 639
 			}
640 640
 
641
-			$gravityview_view->setPaging( $view_entries['paging'] );
642
-			$gravityview_view->setContext( 'directory' );
643
-			$sections = array( 'header', 'body', 'footer' );
641
+			$gravityview_view->setPaging($view_entries['paging']);
642
+			$gravityview_view->setContext('directory');
643
+			$sections = array('header', 'body', 'footer');
644 644
 
645 645
 		} else {
646 646
 
647 647
 			// user requested Single Entry View
648
-			do_action( 'gravityview_log_debug', '[render_view] Executing Single View' );
648
+			do_action('gravityview_log_debug', '[render_view] Executing Single View');
649 649
 
650
-			do_action( 'gravityview_render_entry_'.$view_data['id'] );
650
+			do_action('gravityview_render_entry_'.$view_data['id']);
651 651
 
652 652
 			$entry = $this->getEntry();
653 653
 
654 654
 			// You are not permitted to view this entry.
655
-			if ( empty( $entry ) || ! self::is_entry_approved( $entry, $atts ) ) {
655
+			if (empty($entry) || !self::is_entry_approved($entry, $atts)) {
656 656
 
657
-				do_action( 'gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.' );
657
+				do_action('gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.');
658 658
 
659 659
 				/**
660 660
 				 * @since 1.6
661 661
 				 */
662
-				echo esc_attr( apply_filters( 'gravityview/render/entry/not_visible', __( 'You have attempted to view an entry that is not visible or may not exist.', 'gravityview' ) ) );
662
+				echo esc_attr(apply_filters('gravityview/render/entry/not_visible', __('You have attempted to view an entry that is not visible or may not exist.', 'gravityview')));
663 663
 
664 664
 				return null;
665 665
 			}
666 666
 
667 667
 			// We're in single view, but the view being processed is not the same view the single entry belongs to.
668 668
 			// important: do not remove this as it prevents fake attempts of displaying entries from other views/forms
669
-			if ( $this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id() ) {
670
-				do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '. $view_id );
669
+			if ($this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id()) {
670
+				do_action('gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '.$view_id);
671 671
 				return null;
672 672
 			}
673 673
 
674 674
 			//fetch template and slug
675
-			$view_slug = apply_filters( 'gravityview_template_slug_' . $view_data['template_id'], 'table', 'single' );
676
-			do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug );
675
+			$view_slug = apply_filters('gravityview_template_slug_'.$view_data['template_id'], 'table', 'single');
676
+			do_action('gravityview_log_debug', '[render_view] View single template slug: ', $view_slug);
677 677
 
678 678
 			//fetch entry detail
679 679
 			$view_entries['count'] = 1;
680 680
 			$view_entries['entries'][] = $entry;
681
-			do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] );
681
+			do_action('gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries']);
682 682
 
683
-			$back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null;
683
+			$back_link_label = isset($atts['back_link_label']) ? $atts['back_link_label'] : null;
684 684
 
685 685
 			// set back link label
686
-			$gravityview_view->setBackLinkLabel( $back_link_label );
687
-			$gravityview_view->setContext( 'single' );
688
-			$sections = array( 'single' );
686
+			$gravityview_view->setBackLinkLabel($back_link_label);
687
+			$gravityview_view->setContext('single');
688
+			$sections = array('single');
689 689
 
690 690
 		}
691 691
 
692 692
 		// add template style
693
-		self::add_style( $view_data['template_id'] );
693
+		self::add_style($view_data['template_id']);
694 694
 
695 695
 		// Prepare to render view and set vars
696
-		$gravityview_view->setEntries( $view_entries['entries'] );
697
-		$gravityview_view->setTotalEntries( $view_entries['count'] );
696
+		$gravityview_view->setEntries($view_entries['entries']);
697
+		$gravityview_view->setTotalEntries($view_entries['count']);
698 698
 
699 699
 		// If Edit
700
-		if ( 'edit' === gravityview_get_context() ) {
700
+		if ('edit' === gravityview_get_context()) {
701 701
 
702
-			do_action( 'gravityview_log_debug', '[render_view] Edit Entry ' );
702
+			do_action('gravityview_log_debug', '[render_view] Edit Entry ');
703 703
 
704
-			do_action( 'gravityview_edit_entry', $this->getGvOutputData() );
704
+			do_action('gravityview_edit_entry', $this->getGvOutputData());
705 705
 
706 706
 			return ob_get_clean();
707 707
 
708 708
 		} else {
709 709
 			// finaly we'll render some html
710
-			$sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data['template_id'] );
710
+			$sections = apply_filters('gravityview_render_view_sections', $sections, $view_data['template_id']);
711 711
 
712
-			do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections );
713
-			foreach ( $sections as $section ) {
714
-				do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' );
715
-				$gravityview_view->render( $view_slug, $section, false );
712
+			do_action('gravityview_log_debug', '[render_view] Sections to render: ', $sections);
713
+			foreach ($sections as $section) {
714
+				do_action('gravityview_log_debug', '[render_view] Rendering '.$section.' section.');
715
+				$gravityview_view->render($view_slug, $section, false);
716 716
 			}
717 717
 		}
718 718
 
719 719
 		//@todo: check why we need the IF statement vs. print the view id always.
720
-		if ( $this->isGravityviewPostType() || $this->isPostHasShortcode() ) {
720
+		if ($this->isGravityviewPostType() || $this->isPostHasShortcode()) {
721 721
 			// Print the View ID to enable proper cookie pagination
722
-			echo '<input type="hidden" class="gravityview-view-id" value="' . esc_attr( $view_id ) . '">';
722
+			echo '<input type="hidden" class="gravityview-view-id" value="'.esc_attr($view_id).'">';
723 723
 		}
724 724
 		$output = ob_get_clean();
725 725
 
@@ -741,23 +741,23 @@  discard block
 block discarded – undo
741 741
 	 * @param  array      $search_criteria Search being performed, if any
742 742
 	 * @return array                       Modified `$search_criteria` array
743 743
 	 */
744
-	public static function process_search_dates( $args, $search_criteria = array() ) {
744
+	public static function process_search_dates($args, $search_criteria = array()) {
745 745
 
746 746
 		$return_search_criteria = $search_criteria;
747 747
 
748
-		foreach ( array( 'start_date', 'end_date' ) as $key ) {
748
+		foreach (array('start_date', 'end_date') as $key) {
749 749
 
750 750
 
751 751
 			// Is the start date or end date set in the view or shortcode?
752 752
 			// If so, we want to make sure that the search doesn't go outside the bounds defined.
753
-			if ( ! empty( $args[ $key ] ) ) {
753
+			if (!empty($args[$key])) {
754 754
 
755 755
 				// Get a timestamp and see if it's a valid date format
756
-				$date = strtotime( $args[ $key ] );
756
+				$date = strtotime($args[$key]);
757 757
 
758 758
 				// The date was invalid
759
-				if ( empty( $date ) ) {
760
-					do_action( 'gravityview_log_error', __METHOD__ . ' Invalid ' . $key . ' date format: ' . $args[ $key ] );
759
+				if (empty($date)) {
760
+					do_action('gravityview_log_error', __METHOD__.' Invalid '.$key.' date format: '.$args[$key]);
761 761
 					continue;
762 762
 				}
763 763
 
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
 				$datetime_format = 'Y-m-d H:i:s';
766 766
 				$search_is_outside_view_bounds = false;
767 767
 
768
-				if( ! empty( $search_criteria[ $key ] ) ) {
768
+				if (!empty($search_criteria[$key])) {
769 769
 
770
-					$search_date = strtotime( $search_criteria[ $key ] );
770
+					$search_date = strtotime($search_criteria[$key]);
771 771
 
772 772
 					// The search is for entries before the start date defined by the settings
773
-					switch ( $key ) {
773
+					switch ($key) {
774 774
 						case 'end_date':
775 775
 							/**
776 776
 							 * If the end date is formatted as 'Y-m-d', it should be formatted without hours and seconds
@@ -780,28 +780,28 @@  discard block
 block discarded – undo
780 780
 							 *
781 781
 							 * @see GFFormsModel::get_date_range_where
782 782
 							 */
783
-							$datetime_format               = gravityview_is_valid_datetime( $args[ $key ] ) ? 'Y-m-d' : 'Y-m-d H:i:s';
784
-							$search_is_outside_view_bounds = ( $search_date > $date );
783
+							$datetime_format               = gravityview_is_valid_datetime($args[$key]) ? 'Y-m-d' : 'Y-m-d H:i:s';
784
+							$search_is_outside_view_bounds = ($search_date > $date);
785 785
 							break;
786 786
 						case 'start_date':
787
-							$search_is_outside_view_bounds = ( $search_date < $date );
787
+							$search_is_outside_view_bounds = ($search_date < $date);
788 788
 							break;
789 789
 					}
790 790
 				}
791 791
 
792 792
 				// If there is no search being performed, or if there is a search being performed that's outside the bounds
793
-				if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) {
793
+				if (empty($search_criteria[$key]) || $search_is_outside_view_bounds) {
794 794
 
795 795
 					// Then we override the search and re-set the start date
796
-					$return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true );
796
+					$return_search_criteria[$key] = date_i18n($datetime_format, $date, true);
797 797
 				}
798 798
 			}
799 799
 		}
800 800
 
801
-		if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) {
801
+		if (isset($return_search_criteria['start_date']) && isset($return_search_criteria['end_date'])) {
802 802
 			// The start date is AFTER the end date. This will result in no results, but let's not force the issue.
803
-			if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) {
804
-				do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria );
803
+			if (strtotime($return_search_criteria['start_date']) > strtotime($return_search_criteria['end_date'])) {
804
+				do_action('gravityview_log_error', __METHOD__.' Invalid search: the start date is after the end date.', $return_search_criteria);
805 805
 			}
806 806
 		}
807 807
 
@@ -816,13 +816,13 @@  discard block
 block discarded – undo
816 816
 	 * @param  array      $search_criteria Search being performed, if any
817 817
 	 * @return array                       Modified `$search_criteria` array
818 818
 	 */
819
-	public static function process_search_only_approved( $args, $search_criteria ) {
819
+	public static function process_search_only_approved($args, $search_criteria) {
820 820
 
821
-		if ( ! empty( $args['show_only_approved'] ) ) {
822
-			$search_criteria['field_filters'][] = array( 'key' => 'is_approved', 'value' => 'Approved' );
821
+		if (!empty($args['show_only_approved'])) {
822
+			$search_criteria['field_filters'][] = array('key' => 'is_approved', 'value' => 'Approved');
823 823
 			$search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met
824 824
 
825
-			do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria );
825
+			do_action('gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria);
826 826
 		}
827 827
 
828 828
 		return $search_criteria;
@@ -842,16 +842,16 @@  discard block
 block discarded – undo
842 842
 	 *
843 843
 	 * @return bool
844 844
 	 */
845
-	public static function is_entry_approved( $entry, $args = array() ) {
845
+	public static function is_entry_approved($entry, $args = array()) {
846 846
 
847
-		if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) {
847
+		if (empty($entry['id']) || (array_key_exists('show_only_approved', $args) && !$args['show_only_approved'])) {
848 848
 			// is implicitly approved if entry is null or View settings doesn't require to check for approval
849 849
 			return true;
850 850
 		}
851 851
 
852
-		$is_approved = gform_get_meta( $entry['id'], 'is_approved' );
852
+		$is_approved = gform_get_meta($entry['id'], 'is_approved');
853 853
 
854
-		if ( $is_approved ) {
854
+		if ($is_approved) {
855 855
 			return true;
856 856
 		}
857 857
 
@@ -872,47 +872,47 @@  discard block
 block discarded – undo
872 872
 	 * @param  int $form_id Gravity Forms form ID
873 873
 	 * @return array          Array of search parameters, formatted in Gravity Forms mode, using `status` key set to "active" by default, `field_filters` array with `key`, `value` and `operator` keys.
874 874
 	 */
875
-	public static function get_search_criteria( $args, $form_id ) {
875
+	public static function get_search_criteria($args, $form_id) {
876 876
 
877 877
 		// Search Criteria
878
-		$search_criteria = apply_filters( 'gravityview_fe_search_criteria', array( 'field_filters' => array() ), $form_id );
878
+		$search_criteria = apply_filters('gravityview_fe_search_criteria', array('field_filters' => array()), $form_id);
879 879
 
880 880
 		$original_search_criteria = $search_criteria;
881 881
 
882
-		do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria );
882
+		do_action('gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria);
883 883
 
884 884
 		// implicity search
885
-		if ( ! empty( $args['search_value'] ) ) {
885
+		if (!empty($args['search_value'])) {
886 886
 
887 887
 			// Search operator options. Options: `is` or `contains`
888
-			$operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains';
888
+			$operator = !empty($args['search_operator']) && in_array($args['search_operator'], array('is', 'isnot', '>', '<', 'contains')) ? $args['search_operator'] : 'contains';
889 889
 
890 890
 			$search_criteria['field_filters'][] = array(
891
-				'key' => rgget( 'search_field', $args ), // The field ID to search
892
-				'value' => esc_attr( $args['search_value'] ), // The value to search
891
+				'key' => rgget('search_field', $args), // The field ID to search
892
+				'value' => esc_attr($args['search_value']), // The value to search
893 893
 				'operator' => $operator,
894 894
 			);
895 895
 		}
896 896
 
897
-		if( $search_criteria !== $original_search_criteria ) {
898
-			do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria );
897
+		if ($search_criteria !== $original_search_criteria) {
898
+			do_action('gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria);
899 899
 		}
900 900
 
901 901
 		// Handle setting date range
902
-		$search_criteria = self::process_search_dates( $args, $search_criteria );
902
+		$search_criteria = self::process_search_dates($args, $search_criteria);
903 903
 
904
-		if( $search_criteria !== $original_search_criteria ) {
905
-			do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria );
904
+		if ($search_criteria !== $original_search_criteria) {
905
+			do_action('gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria);
906 906
 		}
907 907
 
908 908
 		// remove not approved entries
909
-		$search_criteria = self::process_search_only_approved( $args, $search_criteria );
909
+		$search_criteria = self::process_search_only_approved($args, $search_criteria);
910 910
 
911 911
 		/**
912 912
 		 * @filter `gravityview_status` Modify entry status requirements to be included in search results.
913 913
 		 * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash`
914 914
 		 */
915
-		$search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args );
915
+		$search_criteria['status'] = apply_filters('gravityview_status', 'active', $args);
916 916
 
917 917
 		return $search_criteria;
918 918
 	}
@@ -946,29 +946,29 @@  discard block
 block discarded – undo
946 946
 	 * @param int $form_id Gravity Forms Form ID
947 947
 	 * @return array Associative array with `count`, `entries`, and `paging` keys. `count` has the total entries count, `entries` is an array with Gravity Forms full entry data, `paging` is an array with `offset` and `page_size` keys
948 948
 	 */
949
-	public static function get_view_entries( $args, $form_id ) {
949
+	public static function get_view_entries($args, $form_id) {
950 950
 
951
-		do_action( 'gravityview_log_debug', '[get_view_entries] init' );
951
+		do_action('gravityview_log_debug', '[get_view_entries] init');
952 952
 		// start filters and sorting
953 953
 
954 954
 		/**
955 955
 		 * Process search parameters
956 956
 		 * @var array
957 957
 		 */
958
-		$search_criteria = self::get_search_criteria( $args, $form_id );
958
+		$search_criteria = self::get_search_criteria($args, $form_id);
959 959
 
960 960
 		// Paging & offset
961
-		$page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : apply_filters( 'gravityview_default_page_size', 25 );
961
+		$page_size = !empty($args['page_size']) ? intval($args['page_size']) : apply_filters('gravityview_default_page_size', 25);
962 962
 
963 963
 		if ( -1 === $page_size ) {
964 964
 			$page_size = PHP_INT_MAX;
965 965
 		}
966 966
 
967
-		if ( isset( $args['offset'] ) ) {
968
-			$offset = intval( $args['offset'] );
967
+		if (isset($args['offset'])) {
968
+			$offset = intval($args['offset']);
969 969
 		} else {
970
-			$curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] );
971
-			$offset = ( $curr_page - 1 ) * $page_size;
970
+			$curr_page = empty($_GET['pagenum']) ? 1 : intval($_GET['pagenum']);
971
+			$offset = ($curr_page - 1) * $page_size;
972 972
 		}
973 973
 
974 974
 		$paging = array(
@@ -976,16 +976,16 @@  discard block
 block discarded – undo
976 976
 			'page_size' => $page_size,
977 977
 		);
978 978
 
979
-		do_action( 'gravityview_log_debug', '[get_view_entries] Paging: ', $paging );
979
+		do_action('gravityview_log_debug', '[get_view_entries] Paging: ', $paging);
980 980
 
981 981
 		// Sorting
982
-		$sorting = self::updateViewSorting( $args, $form_id );
982
+		$sorting = self::updateViewSorting($args, $form_id);
983 983
 
984 984
 		$parameters = array(
985 985
 			'search_criteria' => $search_criteria,
986 986
 			'sorting' => $sorting,
987 987
 			'paging' => $paging,
988
-			'cache' => isset( $args['cache'] ) ? $args['cache'] : true,
988
+			'cache' => isset($args['cache']) ? $args['cache'] : true,
989 989
 		);
990 990
 
991 991
 		/**
@@ -1003,22 +1003,22 @@  discard block
 block discarded – undo
1003 1003
 		 * }
1004 1004
 		 * @param int $form_id ID of Gravity Forms form
1005 1005
 		 */
1006
-		$parameters = apply_filters( 'gravityview_get_entries', $parameters, $args, $form_id );
1006
+		$parameters = apply_filters('gravityview_get_entries', $parameters, $args, $form_id);
1007 1007
 
1008 1008
 		/**
1009 1009
 		 * @filter `gravityview_get_entries_{View ID}` Filter get entries criteria
1010 1010
 		 * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys.
1011 1011
 		 * @param array $args View configuration args.
1012 1012
 		 */
1013
-		$parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id );
1013
+		$parameters = apply_filters('gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id);
1014 1014
 
1015
-		do_action( 'gravityview_log_debug', '[get_view_entries] $parameters passed to gravityview_get_entries(): ', $parameters );
1015
+		do_action('gravityview_log_debug', '[get_view_entries] $parameters passed to gravityview_get_entries(): ', $parameters);
1016 1016
 
1017 1017
 		//fetch entries
1018 1018
 		$count = 0;
1019
-		$entries = gravityview_get_entries( $form_id, $parameters, $count );
1019
+		$entries = gravityview_get_entries($form_id, $parameters, $count);
1020 1020
 
1021
-		do_action( 'gravityview_log_debug', sprintf( '[get_view_entries] Get Entries. Found: %s entries', $count ), $entries );
1021
+		do_action('gravityview_log_debug', sprintf('[get_view_entries] Get Entries. Found: %s entries', $count), $entries);
1022 1022
 
1023 1023
 		/**
1024 1024
 		 * @filter `gravityview_view_entries` Filter the entries output to the View
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 		 * @param array $args View settings associative array
1027 1027
 		 * @var array
1028 1028
 		 */
1029
-		$entries = apply_filters( 'gravityview_view_entries', $entries, $args );
1029
+		$entries = apply_filters('gravityview_view_entries', $entries, $args);
1030 1030
 
1031 1031
 		/**
1032 1032
 		 * @filter `gravityview/view/entries` Filter the entries output to the View
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 		 * @param array $args View settings associative array
1035 1035
 		 * @since 1.5.2
1036 1036
 		 */
1037
-		return apply_filters( 'gravityview/view/entries', compact( 'count', 'entries', 'paging' ), $args );
1037
+		return apply_filters('gravityview/view/entries', compact('count', 'entries', 'paging'), $args);
1038 1038
 
1039 1039
 	}
1040 1040
 
@@ -1048,24 +1048,24 @@  discard block
 block discarded – undo
1048 1048
 	 * @param int $form_id The ID of the form used to sort
1049 1049
 	 * @return array $sorting Array with `key`, `direction` and `is_numeric` keys
1050 1050
 	 */
1051
-	public static function updateViewSorting( $args, $form_id ) {
1051
+	public static function updateViewSorting($args, $form_id) {
1052 1052
 		$sorting = array();
1053
-		$sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' );
1054
-		$sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' );
1053
+		$sort_field_id = isset($_GET['sort']) ? $_GET['sort'] : rgar($args, 'sort_field');
1054
+		$sort_direction = isset($_GET['dir']) ? $_GET['dir'] : rgar($args, 'sort_direction');
1055 1055
 
1056
-		$sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id );
1056
+		$sort_field_id = self::_override_sorting_id_by_field_type($sort_field_id, $form_id);
1057 1057
 
1058
-		if ( ! empty( $sort_field_id ) ) {
1058
+		if (!empty($sort_field_id)) {
1059 1059
 			$sorting = array(
1060 1060
 				'key' => $sort_field_id,
1061
-				'direction' => strtolower( $sort_direction ),
1062
-				'is_numeric' => GVCommon::is_field_numeric( $form_id, $sort_field_id )
1061
+				'direction' => strtolower($sort_direction),
1062
+				'is_numeric' => GVCommon::is_field_numeric($form_id, $sort_field_id)
1063 1063
 			);
1064 1064
 		}
1065 1065
 
1066
-		GravityView_View::getInstance()->setSorting( $sorting );
1066
+		GravityView_View::getInstance()->setSorting($sorting);
1067 1067
 
1068
-		do_action( 'gravityview_log_debug', '[updateViewSorting] Sort Criteria : ', $sorting );
1068
+		do_action('gravityview_log_debug', '[updateViewSorting] Sort Criteria : ', $sorting);
1069 1069
 
1070 1070
 		return $sorting;
1071 1071
 
@@ -1085,17 +1085,17 @@  discard block
 block discarded – undo
1085 1085
 	 *
1086 1086
 	 * @return string Possibly modified sorting ID
1087 1087
 	 */
1088
-	private static function _override_sorting_id_by_field_type( $sort_field_id, $form_id ) {
1088
+	private static function _override_sorting_id_by_field_type($sort_field_id, $form_id) {
1089 1089
 
1090
-		$form = GFAPI::get_form( $form_id );
1090
+		$form = GFAPI::get_form($form_id);
1091 1091
 
1092
-		$sort_field = GFFormsModel::get_field( $form, $sort_field_id );
1092
+		$sort_field = GFFormsModel::get_field($form, $sort_field_id);
1093 1093
 
1094
-		switch ( $sort_field['type'] ) {
1094
+		switch ($sort_field['type']) {
1095 1095
 
1096 1096
 			case 'address':
1097 1097
 				// Sorting by full address
1098
-				if ( floatval( $sort_field_id ) === floor( $sort_field_id ) ) {
1098
+				if (floatval($sort_field_id) === floor($sort_field_id)) {
1099 1099
 
1100 1100
 					/**
1101 1101
 					 * Override how to sort when sorting address
@@ -1106,9 +1106,9 @@  discard block
 block discarded – undo
1106 1106
 					 * @param string $sort_field_id Field used for sorting
1107 1107
 					 * @param int $form_id GF Form ID
1108 1108
 					 */
1109
-					$address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id );
1109
+					$address_part = apply_filters('gravityview/sorting/address', 'city', $sort_field_id, $form_id);
1110 1110
 
1111
-					switch( strtolower( $address_part ) ){
1111
+					switch (strtolower($address_part)) {
1112 1112
 						case 'street':
1113 1113
 							$sort_field_id .= '.1';
1114 1114
 							break;
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 				break;
1135 1135
 			case 'name':
1136 1136
 				// Sorting by full name, not first, last, etc.
1137
-				if ( floatval( $sort_field_id ) === floor( $sort_field_id ) ) {
1137
+				if (floatval($sort_field_id) === floor($sort_field_id)) {
1138 1138
 					/**
1139 1139
 					 * @filter `gravityview/sorting/full-name` Override how to sort when sorting full name.
1140 1140
 					 * @since 1.7.4
@@ -1142,9 +1142,9 @@  discard block
 block discarded – undo
1142 1142
 					 * @param[in] string $sort_field_id Field used for sorting
1143 1143
 					 * @param[in] int $form_id GF Form ID
1144 1144
 					 */
1145
-					$name_part = apply_filters( 'gravityview/sorting/full-name', 'first', $sort_field_id, $form_id );
1145
+					$name_part = apply_filters('gravityview/sorting/full-name', 'first', $sort_field_id, $form_id);
1146 1146
 
1147
-					if ( 'last' === strtolower( $name_part ) ) {
1147
+					if ('last' === strtolower($name_part)) {
1148 1148
 						$sort_field_id .= '.6';
1149 1149
 					} else {
1150 1150
 						$sort_field_id .= '.3';
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 				 * @param[in,out] string $name_part Field used for sorting
1164 1164
 				 * @param[in] int $form_id GF Form ID
1165 1165
 				 */
1166
-				$sort_field_id = apply_filters( 'gravityview/sorting/time', $sort_field_id, $form_id );
1166
+				$sort_field_id = apply_filters('gravityview/sorting/time', $sort_field_id, $form_id);
1167 1167
 				break;
1168 1168
 		}
1169 1169
 
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
 
1179 1179
 		$var_name = GravityView_Post_Types::get_entry_var_name();
1180 1180
 
1181
-		$single_entry = get_query_var( $var_name );
1181
+		$single_entry = get_query_var($var_name);
1182 1182
 
1183 1183
 		/**
1184 1184
 		 * Modify the entry that is being displayed.
@@ -1186,9 +1186,9 @@  discard block
 block discarded – undo
1186 1186
 		 * @internal Should only be used by things like the oEmbed functionality.
1187 1187
 		 * @since 1.6
1188 1188
 		 */
1189
-		$single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry );
1189
+		$single_entry = apply_filters('gravityview/is_single_entry', $single_entry);
1190 1190
 
1191
-		if ( empty( $single_entry ) ){
1191
+		if (empty($single_entry)) {
1192 1192
 			return false;
1193 1193
 		} else {
1194 1194
 			return $single_entry;
@@ -1205,38 +1205,38 @@  discard block
 block discarded – undo
1205 1205
 	public function add_scripts_and_styles() {
1206 1206
 		global $post, $posts;
1207 1207
 		// enqueue template specific styles
1208
-		if ( $this->getGvOutputData() ) {
1208
+		if ($this->getGvOutputData()) {
1209 1209
 
1210 1210
 			$views = $this->getGvOutputData()->get_views();
1211 1211
 
1212
-			foreach ( $views as $view_id => $data ) {
1212
+			foreach ($views as $view_id => $data) {
1213 1213
 
1214 1214
 				/**
1215 1215
 				 * Don't enqueue the scripts or styles if it's not going to be displayed.
1216 1216
 				 * @since 1.15
1217 1217
 				 */
1218
-				if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
1218
+				if (is_user_logged_in() && false === GVCommon::has_cap('read_gravityview', $view_id)) {
1219 1219
 					continue;
1220 1220
 				}
1221 1221
 
1222 1222
 				// By default, no thickbox
1223
-				$js_dependencies = array( 'jquery', 'gravityview-jquery-cookie' );
1223
+				$js_dependencies = array('jquery', 'gravityview-jquery-cookie');
1224 1224
 				$css_dependencies = array();
1225 1225
 
1226 1226
 				// If the thickbox is enqueued, add dependencies
1227
-				if ( ! empty( $data['atts']['lightbox'] ) ) {
1227
+				if (!empty($data['atts']['lightbox'])) {
1228 1228
 
1229 1229
 					/**
1230 1230
 					 * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox`
1231 1231
 					 * @param string $script_slug If you want to use a different lightbox script, return the name of it here.
1232 1232
 					 */
1233
-					$js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' );
1233
+					$js_dependencies[] = apply_filters('gravity_view_lightbox_script', 'thickbox');
1234 1234
 
1235 1235
 					/**
1236 1236
 					 * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox`
1237 1237
 					 * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here.
1238 1238
 					 */
1239
-					$css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' );
1239
+					$css_dependencies[] = apply_filters('gravity_view_lightbox_style', 'thickbox');
1240 1240
 				}
1241 1241
 
1242 1242
 				/**
@@ -1244,34 +1244,34 @@  discard block
 block discarded – undo
1244 1244
 				 * @see https://github.com/katzwebservices/GravityView/issues/536
1245 1245
 				 * @since 1.15
1246 1246
 				 */
1247
-				if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) {
1247
+				if (gravityview_view_has_single_checkbox_or_radio($data['form'], $data['fields'])) {
1248 1248
 					$css_dependencies[] = 'dashicons';
1249 1249
 				}
1250 1250
 
1251
-				wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true );
1251
+				wp_register_script('gravityview-jquery-cookie', plugins_url('includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE), array('jquery'), GravityView_Plugin::version, true);
1252 1252
 
1253
-				$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
1253
+				$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
1254 1254
 
1255
-				wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true );
1255
+				wp_register_script('gravityview-fe-view', plugins_url('assets/js/fe-views'.$script_debug.'.js', GRAVITYVIEW_FILE), apply_filters('gravityview_js_dependencies', $js_dependencies), GravityView_Plugin::version, true);
1256 1256
 
1257
-				wp_enqueue_script( 'gravityview-fe-view' );
1257
+				wp_enqueue_script('gravityview-fe-view');
1258 1258
 
1259
-				if ( ! empty( $data['atts']['sort_columns'] ) ) {
1260
-					wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' );
1259
+				if (!empty($data['atts']['sort_columns'])) {
1260
+					wp_enqueue_style('gravityview_font', plugins_url('assets/css/font.css', GRAVITYVIEW_FILE), $css_dependencies, GravityView_Plugin::version, 'all');
1261 1261
 				}
1262 1262
 
1263
-				wp_enqueue_style( 'gravityview_default_style', plugins_url( 'templates/css/gv-default-styles.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' );
1263
+				wp_enqueue_style('gravityview_default_style', plugins_url('templates/css/gv-default-styles.css', GRAVITYVIEW_FILE), $css_dependencies, GravityView_Plugin::version, 'all');
1264 1264
 
1265
-				self::add_style( $data['template_id'] );
1265
+				self::add_style($data['template_id']);
1266 1266
 
1267 1267
 			}
1268 1268
 
1269
-			if ( 'wp_print_footer_scripts' === current_filter() ) {
1269
+			if ('wp_print_footer_scripts' === current_filter()) {
1270 1270
 
1271 1271
 				$js_localization = array(
1272 1272
 					'cookiepath' => COOKIEPATH,
1273
-					'clear' => _x( 'Clear', 'Clear all data from the form', 'gravityview' ),
1274
-					'reset' => _x( 'Reset', 'Reset the search form to the state that existed on page load', 'gravityview' ),
1273
+					'clear' => _x('Clear', 'Clear all data from the form', 'gravityview'),
1274
+					'reset' => _x('Reset', 'Reset the search form to the state that existed on page load', 'gravityview'),
1275 1275
 				);
1276 1276
 
1277 1277
 				/**
@@ -1279,9 +1279,9 @@  discard block
 block discarded – undo
1279 1279
 				 * @param array $js_localization The data padded to the Javascript file
1280 1280
 				 * @param array $views Array of View data arrays with View settings
1281 1281
 				 */
1282
-				$js_localization = apply_filters( 'gravityview_js_localization', $js_localization, $views );
1282
+				$js_localization = apply_filters('gravityview_js_localization', $js_localization, $views);
1283 1283
 
1284
-				wp_localize_script( 'gravityview-fe-view', 'gvGlobals', $js_localization );
1284
+				wp_localize_script('gravityview-fe-view', 'gvGlobals', $js_localization);
1285 1285
 			}
1286 1286
 		}
1287 1287
 	}
@@ -1290,15 +1290,15 @@  discard block
 block discarded – undo
1290 1290
 	 * Add template extra style if exists
1291 1291
 	 * @param string $template_id
1292 1292
 	 */
1293
-	public static function add_style( $template_id ) {
1293
+	public static function add_style($template_id) {
1294 1294
 
1295
-		if ( ! empty( $template_id ) && wp_style_is( 'gravityview_style_' . $template_id, 'registered' ) ) {
1296
-			do_action( 'gravityview_log_debug', sprintf( '[add_style] Adding extra template style for %s', $template_id ) );
1297
-			wp_enqueue_style( 'gravityview_style_' . $template_id );
1298
-		} elseif ( empty( $template_id ) ) {
1299
-			do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' );
1295
+		if (!empty($template_id) && wp_style_is('gravityview_style_'.$template_id, 'registered')) {
1296
+			do_action('gravityview_log_debug', sprintf('[add_style] Adding extra template style for %s', $template_id));
1297
+			wp_enqueue_style('gravityview_style_'.$template_id);
1298
+		} elseif (empty($template_id)) {
1299
+			do_action('gravityview_log_error', '[add_style] Cannot add template style; template_id is empty');
1300 1300
 		} else {
1301
-			do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) );
1301
+			do_action('gravityview_log_error', sprintf('[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id));
1302 1302
 		}
1303 1303
 
1304 1304
 	}
@@ -1317,17 +1317,17 @@  discard block
 block discarded – undo
1317 1317
 	 *
1318 1318
 	 * @return string Field Label
1319 1319
 	 */
1320
-	public function add_columns_sort_links( $label = '', $field, $form ) {
1320
+	public function add_columns_sort_links($label = '', $field, $form) {
1321 1321
 
1322 1322
 		/**
1323 1323
 		 * Not a table-based template; don't add sort icons
1324 1324
 		 * @since 1.12
1325 1325
 		 */
1326
-		if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) {
1326
+		if (!preg_match('/table/ism', GravityView_View::getInstance()->getTemplatePartSlug())) {
1327 1327
 			return $label;
1328 1328
 		}
1329 1329
 
1330
-		if ( ! $this->is_field_sortable( $field['id'], $form ) ) {
1330
+		if (!$this->is_field_sortable($field['id'], $form)) {
1331 1331
 			return $label;
1332 1332
 		}
1333 1333
 
@@ -1335,16 +1335,16 @@  discard block
 block discarded – undo
1335 1335
 
1336 1336
 		$class = 'gv-sort icon';
1337 1337
 
1338
-		$sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] );
1338
+		$sort_field_id = self::_override_sorting_id_by_field_type($field['id'], $form['id']);
1339 1339
 
1340 1340
 		$sort_args = array(
1341 1341
 			'sort' => $field['id'],
1342 1342
 			'dir' => 'asc',
1343 1343
 		);
1344 1344
 
1345
-		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) {
1345
+		if (!empty($sorting['key']) && (string)$sort_field_id === (string)$sorting['key']) {
1346 1346
 			//toggle sorting direction.
1347
-			if ( 'asc' === $sorting['direction'] ) {
1347
+			if ('asc' === $sorting['direction']) {
1348 1348
 				$sort_args['dir'] = 'desc';
1349 1349
 				$class .= ' gv-icon-sort-desc';
1350 1350
 			} else {
@@ -1355,9 +1355,9 @@  discard block
 block discarded – undo
1355 1355
 			$class .= ' gv-icon-caret-up-down';
1356 1356
 		}
1357 1357
 
1358
-		$url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) );
1358
+		$url = add_query_arg($sort_args, remove_query_arg(array('pagenum')));
1359 1359
 
1360
-		return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a>&nbsp;'. $label;
1360
+		return '<a href="'.esc_url_raw($url).'" class="'.$class.'" ></a>&nbsp;'.$label;
1361 1361
 
1362 1362
 	}
1363 1363
 
@@ -1371,10 +1371,10 @@  discard block
 block discarded – undo
1371 1371
 	 *
1372 1372
 	 * @return bool True: Yes, field is sortable; False: not sortable
1373 1373
 	 */
1374
-	public function is_field_sortable( $field_id = '', $form ) {
1374
+	public function is_field_sortable($field_id = '', $form) {
1375 1375
 
1376
-		if( is_numeric( $field_id ) ) {
1377
-			$field = GFFormsModel::get_field( $form, $field_id );
1376
+		if (is_numeric($field_id)) {
1377
+			$field = GFFormsModel::get_field($form, $field_id);
1378 1378
 			$field_id = $field->type;
1379 1379
 		}
1380 1380
 
@@ -1390,13 +1390,13 @@  discard block
 block discarded – undo
1390 1390
 		 * Modify what fields should never be sortable.
1391 1391
 		 * @since 1.7
1392 1392
 		 */
1393
-		$not_sortable = apply_filters( 'gravityview/sortable/field_blacklist', $not_sortable, $field_id, $form );
1393
+		$not_sortable = apply_filters('gravityview/sortable/field_blacklist', $not_sortable, $field_id, $form);
1394 1394
 
1395
-		if ( in_array( $field_id, $not_sortable ) ) {
1395
+		if (in_array($field_id, $not_sortable)) {
1396 1396
 			return false;
1397 1397
 		}
1398 1398
 
1399
-		return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) );
1399
+		return apply_filters("gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters("gravityview/sortable/field_{$field_id}", true, $form));
1400 1400
 
1401 1401
 	}
1402 1402
 
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   +71 added lines, -71 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
 
@@ -33,18 +33,18 @@  discard block
 block discarded – undo
33 33
 	 * @return void
34 34
 	 */
35 35
 	private function add_hooks() {
36
-		add_filter( 'post_row_actions', array( $this, 'make_duplicate_link_row' ), 10, 2 );
36
+		add_filter('post_row_actions', array($this, 'make_duplicate_link_row'), 10, 2);
37 37
 
38 38
 		/**
39 39
 		 * Connect actions to functions
40 40
 		 */
41
-		add_action( 'admin_action_duplicate_view', array( $this, 'save_as_new_view' ) );
42
-		add_action( 'admin_action_duplicate_view_as_draft', array( $this, 'save_as_new_view_draft' ) );
41
+		add_action('admin_action_duplicate_view', array($this, 'save_as_new_view'));
42
+		add_action('admin_action_duplicate_view_as_draft', array($this, 'save_as_new_view_draft'));
43 43
 
44 44
 		// Using our action hooks to copy meta fields
45
-		add_action( 'gv_duplicate_view', array( $this, 'copy_view_meta_info' ), 10, 2 );
45
+		add_action('gv_duplicate_view', array($this, 'copy_view_meta_info'), 10, 2);
46 46
 
47
-		add_filter( 'gravityview_connected_form_links', array( $this, 'connected_form_links' ), 10, 2 );
47
+		add_filter('gravityview_connected_form_links', array($this, 'connected_form_links'), 10, 2);
48 48
 	}
49 49
 
50 50
 	/**
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return array If it's the All Views page, return unedited. Otherwise, add a link to create cloned draft of View
57 57
 	 */
58
-	function connected_form_links( $links = array(), $form = array() ) {
58
+	function connected_form_links($links = array(), $form = array()) {
59 59
 		/** @global WP_Post $post */
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
 		}
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @since 1.6
90 90
 	 */
91
-	private function current_user_can_copy( $post ) {
91
+	private function current_user_can_copy($post) {
92 92
 
93
-		$id = is_object( $post ) ? $post->ID : $post;
93
+		$id = is_object($post) ? $post->ID : $post;
94 94
 
95 95
 		// Can't edit this current View
96
-		return GVCommon::has_cap( 'copy_gravityviews', $id );
96
+		return GVCommon::has_cap('copy_gravityviews', $id);
97 97
 
98 98
 	}
99 99
 
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 	 * @param string $status The post status
105 105
 	 * @since 1.6
106 106
 	 */
107
-	private function create_duplicate( $post, $status = '' ) {
107
+	private function create_duplicate($post, $status = '') {
108 108
 
109 109
 		// We only want to clone Views
110
-		if ( $post->post_type !== 'gravityview' ) {
110
+		if ($post->post_type !== 'gravityview') {
111 111
 			return;
112 112
 		}
113 113
 
@@ -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,
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 			'post_mime_type' => $post->post_mime_type,
132 132
 			'post_parent'    => $post->post_parent,
133 133
 			'post_password'  => $post->post_password,
134
-			'post_status'    => ( empty( $new_view_status ) ) ? $post->post_status : $new_view_status,
134
+			'post_status'    => (empty($new_view_status)) ? $post->post_status : $new_view_status,
135 135
 			'post_title'     => $post->post_title,
136 136
 			'post_type'      => $post->post_type,
137 137
 		);
@@ -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
-		if ( $copy_date ) {
147
+		if ($copy_date) {
148 148
 			$new_view['post_date']     = $new_post_date = $post->post_date;
149
-			$new_view['post_date_gmt'] = get_gmt_from_date( $new_post_date );
149
+			$new_view['post_date_gmt'] = get_gmt_from_date($new_post_date);
150 150
 		}
151 151
 
152 152
 		/**
@@ -155,15 +155,15 @@  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
-		$new_view_id = wp_insert_post( $new_view );
161
+		$new_view_id = wp_insert_post($new_view);
162 162
 
163 163
 		// If the copy is published or scheduled, we have to set a proper slug.
164
-		if ( $new_view_status == 'publish' || $new_view_status == 'future' ) {
164
+		if ($new_view_status == 'publish' || $new_view_status == 'future') {
165 165
 
166
-			$view_name = wp_unique_post_slug( $post->post_name, $new_view_id, $new_view_status, $post->post_type, $post->post_parent );
166
+			$view_name = wp_unique_post_slug($post->post_name, $new_view_id, $new_view_status, $post->post_type, $post->post_parent);
167 167
 
168 168
 			$new_view_name_array = array(
169 169
 				'ID' => $new_view_id,
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 			);
172 172
 
173 173
 			// Update the post into the database
174
-			wp_update_post( $new_view_name_array );
174
+			wp_update_post($new_view_name_array);
175 175
 		}
176 176
 
177 177
 		/**
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 		 * @param int $new_view_id The ID of the newly created View
182 182
 		 * @param WP_Post The View that was just cloned
183 183
 		 */
184
-		do_action( 'gv_duplicate_view', $new_view_id, $post );
184
+		do_action('gv_duplicate_view', $new_view_id, $post);
185 185
 
186
-		delete_post_meta( $new_view_id, '_dp_original' );
186
+		delete_post_meta($new_view_id, '_dp_original');
187 187
 
188
-		add_post_meta( $new_view_id, '_dp_original', $post->ID, false );
188
+		add_post_meta($new_view_id, '_dp_original', $post->ID, false);
189 189
 
190 190
 		return $new_view_id;
191 191
 	}
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @return void
202 202
 	 */
203
-	public function copy_view_meta_info( $new_id, $post ) {
203
+	public function copy_view_meta_info($new_id, $post) {
204 204
 
205
-		$post_meta_keys = get_post_custom_keys( $post->ID );
205
+		$post_meta_keys = get_post_custom_keys($post->ID);
206 206
 
207
-		if ( empty( $post_meta_keys ) ) {
207
+		if (empty($post_meta_keys)) {
208 208
 			return;
209 209
 		}
210 210
 
211
-		foreach ( $post_meta_keys as $meta_key ) {
211
+		foreach ($post_meta_keys as $meta_key) {
212 212
 
213
-			$meta_values = get_post_custom_values( $meta_key, $post->ID );
213
+			$meta_values = get_post_custom_values($meta_key, $post->ID);
214 214
 
215
-			foreach ( $meta_values as $meta_value ) {
215
+			foreach ($meta_values as $meta_value) {
216 216
 
217
-				$meta_value = maybe_unserialize( $meta_value );
217
+				$meta_value = maybe_unserialize($meta_value);
218 218
 
219
-				add_post_meta( $new_id, $meta_key, $meta_value );
219
+				add_post_meta($new_id, $meta_key, $meta_value);
220 220
 			}
221 221
 		}
222 222
 	}
@@ -228,22 +228,22 @@  discard block
 block discarded – undo
228 228
 	 * @param array $actions Row action links. Defaults are 'Edit', 'Quick Edit', 'Restore, 'Trash', 'Delete Permanently', 'Preview', and 'View'
229 229
 	 * @param WP_Post $post
230 230
 	 */
231
-	public function make_duplicate_link_row( $actions, $post ) {
231
+	public function make_duplicate_link_row($actions, $post) {
232 232
 
233 233
 		// Only process on GravityView Views
234
-		if ( get_post_type( $post ) === 'gravityview' && $this->current_user_can_copy( $post ) ) {
234
+		if (get_post_type($post) === 'gravityview' && $this->current_user_can_copy($post)) {
235 235
 
236
-			$clone_link = $this->get_clone_view_link( $post->ID, 'display', false );
237
-			$clone_text = __( 'Clone', 'gravityview' );
238
-			$clone_title = __( 'Clone this View', 'gravityview' );
236
+			$clone_link = $this->get_clone_view_link($post->ID, 'display', false);
237
+			$clone_text = __('Clone', 'gravityview');
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
-			$clone_draft_link = $this->get_clone_view_link( $post->ID );
243
-			$clone_draft_text = $this->is_all_views_page() ? __( 'New Draft', 'gravityview' ) : __( 'Clone View', 'gravityview' );
244
-			$clone_draft_title = __( 'Copy as a new draft View', 'gravityview' );
242
+			$clone_draft_link = $this->get_clone_view_link($post->ID);
243
+			$clone_draft_text = $this->is_all_views_page() ? __('New Draft', 'gravityview') : __('Clone View', 'gravityview');
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;
@@ -259,31 +259,31 @@  discard block
 block discarded – undo
259 259
 	 * @param string $draft Optional, default to true
260 260
 	 * @return string
261 261
 	 */
262
-	private function get_clone_view_link( $id = 0, $context = 'display', $draft = true ) {
262
+	private function get_clone_view_link($id = 0, $context = 'display', $draft = true) {
263 263
 
264 264
 		// Make sure they have permission
265
-		if ( false === $this->current_user_can_copy( $id ) ) {
265
+		if (false === $this->current_user_can_copy($id)) {
266 266
 			return '';
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
 
274 274
 		$action_name = $draft ? "duplicate_view_as_draft" : "duplicate_view";
275 275
 
276
-		$action = '?action=' . $action_name . '&post=' . $view->ID;
276
+		$action = '?action='.$action_name.'&post='.$view->ID;
277 277
 
278
-		if ( 'display' == $context ) {
279
-			$action = esc_html( $action );
278
+		if ('display' == $context) {
279
+			$action = esc_html($action);
280 280
 		}
281 281
 
282
-		$post_type_object = get_post_type_object( $view->post_type );
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 ) {
286
-			do_action( 'gravityview_log_error', __METHOD__ . ' No gravityview post type exists when trying to clone the View.', $view );
285
+		if (!$post_type_object) {
286
+			do_action('gravityview_log_error', __METHOD__.' No gravityview post type exists when trying to clone the View.', $view);
287 287
 			return '';
288 288
 		}
289 289
 
@@ -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
 	}
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 * @return void
309 309
 	 */
310 310
 	public function save_as_new_view_draft() {
311
-		$this->save_as_new_view( 'draft' );
311
+		$this->save_as_new_view('draft');
312 312
 	}
313 313
 
314 314
 	/**
@@ -319,38 +319,38 @@  discard block
 block discarded – undo
319 319
 	 * @param string $status The status to set for the new View
320 320
 	 * @return void
321 321
 	 */
322
-	public function save_as_new_view( $status = '' ) {
322
+	public function save_as_new_view($status = '') {
323 323
 
324
-		if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) ) ) {
325
-			wp_die( __( 'No post to duplicate has been supplied!', 'gravityview' ) );
324
+		if (!(isset($_GET['post']) || isset($_POST['post']))) {
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 ) ) {
332
-			wp_die( __( 'You don\'t have permission to copy this View.', 'gravityview' ) );
331
+		if (!$this->current_user_can_copy($id)) {
332
+			wp_die(__('You don\'t have permission to copy this View.', 'gravityview'));
333 333
 		}
334 334
 
335
-		$post = get_post( $id );
335
+		$post = get_post($id);
336 336
 
337 337
 		// Copy the post and insert it
338
-		if ( isset( $post ) && $post != NULL ) {
338
+		if (isset($post) && $post != NULL) {
339 339
 
340
-			$new_id = $this->create_duplicate( $post, $status );
340
+			$new_id = $this->create_duplicate($post, $status);
341 341
 
342
-			if ( $status == '' ) {
342
+			if ($status == '') {
343 343
 				// Redirect to the post list screen
344
-				wp_redirect( admin_url( 'edit.php?post_type=' . $post->post_type ) );
344
+				wp_redirect(admin_url('edit.php?post_type='.$post->post_type));
345 345
 			} else {
346 346
 				// Redirect to the edit screen for the new draft post
347
-				wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_id ) );
347
+				wp_redirect(admin_url('post.php?action=edit&post='.$new_id));
348 348
 			}
349 349
 			exit;
350 350
 
351 351
 		} else {
352 352
 
353
-			wp_die( sprintf( esc_attr__( 'Copy creation failed, could not find original View with ID #%d', 'gravityview' ), $id ) );
353
+			wp_die(sprintf(esc_attr__('Copy creation failed, could not find original View with ID #%d', 'gravityview'), $id));
354 354
 
355 355
 		}
356 356
 	}
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   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 	function add_hooks() {
59 59
 
60
-		add_filter( 'gravityview/admin/notices', array( $this, 'insert_admin_notices' ) );
60
+		add_filter('gravityview/admin/notices', array($this, 'insert_admin_notices'));
61 61
 
62 62
 		$this->add_fallback_shortcode();
63 63
 	}
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @return array
70 70
 	 */
71
-	function insert_admin_notices( $notices = array() ) {
72
-		return array_merge( $notices, self::$notices );
71
+	function insert_admin_notices($notices = array()) {
72
+		return array_merge($notices, self::$notices);
73 73
 	}
74 74
 
75 75
 	/**
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;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @return bool
88 88
 	 */
89 89
 	public static function is_valid() {
90
-		return ( self::is_valid_gravity_forms() && self::is_valid_wordpress() && self::is_valid_php() );
90
+		return (self::is_valid_gravity_forms() && self::is_valid_wordpress() && self::is_valid_php());
91 91
 	}
92 92
 
93 93
 	/**
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 		// If Gravity Forms doesn't exist or is outdated, load the admin view class to
124 124
 		// show the notice, but not load any post types or process shortcodes.
125 125
 		// Without Gravity Forms, there is no GravityView. Beautiful, really.
126
-		if( ! self::is_valid() ) {
126
+		if (!self::is_valid()) {
127 127
 
128 128
 			// If the plugin's not loaded, might as well hide the shortcode for people.
129
-			add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice') );
129
+			add_shortcode('gravityview', array($this, '_shortcode_gf_notice'));
130 130
 
131 131
 		}
132 132
 	}
@@ -150,17 +150,17 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @return null|string NULL returned if user can't activate plugins. Notice shown with a warning that GF isn't supported.
152 152
 	 */
153
-	public function _shortcode_gf_notice( $atts = array(), $content = null, $shortcode = 'gravityview' ) {
153
+	public function _shortcode_gf_notice($atts = array(), $content = null, $shortcode = 'gravityview') {
154 154
 
155
-		if( ! GVCommon::has_cap( 'activate_plugins' ) ) {
155
+		if (!GVCommon::has_cap('activate_plugins')) {
156 156
 			return null;
157 157
 		}
158 158
 
159 159
 		$notices = self::get_notices();
160 160
 
161
-		$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>';
162
-		foreach( (array)$notices as $notice ) {
163
-			$message .= wpautop( $notice['message'] );
161
+		$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>';
162
+		foreach ((array)$notices as $notice) {
163
+			$message .= wpautop($notice['message']);
164 164
 		}
165 165
 		$message .= '</div>';
166 166
 
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
 	 * @return boolean
176 176
 	 */
177 177
 	public static function check_php() {
178
-		if( false === version_compare( phpversion(), GV_MIN_PHP_VERSION , '>=' ) ) {
178
+		if (false === version_compare(phpversion(), GV_MIN_PHP_VERSION, '>=')) {
179 179
 
180 180
 			self::$notices['php_version'] = array(
181 181
 				'class' => 'error',
182
-				'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>' ),
182
+				'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>'),
183 183
 				'cap' => 'manage_options',
184 184
 				'dismiss' => 'php_version',
185 185
 			);
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	public static function check_wordpress() {
200 200
 		global $wp_version;
201 201
 
202
-		if( version_compare( $wp_version, GV_MIN_WP_VERSION ) <= 0 ) {
202
+		if (version_compare($wp_version, GV_MIN_WP_VERSION) <= 0) {
203 203
 
204 204
 			self::$notices['wp_version'] = array(
205 205
 				'class' => 'error',
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>' ),
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 207
 			    'cap' => 'update_core',
208 208
 				'dismiss' => 'wp_version',
209 209
 			);
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 	public static function check_gravityforms() {
227 227
 
228 228
 		// Bypass other checks: if the class exists
229
-		if( class_exists( 'GFCommon' ) ) {
229
+		if (class_exists('GFCommon')) {
230 230
 
231 231
 			// and the version's right, we're good.
232
-			if( true === version_compare( GFCommon::$version, GV_MIN_GF_VERSION, ">=" ) ) {
232
+			if (true === version_compare(GFCommon::$version, GV_MIN_GF_VERSION, ">=")) {
233 233
 				return true;
234 234
 			}
235 235
 
236 236
 			// Or the version's wrong
237 237
 			self::$notices['gf_version'] = array(
238 238
 				'class' => 'error',
239
-				'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_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>', "\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'),
239
+				'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_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>', "\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>'),
240 240
 				'cap' => 'update_plugins',
241 241
 				'dismiss' => 'gf_version',
242 242
 			);
@@ -244,40 +244,40 @@  discard block
 block discarded – undo
244 244
 			return false;
245 245
 		}
246 246
 
247
-		$gf_status = self::get_plugin_status( 'gravityforms/gravityforms.php' );
247
+		$gf_status = self::get_plugin_status('gravityforms/gravityforms.php');
248 248
 
249 249
 		/**
250 250
 		 * The plugin is activated and yet somehow GFCommon didn't get picked up...
251 251
 		 * OR
252 252
 		 * It's the Network Admin and we just don't know whether the sites have GF activated themselves.
253 253
 		 */
254
-		if( true === $gf_status || is_network_admin() ) {
254
+		if (true === $gf_status || is_network_admin()) {
255 255
 			return true;
256 256
 		}
257 257
 
258 258
 		// If GFCommon doesn't exist, assume GF not active
259 259
 		$return = false;
260 260
 
261
-		switch( $gf_status ) {
261
+		switch ($gf_status) {
262 262
 			case 'inactive':
263 263
 
264 264
 				// Required for multisite
265
-				if( ! function_exists('wp_create_nonce') ) {
266
-					require_once ABSPATH . WPINC . '/pluggable.php';
265
+				if (!function_exists('wp_create_nonce')) {
266
+					require_once ABSPATH.WPINC.'/pluggable.php';
267 267
 				}
268 268
 
269 269
 				// Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE"
270
-				if( is_multisite() ) {
270
+				if (is_multisite()) {
271 271
 					wp_cookie_constants();
272 272
 				}
273 273
 
274 274
 				$return = false;
275 275
 
276
-				$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">';
276
+				$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">';
277 277
 
278 278
 				self::$notices['gf_inactive'] = array(
279 279
 					'class' => 'error',
280
-					'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>' ),
280
+					'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>'),
281 281
 					'cap' => 'activate_plugins',
282 282
 					'dismiss' => 'gf_inactive',
283 283
 				);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 			default:
287 287
 				self::$notices['gf_installed'] = array(
288 288
 					'class' => 'error',
289
-					'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>'),
289
+					'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>'),
290 290
 					'cap' => 'install_plugins',
291 291
 					'dismiss' => 'gf_installed',
292 292
 				);
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 	 */
304 304
 	private static function check_gf_directory() {
305 305
 
306
-		if( class_exists( 'GFDirectory' ) ) {
306
+		if (class_exists('GFDirectory')) {
307 307
 			self::$notices['gf_directory'] = array(
308 308
 				'class' => 'error is-dismissible',
309
-				'title' => __('Potential Conflict', 'gravityview' ),
310
-				'message' => __( 'GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview' ),
309
+				'title' => __('Potential Conflict', 'gravityview'),
310
+				'message' => __('GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview'),
311 311
 				'dismiss' => 'gf_directory',
312 312
 				'cap' => 'activate_plugins',
313 313
 			);
@@ -323,23 +323,23 @@  discard block
 block discarded – undo
323 323
 	 * @param string $location (default: '')
324 324
 	 * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive
325 325
 	 */
326
-	public static function get_plugin_status( $location = '' ) {
326
+	public static function get_plugin_status($location = '') {
327 327
 
328
-		if( ! function_exists('is_plugin_active') ) {
329
-			include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
328
+		if (!function_exists('is_plugin_active')) {
329
+			include_once(ABSPATH.'/wp-admin/includes/plugin.php');
330 330
 		}
331 331
 
332
-		if( is_network_admin() && is_plugin_active_for_network( $location ) ) {
332
+		if (is_network_admin() && is_plugin_active_for_network($location)) {
333 333
 			return true;
334 334
 		}
335 335
 
336
-		if( !is_network_admin() && is_plugin_active( $location ) ) {
336
+		if (!is_network_admin() && is_plugin_active($location)) {
337 337
 			return true;
338 338
 		}
339 339
 
340
-		if(
341
-			!file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) &&
342
-			!file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location )
340
+		if (
341
+			!file_exists(trailingslashit(WP_PLUGIN_DIR).$location) &&
342
+			!file_exists(trailingslashit(WPMU_PLUGIN_DIR).$location)
343 343
 		) {
344 344
 			return false;
345 345
 		}
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   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -51,17 +51,17 @@  discard block
 block discarded – undo
51 51
 	 * @since 1.15
52 52
 	 */
53 53
 	private function add_hooks() {
54
-		add_shortcode( 'gv_entry_link', array( $this, 'read_shortcode' ) );
55
-		add_shortcode( 'gv_edit_entry_link', array( $this, 'edit_shortcode' ) );
56
-		add_shortcode( 'gv_delete_entry_link', array( $this, 'delete_shortcode' ) );
54
+		add_shortcode('gv_entry_link', array($this, 'read_shortcode'));
55
+		add_shortcode('gv_edit_entry_link', array($this, 'edit_shortcode'));
56
+		add_shortcode('gv_delete_entry_link', array($this, 'delete_shortcode'));
57 57
 	}
58 58
 
59 59
 	/**
60 60
 	 * @since 1.15
61 61
 	 * @copydoc GravityView_Entry_Link_Shortcode::shortcode
62 62
 	 */
63
-	public function read_shortcode( $atts, $content = null, $context = 'gv_entry_link' ) {
64
-		return $this->shortcode( $atts, $content, $context );
63
+	public function read_shortcode($atts, $content = null, $context = 'gv_entry_link') {
64
+		return $this->shortcode($atts, $content, $context);
65 65
 	}
66 66
 
67 67
 	/**
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 	 * @since 1.15
72 72
 	 * @copydoc GravityView_Entry_Link_Shortcode::shortcode
73 73
 	 */
74
-	public function edit_shortcode( $atts, $content = null, $context = 'gv_edit_entry_link' ) {
74
+	public function edit_shortcode($atts, $content = null, $context = 'gv_edit_entry_link') {
75 75
 		$atts['action'] = 'edit';
76 76
 
77
-		return $this->shortcode( $atts, $content, $context );
77
+		return $this->shortcode($atts, $content, $context);
78 78
 	}
79 79
 
80 80
 	/**
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
 	 * @since 1.15
85 85
 	 * @copydoc GravityView_Entry_Link_Shortcode::shortcode
86 86
 	 */
87
-	public function delete_shortcode( $atts, $content = null, $context = 'gv_delete_entry_link' ) {
87
+	public function delete_shortcode($atts, $content = null, $context = 'gv_delete_entry_link') {
88 88
 		$atts['action'] = 'delete';
89 89
 
90
-		return $this->shortcode( $atts, $content, $context );
90
+		return $this->shortcode($atts, $content, $context);
91 91
 	}
92 92
 
93 93
 	/**
@@ -110,58 +110,58 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return null|string If admin or an error occurred, returns null. Otherwise, returns entry link output. If `$atts['return']` is 'url', the entry link URL. Otherwise, entry link `<a>` HTML tag.
112 112
 	 */
113
-	private function shortcode( $atts, $content = null, $context = 'gv_entry_link' ) {
113
+	private function shortcode($atts, $content = null, $context = 'gv_entry_link') {
114 114
 
115 115
 		// Don't process when saving post. Keep processing if it's admin-ajax.php
116
-		if ( ! class_exists( 'GravityView_Plugin' ) || GravityView_Plugin::is_admin() ) {
116
+		if (!class_exists('GravityView_Plugin') || GravityView_Plugin::is_admin()) {
117 117
 			return null;
118 118
 		}
119 119
 
120 120
 		// Make sure GV is loaded
121
-		if ( ! class_exists( 'GravityView_frontend' ) || ! class_exists( 'GravityView_View' ) ) {
122
-			do_action( 'gravityview_log_error', __METHOD__ . ' GravityView_frontend or GravityView_View do not exist.' );
121
+		if (!class_exists('GravityView_frontend') || !class_exists('GravityView_View')) {
122
+			do_action('gravityview_log_error', __METHOD__.' GravityView_frontend or GravityView_View do not exist.');
123 123
 
124 124
 			return null;
125 125
 		}
126 126
 
127
-		$this->settings = shortcode_atts( self::$defaults, $atts, $context );
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
-		if ( empty( $this->view_id ) ) {
132
-			do_action( 'gravityview_log_error', __METHOD__ . ' A View ID was not defined and we are not inside a View' );
131
+		if (empty($this->view_id)) {
132
+			do_action('gravityview_log_error', __METHOD__.' A View ID was not defined and we are not inside a View');
133 133
 
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
-		do_action( 'gravityview_log_debug', __METHOD__ . ' ' . $context . ' $atts: ', $atts );
139
+		do_action('gravityview_log_debug', __METHOD__.' '.$context.' $atts: ', $atts);
140 140
 
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'] );
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']);
143 143
 
144 144
 			return null;
145 145
 		}
146 146
 
147 147
 		$url = $this->get_url();
148 148
 
149
-		if ( ! $url ) {
150
-			do_action( 'gravityview_log_error', __METHOD__ . ' Link returned false; View or Post may not exist.' );
149
+		if (!$url) {
150
+			do_action('gravityview_log_error', __METHOD__.' Link returned false; View or Post may not exist.');
151 151
 
152 152
 			return false;
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
 
160 160
 		$link_atts = $this->get_link_atts();
161 161
 
162
-		$link_text = $this->get_anchor_text( $content );
162
+		$link_text = $this->get_anchor_text($content);
163 163
 
164
-		return gravityview_get_link( $url, $link_text, $link_atts );
164
+		return gravityview_get_link($url, $link_text, $link_atts);
165 165
 	}
166 166
 
167 167
 	/**
@@ -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
 	/**
@@ -194,21 +194,21 @@  discard block
 block discarded – undo
194 194
 	 *
195 195
 	 * @return string Text to use for HTML anchor
196 196
 	 */
197
-	private function get_anchor_text( $content = null ) {
197
+	private function get_anchor_text($content = null) {
198 198
 
199
-		if ( $content ) {
199
+		if ($content) {
200 200
 			return $content;
201 201
 		}
202 202
 
203
-		switch ( $this->settings['action'] ) {
203
+		switch ($this->settings['action']) {
204 204
 			case 'edit':
205
-				$anchor_text = __( 'Edit Entry', 'gravityview' );
205
+				$anchor_text = __('Edit Entry', 'gravityview');
206 206
 				break;
207 207
 			case 'delete':
208
-				$anchor_text = __( 'Delete Entry', 'gravityview' );
208
+				$anchor_text = __('Delete Entry', 'gravityview');
209 209
 				break;
210 210
 			default:
211
-				$anchor_text = __( 'View Details', 'gravityview' );
211
+				$anchor_text = __('View Details', 'gravityview');
212 212
 		}
213 213
 
214 214
 		return $anchor_text;
@@ -228,21 +228,21 @@  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
-				$url = GravityView_Edit_Entry::get_edit_link( $this->entry, $this->view_id, $post_id );
235
+				$url = GravityView_Edit_Entry::get_edit_link($this->entry, $this->view_id, $post_id);
236 236
 				break;
237 237
 			case 'delete':
238
-				$url = GravityView_Delete_Entry::get_delete_link( $this->entry, $this->view_id, $post_id );
238
+				$url = GravityView_Delete_Entry::get_delete_link($this->entry, $this->view_id, $post_id);
239 239
 				break;
240 240
 			case 'read':
241 241
 			default:
242
-				$url = GravityView_API::entry_link( $this->entry, $post_id );
242
+				$url = GravityView_API::entry_link($this->entry, $post_id);
243 243
 		}
244 244
 
245
-		$url = $this->maybe_add_field_values_query_args( $url );
245
+		$url = $this->maybe_add_field_values_query_args($url);
246 246
 
247 247
 		return $url;
248 248
 	}
@@ -255,12 +255,12 @@  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
-				$has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry, $this->view_id );
260
+				$has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry($this->entry, $this->view_id);
261 261
 				break;
262 262
 			case 'delete':
263
-				$has_cap = GravityView_Delete_Entry::check_user_cap_delete_entry( $this->entry, array(), $this->view_id );
263
+				$has_cap = GravityView_Delete_Entry::check_user_cap_delete_entry($this->entry, array(), $this->view_id);
264 264
 				break;
265 265
 			case 'read':
266 266
 			default:
@@ -281,28 +281,28 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return array|bool Gravity Forms array, if found. Otherwise, false.
283 283
 	 */
284
-	private function get_entry( $entry_id = 0 ) {
284
+	private function get_entry($entry_id = 0) {
285 285
 
286 286
 		$backup_entry = GravityView_frontend::getInstance()->getSingleEntry() ? GravityView_frontend::getInstance()->getEntry() : GravityView_View::getInstance()->getCurrentEntry();
287 287
 
288
-		if ( empty( $entry_id ) ) {
289
-			if ( ! $backup_entry ) {
290
-				do_action( 'gravityview_log_error', __METHOD__ . ' No entry defined (or entry id not valid number)', $this->settings );
288
+		if (empty($entry_id)) {
289
+			if (!$backup_entry) {
290
+				do_action('gravityview_log_error', __METHOD__.' No entry defined (or entry id not valid number)', $this->settings);
291 291
 
292 292
 				return false;
293 293
 			}
294 294
 			$entry = $backup_entry;
295 295
 		} else {
296
-			$entry = wp_cache_get( 'gv_entry_link_entry_' . $entry_id, 'gravityview_entry_link_shortcode' );
297
-			if ( false === $entry ) {
298
-				$entry = GVCommon::get_entry( $entry_id, true, false );
299
-				wp_cache_add( 'gv_entry_link_entry_' . $entry_id, $entry, 'gravityview_entry_link_shortcode' );
296
+			$entry = wp_cache_get('gv_entry_link_entry_'.$entry_id, 'gravityview_entry_link_shortcode');
297
+			if (false === $entry) {
298
+				$entry = GVCommon::get_entry($entry_id, true, false);
299
+				wp_cache_add('gv_entry_link_entry_'.$entry_id, $entry, 'gravityview_entry_link_shortcode');
300 300
 			}
301 301
 		}
302 302
 
303 303
 		// No search results
304
-		if ( false === $entry ) {
305
-			do_action( 'gravityview_log_error', __METHOD__ . ' No entries match the entry ID defined', $entry_id );
304
+		if (false === $entry) {
305
+			do_action('gravityview_log_error', __METHOD__.' No entries match the entry ID defined', $entry_id);
306 306
 
307 307
 			return false;
308 308
 		}
@@ -318,13 +318,13 @@  discard block
 block discarded – undo
318 318
 	 *
319 319
 	 * @param string $href URL
320 320
 	 */
321
-	private function maybe_add_field_values_query_args( $url ) {
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
-			$url = add_query_arg( $field_values, $url );
327
+			$url = add_query_arg($field_values, $url);
328 328
 		}
329 329
 
330 330
 		return $url;
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   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -69,22 +69,22 @@  discard block
 block discarded – undo
69 69
 
70 70
 	function __construct() {
71 71
 
72
-		add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
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
-		add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 );
76
+		add_action('admin_notices', array($this, 'admin_notice'), 100);
77 77
 
78
-		add_action( 'gravityview/metaboxes/before_render', array( $this, 'add_metabox_tab' ) );
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
 
84
-		add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) );
84
+		add_filter('gravityview_tooltips', array($this, 'tooltips'));
85 85
 
86 86
 		// Save the form configuration. Run at 14 so that View metadata is already saved (at 10)
87
-		add_action( 'save_post', array( $this, 'save_post' ), 14 );
87
+		add_action('save_post', array($this, 'save_post'), 14);
88 88
 
89 89
 		$this->add_hooks();
90 90
 
@@ -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
 
@@ -131,20 +131,20 @@  discard block
 block discarded – undo
131 131
 			'priority' => 'default',
132 132
 		);
133 133
 
134
-		$tab = wp_parse_args( $tab_settings, $tab_defaults );
134
+		$tab = wp_parse_args($tab_settings, $tab_defaults);
135 135
 
136 136
 		// Force the screen to be GravityView
137 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
-			GravityView_Metabox_Tabs::add( $metabox );
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,37 +160,37 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function load_plugin_textdomain() {
162 162
 
163
-		if( empty( $this->_text_domain ) ) {
164
-			do_action( 'gravityview_log_debug', __METHOD__ . ': Extension translation cannot be loaded; the `_text_domain` variable is not defined', $this );
163
+		if (empty($this->_text_domain)) {
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
 		}
167 167
 
168 168
 		// Backward compat for Ratings & Reviews / Maps
169
-		$path = isset( $this->_path ) ? $this->_path : ( isset( $this->plugin_file ) ? $this->plugin_file : '' );
169
+		$path = isset($this->_path) ? $this->_path : (isset($this->plugin_file) ? $this->plugin_file : '');
170 170
 
171 171
 		// Set filter for plugin's languages directory
172
-		$lang_dir = dirname( plugin_basename( $path ) ) . '/languages/';
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
-		$mofile = sprintf( '%1$s-%2$s.mo', $this->_text_domain, $locale );
177
+		$mofile = sprintf('%1$s-%2$s.mo', $this->_text_domain, $locale);
178 178
 
179 179
 		// Setup paths to current locale file
180
-		$mofile_local  = $lang_dir . $mofile;
181
-		$mofile_global = WP_LANG_DIR . '/' . $this->_text_domain . '/' . $mofile;
180
+		$mofile_local  = $lang_dir.$mofile;
181
+		$mofile_global = WP_LANG_DIR.'/'.$this->_text_domain.'/'.$mofile;
182 182
 
183
-		if ( file_exists( $mofile_global ) ) {
183
+		if (file_exists($mofile_global)) {
184 184
 			// Look in global /wp-content/languages/[plugin-dir]/ folder
185
-			load_textdomain( $this->_text_domain, $mofile_global );
185
+			load_textdomain($this->_text_domain, $mofile_global);
186 186
 		}
187
-		elseif ( file_exists( $mofile_local ) ) {
187
+		elseif (file_exists($mofile_local)) {
188 188
 			// Look in local /wp-content/plugins/[plugin-dir]/languages/ folder
189
-			load_textdomain( $this->_text_domain, $mofile_local );
189
+			load_textdomain($this->_text_domain, $mofile_local);
190 190
 		}
191 191
 		else {
192 192
 			// Load the default language files
193
-			load_plugin_textdomain( $this->_text_domain, false, $lang_dir );
193
+			load_plugin_textdomain($this->_text_domain, false, $lang_dir);
194 194
 		}
195 195
 	}
196 196
 
@@ -202,7 +202,7 @@  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
 
@@ -219,17 +219,17 @@  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
-			$file_path = plugin_dir_path( __FILE__ ) . 'lib/EDD_SL_Plugin_Updater.php';
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 ) ) {
232
-				$file_path = plugin_dir_path( __FILE__ ) . '/EDD_SL_Plugin_Updater.php';
231
+			if (!file_exists($file_path)) {
232
+				$file_path = plugin_dir_path(__FILE__).'/EDD_SL_Plugin_Updater.php';
233 233
 			}
234 234
 
235 235
 			include_once $file_path;
@@ -238,7 +238,7 @@  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,
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
             	'version'	=> $this->_version, // current version number
248 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
251
-            	'author' 	=> strip_tags( $this->_author )  // author of this plugin
250
+            	'item_name' => $this->_title, // name of this plugin
251
+            	'author' 	=> strip_tags($this->_author)  // author of this plugin
252 252
           	)
253 253
         );
254 254
 	}
@@ -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
 		}
@@ -280,16 +280,16 @@  discard block
 block discarded – undo
280 280
 	 * Add a notice to be displayed in the admin.
281 281
 	 * @param array $notice Array with `class` and `message` keys. The message is not escaped.
282 282
 	 */
283
-	public static function add_notice( $notice = array() ) {
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 ) ) {
289
-			$notice = array( 'message' => $notice );
288
+		} else if (is_string($notice)) {
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 294
 		self::$admin_notices[] = $notice;
295 295
 	}
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 * @param  int $post_id Post ID
305 305
 	 * @return void
306 306
 	 */
307
-	public function save_post( $post_id ) {}
307
+	public function save_post($post_id) {}
308 308
 
309 309
 	/**
310 310
 	 * Add tooltips for the extension.
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	 * @param  array  $tooltips Existing GV tooltips, with `title` and `value` keys
324 324
 	 * @return array           Modified tooltips
325 325
 	 */
326
-	public function tooltips( $tooltips = array() ) {
326
+	public function tooltips($tooltips = array()) {
327 327
 
328 328
 		return $tooltips;
329 329
 
@@ -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
 
@@ -364,11 +364,11 @@  discard block
 block discarded – undo
364 364
 
365 365
 		}
366 366
 
367
-		if ( ! empty( $message ) ) {
367
+		if (!empty($message)) {
368 368
 
369
-			self::add_notice( $message );
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   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -183,12 +183,10 @@
 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
 		}
Please login to merge, or discard this patch.
includes/class-gravityview-merge-tags.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
 	 * @param bool $url_encode Whether to URL-encode output
136 136
 	 * @param bool $esc_html Whether to apply `esc_html()` to output
137 137
 	 *
138
-	 * @return mixed
138
+	 * @return string
139 139
 	 */
140 140
 	public static function replace_gv_merge_tags(  $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) {
141 141
 
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	private function add_hooks() {
21 21
 
22
-		add_filter( 'gform_custom_merge_tags', array( $this, '_gform_custom_merge_tags' ), 10, 4 );
22
+		add_filter('gform_custom_merge_tags', array($this, '_gform_custom_merge_tags'), 10, 4);
23 23
 
24 24
 		/** @see GFCommon::replace_variables_prepopulate **/
25
-		add_filter( 'gform_replace_merge_tags', array( 'GravityView_Merge_Tags', 'replace_gv_merge_tags' ), 10, 7 );
25
+		add_filter('gform_replace_merge_tags', array('GravityView_Merge_Tags', 'replace_gv_merge_tags'), 10, 7);
26 26
 
27 27
 	}
28 28
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @param  bool       $esc_html     Pass return value through `esc_html()`
44 44
 	 * @return string                  Text with variables maybe replaced
45 45
 	 */
46
-	public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true ) {
46
+	public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true) {
47 47
 
48 48
 		/**
49 49
 		 * @filter `gravityview_do_replace_variables` Turn off merge tag variable replacements.\n
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 		 * @param[in]  array      $form        GF Form array
55 55
 		 * @param[in]  array      $entry        GF Entry array
56 56
 		 */
57
-		$do_replace_variables = apply_filters( 'gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry );
57
+		$do_replace_variables = apply_filters('gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry);
58 58
 
59
-		if( strpos( $text, '{') === false || ! $do_replace_variables ) {
59
+		if (strpos($text, '{') === false || !$do_replace_variables) {
60 60
 			return $text;
61 61
 		}
62 62
 
@@ -65,20 +65,20 @@  discard block
 block discarded – undo
65 65
 		 * This allows us to replace our tags first.
66 66
 		 * @since 1.15
67 67
 		 */
68
-		$text = self::replace_gv_merge_tags( $text, $form, $entry );
68
+		$text = self::replace_gv_merge_tags($text, $form, $entry);
69 69
 
70 70
 		// Check for fields - if they exist, we let Gravity Forms handle it.
71 71
 		preg_match_all('/{[^{]*?:(\d+(\.\d+)?)(:(.*?))?}/mi', $text, $matches, PREG_SET_ORDER);
72 72
 
73
-		if( empty( $matches ) ) {
73
+		if (empty($matches)) {
74 74
 
75 75
 			// Check for form variables
76
-			if( !preg_match( '/\{(all_fields(:(.*?))?|all_fields_display_empty|pricing_fields|form_title|entry_url|ip|post_id|admin_email|post_edit_url|form_id|entry_id|embed_url|date_mdy|date_dmy|embed_post:(.*?)|custom_field:(.*?)|user_agent|referer|gv:(.*?)|get:(.*?)|user:(.*?)|created_by:(.*?))\}/ism', $text ) ) {
76
+			if (!preg_match('/\{(all_fields(:(.*?))?|all_fields_display_empty|pricing_fields|form_title|entry_url|ip|post_id|admin_email|post_edit_url|form_id|entry_id|embed_url|date_mdy|date_dmy|embed_post:(.*?)|custom_field:(.*?)|user_agent|referer|gv:(.*?)|get:(.*?)|user:(.*?)|created_by:(.*?))\}/ism', $text)) {
77 77
 				return $text;
78 78
 			}
79 79
 		}
80 80
 
81
-		return GFCommon::replace_variables( $text, $form, $entry, $url_encode, $esc_html );
81
+		return GFCommon::replace_variables($text, $form, $entry, $url_encode, $esc_html);
82 82
 	}
83 83
 
84 84
 	/**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @return array Modified merge tags
95 95
 	 */
96
-	public function _gform_custom_merge_tags( $existing_merge_tags = array(), $form_id, $fields = array(), $element_id = '' ) {
96
+	public function _gform_custom_merge_tags($existing_merge_tags = array(), $form_id, $fields = array(), $element_id = '') {
97 97
 
98 98
 		$created_by_merge_tags = array(
99 99
 			array(
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		);
120 120
 
121 121
 		//return the form object from the php hook
122
-		return array_merge( $existing_merge_tags, $created_by_merge_tags );
122
+		return array_merge($existing_merge_tags, $created_by_merge_tags);
123 123
 	}
124 124
 
125 125
 	/**
@@ -137,21 +137,21 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return mixed
139 139
 	 */
140
-	public static function replace_gv_merge_tags(  $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) {
140
+	public static function replace_gv_merge_tags($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false) {
141 141
 
142 142
 		/**
143 143
 		 * This prevents the gform_replace_merge_tags filter from being called twice, as defined in:
144 144
 		 * @see GFCommon::replace_variables()
145 145
 		 * @see GFCommon::replace_variables_prepopulate()
146 146
 		 */
147
-		if( false === $form ) {
147
+		if (false === $form) {
148 148
 			return $text;
149 149
 		}
150 150
 
151
-		$text = self::replace_get_variables( $text, $form, $entry, $url_encode );
151
+		$text = self::replace_get_variables($text, $form, $entry, $url_encode);
152 152
 
153 153
 		// Process the merge vars here
154
-		$text = self::replace_user_variables_created_by( $text, $form, $entry, $url_encode, $esc_html );
154
+		$text = self::replace_user_variables_created_by($text, $form, $entry, $url_encode, $esc_html);
155 155
 
156 156
 		return $text;
157 157
 	}
@@ -177,22 +177,22 @@  discard block
 block discarded – undo
177 177
 	 * @param array $entry Entry array
178 178
 	 * @param bool $url_encode Whether to URL-encode output
179 179
 	 */
180
-	public static function replace_get_variables( $text, $form = array(), $entry = array(), $url_encode = false ) {
180
+	public static function replace_get_variables($text, $form = array(), $entry = array(), $url_encode = false) {
181 181
 
182 182
 		// Is there is {get:[xyz]} merge tag?
183
-		preg_match_all( "/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER );
183
+		preg_match_all("/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER);
184 184
 
185 185
 		// If there are no matches OR the Entry `created_by` isn't set or is 0 (no user)
186
-		if( empty( $matches ) ) {
186
+		if (empty($matches)) {
187 187
 			return $text;
188 188
 		}
189 189
 
190
-		foreach ( $matches as $match ) {
190
+		foreach ($matches as $match) {
191 191
 
192 192
 			$full_tag = $match[0];
193 193
 			$property = $match[1];
194 194
 
195
-			$value = stripslashes_deep( rgget( $property ) );
195
+			$value = stripslashes_deep(rgget($property));
196 196
 
197 197
 			/**
198 198
 			 * @filter `gravityview/merge_tags/get/glue/` Modify the glue used to convert an array of `{get}` values from an array to string
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
 			 * @param[in,out] string $glue String used to `implode()` $_GET values Default: ', '
201 201
 			 * @param[in] string $property The current name of the $_GET parameter being combined
202 202
 			 */
203
-			$glue = apply_filters( 'gravityview/merge_tags/get/glue/', ', ', $property );
203
+			$glue = apply_filters('gravityview/merge_tags/get/glue/', ', ', $property);
204 204
 
205
-			$value = is_array( $value ) ? implode( $glue, $value ) : $value;
205
+			$value = is_array($value) ? implode($glue, $value) : $value;
206 206
 
207
-			$value = $url_encode ? urlencode( $value ) : $value;
207
+			$value = $url_encode ? urlencode($value) : $value;
208 208
 
209 209
 			/**
210 210
 			 * @filter `gravityview/merge_tags/get/esc_html/{url parameter name}` Disable esc_html() from running on `{get}` merge tag
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
 			 * @since 1.15
215 215
 			 * @param bool $esc_html Whether to esc_html() the value. Default: `true`
216 216
 			 */
217
-			$esc_html = apply_filters('gravityview/merge_tags/get/esc_html/' . $property, true );
217
+			$esc_html = apply_filters('gravityview/merge_tags/get/esc_html/'.$property, true);
218 218
 
219
-			$value = $esc_html ? esc_html( $value ) : $value;
219
+			$value = $esc_html ? esc_html($value) : $value;
220 220
 
221 221
 			/**
222 222
 			 * @filter `gravityview/merge_tags/get/esc_html/{url parameter name}` Modify the value of the `{get}` replacement before being used
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
 			 * @param[in] array $form Gravity Forms form array
226 226
 			 * @param[in] array $entry Entry array
227 227
 			 */
228
-			$value = apply_filters('gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry );
228
+			$value = apply_filters('gravityview/merge_tags/get/value/'.$property, $value, $text, $form, $entry);
229 229
 
230
-			$text = str_replace( $full_tag, $value, $text );
230
+			$text = str_replace($full_tag, $value, $text);
231 231
 		}
232 232
 
233
-		unset( $value, $glue, $matches );
233
+		unset($value, $glue, $matches);
234 234
 
235 235
 		return $text;
236 236
 	}
@@ -251,41 +251,41 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @return string Text, with user variables replaced, if they existed
253 253
 	 */
254
-	private static function replace_user_variables_created_by( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) {
254
+	private static function replace_user_variables_created_by($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false) {
255 255
 
256 256
 		// Is there is {created_by:[xyz]} merge tag?
257
-		preg_match_all( "/\{created_by:(.*?)\}/", $text, $matches, PREG_SET_ORDER );
257
+		preg_match_all("/\{created_by:(.*?)\}/", $text, $matches, PREG_SET_ORDER);
258 258
 
259 259
 		// If there are no matches OR the Entry `created_by` isn't set or is 0 (no user)
260
-		if( empty( $matches ) || empty( $entry['created_by'] ) ) {
260
+		if (empty($matches) || empty($entry['created_by'])) {
261 261
 			return $text;
262 262
 		}
263 263
 
264 264
 		// Get the creator of the entry
265
-		$entry_creator = new WP_User( $entry['created_by'] );
265
+		$entry_creator = new WP_User($entry['created_by']);
266 266
 
267
-		foreach ( $matches as $match ) {
267
+		foreach ($matches as $match) {
268 268
 
269 269
 			$full_tag = $match[0];
270 270
 			$property = $match[1];
271 271
 
272
-			switch( $property ) {
272
+			switch ($property) {
273 273
 				/** @since 1.13.2 */
274 274
 				case 'roles':
275
-					$value = implode( ', ', $entry_creator->roles );
275
+					$value = implode(', ', $entry_creator->roles);
276 276
 					break;
277 277
 				default:
278
-					$value = $entry_creator->get( $property );
278
+					$value = $entry_creator->get($property);
279 279
 			}
280 280
 
281
-			$value = $url_encode ? urlencode( $value ) : $value;
281
+			$value = $url_encode ? urlencode($value) : $value;
282 282
 
283
-			$value = $esc_html ? esc_html( $value ) : $value;
283
+			$value = $esc_html ? esc_html($value) : $value;
284 284
 
285
-			$text = str_replace( $full_tag, $value, $text );
285
+			$text = str_replace($full_tag, $value, $text);
286 286
 		}
287 287
 
288
-		unset( $entry_creator );
288
+		unset($entry_creator);
289 289
 
290 290
 		return $text;
291 291
 	}
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   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-defined( 'ABSPATH' ) || exit;
14
+defined('ABSPATH') || exit;
15 15
 
16 16
 /**
17 17
  * GravityView Roles Class
@@ -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
 
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 	 * @since 1.15
54 54
 	 */
55 55
 	private function add_hooks() {
56
-		add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) );
57
-		add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 );
58
-		add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 );
59
-        add_action( 'admin_init', array( $this, 'add_caps') );
56
+		add_filter('members_get_capabilities', array('GravityView_Roles_Capabilities', 'merge_with_all_caps'));
57
+		add_action('members_register_cap_groups', array($this, 'members_register_cap_group'), 20);
58
+		add_filter('user_has_cap', array($this, 'filter_user_has_cap'), 10, 4);
59
+        add_action('admin_init', array($this, 'add_caps'));
60 60
 	}
61 61
 
62 62
 
@@ -74,28 +74,28 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return mixed
76 76
 	 */
77
-	public function filter_user_has_cap( $usercaps = array(), $caps = array(), $args = array(), $user = NULL ) {
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 ) {
92
-				$usercaps[ $gv_cap ] = true;
91
+			foreach ($all_gravityview_caps as $gv_cap) {
92
+				$usercaps[$gv_cap] = true;
93 93
 			}
94 94
 
95
-			unset( $all_gravityview_caps );
95
+			unset($all_gravityview_caps);
96 96
 		}
97 97
 
98
-		$usercaps = $this->add_gravity_forms_usercaps_to_gravityview_caps( $usercaps );
98
+		$usercaps = $this->add_gravity_forms_usercaps_to_gravityview_caps($usercaps);
99 99
 
100 100
 		return $usercaps;
101 101
 	}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @return array
116 116
 	 */
117
-	private function add_gravity_forms_usercaps_to_gravityview_caps( $usercaps ) {
117
+	private function add_gravity_forms_usercaps_to_gravityview_caps($usercaps) {
118 118
 
119 119
 		$gf_to_gv_caps = array(
120 120
 			'gravityforms_edit_entries'     => 'gravityview_edit_others_entries',
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 			'gravityforms_edit_entry_notes' => 'gravityview_edit_others_entry_notes',
123 123
 		);
124 124
 
125
-		foreach ( $gf_to_gv_caps as $gf_cap => $gv_cap ) {
126
-			if ( isset( $usercaps[ $gf_cap ] ) && ! isset( $usercaps[ $gv_cap ] ) ) {
127
-				$usercaps[ $gv_cap ] = $usercaps[ $gf_cap ];
125
+		foreach ($gf_to_gv_caps as $gf_cap => $gv_cap) {
126
+			if (isset($usercaps[$gf_cap]) && !isset($usercaps[$gv_cap])) {
127
+				$usercaps[$gv_cap] = $usercaps[$gf_cap];
128 128
 			}
129 129
 		}
130 130
 
@@ -138,17 +138,17 @@  discard block
 block discarded – undo
138 138
 	 * @return void
139 139
 	 */
140 140
 	function members_register_cap_group() {
141
-		if ( function_exists( 'members_register_cap_group' ) ) {
141
+		if (function_exists('members_register_cap_group')) {
142 142
 
143 143
 			$args = array(
144
-				'label'         => __( 'GravityView', 'gravityview' ),
144
+				'label'         => __('GravityView', 'gravityview'),
145 145
 				'icon'          => 'gv-icon-astronaut-head',
146 146
 				'caps'          => self::all_caps(),
147 147
 				'merge_added'   => true,
148 148
 				'diff_added'    => false,
149 149
 			);
150 150
 
151
-			members_register_cap_group( 'gravityview', $args );
151
+			members_register_cap_group('gravityview', $args);
152 152
 		}
153 153
 	}
154 154
 
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 * @param array $caps Existing capabilities
160 160
 	 * @return array Modified capabilities array
161 161
 	 */
162
-	public static function merge_with_all_caps( $caps ) {
162
+	public static function merge_with_all_caps($caps) {
163 163
 
164
-		$return_caps = array_merge( $caps, self::all_caps() );
164
+		$return_caps = array_merge($caps, self::all_caps());
165 165
 
166
-		return array_unique( $return_caps );
166
+		return array_unique($return_caps);
167 167
 	}
168 168
 
169 169
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	private function wp_roles() {
179 179
 		global $wp_roles;
180 180
 
181
-		if ( ! isset( $wp_roles ) ) {
181
+		if (!isset($wp_roles)) {
182 182
 			$wp_roles = new WP_Roles();
183 183
 		}
184 184
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
 		$wp_roles = $this->wp_roles();
198 198
 
199
-		if ( is_object( $wp_roles ) ) {
199
+		if (is_object($wp_roles)) {
200 200
 
201 201
 			$_use_db_backup = $wp_roles->use_db;
202 202
 
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
 			 */
207 207
 			$wp_roles->use_db = false;
208 208
 
209
-			$capabilities = self::all_caps( false, false );
209
+			$capabilities = self::all_caps(false, false);
210 210
 
211
-			foreach ( $capabilities as $role_slug => $role_caps ) {
212
-				foreach ( $role_caps as $cap ) {
213
-					$wp_roles->add_cap( $role_slug, $cap );
211
+			foreach ($capabilities as $role_slug => $role_caps) {
212
+				foreach ($role_caps as $cap) {
213
+					$wp_roles->add_cap($role_slug, $cap);
214 214
 				}
215 215
 			}
216 216
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 			 *
220 220
 			 * @see WP_Roles::add_cap() Original code
221 221
 			 */
222
-			update_option( $wp_roles->role_key, $wp_roles->roles );
222
+			update_option($wp_roles->role_key, $wp_roles->roles);
223 223
 
224 224
 			/**
225 225
 			 * Restore previous $use_db setting
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @return array If $role is set, flat array of caps_to_check. Otherwise, a multi-dimensional array of roles and their caps_to_check with the following keys: 'administrator', 'editor', 'author', 'contributor', 'subscriber'
242 242
 	 */
243
-	public static function all_caps( $single_role = false, $flat_array = true ) {
243
+	public static function all_caps($single_role = false, $flat_array = true) {
244 244
 
245 245
 		// Change settings
246 246
 		$administrator_caps = array(
@@ -297,20 +297,20 @@  discard block
 block discarded – undo
297 297
 		);
298 298
 
299 299
 		$subscriber = $subscriber_caps;
300
-		$contributor = array_merge( $contributor_caps, $subscriber_caps );
301
-		$author = array_merge( $author_caps, $contributor_caps, $subscriber_caps );
302
-		$editor = array_merge( $editor_caps, $author_caps, $contributor_caps, $subscriber_caps );
303
-		$administrator = array_merge( $administrator_caps, $editor_caps, $author_caps, $contributor_caps, $subscriber_caps );
300
+		$contributor = array_merge($contributor_caps, $subscriber_caps);
301
+		$author = array_merge($author_caps, $contributor_caps, $subscriber_caps);
302
+		$editor = array_merge($editor_caps, $author_caps, $contributor_caps, $subscriber_caps);
303
+		$administrator = array_merge($administrator_caps, $editor_caps, $author_caps, $contributor_caps, $subscriber_caps);
304 304
 		$all = $administrator;
305 305
 
306 306
 		// If role is set, return caps_to_check for just that role.
307
-		if( $single_role ) {
308
-			$caps = isset( ${$single_role} ) ? ${$single_role} : false;
309
-			return $flat_array ? $caps : array( $single_role => $caps );
307
+		if ($single_role) {
308
+			$caps = isset(${$single_role} ) ? ${$single_role} : false;
309
+			return $flat_array ? $caps : array($single_role => $caps);
310 310
 		}
311 311
 
312 312
 		// Otherwise, return multi-dimensional array of all caps_to_check
313
-		return $flat_array ? $all : compact( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
313
+		return $flat_array ? $all : compact('administrator', 'editor', 'author', 'contributor', 'subscriber');
314 314
 	}
315 315
 
316 316
 	/**
@@ -330,25 +330,25 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities
332 332
 	 */
333
-	public static function has_cap( $caps_to_check = '', $object_id = null, $user_id = null ) {
333
+	public static function has_cap($caps_to_check = '', $object_id = null, $user_id = null) {
334 334
 
335 335
 		$has_cap = false;
336 336
 
337
-		if( empty( $caps_to_check ) ) {
337
+		if (empty($caps_to_check)) {
338 338
 			return $has_cap;
339 339
 		}
340 340
 
341 341
 		// Add full access caps for GV & GF
342
-		$caps_to_check = self::maybe_add_full_access_caps( $caps_to_check );
342
+		$caps_to_check = self::maybe_add_full_access_caps($caps_to_check);
343 343
 
344
-		foreach ( $caps_to_check as $cap ) {
345
-			if( ! is_null( $object_id ) ) {
346
-				$has_cap = $user_id ? user_can( $user_id, $cap, $object_id ) : current_user_can( $cap, $object_id );
344
+		foreach ($caps_to_check as $cap) {
345
+			if (!is_null($object_id)) {
346
+				$has_cap = $user_id ? user_can($user_id, $cap, $object_id) : current_user_can($cap, $object_id);
347 347
 			} else {
348
-				$has_cap = $user_id ? user_can( $user_id, $cap ) : current_user_can( $cap );
348
+				$has_cap = $user_id ? user_can($user_id, $cap) : current_user_can($cap);
349 349
 			}
350 350
 			// At the first successful response, stop checking
351
-			if( $has_cap ) {
351
+			if ($has_cap) {
352 352
 				break;
353 353
 			}
354 354
 		}
@@ -365,25 +365,25 @@  discard block
 block discarded – undo
365 365
 	 *
366 366
 	 * @return array
367 367
 	 */
368
-	public static function maybe_add_full_access_caps( $caps_to_check = array() ) {
368
+	public static function maybe_add_full_access_caps($caps_to_check = array()) {
369 369
 
370 370
 		$caps_to_check = (array)$caps_to_check;
371 371
 
372 372
 		$all_gravityview_caps = self::all_caps();
373 373
 
374 374
 		// Are there any $caps_to_check that are from GravityView?
375
-		if( $has_gravityview_caps = array_intersect( $caps_to_check, $all_gravityview_caps ) ) {
375
+		if ($has_gravityview_caps = array_intersect($caps_to_check, $all_gravityview_caps)) {
376 376
 			$caps_to_check[] = 'gravityview_full_access';
377 377
 		}
378 378
 
379
-		$all_gravity_forms_caps = class_exists( 'GFCommon' ) ? GFCommon::all_caps() : array();
379
+		$all_gravity_forms_caps = class_exists('GFCommon') ? GFCommon::all_caps() : array();
380 380
 
381 381
 		// Are there any $caps_to_check that are from Gravity Forms?
382
-		if( $all_gravity_forms_caps = array_intersect( $caps_to_check, $all_gravity_forms_caps ) ) {
382
+		if ($all_gravity_forms_caps = array_intersect($caps_to_check, $all_gravity_forms_caps)) {
383 383
 			$caps_to_check[] = 'gform_full_access';
384 384
 		}
385 385
 
386
-		return array_unique( $caps_to_check );
386
+		return array_unique($caps_to_check);
387 387
 	}
388 388
 
389 389
 	/**
@@ -396,19 +396,19 @@  discard block
 block discarded – undo
396 396
 
397 397
 		$wp_roles = $this->wp_roles();
398 398
 
399
-		if ( is_object( $wp_roles ) ) {
399
+		if (is_object($wp_roles)) {
400 400
 
401 401
 			/** Remove all GravityView caps_to_check from all roles */
402 402
 			$capabilities = self::all_caps();
403 403
 
404 404
 			// Loop through each role and remove GV caps_to_check
405
-			foreach( $wp_roles->get_names() as $role_slug => $role_name ) {
406
-				foreach ( $capabilities as $cap ) {
407
-					$wp_roles->remove_cap( $role_slug, $cap );
405
+			foreach ($wp_roles->get_names() as $role_slug => $role_name) {
406
+				foreach ($capabilities as $cap) {
407
+					$wp_roles->remove_cap($role_slug, $cap);
408 408
 				}
409 409
 			}
410 410
 		}
411 411
 	}
412 412
 }
413 413
 
414
-add_action( 'init', array( 'GravityView_Roles_Capabilities', 'get_instance' ), 1 );
415 414
\ No newline at end of file
415
+add_action('init', array('GravityView_Roles_Capabilities', 'get_instance'), 1);
416 416
\ No newline at end of file
Please login to merge, or discard this patch.