Completed
Push — develop ( 3b31c7...af81b2 )
by Zack
03:48
created
includes/class-frontend-views.php 2 patches
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 = gravityview_get_form( $form_id );
1090
+		$form = gravityview_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
 		 * @param string $field_id Field ID to check whether the field is sortable
1391 1391
 		 * @param array $form Gravity Forms form
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-api.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -214,7 +214,6 @@  discard block
 block discarded – undo
214 214
 	 *
215 215
 	 * @access public
216 216
 	 * @param array $entry
217
-	 * @param integer $field
218 217
 	 * @return null|string
219 218
 	 */
220 219
 	public static function field_value( $entry, $field_settings, $format = 'html' ) {
@@ -967,7 +966,7 @@  discard block
 block discarded – undo
967 966
  * Get the current View ID being rendered
968 967
  *
969 968
  * @global GravityView_View $gravityview_view
970
- * @return string View context "directory" or "single"
969
+ * @return integer View context "directory" or "single"
971 970
  */
972 971
 function gravityview_get_view_id() {
973 972
 	return GravityView_View::getInstance()->getViewId();
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * GravityView template tags API
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 template tags API
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
 class GravityView_API {
15 15
 
@@ -146,20 +146,20 @@  discard block
 block discarded – undo
146 146
 
147 147
 		if( !empty( $field['custom_class'] ) ) {
148 148
 
149
-            $custom_class = $field['custom_class'];
149
+			$custom_class = $field['custom_class'];
150 150
 
151
-            if( !empty( $entry ) ) {
151
+			if( !empty( $entry ) ) {
152 152
 
153
-                // We want the merge tag to be formatted as a class. The merge tag may be
154
-                // replaced by a multiple-word value that should be output as a single class.
155
-                // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager`
156
-                add_filter('gform_merge_tag_filter', 'sanitize_html_class');
153
+				// We want the merge tag to be formatted as a class. The merge tag may be
154
+				// replaced by a multiple-word value that should be output as a single class.
155
+				// "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager`
156
+				add_filter('gform_merge_tag_filter', 'sanitize_html_class');
157 157
 
158
-                $custom_class = self::replace_variables( $custom_class, $form, $entry);
158
+				$custom_class = self::replace_variables( $custom_class, $form, $entry);
159 159
 
160
-                // And then we want life to return to normal
161
-                remove_filter('gform_merge_tag_filter', 'sanitize_html_class');
162
-            }
160
+				// And then we want life to return to normal
161
+				remove_filter('gform_merge_tag_filter', 'sanitize_html_class');
162
+			}
163 163
 
164 164
 			// And now we want the spaces to be handled nicely.
165 165
 			$classes[] = gravityview_sanitize_html_class( $custom_class );
@@ -591,29 +591,29 @@  discard block
 block discarded – undo
591 591
 		return sanitize_title( $slug );
592 592
 	}
593 593
 
594
-    /**
595
-     * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta
596
-     *
597
-     * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );
598
-     *
599
-     * @param $entry array Gravity Forms entry object
600
-     * @param $form array Gravity Forms form object
601
-     */
602
-    public static function entry_create_custom_slug( $entry, $form ) {
603
-        /**
604
-         * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta
605
-         * @param boolean $custom Should we process the custom entry slug?
606
-         */
607
-        $custom = apply_filters( 'gravityview_custom_entry_slug', false );
608
-        if( $custom ) {
609
-            // create the gravityview_unique_id and save it
594
+	/**
595
+	 * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta
596
+	 *
597
+	 * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );
598
+	 *
599
+	 * @param $entry array Gravity Forms entry object
600
+	 * @param $form array Gravity Forms form object
601
+	 */
602
+	public static function entry_create_custom_slug( $entry, $form ) {
603
+		/**
604
+		 * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta
605
+		 * @param boolean $custom Should we process the custom entry slug?
606
+		 */
607
+		$custom = apply_filters( 'gravityview_custom_entry_slug', false );
608
+		if( $custom ) {
609
+			// create the gravityview_unique_id and save it
610 610
 
611
-            // Get the entry hash
612
-            $hash = self::get_custom_entry_slug( $entry['id'], $entry );
613
-            gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash );
611
+			// Get the entry hash
612
+			$hash = self::get_custom_entry_slug( $entry['id'], $entry );
613
+			gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash );
614 614
 
615
-        }
616
-    }
615
+		}
616
+	}
617 617
 
618 618
 
619 619
 
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 
852 852
 			// If there was an error, continue to the next term.
853 853
 			if ( is_wp_error( $term_link ) ) {
854
-			    continue;
854
+				continue;
855 855
 			}
856 856
 
857 857
 			$output[] = gravityview_get_link( $term_link, esc_html( $term->name ) );
Please login to merge, or discard this patch.
Spacing   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -23,36 +23,36 @@  discard block
 block discarded – undo
23 23
 	 * @param boolean $force_show_label Whether to always show the label, regardless of field settings
24 24
 	 * @return string
25 25
 	 */
26
-	public static function field_label( $field, $entry = array(), $force_show_label = false ) {
26
+	public static function field_label($field, $entry = array(), $force_show_label = false) {
27 27
 		$gravityview_view = GravityView_View::getInstance();
28 28
 
29 29
 		$form = $gravityview_view->getForm();
30 30
 
31 31
 		$label = '';
32 32
 
33
-		if( !empty( $field['show_label'] ) || $force_show_label ) {
33
+		if (!empty($field['show_label']) || $force_show_label) {
34 34
 
35 35
 			$label = $field['label'];
36 36
 
37 37
 			// Support Gravity Forms 1.9+
38
-			if( class_exists( 'GF_Field' ) ) {
38
+			if (class_exists('GF_Field')) {
39 39
 
40
-				$field_object = RGFormsModel::get_field( $form, $field['id'] );
40
+				$field_object = RGFormsModel::get_field($form, $field['id']);
41 41
 
42
-				if( $field_object ) {
42
+				if ($field_object) {
43 43
 
44
-					$input = GFFormsModel::get_input( $field_object, $field['id'] );
44
+					$input = GFFormsModel::get_input($field_object, $field['id']);
45 45
 
46 46
 					// This is a complex field, with labels on a per-input basis
47
-					if( $input ) {
47
+					if ($input) {
48 48
 
49 49
 						// Does the input have a custom label on a per-input basis? Otherwise, default label.
50
-						$label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label'];
50
+						$label = !empty($input['customLabel']) ? $input['customLabel'] : $input['label'];
51 51
 
52 52
 					} else {
53 53
 
54 54
 						// This is a field with one label
55
-						$label = $field_object->get_field_label( true, $field['label'] );
55
+						$label = $field_object->get_field_label(true, $field['label']);
56 56
 
57 57
 					}
58 58
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 			}
62 62
 
63 63
 			// Use Gravity Forms label by default, but if a custom label is defined in GV, use it.
64
-			if ( !empty( $field['custom_label'] ) ) {
64
+			if (!empty($field['custom_label'])) {
65 65
 
66
-				$label = self::replace_variables( $field['custom_label'], $form, $entry );
66
+				$label = self::replace_variables($field['custom_label'], $form, $entry);
67 67
 
68 68
 			}
69 69
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			 * @param[in,out] string $appended_content Content you can add after a label. Empty by default.
73 73
 			 * @param[in] array $field GravityView field array
74 74
 			 */
75
-			$label .= apply_filters( 'gravityview_render_after_label', '', $field );
75
+			$label .= apply_filters('gravityview_render_after_label', '', $field);
76 76
 
77 77
 		} // End $field['show_label']
78 78
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		 * @param[in] array $form Gravity Forms form array
85 85
 		 * @param[in] array $entry Gravity Forms entry array
86 86
 		 */
87
-		$label = apply_filters( 'gravityview/template/field_label', $label, $field, $form, $entry );
87
+		$label = apply_filters('gravityview/template/field_label', $label, $field, $form, $entry);
88 88
 
89 89
 		return $label;
90 90
 	}
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 	 * @param  array      $entry        GF Entry array
100 100
 	 * @return string                  Text with variables maybe replaced
101 101
 	 */
102
-	public static function replace_variables($text, $form, $entry ) {
103
-		return GravityView_Merge_Tags::replace_variables( $text, $form, $entry );
102
+	public static function replace_variables($text, $form, $entry) {
103
+		return GravityView_Merge_Tags::replace_variables($text, $form, $entry);
104 104
 	}
105 105
 
106 106
 	/**
@@ -113,19 +113,19 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return string|null If not empty, string in $format format. Otherwise, null.
115 115
 	 */
116
-	public static function field_width( $field, $format = '%d%%' ) {
116
+	public static function field_width($field, $format = '%d%%') {
117 117
 
118 118
 		$width = NULL;
119 119
 
120
-		if( !empty( $field['width'] ) ) {
121
-			$width = absint( $field['width'] );
120
+		if (!empty($field['width'])) {
121
+			$width = absint($field['width']);
122 122
 
123 123
 			// If using percentages, limit to 100%
124
-			if( '%d%%' === $format && $width > 100 ) {
124
+			if ('%d%%' === $format && $width > 100) {
125 125
 				$width = 100;
126 126
 			}
127 127
 
128
-			$width = sprintf( $format, $width );
128
+			$width = sprintf($format, $width);
129 129
 		}
130 130
 
131 131
 		return $width;
@@ -139,38 +139,38 @@  discard block
 block discarded – undo
139 139
 	 * @param mixed $field
140 140
 	 * @return string
141 141
 	 */
142
-	public static function field_class( $field, $form = NULL, $entry = NULL ) {
142
+	public static function field_class($field, $form = NULL, $entry = NULL) {
143 143
 		$gravityview_view = GravityView_View::getInstance();
144 144
 
145 145
 		$classes = array();
146 146
 
147
-		if( !empty( $field['custom_class'] ) ) {
147
+		if (!empty($field['custom_class'])) {
148 148
 
149 149
             $custom_class = $field['custom_class'];
150 150
 
151
-            if( !empty( $entry ) ) {
151
+            if (!empty($entry)) {
152 152
 
153 153
                 // We want the merge tag to be formatted as a class. The merge tag may be
154 154
                 // replaced by a multiple-word value that should be output as a single class.
155 155
                 // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager`
156 156
                 add_filter('gform_merge_tag_filter', 'sanitize_html_class');
157 157
 
158
-                $custom_class = self::replace_variables( $custom_class, $form, $entry);
158
+                $custom_class = self::replace_variables($custom_class, $form, $entry);
159 159
 
160 160
                 // And then we want life to return to normal
161 161
                 remove_filter('gform_merge_tag_filter', 'sanitize_html_class');
162 162
             }
163 163
 
164 164
 			// And now we want the spaces to be handled nicely.
165
-			$classes[] = gravityview_sanitize_html_class( $custom_class );
165
+			$classes[] = gravityview_sanitize_html_class($custom_class);
166 166
 
167 167
 		}
168 168
 
169
-		if(!empty($field['id'])) {
170
-			if( !empty( $form ) && !empty( $form['id'] ) ) {
169
+		if (!empty($field['id'])) {
170
+			if (!empty($form) && !empty($form['id'])) {
171 171
 				$form_id = '-'.$form['id'];
172 172
 			} else {
173
-				$form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : '';
173
+				$form_id = $gravityview_view->getFormId() ? '-'.$gravityview_view->getFormId() : '';
174 174
 			}
175 175
 
176 176
 			$classes[] = 'gv-field'.$form_id.'-'.$field['id'];
@@ -191,21 +191,21 @@  discard block
 block discarded – undo
191 191
 	 * @param array $entry Gravity Forms entry array
192 192
 	 * @return string Sanitized unique HTML `id` attribute for the field
193 193
 	 */
194
-	public static function field_html_attr_id( $field, $form = array(), $entry = array() ) {
194
+	public static function field_html_attr_id($field, $form = array(), $entry = array()) {
195 195
 		$gravityview_view = GravityView_View::getInstance();
196 196
 		$id = $field['id'];
197 197
 
198
-		if ( ! empty( $id ) ) {
199
-			if ( ! empty( $form ) && ! empty( $form['id'] ) ) {
200
-				$form_id = '-' . $form['id'];
198
+		if (!empty($id)) {
199
+			if (!empty($form) && !empty($form['id'])) {
200
+				$form_id = '-'.$form['id'];
201 201
 			} else {
202
-				$form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : '';
202
+				$form_id = $gravityview_view->getFormId() ? '-'.$gravityview_view->getFormId() : '';
203 203
 			}
204 204
 
205
-			$id = 'gv-field' . $form_id . '-' . $field['id'];
205
+			$id = 'gv-field'.$form_id.'-'.$field['id'];
206 206
 		}
207 207
 
208
-		return esc_attr( $id );
208
+		return esc_attr($id);
209 209
 	}
210 210
 
211 211
 
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 	 * @param integer $field
218 218
 	 * @return null|string
219 219
 	 */
220
-	public static function field_value( $entry, $field_settings, $format = 'html' ) {
220
+	public static function field_value($entry, $field_settings, $format = 'html') {
221 221
 
222
-		if( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) {
222
+		if (empty($entry['form_id']) || empty($field_settings['id'])) {
223 223
 			return NULL;
224 224
 		}
225 225
 
226 226
 		$gravityview_view = GravityView_View::getInstance();
227 227
 
228
-		if( class_exists( 'GFCache' ) ) {
228
+		if (class_exists('GFCache')) {
229 229
 			/**
230 230
 			 * Gravity Forms' GFCache function was thrashing the database, causing double the amount of time for the field_value() method to run.
231 231
 			 *
@@ -240,18 +240,18 @@  discard block
 block discarded – undo
240 240
 			 * @param boolean false Tell Gravity Forms not to store this as a transient
241 241
 			 * @param  int 0 Time to store the value. 0 is maximum amount of time possible.
242 242
 			 */
243
-			GFCache::set( "GFFormsModel::get_lead_field_value_" . $entry["id"] . "_" . $field_settings["id"], false, false, 0 );
243
+			GFCache::set("GFFormsModel::get_lead_field_value_".$entry["id"]."_".$field_settings["id"], false, false, 0);
244 244
 		}
245 245
 
246 246
 		$field_id = $field_settings['id'];
247 247
 
248 248
 		$form = $gravityview_view->getForm();
249 249
 
250
-		$field = gravityview_get_field( $form, $field_id );
250
+		$field = gravityview_get_field($form, $field_id);
251 251
 
252 252
 		$field_type = RGFormsModel::get_input_type($field);
253 253
 
254
-		if( $field_type ) {
254
+		if ($field_type) {
255 255
 			$field_type = $field['type'];
256 256
 			$value = RGFormsModel::get_lead_field_value($entry, $field);
257 257
 		} else {
@@ -266,15 +266,15 @@  discard block
 block discarded – undo
266 266
 
267 267
 		$display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format);
268 268
 
269
-		if( $errors = ob_get_clean() ) {
270
-			do_action( 'gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors );
269
+		if ($errors = ob_get_clean()) {
270
+			do_action('gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors);
271 271
 		}
272 272
 
273 273
 		$display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form);
274 274
 
275 275
 		// prevent the use of merge_tags for non-admin fields
276
-		if( !empty( $field['adminOnly'] ) ) {
277
-			$display_value = self::replace_variables( $display_value, $form, $entry );
276
+		if (!empty($field['adminOnly'])) {
277
+			$display_value = self::replace_variables($display_value, $form, $entry);
278 278
 		}
279 279
 
280 280
 		// Check whether the field exists in /includes/fields/{$field_type}.php
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		$field_path = $gravityview_view->locate_template("fields/{$field_type}.php");
283 283
 
284 284
 		// Set the field data to be available in the templates
285
-		$gravityview_view->setCurrentField( array(
285
+		$gravityview_view->setCurrentField(array(
286 286
 			'form' => $form,
287 287
 			'field_id' => $field_id,
288 288
 			'field' => $field,
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 			'field_type' => $field_type, /** {@since 1.6} **/
295 295
 		));
296 296
 
297
-		if( ! empty( $field_path ) ) {
297
+		if (!empty($field_path)) {
298 298
 
299
-			do_action( 'gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path ) );
299
+			do_action('gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path));
300 300
 
301 301
 			ob_start();
302 302
 
303
-			load_template( $field_path, false );
303
+			load_template($field_path, false);
304 304
 
305 305
 			$output = ob_get_clean();
306 306
 
@@ -319,11 +319,11 @@  discard block
 block discarded – undo
319 319
 		 * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example.
320 320
 		 *
321 321
 		 */
322
-		if( !empty( $field_settings['show_as_link'] ) ) {
322
+		if (!empty($field_settings['show_as_link'])) {
323 323
 
324
-			$link_atts = empty( $field_settings['new_window'] ) ? array() : array( 'target' => '_blank' );
324
+			$link_atts = empty($field_settings['new_window']) ? array() : array('target' => '_blank');
325 325
 
326
-			$output = self::entry_link_html( $entry, $output, $link_atts, $field_settings );
326
+			$output = self::entry_link_html($entry, $output, $link_atts, $field_settings);
327 327
 
328 328
 		}
329 329
 
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 		 * @param array  $entry The GF entry array
335 335
 		 * @param  array $field_settings Settings for the particular GV field
336 336
 		 */
337
-		$output = apply_filters( 'gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() );
337
+		$output = apply_filters('gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField());
338 338
 
339 339
 		/**
340 340
 		 * @filter `gravityview_field_entry_value` Modify the field value output for all field types
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		 * @param  array $field_settings Settings for the particular GV field
344 344
 		 * @param array $field_data  {@since 1.6}
345 345
 		 */
346
-		$output = apply_filters( 'gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField() );
346
+		$output = apply_filters('gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField());
347 347
 
348 348
 		return $output;
349 349
 	}
@@ -357,18 +357,18 @@  discard block
 block discarded – undo
357 357
 	 * @param array $entry Gravity Forms entry array
358 358
 	 * @param array $field_settings Array of field settings. Optional, but passed to the `gravityview_field_entry_link` filter
359 359
 	 */
360
-	public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array() ) {
360
+	public static function entry_link_html($entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array()) {
361 361
 
362
-		if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) {
362
+		if (empty($entry) || !is_array($entry) || !isset($entry['id'])) {
363 363
 
364
-			do_action( 'gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry );
364
+			do_action('gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry);
365 365
 
366 366
 			return NULL;
367 367
 		}
368 368
 
369
-		$href = self::entry_link( $entry );
369
+		$href = self::entry_link($entry);
370 370
 
371
-		$link = gravityview_get_link( $href, $anchor_text, $passed_tag_atts );
371
+		$link = gravityview_get_link($href, $anchor_text, $passed_tag_atts);
372 372
 
373 373
 		/**
374 374
 		 * @filter `gravityview_field_entry_link` Modify the link HTML
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 		 * @param array  $entry The GF entry array
378 378
 		 * @param  array $field_settings Settings for the particular GV field
379 379
 		 */
380
-		$output = apply_filters( 'gravityview_field_entry_link', $link, $href, $entry, $field_settings );
380
+		$output = apply_filters('gravityview_field_entry_link', $link, $href, $entry, $field_settings);
381 381
 
382 382
 		return $output;
383 383
 	}
@@ -392,11 +392,11 @@  discard block
 block discarded – undo
392 392
 
393 393
 		$is_search = false;
394 394
 
395
-		if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) {
395
+		if ($gravityview_view && ($gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search)) {
396 396
 			$is_search = true;
397 397
 		}
398 398
 
399
-		if($is_search) {
399
+		if ($is_search) {
400 400
 			$output = __('This search returned no results.', 'gravityview');
401 401
 		} else {
402 402
 			$output = __('No entries match your request.', 'gravityview');
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 		 * @param string $output The existing "No Entries" text
408 408
 		 * @param boolean $is_search Is the current page a search result, or just a multiple entries screen?
409 409
 		 */
410
-		$output = apply_filters( 'gravitview_no_entries_text', $output, $is_search);
410
+		$output = apply_filters('gravitview_no_entries_text', $output, $is_search);
411 411
 
412 412
 		return $wpautop ? wpautop($output) : $output;
413 413
 	}
@@ -421,42 +421,42 @@  discard block
 block discarded – undo
421 421
 	 * @param boolean $add_query_args Add pagination and sorting arguments
422 422
 	 * @return string      Permalink to multiple entries view
423 423
 	 */
424
-	public static function directory_link( $post_id = NULL, $add_query_args = true ) {
424
+	public static function directory_link($post_id = NULL, $add_query_args = true) {
425 425
 		global $post;
426 426
 
427 427
 		$gravityview_view = GravityView_View::getInstance();
428 428
 
429
-		if( empty( $post_id ) ) {
429
+		if (empty($post_id)) {
430 430
 
431 431
 			$post_id = false;
432 432
 
433 433
 			// DataTables passes the Post ID
434
-			if( defined('DOING_AJAX') && DOING_AJAX ) {
434
+			if (defined('DOING_AJAX') && DOING_AJAX) {
435 435
 
436
-				$post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : false;
436
+				$post_id = isset($_POST['post_id']) ? (int)$_POST['post_id'] : false;
437 437
 
438 438
 			} else {
439 439
 
440 440
 				// The Post ID has been passed via the shortcode
441
-				if( !empty( $gravityview_view ) && $gravityview_view->getPostId() ) {
441
+				if (!empty($gravityview_view) && $gravityview_view->getPostId()) {
442 442
 
443 443
 					$post_id = $gravityview_view->getPostId();
444 444
 
445 445
 				} else {
446 446
 
447 447
 					// This is a GravityView post type
448
-					if( GravityView_frontend::getInstance()->isGravityviewPostType() ) {
448
+					if (GravityView_frontend::getInstance()->isGravityviewPostType()) {
449 449
 
450
-						$post_id = isset( $gravityview_view ) ? $gravityview_view->getViewId() : $post->ID;
450
+						$post_id = isset($gravityview_view) ? $gravityview_view->getViewId() : $post->ID;
451 451
 
452 452
 					} else {
453 453
 
454 454
 						// This is an embedded GravityView; use the embedded post's ID as the base.
455
-						if( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) {
455
+						if (GravityView_frontend::getInstance()->isPostHasShortcode() && is_a($post, 'WP_Post')) {
456 456
 
457 457
 							$post_id = $post->ID;
458 458
 
459
-						} elseif( $gravityview_view->getViewId() ) {
459
+						} elseif ($gravityview_view->getViewId()) {
460 460
 
461 461
 							// The GravityView has been embedded in a widget or in a template, and
462 462
 							// is not in the current content. Thus, we defer to the View's own ID.
@@ -471,39 +471,39 @@  discard block
 block discarded – undo
471 471
 		}
472 472
 
473 473
 		// No post ID, get outta here.
474
-		if( empty( $post_id ) ) {
474
+		if (empty($post_id)) {
475 475
 			return NULL;
476 476
 		}
477 477
 
478 478
 		// If we've saved the permalink in memory, use it
479 479
 		// @since 1.3
480
-		$link = wp_cache_get( 'gv_directory_link_'.$post_id );
480
+		$link = wp_cache_get('gv_directory_link_'.$post_id);
481 481
 
482
-		if( empty( $link ) ) {
482
+		if (empty($link)) {
483 483
 
484
-			$link = get_permalink( $post_id );
484
+			$link = get_permalink($post_id);
485 485
 
486 486
 			// If not yet saved, cache the permalink.
487 487
 			// @since 1.3
488
-			wp_cache_set( 'gv_directory_link_'.$post_id, $link );
488
+			wp_cache_set('gv_directory_link_'.$post_id, $link);
489 489
 
490 490
 		}
491 491
 
492 492
 		// Deal with returning to proper pagination for embedded views
493
-		if( $link && $add_query_args ) {
493
+		if ($link && $add_query_args) {
494 494
 
495 495
 			$args = array();
496 496
 
497
-			if( $pagenum = rgget('pagenum') ) {
498
-				$args['pagenum'] = intval( $pagenum );
497
+			if ($pagenum = rgget('pagenum')) {
498
+				$args['pagenum'] = intval($pagenum);
499 499
 			}
500 500
 
501
-			if( $sort = rgget('sort') ) {
501
+			if ($sort = rgget('sort')) {
502 502
 				$args['sort'] = $sort;
503 503
 				$args['dir'] = rgget('dir');
504 504
 			}
505 505
 
506
-			$link = add_query_arg( $args, $link );
506
+			$link = add_query_arg($args, $link);
507 507
 		}
508 508
 
509 509
 		return $link;
@@ -520,10 +520,10 @@  discard block
 block discarded – undo
520 520
 	 * @param  array  $entry        Entry data passed to provide additional information when generating the hash. Optional - don't rely on it being available.
521 521
 	 * @return string               Hashed unique value for entry
522 522
 	 */
523
-	private static function get_custom_entry_slug( $id, $entry = array() ) {
523
+	private static function get_custom_entry_slug($id, $entry = array()) {
524 524
 
525 525
 		// Generate an unique hash to use as the default value
526
-		$slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 );
526
+		$slug = substr(wp_hash($id, 'gravityview'.$id), 0, 8);
527 527
 
528 528
 		/**
529 529
 		 * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}`
@@ -531,14 +531,14 @@  discard block
 block discarded – undo
531 531
 		 * @param  string $id The entry ID
532 532
 		 * @param  array $entry Entry data array. May be empty.
533 533
 		 */
534
-		$slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry );
534
+		$slug = apply_filters('gravityview_entry_slug', $slug, $id, $entry);
535 535
 
536 536
 		// Make sure we have something - use the original ID as backup.
537
-		if( empty( $slug ) ) {
537
+		if (empty($slug)) {
538 538
 			$slug = $id;
539 539
 		}
540 540
 
541
-		return sanitize_title( $slug );
541
+		return sanitize_title($slug);
542 542
 	}
543 543
 
544 544
 	/**
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 	 * @param  array  $entry        Gravity Forms Entry array, optional. Used only to provide data to customize the `gravityview_entry_slug` filter
553 553
 	 * @return string               Unique slug ID, passed through `sanitize_title()`
554 554
 	 */
555
-	public static function get_entry_slug( $id_or_string, $entry = array() ) {
555
+	public static function get_entry_slug($id_or_string, $entry = array()) {
556 556
 
557 557
 		/**
558 558
 		 * Default: use the entry ID as the unique identifier
@@ -563,32 +563,32 @@  discard block
 block discarded – undo
563 563
 		 * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs.
564 564
 		 * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default)
565 565
 		 */
566
-		$custom = apply_filters('gravityview_custom_entry_slug', false );
566
+		$custom = apply_filters('gravityview_custom_entry_slug', false);
567 567
 
568 568
 		// If we're using custom slug...
569
-		if ( $custom ) {
569
+		if ($custom) {
570 570
 
571 571
 			// Get the entry hash
572
-			$hash = self::get_custom_entry_slug( $id_or_string, $entry );
572
+			$hash = self::get_custom_entry_slug($id_or_string, $entry);
573 573
 
574 574
 			// See if the entry already has a hash set
575
-			$value = gform_get_meta( $id_or_string, 'gravityview_unique_id' );
575
+			$value = gform_get_meta($id_or_string, 'gravityview_unique_id');
576 576
 
577 577
 			// If it does have a hash set, and the hash is expected, use it.
578 578
 			// This check allows users to change the hash structure using the
579 579
 			// gravityview_entry_hash filter and have the old hashes expire.
580
-			if( empty( $value ) || $value !== $hash ) {
580
+			if (empty($value) || $value !== $hash) {
581 581
 
582
-				gform_update_meta( $id_or_string, 'gravityview_unique_id', $hash );
582
+				gform_update_meta($id_or_string, 'gravityview_unique_id', $hash);
583 583
 
584 584
 			}
585 585
 
586 586
 			$slug = $hash;
587 587
 
588
-			unset( $value, $hash );
588
+			unset($value, $hash);
589 589
 		}
590 590
 
591
-		return sanitize_title( $slug );
591
+		return sanitize_title($slug);
592 592
 	}
593 593
 
594 594
     /**
@@ -599,18 +599,18 @@  discard block
 block discarded – undo
599 599
      * @param $entry array Gravity Forms entry object
600 600
      * @param $form array Gravity Forms form object
601 601
      */
602
-    public static function entry_create_custom_slug( $entry, $form ) {
602
+    public static function entry_create_custom_slug($entry, $form) {
603 603
         /**
604 604
          * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta
605 605
          * @param boolean $custom Should we process the custom entry slug?
606 606
          */
607
-        $custom = apply_filters( 'gravityview_custom_entry_slug', false );
608
-        if( $custom ) {
607
+        $custom = apply_filters('gravityview_custom_entry_slug', false);
608
+        if ($custom) {
609 609
             // create the gravityview_unique_id and save it
610 610
 
611 611
             // Get the entry hash
612
-            $hash = self::get_custom_entry_slug( $entry['id'], $entry );
613
-            gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash );
612
+            $hash = self::get_custom_entry_slug($entry['id'], $entry);
613
+            gform_update_meta($entry['id'], 'gravityview_unique_id', $hash);
614 614
 
615 615
         }
616 616
     }
@@ -625,55 +625,55 @@  discard block
 block discarded – undo
625 625
 	 * @param boolean $add_directory_args True: Add args to help return to directory; False: only include args required to get to entry {@since 1.7.3}
626 626
 	 * @return string          Link to the entry with the directory parent slug
627 627
 	 */
628
-	public static function entry_link( $entry, $post_id = NULL, $add_directory_args = true ) {
628
+	public static function entry_link($entry, $post_id = NULL, $add_directory_args = true) {
629 629
 
630
-		if( ! empty( $entry ) && ! is_array( $entry ) ) {
631
-			$entry = GVCommon::get_entry( $entry );
632
-		} else if( empty( $entry ) ) {
630
+		if (!empty($entry) && !is_array($entry)) {
631
+			$entry = GVCommon::get_entry($entry);
632
+		} else if (empty($entry)) {
633 633
 			$entry = GravityView_frontend::getInstance()->getEntry();
634 634
 		}
635 635
 
636 636
 		// Second parameter used to be passed as $field; this makes sure it's not an array
637
-		if( !is_numeric( $post_id ) ) {
637
+		if (!is_numeric($post_id)) {
638 638
 			$post_id = NULL;
639 639
 		}
640 640
 
641 641
 		// Get the permalink to the View
642
-		$directory_link = self::directory_link( $post_id, false );
642
+		$directory_link = self::directory_link($post_id, false);
643 643
 
644 644
 		// No post ID? Get outta here.
645
-		if( empty( $directory_link ) ) {
645
+		if (empty($directory_link)) {
646 646
 			return '';
647 647
 		}
648 648
 
649 649
 		$query_arg_name = GravityView_Post_Types::get_entry_var_name();
650 650
 
651
-		$entry_slug = self::get_entry_slug( $entry['id'], $entry );
651
+		$entry_slug = self::get_entry_slug($entry['id'], $entry);
652 652
 
653
-		if( get_option('permalink_structure') && !is_preview() ) {
653
+		if (get_option('permalink_structure') && !is_preview()) {
654 654
 
655 655
 			$args = array();
656 656
 
657
-			$directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/'. $entry_slug .'/';
657
+			$directory_link = trailingslashit($directory_link).$query_arg_name.'/'.$entry_slug.'/';
658 658
 
659 659
 		} else {
660 660
 
661
-			$args = array( $query_arg_name => $entry_slug );
661
+			$args = array($query_arg_name => $entry_slug);
662 662
 		}
663 663
 
664 664
 		/**
665 665
 		 * @since 1.7.3
666 666
 		 */
667
-		if( $add_directory_args ) {
667
+		if ($add_directory_args) {
668 668
 
669
-			if( !empty( $_GET['pagenum'] ) ) {
670
-				$args['pagenum'] = intval( $_GET['pagenum'] );
669
+			if (!empty($_GET['pagenum'])) {
670
+				$args['pagenum'] = intval($_GET['pagenum']);
671 671
 			}
672 672
 
673 673
 			/**
674 674
 			 * @since 1.7
675 675
 			 */
676
-			if( $sort = rgget('sort') ) {
676
+			if ($sort = rgget('sort')) {
677 677
 				$args['sort'] = $sort;
678 678
 				$args['dir'] = rgget('dir');
679 679
 			}
@@ -685,11 +685,11 @@  discard block
 block discarded – undo
685 685
 		 * has the view id so that Advanced Filters can be applied correctly when rendering the single view
686 686
 		 * @see GravityView_frontend::get_context_view_id()
687 687
 		 */
688
-		if( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) {
688
+		if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views()) {
689 689
 			$args['gvid'] = gravityview_get_view_id();
690 690
 		}
691 691
 
692
-		return add_query_arg( $args, $directory_link );
692
+		return add_query_arg($args, $directory_link);
693 693
 
694 694
 	}
695 695
 
@@ -699,54 +699,54 @@  discard block
 block discarded – undo
699 699
 
700 700
 // inside loop functions
701 701
 
702
-function gv_label( $field, $entry = NULL ) {
703
-	return GravityView_API::field_label( $field, $entry );
702
+function gv_label($field, $entry = NULL) {
703
+	return GravityView_API::field_label($field, $entry);
704 704
 }
705 705
 
706
-function gv_class( $field, $form = NULL, $entry = array() ) {
707
-	return GravityView_API::field_class( $field, $form, $entry  );
706
+function gv_class($field, $form = NULL, $entry = array()) {
707
+	return GravityView_API::field_class($field, $form, $entry);
708 708
 }
709 709
 
710
-function gv_container_class( $class = '' ) {
710
+function gv_container_class($class = '') {
711 711
 
712 712
 	$default = ' gv-container';
713 713
 
714
-	if( GravityView_View::getInstance()->isHideUntilSearched() ) {
714
+	if (GravityView_View::getInstance()->isHideUntilSearched()) {
715 715
 		$default .= ' hidden';
716 716
 	}
717 717
 
718
-	$class = apply_filters( 'gravityview/render/container/class', $class . $default );
718
+	$class = apply_filters('gravityview/render/container/class', $class.$default);
719 719
 
720
-	$class = gravityview_sanitize_html_class( $class );
720
+	$class = gravityview_sanitize_html_class($class);
721 721
 
722 722
 	echo $class;
723 723
 }
724 724
 
725
-function gv_value( $entry, $field ) {
725
+function gv_value($entry, $field) {
726 726
 
727
-	$value = GravityView_API::field_value( $entry, $field );
727
+	$value = GravityView_API::field_value($entry, $field);
728 728
 
729
-	if( $value === '') {
729
+	if ($value === '') {
730 730
 		/**
731 731
 		 * @filter `gravityview_empty_value` What to display when a field is empty
732 732
 		 * @param string $value (empty string)
733 733
 		 */
734
-		$value = apply_filters( 'gravityview_empty_value', '' );
734
+		$value = apply_filters('gravityview_empty_value', '');
735 735
 	}
736 736
 
737 737
 	return $value;
738 738
 }
739 739
 
740
-function gv_directory_link( $post = NULL, $add_pagination = true ) {
741
-	return GravityView_API::directory_link( $post, $add_pagination );
740
+function gv_directory_link($post = NULL, $add_pagination = true) {
741
+	return GravityView_API::directory_link($post, $add_pagination);
742 742
 }
743 743
 
744
-function gv_entry_link( $entry, $post_id = NULL ) {
745
-	return GravityView_API::entry_link( $entry, $post_id );
744
+function gv_entry_link($entry, $post_id = NULL) {
745
+	return GravityView_API::entry_link($entry, $post_id);
746 746
 }
747 747
 
748 748
 function gv_no_results($wpautop = true) {
749
-	return GravityView_API::no_results( $wpautop );
749
+	return GravityView_API::no_results($wpautop);
750 750
 }
751 751
 
752 752
 /**
@@ -758,21 +758,21 @@  discard block
 block discarded – undo
758 758
 
759 759
 	$href = gv_directory_link();
760 760
 
761
-	if( empty( $href ) ) { return NULL; }
761
+	if (empty($href)) { return NULL; }
762 762
 
763 763
 	// calculate link label
764 764
 	$gravityview_view = GravityView_View::getInstance();
765 765
 
766
-	$label = $gravityview_view->getBackLinkLabel() ? $gravityview_view->getBackLinkLabel() : __( '&larr; Go back', 'gravityview' );
766
+	$label = $gravityview_view->getBackLinkLabel() ? $gravityview_view->getBackLinkLabel() : __('&larr; Go back', 'gravityview');
767 767
 
768 768
 	/**
769 769
 	 * @filter `gravityview_go_back_label` Modify the back link text
770 770
 	 * @since 1.0.9
771 771
 	 * @param string $label Existing label text
772 772
 	 */
773
-	$label = apply_filters( 'gravityview_go_back_label', $label );
773
+	$label = apply_filters('gravityview_go_back_label', $label);
774 774
 
775
-	$link = gravityview_get_link( $href, esc_html( $label ), array(
775
+	$link = gravityview_get_link($href, esc_html($label), array(
776 776
 		'data-viewid' => $gravityview_view->getViewId()
777 777
 	));
778 778
 
@@ -791,9 +791,9 @@  discard block
 block discarded – undo
791 791
  * @param  string 	$display_value The value generated by Gravity Forms
792 792
  * @return string                Value
793 793
  */
794
-function gravityview_get_field_value( $entry, $field_id, $display_value ) {
794
+function gravityview_get_field_value($entry, $field_id, $display_value) {
795 795
 
796
-	if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) {
796
+	if (floatval($field_id) === floor(floatval($field_id))) {
797 797
 
798 798
 		// For the complete field value as generated by Gravity Forms
799 799
 		return $display_value;
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 	} else {
802 802
 
803 803
 		// For one part of the address (City, ZIP, etc.)
804
-		return isset( $entry[ $field_id ] ) ? $entry[ $field_id ] : '';
804
+		return isset($entry[$field_id]) ? $entry[$field_id] : '';
805 805
 
806 806
 	}
807 807
 
@@ -817,48 +817,48 @@  discard block
 block discarded – undo
817 817
  * @param  string      $taxonomy Type of term (`post_tag` or `category`)
818 818
  * @return string                CSV of linked terms
819 819
  */
820
-function gravityview_convert_value_to_term_list( $value, $taxonomy = 'post_tag' ) {
820
+function gravityview_convert_value_to_term_list($value, $taxonomy = 'post_tag') {
821 821
 
822 822
 	$output = array();
823 823
 
824
-	$terms = explode( ', ', $value );
824
+	$terms = explode(', ', $value);
825 825
 
826
-	foreach ($terms as $term_name ) {
826
+	foreach ($terms as $term_name) {
827 827
 
828 828
 		// If we're processing a category,
829
-		if( $taxonomy === 'category' ) {
829
+		if ($taxonomy === 'category') {
830 830
 
831 831
 			// Use rgexplode to prevent errors if : doesn't exist
832
-			list( $term_name, $term_id ) = rgexplode( ':', $value, 2 );
832
+			list($term_name, $term_id) = rgexplode(':', $value, 2);
833 833
 
834 834
 			// The explode was succesful; we have the category ID
835
-			if( !empty( $term_id )) {
836
-				$term = get_term_by( 'id', $term_id, $taxonomy );
835
+			if (!empty($term_id)) {
836
+				$term = get_term_by('id', $term_id, $taxonomy);
837 837
 			} else {
838 838
 			// We have to fall back to the name
839
-				$term = get_term_by( 'name', $term_name, $taxonomy );
839
+				$term = get_term_by('name', $term_name, $taxonomy);
840 840
 			}
841 841
 
842 842
 		} else {
843 843
 			// Use the name of the tag to get the full term information
844
-			$term = get_term_by( 'name', $term_name, $taxonomy );
844
+			$term = get_term_by('name', $term_name, $taxonomy);
845 845
 		}
846 846
 
847 847
 		// There's still a tag/category here.
848
-		if( $term ) {
848
+		if ($term) {
849 849
 
850
-			$term_link = get_term_link( $term, $taxonomy );
850
+			$term_link = get_term_link($term, $taxonomy);
851 851
 
852 852
 			// If there was an error, continue to the next term.
853
-			if ( is_wp_error( $term_link ) ) {
853
+			if (is_wp_error($term_link)) {
854 854
 			    continue;
855 855
 			}
856 856
 
857
-			$output[] = gravityview_get_link( $term_link, esc_html( $term->name ) );
857
+			$output[] = gravityview_get_link($term_link, esc_html($term->name));
858 858
 		}
859 859
 	}
860 860
 
861
-	return implode(', ', $output );
861
+	return implode(', ', $output);
862 862
 }
863 863
 
864 864
 /**
@@ -868,12 +868,12 @@  discard block
 block discarded – undo
868 868
  * @param  string      $taxonomy Taxonomy of term to fetch.
869 869
  * @return string                String with terms
870 870
  */
871
-function gravityview_get_the_term_list( $post_id, $link = true, $taxonomy = 'post_tag' ) {
871
+function gravityview_get_the_term_list($post_id, $link = true, $taxonomy = 'post_tag') {
872 872
 
873
-	$output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' );
873
+	$output = get_the_term_list($post_id, $taxonomy, NULL, ', ');
874 874
 
875
-	if( empty( $link ) ) {
876
-		return strip_tags( $output);
875
+	if (empty($link)) {
876
+		return strip_tags($output);
877 877
 	}
878 878
 
879 879
 	return $output;
@@ -892,17 +892,17 @@  discard block
 block discarded – undo
892 892
 	$fe = GravityView_frontend::getInstance();
893 893
 
894 894
 	// Solve problem when loading content via admin-ajax.php
895
-	if( ! $fe->getGvOutputData() ) {
895
+	if (!$fe->getGvOutputData()) {
896 896
 
897
-		do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.' );
897
+		do_action('gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.');
898 898
 
899 899
 		$fe->parse_content();
900 900
 	}
901 901
 
902 902
 	// Make 100% sure that we're dealing with a properly called situation
903
-	if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) {
903
+	if (!is_a($fe->getGvOutputData(), 'GravityView_View_Data')) {
904 904
 
905
-		do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData() );
905
+		do_action('gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData());
906 906
 
907 907
 		return array();
908 908
 	}
@@ -916,18 +916,18 @@  discard block
 block discarded – undo
916 916
  * @see  GravityView_View_Data::get_view()
917 917
  * @return array View data with `id`, `view_id`, `form_id`, `template_id`, `atts`, `fields`, `widgets`, `form` keys.
918 918
  */
919
-function gravityview_get_current_view_data( $view_id = 0 ) {
919
+function gravityview_get_current_view_data($view_id = 0) {
920 920
 
921 921
 	$fe = GravityView_frontend::getInstance();
922 922
 
923
-	if( ! $fe->getGvOutputData() ) { return array(); }
923
+	if (!$fe->getGvOutputData()) { return array(); }
924 924
 
925 925
 	// If not set, grab the current view ID
926
-	if( empty( $view_id ) ) {
926
+	if (empty($view_id)) {
927 927
 		$view_id = $fe->get_context_view_id();
928 928
 	}
929 929
 
930
-	return $fe->getGvOutputData()->get_view( $view_id );
930
+	return $fe->getGvOutputData()->get_view($view_id);
931 931
 }
932 932
 
933 933
 // Templates' hooks
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 	 * @action `gravityview_before` Display content before a View. Used to render widget areas. Rendered outside the View container `<div>`
937 937
 	 * @param int $view_id The ID of the View being displayed
938 938
 	 */
939
-	do_action( 'gravityview_before', gravityview_get_view_id() );
939
+	do_action('gravityview_before', gravityview_get_view_id());
940 940
 }
941 941
 
942 942
 function gravityview_header() {
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 	 * @action `gravityview_header` Prepend content to the View container `<div>`
945 945
 	 * @param int $view_id The ID of the View being displayed
946 946
 	 */
947
-	do_action( 'gravityview_header', gravityview_get_view_id() );
947
+	do_action('gravityview_header', gravityview_get_view_id());
948 948
 }
949 949
 
950 950
 function gravityview_footer() {
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
 	 * @action `gravityview_after` Display content after a View. Used to render footer widget areas. Rendered outside the View container `<div>`
953 953
 	 * @param int $view_id The ID of the View being displayed
954 954
 	 */
955
-	do_action( 'gravityview_footer', gravityview_get_view_id() );
955
+	do_action('gravityview_footer', gravityview_get_view_id());
956 956
 }
957 957
 
958 958
 function gravityview_after() {
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
 	 * @action `gravityview_after` Append content to the View container `<div>`
961 961
 	 * @param int $view_id The ID of the View being displayed
962 962
 	 */
963
-	do_action( 'gravityview_after', gravityview_get_view_id() );
963
+	do_action('gravityview_after', gravityview_get_view_id());
964 964
 }
965 965
 
966 966
 /**
@@ -986,13 +986,13 @@  discard block
 block discarded – undo
986 986
 	 * The Edit Entry functionality overrides this value.
987 987
 	 * @param boolean $is_edit_entry
988 988
 	 */
989
-	$is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false );
989
+	$is_edit_entry = apply_filters('gravityview_is_edit_entry', false);
990 990
 
991
-	if( $is_edit_entry ) {
991
+	if ($is_edit_entry) {
992 992
 		$context = 'edit';
993
-	} else if( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) {
993
+	} else if (class_exists('GravityView_frontend') && $single = GravityView_frontend::is_single_entry()) {
994 994
 		$context = 'single';
995
-	} else if( class_exists( 'GravityView_View' ) ) {
995
+	} else if (class_exists('GravityView_View')) {
996 996
 		$context = GravityView_View::getInstance()->getContext();
997 997
 	}
998 998
 
@@ -1017,18 +1017,18 @@  discard block
 block discarded – undo
1017 1017
  * @param  string $gv_class Field class to add to the output HTML
1018 1018
  * @return array           Array of file output, with `file_path` and `html` keys (see comments above)
1019 1019
  */
1020
-function gravityview_get_files_array( $value, $gv_class = '' ) {
1020
+function gravityview_get_files_array($value, $gv_class = '') {
1021 1021
 	/** @define "GRAVITYVIEW_DIR" "../" */
1022 1022
 
1023
-	if( !class_exists( 'GravityView_Field' ) ) {
1024
-		include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' );
1023
+	if (!class_exists('GravityView_Field')) {
1024
+		include_once(GRAVITYVIEW_DIR.'includes/fields/class-gravityview-field.php');
1025 1025
 	}
1026 1026
 
1027
-	if( !class_exists( 'GravityView_Field_FileUpload' ) ) {
1028
-		include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' );
1027
+	if (!class_exists('GravityView_Field_FileUpload')) {
1028
+		include_once(GRAVITYVIEW_DIR.'includes/fields/fileupload.php');
1029 1029
 	}
1030 1030
 
1031
-	return GravityView_Field_FileUpload::get_files_array( $value, $gv_class );
1031
+	return GravityView_Field_FileUpload::get_files_array($value, $gv_class);
1032 1032
 }
1033 1033
 
1034 1034
 /**
@@ -1042,16 +1042,16 @@  discard block
 block discarded – undo
1042 1042
  * @param  string $address Address
1043 1043
  * @return string          URL of link to map of address
1044 1044
  */
1045
-function gravityview_get_map_link( $address ) {
1045
+function gravityview_get_map_link($address) {
1046 1046
 
1047
-	$address_qs = str_replace( array( '<br />', "\n" ), ' ', $address ); // Replace \n with spaces
1048
-	$address_qs = urlencode( $address_qs );
1047
+	$address_qs = str_replace(array('<br />', "\n"), ' ', $address); // Replace \n with spaces
1048
+	$address_qs = urlencode($address_qs);
1049 1049
 
1050 1050
 	$url = "https://maps.google.com/maps?q={$address_qs}";
1051 1051
 
1052
-	$link_text = esc_html__( 'Map It', 'gravityview' );
1052
+	$link_text = esc_html__('Map It', 'gravityview');
1053 1053
 
1054
-	$link = gravityview_get_link( $url, $link_text, 'class=map-it-link' );
1054
+	$link = gravityview_get_link($url, $link_text, 'class=map-it-link');
1055 1055
 
1056 1056
 	/**
1057 1057
 	 * @filter `gravityview_map_link` Modify the map link generated. You can use a different mapping service, for example.
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
 	 * @param[in] string $address Address to generate link for
1060 1060
 	 * @param[in] string $url URL generated by the function
1061 1061
 	 */
1062
-	$link = apply_filters( 'gravityview_map_link', $link, $address, $url );
1062
+	$link = apply_filters('gravityview_map_link', $link, $address, $url);
1063 1063
 
1064 1064
 	return $link;
1065 1065
 }
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
  * @param  array $passed_args Associative array with field data. `field` and `form` are required.
1081 1081
  * @return string Field output. If empty value and hide empty is true, return empty.
1082 1082
  */
1083
-function gravityview_field_output( $passed_args ) {
1083
+function gravityview_field_output($passed_args) {
1084 1084
 	$defaults = array(
1085 1085
 		'entry' => null,
1086 1086
 		'field' => null,
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 		'zone_id' => null,
1093 1093
 	);
1094 1094
 
1095
-	$args = wp_parse_args( $passed_args, $defaults );
1095
+	$args = wp_parse_args($passed_args, $defaults);
1096 1096
 
1097 1097
 	/**
1098 1098
 	 * @filter `gravityview/field_output/args` Modify the args before generation begins
@@ -1100,15 +1100,15 @@  discard block
 block discarded – undo
1100 1100
 	 * @param array $args Associative array; `field` and `form` is required.
1101 1101
 	 * @param array $passed_args Original associative array with field data. `field` and `form` are required.
1102 1102
 	 */
1103
-	$args = apply_filters( 'gravityview/field_output/args', $args, $passed_args );
1103
+	$args = apply_filters('gravityview/field_output/args', $args, $passed_args);
1104 1104
 
1105 1105
 	// Required fields.
1106
-	if ( empty( $args['field'] ) || empty( $args['form'] ) ) {
1107
-		do_action( 'gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args );
1106
+	if (empty($args['field']) || empty($args['form'])) {
1107
+		do_action('gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args);
1108 1108
 		return '';
1109 1109
 	}
1110 1110
 
1111
-	$entry = empty( $args['entry'] ) ? array() : $args['entry'];
1111
+	$entry = empty($args['entry']) ? array() : $args['entry'];
1112 1112
 
1113 1113
 	/**
1114 1114
 	 * Create the content variables for replacing.
@@ -1124,36 +1124,36 @@  discard block
 block discarded – undo
1124 1124
 		'field_id' => '',
1125 1125
 	);
1126 1126
 
1127
-	$context['value'] = gv_value( $entry, $args['field'] );
1127
+	$context['value'] = gv_value($entry, $args['field']);
1128 1128
 
1129 1129
 	// If the value is empty and we're hiding empty, return empty.
1130
-	if ( $context['value'] === '' && ! empty( $args['hide_empty'] ) ) {
1130
+	if ($context['value'] === '' && !empty($args['hide_empty'])) {
1131 1131
 		return '';
1132 1132
 	}
1133 1133
 
1134
-	if ( $context['value'] !== '' && ! empty( $args['wpautop'] ) ) {
1135
-		$context['value'] = wpautop( $context['value'] );
1134
+	if ($context['value'] !== '' && !empty($args['wpautop'])) {
1135
+		$context['value'] = wpautop($context['value']);
1136 1136
 	}
1137 1137
 
1138 1138
 	// Get width setting, if exists
1139
-	$context['width'] = GravityView_API::field_width( $args['field'] );
1139
+	$context['width'] = GravityView_API::field_width($args['field']);
1140 1140
 
1141 1141
 	// If replacing with CSS inline formatting, let's do it.
1142
-	$context['width:style'] = GravityView_API::field_width( $args['field'], 'width:' . $context['width'] . '%;' );
1142
+	$context['width:style'] = GravityView_API::field_width($args['field'], 'width:'.$context['width'].'%;');
1143 1143
 
1144 1144
 	// Grab the Class using `gv_class`
1145
-	$context['class'] = gv_class( $args['field'], $args['form'], $entry );
1146
-	$context['field_id'] = GravityView_API::field_html_attr_id( $args['field'], $args['form'], $entry );
1145
+	$context['class'] = gv_class($args['field'], $args['form'], $entry);
1146
+	$context['field_id'] = GravityView_API::field_html_attr_id($args['field'], $args['form'], $entry);
1147 1147
 
1148 1148
 	// Get field label if needed
1149
-	if ( ! empty( $args['label_markup'] ) ) {
1150
-		$context['label'] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup'] );
1149
+	if (!empty($args['label_markup'])) {
1150
+		$context['label'] = str_replace(array('{{label}}', '{{ label }}'), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup']);
1151 1151
 	}
1152 1152
 
1153 1153
 	// Default Label value
1154
-	$context['label_value'] = gv_label( $args['field'], $entry );
1154
+	$context['label_value'] = gv_label($args['field'], $entry);
1155 1155
 
1156
-	if ( empty( $context['label'] ) && ! empty( $context['label_value'] ) ){
1156
+	if (empty($context['label']) && !empty($context['label_value'])) {
1157 1157
 		$context['label'] = '<span class="gv-field-label">{{ label_value }}</span>';
1158 1158
 	}
1159 1159
 
@@ -1163,37 +1163,37 @@  discard block
 block discarded – undo
1163 1163
 	 * @param string $markup The HTML for the markup
1164 1164
 	 * @param array $args All args for the field output
1165 1165
 	 */
1166
-	$html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args );
1166
+	$html = apply_filters('gravityview/field_output/pre_html', $args['markup'], $args);
1167 1167
 
1168 1168
 	/**
1169 1169
 	 * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders
1170 1170
 	 * @since 1.11
1171 1171
 	 * @param string $open_tag Open tag for template content placeholders. Default: `{{`
1172 1172
 	 */
1173
-	$open_tag = apply_filters( 'gravityview/field_output/open_tag', '{{', $args );
1173
+	$open_tag = apply_filters('gravityview/field_output/open_tag', '{{', $args);
1174 1174
 
1175 1175
 	/**
1176 1176
 	 * @filter `gravityview/field_output/close_tag` Modify the closing tags for the template content placeholders
1177 1177
 	 * @since 1.11
1178 1178
 	 * @param string $close_tag Close tag for template content placeholders. Default: `}}`
1179 1179
 	 */
1180
-	$close_tag = apply_filters( 'gravityview/field_output/close_tag', '}}', $args );
1180
+	$close_tag = apply_filters('gravityview/field_output/close_tag', '}}', $args);
1181 1181
 
1182 1182
 	/**
1183 1183
 	 * Loop through each of the tags to replace and replace both `{{tag}}` and `{{ tag }}` with the values
1184 1184
 	 * @since 1.11
1185 1185
 	 */
1186
-	foreach ( $context as $tag => $value ) {
1186
+	foreach ($context as $tag => $value) {
1187 1187
 
1188 1188
 		// If the tag doesn't exist just skip it
1189
-		if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){
1189
+		if (false === strpos($html, $open_tag.$tag.$close_tag) && false === strpos($html, $open_tag.' '.$tag.' '.$close_tag)) {
1190 1190
 			continue;
1191 1191
 		}
1192 1192
 
1193 1193
 		// Array to search
1194 1194
 		$search = array(
1195
-			$open_tag . $tag . $close_tag,
1196
-			$open_tag . ' ' . $tag . ' ' . $close_tag,
1195
+			$open_tag.$tag.$close_tag,
1196
+			$open_tag.' '.$tag.' '.$close_tag,
1197 1197
 		);
1198 1198
 
1199 1199
 		/**
@@ -1202,26 +1202,26 @@  discard block
 block discarded – undo
1202 1202
 		 * @param string $value The content to be shown instead of the {{tag}} placeholder
1203 1203
 		 * @param array $args Arguments passed to the function
1204 1204
 		 */
1205
-		$value = apply_filters( 'gravityview/field_output/context/' . $tag, $value, $args );
1205
+		$value = apply_filters('gravityview/field_output/context/'.$tag, $value, $args);
1206 1206
 
1207 1207
 		// Finally do the replace
1208
-		$html = str_replace( $search, $value, $html );
1208
+		$html = str_replace($search, $value, $html);
1209 1209
 	}
1210 1210
 
1211 1211
 	/**
1212 1212
 	 * @todo  Depricate `gravityview_field_output`
1213 1213
 	 */
1214
-	$html = apply_filters( 'gravityview_field_output', $html, $args );
1214
+	$html = apply_filters('gravityview_field_output', $html, $args);
1215 1215
 
1216 1216
 	/**
1217 1217
 	 * @filter `gravityview/field_output/html` Modify field HTML output
1218 1218
 	 * @param string $html Existing HTML output
1219 1219
 	 * @param array $args Arguments passed to the function
1220 1220
 	 */
1221
-	$html = apply_filters( 'gravityview/field_output/html', $html, $args );
1221
+	$html = apply_filters('gravityview/field_output/html', $html, $args);
1222 1222
 
1223 1223
 	// Just free up a tiny amount of memory
1224
-	unset( $value, $args, $passed_args, $entry, $context, $search, $open_tag, $tag, $close_tag );
1224
+	unset($value, $args, $passed_args, $entry, $context, $search, $open_tag, $tag, $close_tag);
1225 1225
 
1226 1226
 	return $html;
1227 1227
 }
@@ -1239,18 +1239,18 @@  discard block
 block discarded – undo
1239 1239
  *
1240 1240
  * @return string html attribute or empty string
1241 1241
  */
1242
-function gv_selected( $value, $current, $echo = true, $type = 'selected' ) {
1242
+function gv_selected($value, $current, $echo = true, $type = 'selected') {
1243 1243
 
1244 1244
 	$output = '';
1245
-	if( is_array( $current ) ) {
1246
-		if( in_array( $value, $current ) ) {
1247
-			$output = __checked_selected_helper( true, true, false, $type );
1245
+	if (is_array($current)) {
1246
+		if (in_array($value, $current)) {
1247
+			$output = __checked_selected_helper(true, true, false, $type);
1248 1248
 		}
1249 1249
 	} else {
1250
-		$output = __checked_selected_helper( $value, $current, false, $type );
1250
+		$output = __checked_selected_helper($value, $current, false, $type);
1251 1251
 	}
1252 1252
 
1253
-	if( $echo ) {
1253
+	if ($echo) {
1254 1254
 		echo $output;
1255 1255
 	}
1256 1256
 
Please login to merge, or discard this patch.
gravityview.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  */
27 27
 
28 28
 /** If this file is called directly, abort. */
29
-if ( ! defined( 'ABSPATH' ) ) {
29
+if (!defined('ABSPATH')) {
30 30
 	die;
31 31
 }
32 32
 
@@ -36,52 +36,52 @@  discard block
 block discarded – undo
36 36
  * Full path to the GravityView file
37 37
  * @define "GRAVITYVIEW_FILE" "./gravityview.php"
38 38
  */
39
-define( 'GRAVITYVIEW_FILE', __FILE__ );
39
+define('GRAVITYVIEW_FILE', __FILE__);
40 40
 
41 41
 /**
42 42
  * The URL to this file
43 43
  */
44
-define( 'GRAVITYVIEW_URL', plugin_dir_url( __FILE__ ) );
44
+define('GRAVITYVIEW_URL', plugin_dir_url(__FILE__));
45 45
 
46 46
 
47 47
 /** @define "GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory */
48
-define( 'GRAVITYVIEW_DIR', plugin_dir_path( __FILE__ ) );
48
+define('GRAVITYVIEW_DIR', plugin_dir_path(__FILE__));
49 49
 
50 50
 /**
51 51
  * GravityView requires at least this version of Gravity Forms to function properly.
52 52
  */
53
-define( 'GV_MIN_GF_VERSION', '1.9.9.10' );
53
+define('GV_MIN_GF_VERSION', '1.9.9.10');
54 54
 
55 55
 /**
56 56
  * GravityView requires at least this version of WordPress to function properly.
57 57
  * @since 1.12
58 58
  */
59
-define( 'GV_MIN_WP_VERSION', '3.3' );
59
+define('GV_MIN_WP_VERSION', '3.3');
60 60
 
61 61
 /**
62 62
  * GravityView requires at least this version of PHP to function properly.
63 63
  * @since 1.12
64 64
  */
65
-define( 'GV_MIN_PHP_VERSION', '5.2.4' );
65
+define('GV_MIN_PHP_VERSION', '5.2.4');
66 66
 
67 67
 /** Load common & connector functions */
68
-require_once( GRAVITYVIEW_DIR . 'includes/helper-functions.php' );
69
-require_once( GRAVITYVIEW_DIR . 'includes/class-common.php');
70
-require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php');
71
-require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-compatibility.php' );
72
-require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-roles-capabilities.php' );
73
-require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-notices.php' );
68
+require_once(GRAVITYVIEW_DIR.'includes/helper-functions.php');
69
+require_once(GRAVITYVIEW_DIR.'includes/class-common.php');
70
+require_once(GRAVITYVIEW_DIR.'includes/connector-functions.php');
71
+require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-compatibility.php');
72
+require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-roles-capabilities.php');
73
+require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-admin-notices.php');
74 74
 
75 75
 /** Register Post Types and Rewrite Rules */
76
-require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php');
76
+require_once(GRAVITYVIEW_DIR.'includes/class-post-types.php');
77 77
 
78 78
 /** Add Cache Class */
79
-require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php');
79
+require_once(GRAVITYVIEW_DIR.'includes/class-cache.php');
80 80
 
81 81
 /** Register hooks that are fired when the plugin is activated and deactivated. */
82
-if( is_admin() ) {
83
-	register_activation_hook( __FILE__, array( 'GravityView_Plugin', 'activate' ) );
84
-	register_deactivation_hook( __FILE__, array( 'GravityView_Plugin', 'deactivate' ) );
82
+if (is_admin()) {
83
+	register_activation_hook(__FILE__, array('GravityView_Plugin', 'activate'));
84
+	register_deactivation_hook(__FILE__, array('GravityView_Plugin', 'deactivate'));
85 85
 }
86 86
 
87 87
 /**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public static function getInstance() {
102 102
 
103
-		if( empty( self::$instance ) ) {
103
+		if (empty(self::$instance)) {
104 104
 			self::$instance = new self;
105 105
 		}
106 106
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	private function __construct() {
111 111
 
112 112
 
113
-		if( ! GravityView_Compatibility::is_valid() ) {
113
+		if (!GravityView_Compatibility::is_valid()) {
114 114
 			return;
115 115
 		}
116 116
 
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	private function add_hooks() {
128 128
 		// Load plugin text domain
129
-		add_action( 'init', array( $this, 'load_plugin_textdomain' ), 1 );
129
+		add_action('init', array($this, 'load_plugin_textdomain'), 1);
130 130
 
131 131
 		// Load frontend files
132
-		add_action( 'init', array( $this, 'frontend_actions' ), 20 );
132
+		add_action('init', array($this, 'frontend_actions'), 20);
133 133
 	}
134 134
 
135 135
 	/**
@@ -139,47 +139,47 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	public function include_files() {
141 141
 
142
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin.php' );
142
+		include_once(GRAVITYVIEW_DIR.'includes/class-admin.php');
143 143
 
144 144
 		// Load fields
145
-		include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' );
145
+		include_once(GRAVITYVIEW_DIR.'includes/fields/class-gravityview-field.php');
146 146
 
147 147
 		// Load all field files automatically
148
-		foreach ( glob( GRAVITYVIEW_DIR . 'includes/fields/*.php' ) as $gv_field_filename ) {
149
-			include_once( $gv_field_filename );
148
+		foreach (glob(GRAVITYVIEW_DIR.'includes/fields/*.php') as $gv_field_filename) {
149
+			include_once($gv_field_filename);
150 150
 		}
151 151
 
152
-		include_once( GRAVITYVIEW_DIR .'includes/class-gravityview-entry-notes.php' );
153
-		include_once( GRAVITYVIEW_DIR .'includes/load-plugin-and-theme-hooks.php' );
152
+		include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-entry-notes.php');
153
+		include_once(GRAVITYVIEW_DIR.'includes/load-plugin-and-theme-hooks.php');
154 154
 
155 155
 		// Load Extensions
156 156
 		// @todo: Convert to a scan of the directory or a method where this all lives
157
-		include_once( GRAVITYVIEW_DIR .'includes/extensions/edit-entry/class-edit-entry.php' );
158
-		include_once( GRAVITYVIEW_DIR .'includes/extensions/delete-entry/class-delete-entry.php' );
157
+		include_once(GRAVITYVIEW_DIR.'includes/extensions/edit-entry/class-edit-entry.php');
158
+		include_once(GRAVITYVIEW_DIR.'includes/extensions/delete-entry/class-delete-entry.php');
159 159
 
160 160
 		// Load WordPress Widgets
161
-		include_once( GRAVITYVIEW_DIR .'includes/wordpress-widgets/register-wordpress-widgets.php' );
161
+		include_once(GRAVITYVIEW_DIR.'includes/wordpress-widgets/register-wordpress-widgets.php');
162 162
 
163 163
 		// Load GravityView Widgets
164
-		include_once( GRAVITYVIEW_DIR .'includes/widgets/register-gravityview-widgets.php' );
164
+		include_once(GRAVITYVIEW_DIR.'includes/widgets/register-gravityview-widgets.php');
165 165
 
166 166
 		// Add oEmbed
167
-		include_once( GRAVITYVIEW_DIR . 'includes/class-oembed.php' );
167
+		include_once(GRAVITYVIEW_DIR.'includes/class-oembed.php');
168 168
 
169 169
 		// Add logging
170
-		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-logging.php' );
171
-
172
-		include_once( GRAVITYVIEW_DIR . 'includes/class-ajax.php' );
173
-		include_once( GRAVITYVIEW_DIR . 'includes/class-settings.php');
174
-		include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' );
175
-		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-bar.php' );
176
-		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-list.php' );
177
-		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php'); /** @since 1.8.4 */
178
-		include_once( GRAVITYVIEW_DIR . 'includes/class-data.php' );
179
-		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-shortcode.php' );
180
-		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-link-shortcode.php' );
181
-		include_once( GRAVITYVIEW_DIR . 'includes/class-gvlogic-shortcode.php' );
182
-		include_once( GRAVITYVIEW_DIR . 'includes/presets/register-default-templates.php' );
170
+		include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-logging.php');
171
+
172
+		include_once(GRAVITYVIEW_DIR.'includes/class-ajax.php');
173
+		include_once(GRAVITYVIEW_DIR.'includes/class-settings.php');
174
+		include_once(GRAVITYVIEW_DIR.'includes/class-frontend-views.php');
175
+		include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-admin-bar.php');
176
+		include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-entry-list.php');
177
+		include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-merge-tags.php'); /** @since 1.8.4 */
178
+		include_once(GRAVITYVIEW_DIR.'includes/class-data.php');
179
+		include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-shortcode.php');
180
+		include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-entry-link-shortcode.php');
181
+		include_once(GRAVITYVIEW_DIR.'includes/class-gvlogic-shortcode.php');
182
+		include_once(GRAVITYVIEW_DIR.'includes/presets/register-default-templates.php');
183 183
 
184 184
 	}
185 185
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @return bool
190 190
 	 */
191 191
 	public static function is_network_activated() {
192
-		return is_multisite() && ( function_exists('is_plugin_active_for_network') && is_plugin_active_for_network( 'gravityview/gravityview.php' ) );
192
+		return is_multisite() && (function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('gravityview/gravityview.php'));
193 193
 	}
194 194
 
195 195
 
@@ -211,13 +211,13 @@  discard block
 block discarded – undo
211 211
 		flush_rewrite_rules();
212 212
 
213 213
 		// Update the current GV version
214
-		update_option( 'gv_version', self::version );
214
+		update_option('gv_version', self::version);
215 215
 
216 216
 		// Add the transient to redirect to configuration page
217
-		set_transient( '_gv_activation_redirect', true, 60 );
217
+		set_transient('_gv_activation_redirect', true, 60);
218 218
 
219 219
 		// Clear settings transient
220
-		delete_transient( 'redux_edd_license_license_valid' );
220
+		delete_transient('redux_edd_license_license_valid');
221 221
 
222 222
 		GravityView_Roles_Capabilities::get_instance()->add_caps();
223 223
 	}
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 	 * @return void
244 244
 	 */
245 245
 	public static function include_extension_framework() {
246
-		if ( ! class_exists( 'GravityView_Extension' ) ) {
247
-			require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-extension.php' );
246
+		if (!class_exists('GravityView_Extension')) {
247
+			require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-extension.php');
248 248
 		}
249 249
 	}
250 250
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 * @since 1.7.5.1
255 255
 	 */
256 256
 	public static function include_widget_class() {
257
-		include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' );
257
+		include_once(GRAVITYVIEW_DIR.'includes/widgets/class-gravityview-widget.php');
258 258
 	}
259 259
 
260 260
 
@@ -266,17 +266,17 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	public function load_plugin_textdomain() {
268 268
 
269
-		$loaded = load_plugin_textdomain( 'gravityview', false, '/languages/' );
270
-		if ( ! $loaded ) {
271
-			$loaded = load_muplugin_textdomain( 'gravityview', '/languages/' );
269
+		$loaded = load_plugin_textdomain('gravityview', false, '/languages/');
270
+		if (!$loaded) {
271
+			$loaded = load_muplugin_textdomain('gravityview', '/languages/');
272 272
 		}
273
-		if ( ! $loaded ) {
274
-			$loaded = load_theme_textdomain( 'gravityview', '/languages/' );
273
+		if (!$loaded) {
274
+			$loaded = load_theme_textdomain('gravityview', '/languages/');
275 275
 		}
276
-		if ( ! $loaded ) {
277
-			$locale = apply_filters( 'plugin_locale', get_locale(), 'gravityview' );
278
-			$mofile = dirname( __FILE__ ) . '/languages/gravityview-'. $locale .'.mo';
279
-			load_textdomain( 'gravityview', $mofile );
276
+		if (!$loaded) {
277
+			$locale = apply_filters('plugin_locale', get_locale(), 'gravityview');
278
+			$mofile = dirname(__FILE__).'/languages/gravityview-'.$locale.'.mo';
279
+			load_textdomain('gravityview', $mofile);
280 280
 		}
281 281
 
282 282
 	}
@@ -288,9 +288,9 @@  discard block
 block discarded – undo
288 288
 	 */
289 289
 	public static function is_admin() {
290 290
 
291
-		$doing_ajax = defined( 'DOING_AJAX' ) ? DOING_AJAX : false;
291
+		$doing_ajax = defined('DOING_AJAX') ? DOING_AJAX : false;
292 292
 
293
-		return is_admin() && ! $doing_ajax;
293
+		return is_admin() && !$doing_ajax;
294 294
 	}
295 295
 
296 296
 	/**
@@ -301,27 +301,27 @@  discard block
 block discarded – undo
301 301
 	 */
302 302
 	public function frontend_actions() {
303 303
 
304
-		if( self::is_admin() ) { return; }
304
+		if (self::is_admin()) { return; }
305 305
 
306
-		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-image.php' );
307
-		include_once( GRAVITYVIEW_DIR .'includes/class-template.php' );
308
-		include_once( GRAVITYVIEW_DIR .'includes/class-api.php' );
309
-		include_once( GRAVITYVIEW_DIR .'includes/class-frontend-views.php' );
310
-		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' );
306
+		include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-image.php');
307
+		include_once(GRAVITYVIEW_DIR.'includes/class-template.php');
308
+		include_once(GRAVITYVIEW_DIR.'includes/class-api.php');
309
+		include_once(GRAVITYVIEW_DIR.'includes/class-frontend-views.php');
310
+		include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-change-entry-creator.php');
311 311
 
312 312
 
313 313
         /**
314 314
          * When an entry is created, check if we need to update the custom slug meta
315 315
          * todo: move this to its own class..
316 316
          */
317
-        add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );
317
+        add_action('gform_entry_created', array('GravityView_API', 'entry_create_custom_slug'), 10, 2);
318 318
 
319 319
 		/**
320 320
 		 * @action `gravityview_include_frontend_actions` Triggered after all GravityView frontend files are loaded
321 321
 		 *
322 322
 		 * Nice place to insert extensions' frontend stuff
323 323
 		 */
324
-		do_action( 'gravityview_include_frontend_actions' );
324
+		do_action('gravityview_include_frontend_actions');
325 325
 	}
326 326
 
327 327
 	/**
@@ -331,15 +331,15 @@  discard block
 block discarded – undo
331 331
 	 */
332 332
 	public static function get_default_widget_areas() {
333 333
 		$default_areas = array(
334
-			array( '1-1' => array( array( 'areaid' => 'top', 'title' => __('Top', 'gravityview' ) , 'subtitle' => '' ) ) ),
335
-			array( '1-2' => array( array( 'areaid' => 'left', 'title' => __('Left', 'gravityview') , 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __('Right', 'gravityview') , 'subtitle' => '' ) ) ),
334
+			array('1-1' => array(array('areaid' => 'top', 'title' => __('Top', 'gravityview'), 'subtitle' => ''))),
335
+			array('1-2' => array(array('areaid' => 'left', 'title' => __('Left', 'gravityview'), 'subtitle' => '')), '2-2' => array(array('areaid' => 'right', 'title' => __('Right', 'gravityview'), 'subtitle' => ''))),
336 336
 		);
337 337
 
338 338
 		/**
339 339
 		 * @filter `gravityview_widget_active_areas` Array of zones available for widgets to be dropped into
340 340
 		 * @param array $default_areas Definition for default widget areas
341 341
 		 */
342
-		return apply_filters( 'gravityview_widget_active_areas', $default_areas );
342
+		return apply_filters('gravityview_widget_active_areas', $default_areas);
343 343
 	}
344 344
 
345 345
 	/** DEBUG */
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
      * @param mixed $data Additional data to display
351 351
      * @return void
352 352
      */
353
-    public static function log_debug( $message, $data = null ){
353
+    public static function log_debug($message, $data = null) {
354 354
 	    /**
355 355
 	     * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
356 356
 	     * @param string $message Message to display
357 357
 	     * @param mixed $data Supporting data to print alongside it
358 358
 	     */
359
-    	do_action( 'gravityview_log_debug', $message, $data );
359
+    	do_action('gravityview_log_debug', $message, $data);
360 360
     }
361 361
 
362 362
     /**
@@ -364,13 +364,13 @@  discard block
 block discarded – undo
364 364
      * @param  string $message log message
365 365
      * @return void
366 366
      */
367
-    public static function log_error( $message, $data = null ){
367
+    public static function log_error($message, $data = null) {
368 368
 	    /**
369 369
 	     * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
370 370
 	     * @param string $message Error message to display
371 371
 	     * @param mixed $data Supporting data to print alongside it
372 372
 	     */
373
-    	do_action( 'gravityview_log_error', $message, $data );
373
+    	do_action('gravityview_log_error', $message, $data);
374 374
     }
375 375
 
376 376
 } // end class GravityView_Plugin
Please login to merge, or discard this patch.
includes/class-admin-add-shortcode.php 2 patches
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
- * Adds a button to add the View shortcode into the post content
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
+			 * Adds a button to add the View shortcode into the post content
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
 /** If this file is called directly, abort. */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 /** If this file is called directly, abort. */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	die;
17 17
 }
18 18
 
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
 
21 21
 	function __construct() {
22 22
 
23
-			add_action( 'media_buttons', array( $this, 'add_shortcode_button'), 30);
23
+			add_action('media_buttons', array($this, 'add_shortcode_button'), 30);
24 24
 
25
-			add_action( 'admin_footer',	array( $this, 'add_shortcode_popup') );
25
+			add_action('admin_footer', array($this, 'add_shortcode_popup'));
26 26
 
27 27
 			// adding styles and scripts
28
-			add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') );
28
+			add_action('admin_enqueue_scripts', array($this, 'add_scripts_and_styles'));
29 29
 
30 30
 			// ajax - populate sort fields based on the selected view
31
-			add_action( 'wp_ajax_gv_sortable_fields', array( $this, 'get_sortable_fields' ) );
31
+			add_action('wp_ajax_gv_sortable_fields', array($this, 'get_sortable_fields'));
32 32
 	}
33 33
 
34 34
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	function is_post_editor_screen() {
42 42
 		global $current_screen, $pagenow;
43
-		return !empty( $current_screen->post_type ) && 'gravityview' != $current_screen->post_type && in_array( $pagenow , array( 'post.php' , 'post-new.php' ) );
43
+		return !empty($current_screen->post_type) && 'gravityview' != $current_screen->post_type && in_array($pagenow, array('post.php', 'post-new.php'));
44 44
 	}
45 45
 
46 46
 
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 		/**
56 56
 		 * @since 1.15.3
57 57
 		 */
58
-		if( ! GVCommon::has_cap( array( 'publish_gravityviews' ) ) ) {
58
+		if (!GVCommon::has_cap(array('publish_gravityviews'))) {
59 59
 			return;
60 60
 		}
61 61
 
62
-		if( !$this->is_post_editor_screen() ) {
62
+		if (!$this->is_post_editor_screen()) {
63 63
 			return;
64 64
 		}
65 65
 		?>
66
-		<a href="#TB_inline?width=480&amp;inlineId=select_gravityview_view&amp;width=600&amp;height=800" class="thickbox button gform_media_link" id="add_gravityview" title="<?php esc_attr_e("Insert View", 'gravityview'); ?>"><span class="icon gv-icon-astronaut-head"></span><?php esc_html_e( 'Add View', 'gravityview' ); ?></a>
66
+		<a href="#TB_inline?width=480&amp;inlineId=select_gravityview_view&amp;width=600&amp;height=800" class="thickbox button gform_media_link" id="add_gravityview" title="<?php esc_attr_e("Insert View", 'gravityview'); ?>"><span class="icon gv-icon-astronaut-head"></span><?php esc_html_e('Add View', 'gravityview'); ?></a>
67 67
 		<?php
68 68
 
69 69
 	}
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
 	function add_shortcode_popup() {
80 80
 		global $post;
81 81
 
82
-		if( !$this->is_post_editor_screen() ) {
82
+		if (!$this->is_post_editor_screen()) {
83 83
 			return;
84 84
 		}
85 85
 
86 86
 		$post_type = get_post_type_object($post->post_type);
87 87
 
88
-		$views = get_posts( array('post_type' => 'gravityview', 'posts_per_page' => -1 ) );
88
+		$views = get_posts(array('post_type' => 'gravityview', 'posts_per_page' => -1));
89 89
 
90 90
 		// If there are no views set up yet, we get outta here.
91
-		if( empty( $views ) ) {
92
-			echo '<div id="select_gravityview_view"><div class="wrap">'. GravityView_Post_Types::no_views_text() .'</div></div>';
91
+		if (empty($views)) {
92
+			echo '<div id="select_gravityview_view"><div class="wrap">'.GravityView_Post_Types::no_views_text().'</div></div>';
93 93
 			return;
94 94
 		}
95 95
 
@@ -98,18 +98,18 @@  discard block
 block discarded – undo
98 98
 			<form action="#" method="get" id="select_gravityview_view_form">
99 99
 				<div class="wrap">
100 100
 
101
-					<h2 class=""><?php esc_html_e( 'Embed a View', 'gravityview' ); ?></h2>
102
-					<p class="subtitle"><?php printf( esc_attr ( __( 'Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview') ), $post_type->labels->singular_name, '<a href="http://gravityview.co/support/documentation/202934188/" target="_blank">', '</a>' ); ?></p>
101
+					<h2 class=""><?php esc_html_e('Embed a View', 'gravityview'); ?></h2>
102
+					<p class="subtitle"><?php printf(esc_attr(__('Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview')), $post_type->labels->singular_name, '<a href="http://gravityview.co/support/documentation/202934188/" target="_blank">', '</a>'); ?></p>
103 103
 
104 104
 					<div>
105
-						<h3><label for="gravityview_id"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label></h3>
105
+						<h3><label for="gravityview_id"><?php esc_html_e('Select a View', 'gravityview'); ?></label></h3>
106 106
 
107 107
 						<select name="gravityview_id" id="gravityview_id">
108
-							<option value=""><?php esc_html_e( '&mdash; Select a View to Insert &mdash;', 'gravityview' ); ?></option>
108
+							<option value=""><?php esc_html_e('&mdash; Select a View to Insert &mdash;', 'gravityview'); ?></option>
109 109
 							<?php
110
-							foreach( $views as $view ) {
111
-								$title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title;
112
-								echo '<option value="'. $view->ID .'">'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>';
110
+							foreach ($views as $view) {
111
+								$title = empty($view->post_title) ? __('(no title)', 'gravityview') : $view->post_title;
112
+								echo '<option value="'.$view->ID.'">'.esc_html(sprintf('%s #%d', $title, $view->ID)).'</option>';
113 113
 							}
114 114
 							?>
115 115
 						</select>
@@ -117,24 +117,24 @@  discard block
 block discarded – undo
117 117
 
118 118
 					<table class="form-table hide-if-js">
119 119
 
120
-						<caption><?php esc_html_e( 'View Settings', 'gravityview' ); ?></caption>
120
+						<caption><?php esc_html_e('View Settings', 'gravityview'); ?></caption>
121 121
 
122 122
 						<?php
123 123
 
124
-						$settings = GravityView_View_Data::get_default_args( true );
124
+						$settings = GravityView_View_Data::get_default_args(true);
125 125
 
126
-						foreach ( $settings as $key => $setting ) {
126
+						foreach ($settings as $key => $setting) {
127 127
 
128
-							if( empty( $setting['show_in_shortcode'] ) ) { continue; }
128
+							if (empty($setting['show_in_shortcode'])) { continue; }
129 129
 
130
-							GravityView_Render_Settings::render_setting_row( $key, array(), NULL, 'gravityview_%s', 'gravityview_%s' );
130
+							GravityView_Render_Settings::render_setting_row($key, array(), NULL, 'gravityview_%s', 'gravityview_%s');
131 131
 						}
132 132
 						?>
133 133
 
134 134
 					</table>
135 135
 
136 136
 					<div class="submit">
137
-						<input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e('Insert View', 'gravityview' ); ?>" id="insert_gravityview_view" />
137
+						<input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e('Insert View', 'gravityview'); ?>" id="insert_gravityview_view" />
138 138
 						<input class="button button-secondary alignright" type="submit" onclick="tb_remove(); return false;" value="<?php esc_attr_e("Cancel", 'gravityview'); ?>" />
139 139
 					</div>
140 140
 
@@ -157,32 +157,32 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	function add_scripts_and_styles() {
159 159
 
160
-		if( ! $this->is_post_editor_screen() ) {
160
+		if (!$this->is_post_editor_screen()) {
161 161
 			return;
162 162
 		}
163 163
 
164
-		wp_enqueue_style( 'dashicons' );
164
+		wp_enqueue_style('dashicons');
165 165
 
166 166
 		// date picker
167
-		wp_enqueue_script( 'jquery-ui-datepicker' );
167
+		wp_enqueue_script('jquery-ui-datepicker');
168 168
 
169 169
 		$protocol = is_ssl() ? 'https://' : 'http://';
170 170
 
171
-		wp_enqueue_style( 'jquery-ui-datepicker', $protocol.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version );
171
+		wp_enqueue_style('jquery-ui-datepicker', $protocol.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version);
172 172
 
173 173
 		//enqueue styles
174
-		wp_register_style( 'gravityview_postedit_styles', plugins_url('assets/css/admin-post-edit.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version );
175
-		wp_enqueue_style( 'gravityview_postedit_styles' );
174
+		wp_register_style('gravityview_postedit_styles', plugins_url('assets/css/admin-post-edit.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version);
175
+		wp_enqueue_style('gravityview_postedit_styles');
176 176
 
177 177
 		$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
178 178
 
179 179
 		// custom js
180
-		wp_register_script( 'gravityview_postedit_scripts',  plugins_url('assets/js/admin-post-edit'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'jquery-ui-datepicker' ), GravityView_Plugin::version );
181
-		wp_enqueue_script( 'gravityview_postedit_scripts' );
180
+		wp_register_script('gravityview_postedit_scripts', plugins_url('assets/js/admin-post-edit'.$script_debug.'.js', GRAVITYVIEW_FILE), array('jquery', 'jquery-ui-datepicker'), GravityView_Plugin::version);
181
+		wp_enqueue_script('gravityview_postedit_scripts');
182 182
 		wp_localize_script('gravityview_postedit_scripts', 'gvGlobals', array(
183
-			'nonce' => wp_create_nonce( 'gravityview_ajaxaddshortcode'),
184
-			'loading_text' => esc_html__( 'Loading&hellip;', 'gravityview' ),
185
-			'alert_1' => esc_html__( 'Please select a View', 'gravityview'),
183
+			'nonce' => wp_create_nonce('gravityview_ajaxaddshortcode'),
184
+			'loading_text' => esc_html__('Loading&hellip;', 'gravityview'),
185
+			'alert_1' => esc_html__('Please select a View', 'gravityview'),
186 186
 		));
187 187
 
188 188
 	}
@@ -199,27 +199,27 @@  discard block
 block discarded – undo
199 199
 	function get_sortable_fields() {
200 200
 
201 201
 		// Not properly formatted request
202
-		if ( empty( $_POST['viewid'] ) || !is_numeric( $_POST['viewid'] ) ) {
203
-			exit( false );
202
+		if (empty($_POST['viewid']) || !is_numeric($_POST['viewid'])) {
203
+			exit(false);
204 204
 		}
205 205
 
206 206
 		// Not valid request
207
-		if( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxaddshortcode' ) ) {
208
-			exit( false );
207
+		if (empty($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxaddshortcode')) {
208
+			exit(false);
209 209
 		}
210 210
 
211 211
 		$viewid = (int)$_POST['viewid'];
212 212
 
213 213
 		// fetch form id assigned to the view
214
-		$formid = gravityview_get_form_id( $viewid );
214
+		$formid = gravityview_get_form_id($viewid);
215 215
 
216 216
 		// Get the default sort field for the view
217
-		$sort_field = gravityview_get_template_setting( $viewid, 'sort_field' );
217
+		$sort_field = gravityview_get_template_setting($viewid, 'sort_field');
218 218
 
219 219
 		// Generate the output `<option>`s
220
-		$response = gravityview_get_sortable_fields( $formid, $sort_field );
220
+		$response = gravityview_get_sortable_fields($formid, $sort_field);
221 221
 
222
-		exit( $response );
222
+		exit($response);
223 223
 	}
224 224
 
225 225
 }
Please login to merge, or discard this patch.
includes/widgets/search-widget/class-search-widget.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * The GravityView New Search widget
4
- *
5
- * @package   GravityView-DataTables-Ext
6
- * @license   GPL2+
7
- * @author    Katz Web Services, Inc.
8
- * @link      http://gravityview.co
9
- * @copyright Copyright 2014, Katz Web Services, Inc.
10
- */
3
+			 * The GravityView New Search widget
4
+			 *
5
+			 * @package   GravityView-DataTables-Ext
6
+			 * @license   GPL2+
7
+			 * @author    Katz Web Services, Inc.
8
+			 * @link      http://gravityview.co
9
+			 * @copyright Copyright 2014, Katz Web Services, Inc.
10
+			 */
11 11
 
12 12
 if ( ! defined( 'WPINC' ) ) {
13 13
 	die;
@@ -384,16 +384,16 @@  discard block
 block discarded – undo
384 384
 		$curr_start = esc_attr( rgget( 'gv_start' ) );
385 385
 		$curr_end = esc_attr( rgget( 'gv_end' ) );
386 386
 
387
-        /**
388
-         * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n
389
-         * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php)
390
-         * @since 1.12
391
-         * @param[out,in] boolean $adjust_tz  Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true
392
-         * @param[in] string $context Where the filter is being called from. `search` in this case.
393
-         */
394
-        $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' );
395
-        $search_criteria['start_date'] = ( $adjust_tz && !empty( $curr_start ) ) ? get_gmt_from_date( $curr_start ) : $curr_start;
396
-        $search_criteria['end_date'] = ( $adjust_tz  && !empty( $curr_end ) ) ? get_gmt_from_date( $curr_end ) : $curr_end;
387
+		/**
388
+		 * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n
389
+		 * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php)
390
+		 * @since 1.12
391
+		 * @param[out,in] boolean $adjust_tz  Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true
392
+		 * @param[in] string $context Where the filter is being called from. `search` in this case.
393
+		 */
394
+		$adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' );
395
+		$search_criteria['start_date'] = ( $adjust_tz && !empty( $curr_start ) ) ? get_gmt_from_date( $curr_start ) : $curr_start;
396
+		$search_criteria['end_date'] = ( $adjust_tz  && !empty( $curr_end ) ) ? get_gmt_from_date( $curr_end ) : $curr_end;
397 397
 
398 398
 
399 399
 		// search for a specific entry ID
Please login to merge, or discard this patch.
Spacing   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @copyright Copyright 2014, Katz Web Services, Inc.
10 10
  */
11 11
 
12
-if ( ! defined( 'WPINC' ) ) {
12
+if (!defined('WPINC')) {
13 13
 	die;
14 14
 }
15 15
 
@@ -22,28 +22,28 @@  discard block
 block discarded – undo
22 22
 
23 23
 	public function __construct() {
24 24
 
25
-		$this->widget_description = esc_html__( 'Search form for searching entries.', 'gravityview' );
25
+		$this->widget_description = esc_html__('Search form for searching entries.', 'gravityview');
26 26
 
27 27
 		self::$instance = &$this;
28 28
 
29
-		self::$file = plugin_dir_path( __FILE__ );
29
+		self::$file = plugin_dir_path(__FILE__);
30 30
 
31
-		$default_values = array( 'header' => 0, 'footer' => 0 );
31
+		$default_values = array('header' => 0, 'footer' => 0);
32 32
 
33 33
 		$settings = array(
34 34
 			'search_layout' => array(
35 35
 				'type' => 'radio',
36 36
 				'full_width' => true,
37
-				'label' => esc_html__( 'Search Layout', 'gravityview' ),
37
+				'label' => esc_html__('Search Layout', 'gravityview'),
38 38
 				'value' => 'horizontal',
39 39
 				'options' => array(
40
-					'horizontal' => esc_html__( 'Horizontal', 'gravityview' ),
41
-					'vertical' => esc_html__( 'Vertical', 'gravityview' ),
40
+					'horizontal' => esc_html__('Horizontal', 'gravityview'),
41
+					'vertical' => esc_html__('Vertical', 'gravityview'),
42 42
 				),
43 43
 			),
44 44
 			'search_clear' => array(
45 45
 				'type' => 'checkbox',
46
-				'label' => __( 'Show Clear button', 'gravityview' ),
46
+				'label' => __('Show Clear button', 'gravityview'),
47 47
 				'value' => false,
48 48
 			),
49 49
 			'search_fields' => array(
@@ -55,33 +55,33 @@  discard block
 block discarded – undo
55 55
 			'search_mode' => array(
56 56
 				'type' => 'radio',
57 57
 				'full_width' => true,
58
-				'label' => esc_html__( 'Search Mode', 'gravityview' ),
58
+				'label' => esc_html__('Search Mode', 'gravityview'),
59 59
 				'desc' => __('Should search results match all search fields, or any?', 'gravityview'),
60 60
 				'value' => 'any',
61 61
 				'class' => 'hide-if-js',
62 62
 				'options' => array(
63
-					'any' => esc_html__( 'Match Any Fields', 'gravityview' ),
64
-					'all' => esc_html__( 'Match All Fields', 'gravityview' ),
63
+					'any' => esc_html__('Match Any Fields', 'gravityview'),
64
+					'all' => esc_html__('Match All Fields', 'gravityview'),
65 65
 				),
66 66
 			),
67 67
 		);
68
-		parent::__construct( esc_html__( 'Search Bar', 'gravityview' ), 'search_bar', $default_values, $settings );
68
+		parent::__construct(esc_html__('Search Bar', 'gravityview'), 'search_bar', $default_values, $settings);
69 69
 
70 70
 		// frontend - filter entries
71
-		add_filter( 'gravityview_fe_search_criteria', array( $this, 'filter_entries' ), 10, 1 );
71
+		add_filter('gravityview_fe_search_criteria', array($this, 'filter_entries'), 10, 1);
72 72
 
73 73
 		// frontend - add template path
74
-		add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
74
+		add_filter('gravityview_template_paths', array($this, 'add_template_path'));
75 75
 
76 76
 		// Add hidden fields for "Default" permalink structure
77
-		add_filter( 'gravityview_widget_search_filters', array( $this, 'add_no_permalink_fields' ), 10, 3 );
77
+		add_filter('gravityview_widget_search_filters', array($this, 'add_no_permalink_fields'), 10, 3);
78 78
 
79 79
 		// admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999
80
-		add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 );
81
-		add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) );
80
+		add_action('admin_enqueue_scripts', array($this, 'add_scripts_and_styles'), 1100);
81
+		add_filter('gravityview_noconflict_scripts', array($this, 'register_no_conflict'));
82 82
 
83 83
 		// ajax - get the searchable fields
84
-		add_action( 'wp_ajax_gv_searchable_fields', array( 'GravityView_Widget_Search', 'get_searchable_fields' ) );
84
+		add_action('wp_ajax_gv_searchable_fields', array('GravityView_Widget_Search', 'get_searchable_fields'));
85 85
 
86 86
 	}
87 87
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return GravityView_Widget_Search
90 90
 	 */
91 91
 	public static function getInstance() {
92
-		if ( empty( self::$instance ) ) {
92
+		if (empty(self::$instance)) {
93 93
 			self::$instance = new GravityView_Widget_Search;
94 94
 		}
95 95
 		return self::$instance;
@@ -100,18 +100,18 @@  discard block
 block discarded – undo
100 100
 	 * Add script to Views edit screen (admin)
101 101
 	 * @param  mixed $hook
102 102
 	 */
103
-	public function add_scripts_and_styles( $hook ) {
103
+	public function add_scripts_and_styles($hook) {
104 104
 		global $pagenow;
105 105
 
106 106
 		// Don't process any scripts below here if it's not a GravityView page or the widgets screen
107
-		if ( ! gravityview_is_admin_page( $hook ) && ( 'widgets.php' !== $pagenow ) ) {
107
+		if (!gravityview_is_admin_page($hook) && ('widgets.php' !== $pagenow)) {
108 108
 			return;
109 109
 		}
110 110
 
111
-		$script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
112
-		$script_source = empty( $script_min ) ? '/source' : '';
111
+		$script_min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
112
+		$script_source = empty($script_min) ? '/source' : '';
113 113
 
114
-		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version );
114
+		wp_enqueue_script('gravityview_searchwidget_admin', plugins_url('assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__), array('jquery', 'gravityview_views_scripts'), GravityView_Plugin::version);
115 115
 
116 116
 
117 117
 		/**
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
 		 * @var array
121 121
 		 */
122 122
 		$input_labels = array(
123
-			'input_text' => esc_html__( 'Text', 'gravityview' ),
124
-			'date' => esc_html__( 'Date', 'gravityview' ),
125
-			'select' => esc_html__( 'Select', 'gravityview' ),
126
-			'multiselect' => esc_html__( 'Select (multiple values)', 'gravityview' ),
127
-			'radio' => esc_html__( 'Radio', 'gravityview' ),
128
-			'checkbox' => esc_html__( 'Checkbox', 'gravityview' ),
129
-			'single_checkbox' => esc_html__( 'Checkbox', 'gravityview' ),
130
-			'link' => esc_html__( 'Links', 'gravityview' ),
131
-			'date_range' => esc_html__( 'Date range', 'gravityview' ),
123
+			'input_text' => esc_html__('Text', 'gravityview'),
124
+			'date' => esc_html__('Date', 'gravityview'),
125
+			'select' => esc_html__('Select', 'gravityview'),
126
+			'multiselect' => esc_html__('Select (multiple values)', 'gravityview'),
127
+			'radio' => esc_html__('Radio', 'gravityview'),
128
+			'checkbox' => esc_html__('Checkbox', 'gravityview'),
129
+			'single_checkbox' => esc_html__('Checkbox', 'gravityview'),
130
+			'link' => esc_html__('Links', 'gravityview'),
131
+			'date_range' => esc_html__('Date range', 'gravityview'),
132 132
 		);
133 133
 
134 134
 		/**
@@ -137,31 +137,31 @@  discard block
 block discarded – undo
137 137
 		 * @var array
138 138
 		 */
139 139
 		$input_types = array(
140
-			'text' => array( 'input_text' ),
141
-			'address' => array( 'input_text' ),
142
-			'date' => array( 'date', 'date_range' ),
143
-			'boolean' => array( 'single_checkbox' ),
144
-			'select' => array( 'select', 'radio', 'link' ),
145
-			'multi' => array( 'select', 'multiselect', 'radio', 'checkbox', 'link' ),
140
+			'text' => array('input_text'),
141
+			'address' => array('input_text'),
142
+			'date' => array('date', 'date_range'),
143
+			'boolean' => array('single_checkbox'),
144
+			'select' => array('select', 'radio', 'link'),
145
+			'multi' => array('select', 'multiselect', 'radio', 'checkbox', 'link'),
146 146
 		);
147 147
 
148
-		wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array(
149
-			'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ),
150
-			'label_nofields' => esc_html__( 'No search fields configured yet.', 'gravityview' ),
151
-			'label_addfield' => esc_html__( 'Add Search Field', 'gravityview' ),
152
-			'label_label' => esc_html__( 'Label', 'gravityview' ),
153
-			'label_searchfield' => esc_html__( 'Search Field', 'gravityview' ),
154
-			'label_inputtype' => esc_html__( 'Input Type', 'gravityview' ),
155
-			'input_labels' => json_encode( $input_labels ),
156
-			'input_types' => json_encode( $input_types ),
157
-		) );
148
+		wp_localize_script('gravityview_searchwidget_admin', 'gvSearchVar', array(
149
+			'nonce' => wp_create_nonce('gravityview_ajaxsearchwidget'),
150
+			'label_nofields' => esc_html__('No search fields configured yet.', 'gravityview'),
151
+			'label_addfield' => esc_html__('Add Search Field', 'gravityview'),
152
+			'label_label' => esc_html__('Label', 'gravityview'),
153
+			'label_searchfield' => esc_html__('Search Field', 'gravityview'),
154
+			'label_inputtype' => esc_html__('Input Type', 'gravityview'),
155
+			'input_labels' => json_encode($input_labels),
156
+			'input_types' => json_encode($input_types),
157
+		));
158 158
 
159 159
 	}
160 160
 
161 161
 	/**
162 162
 	 * Add admin script to the whitelist
163 163
 	 */
164
-	public function register_no_conflict( $required ) {
164
+	public function register_no_conflict($required) {
165 165
 		$required[] = 'gravityview_searchwidget_admin';
166 166
 		return $required;
167 167
 	}
@@ -175,30 +175,30 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	public static function get_searchable_fields() {
177 177
 
178
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) {
179
-			exit( 0 );
178
+		if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxsearchwidget')) {
179
+			exit(0);
180 180
 		}
181 181
 		$form = '';
182 182
 
183 183
 		// Fetch the form for the current View
184
-		if ( ! empty( $_POST['view_id'] ) ) {
184
+		if (!empty($_POST['view_id'])) {
185 185
 
186
-			$form = gravityview_get_form_id( $_POST['view_id'] );
186
+			$form = gravityview_get_form_id($_POST['view_id']);
187 187
 
188
-		} elseif ( ! empty( $_POST['formid'] ) ) {
188
+		} elseif (!empty($_POST['formid'])) {
189 189
 
190
-			$form = (int) $_POST['formid'];
190
+			$form = (int)$_POST['formid'];
191 191
 
192
-		} elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) {
192
+		} elseif (!empty($_POST['template_id']) && class_exists('GravityView_Ajax')) {
193 193
 
194
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
194
+			$form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']);
195 195
 
196 196
 		}
197 197
 
198 198
 		// fetch form id assigned to the view
199
-		$response = self::render_searchable_fields( $form );
199
+		$response = self::render_searchable_fields($form);
200 200
 
201
-		exit( $response );
201
+		exit($response);
202 202
 	}
203 203
 
204 204
 	/**
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 	 * @param  string $current (for future use)
208 208
 	 * @return string
209 209
 	 */
210
-	public static function render_searchable_fields( $form_id = null, $current = '' ) {
210
+	public static function render_searchable_fields($form_id = null, $current = '') {
211 211
 
212
-		if ( is_null( $form_id ) ) {
212
+		if (is_null($form_id)) {
213 213
 			return '';
214 214
 		}
215 215
 
216 216
 		// Get fields with sub-inputs and no parent
217
-		$fields = gravityview_get_form_fields( $form_id, true, true );
217
+		$fields = gravityview_get_form_fields($form_id, true, true);
218 218
 
219 219
 		// start building output
220 220
 
@@ -222,40 +222,40 @@  discard block
 block discarded – undo
222 222
 
223 223
 		$custom_fields = array(
224 224
 			'search_all' => array(
225
-				'text' => esc_html__( 'Search Everything', 'gravityview' ),
225
+				'text' => esc_html__('Search Everything', 'gravityview'),
226 226
 				'type' => 'text',
227 227
 			),
228 228
 			'entry_date' => array(
229
-				'text' => esc_html__( 'Entry Date', 'gravityview' ),
229
+				'text' => esc_html__('Entry Date', 'gravityview'),
230 230
 				'type' => 'date',
231 231
 			),
232 232
 			'entry_id' => array(
233
-				'text' => esc_html__( 'Entry ID', 'gravityview' ),
233
+				'text' => esc_html__('Entry ID', 'gravityview'),
234 234
 				'type' => 'text',
235 235
 			),
236 236
 			'created_by' => array(
237
-				'text' => esc_html__( 'Entry Creator', 'gravityview' ),
237
+				'text' => esc_html__('Entry Creator', 'gravityview'),
238 238
 				'type' => 'select',
239 239
 			)
240 240
 		);
241 241
 
242
-		foreach( $custom_fields as $custom_field_key => $custom_field ) {
243
-			$output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] );
242
+		foreach ($custom_fields as $custom_field_key => $custom_field) {
243
+			$output .= sprintf('<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected($custom_field_key, $current, false), $custom_field['type'], self::get_field_label(array('field' => $custom_field_key)), $custom_field['text']);
244 244
 		}
245 245
 
246
-		if ( ! empty( $fields ) ) {
246
+		if (!empty($fields)) {
247 247
 
248
-			$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'fileupload', 'post_image', 'post_id' ), null );
248
+			$blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('fileupload', 'post_image', 'post_id'), null);
249 249
 
250
-			foreach ( $fields as $id => $field ) {
250
+			foreach ($fields as $id => $field) {
251 251
 
252
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
252
+				if (in_array($field['type'], $blacklist_field_types)) {
253 253
 					continue;
254 254
 				}
255 255
 
256
-				$types = self::get_search_input_types( $id, $field['type'] );
256
+				$types = self::get_search_input_types($id, $field['type']);
257 257
 
258
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>';
258
+				$output .= '<option value="'.$id.'" '.selected($id, $current, false).'data-inputtypes="'.esc_attr($types).'">'.esc_html($field['label']).'</option>';
259 259
 			}
260 260
 		}
261 261
 
@@ -274,21 +274,21 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @return string GV field search input type ('multi', 'boolean', 'select', 'date', 'text')
276 276
 	 */
277
-	public static function get_search_input_types( $id = '', $field_type = null ) {
277
+	public static function get_search_input_types($id = '', $field_type = null) {
278 278
 
279 279
 		// @todo - This needs to be improved - many fields have . including products and addresses
280
-		if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) {
280
+		if (false !== strpos((string)$id, '.') && in_array($field_type, array('checkbox')) || in_array($id, array('is_fulfilled'))) {
281 281
 			// on/off checkbox
282 282
 			$input_type = 'boolean';
283
-		} elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) {
283
+		} elseif (in_array($field_type, array('checkbox', 'post_category', 'multiselect'))) {
284 284
 			//multiselect
285 285
 			$input_type = 'multi';
286 286
 
287
-		} elseif ( in_array( $field_type, array( 'select', 'radio' ) ) ) {
287
+		} elseif (in_array($field_type, array('select', 'radio'))) {
288 288
 			//single select
289 289
 			$input_type = 'select';
290 290
 
291
-		} elseif ( in_array( $field_type, array( 'date' ) ) || in_array( $id, array( 'payment_date' ) ) ) {
291
+		} elseif (in_array($field_type, array('date')) || in_array($id, array('payment_date'))) {
292 292
 			// date
293 293
 			$input_type = 'date';
294 294
 		} else {
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 		 * @param string $field_type Gravity Forms field type
303 303
 		 * @since 1.2
304 304
 		 */
305
-		$input_type = apply_filters( 'gravityview/extension/search/input_type', $input_type, $field_type );
305
+		$input_type = apply_filters('gravityview/extension/search/input_type', $input_type, $field_type);
306 306
 
307 307
 		return $input_type;
308 308
 	}
@@ -313,29 +313,29 @@  discard block
 block discarded – undo
313 313
 	 * @since 1.8
314 314
 	 * @return array Search fields, modified if not using permalinks
315 315
 	 */
316
-	public function add_no_permalink_fields( $search_fields, $object, $widget_args = array() ) {
316
+	public function add_no_permalink_fields($search_fields, $object, $widget_args = array()) {
317 317
 		/** @global WP_Rewrite $wp_rewrite */
318 318
 		global $wp_rewrite;
319 319
 
320 320
 		// Support default permalink structure
321
-		if ( false === $wp_rewrite->using_permalinks() ) {
321
+		if (false === $wp_rewrite->using_permalinks()) {
322 322
 
323 323
 			// By default, use current post.
324 324
 			$post_id = 0;
325 325
 
326 326
 			// We're in the WordPress Widget context, and an overriding post ID has been set.
327
-			if ( ! empty( $widget_args['post_id'] ) ) {
328
-				$post_id = absint( $widget_args['post_id'] );
327
+			if (!empty($widget_args['post_id'])) {
328
+				$post_id = absint($widget_args['post_id']);
329 329
 			}
330 330
 			// We're in the WordPress Widget context, and the base View ID should be used
331
-			else if ( ! empty( $widget_args['view_id'] ) ) {
332
-				$post_id = absint( $widget_args['view_id'] );
331
+			else if (!empty($widget_args['view_id'])) {
332
+				$post_id = absint($widget_args['view_id']);
333 333
 			}
334 334
 
335
-			$args = gravityview_get_permalink_query_args( $post_id );
335
+			$args = gravityview_get_permalink_query_args($post_id);
336 336
 
337 337
 			// Add hidden fields to the search form
338
-			foreach ( $args as $key => $value ) {
338
+			foreach ($args as $key => $value) {
339 339
 				$search_fields[] = array(
340 340
 					'name'  => $key,
341 341
 					'input' => 'hidden',
@@ -355,23 +355,23 @@  discard block
 block discarded – undo
355 355
 	 * @param  array $search_criteria
356 356
 	 * @return array
357 357
 	 */
358
-	public function filter_entries( $search_criteria ) {
358
+	public function filter_entries($search_criteria) {
359 359
 
360
-		do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Requested $_GET: ', get_class( $this ) ), $_GET );
360
+		do_action('gravityview_log_debug', sprintf('%s[filter_entries] Requested $_GET: ', get_class($this)), $_GET);
361 361
 
362
-		if ( empty( $_GET ) || ! is_array( $_GET ) ) {
362
+		if (empty($_GET) || !is_array($_GET)) {
363 363
 			return $search_criteria;
364 364
 		}
365 365
 
366 366
 		// add free search
367
-		if ( ! empty( $_GET['gv_search'] ) ) {
367
+		if (!empty($_GET['gv_search'])) {
368 368
 
369 369
 			// Search for a piece
370
-			$words = explode( ' ', stripslashes_deep( urldecode( $_GET['gv_search'] ) ) );
370
+			$words = explode(' ', stripslashes_deep(urldecode($_GET['gv_search'])));
371 371
 
372
-			$words = array_filter( $words );
372
+			$words = array_filter($words);
373 373
 
374
-			foreach ( $words as $word ) {
374
+			foreach ($words as $word) {
375 375
 				$search_criteria['field_filters'][] = array(
376 376
 					'key' => null, // The field ID to search
377 377
 					'value' => $word, // The value to search
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
 		}
382 382
 
383 383
 		//start date & end date
384
-		$curr_start = esc_attr( rgget( 'gv_start' ) );
385
-		$curr_end = esc_attr( rgget( 'gv_end' ) );
384
+		$curr_start = esc_attr(rgget('gv_start'));
385
+		$curr_end = esc_attr(rgget('gv_end'));
386 386
 
387 387
         /**
388 388
          * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n
@@ -391,51 +391,51 @@  discard block
 block discarded – undo
391 391
          * @param[out,in] boolean $adjust_tz  Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true
392 392
          * @param[in] string $context Where the filter is being called from. `search` in this case.
393 393
          */
394
-        $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' );
395
-        $search_criteria['start_date'] = ( $adjust_tz && !empty( $curr_start ) ) ? get_gmt_from_date( $curr_start ) : $curr_start;
396
-        $search_criteria['end_date'] = ( $adjust_tz  && !empty( $curr_end ) ) ? get_gmt_from_date( $curr_end ) : $curr_end;
394
+        $adjust_tz = apply_filters('gravityview_date_created_adjust_timezone', true, 'search');
395
+        $search_criteria['start_date'] = ($adjust_tz && !empty($curr_start)) ? get_gmt_from_date($curr_start) : $curr_start;
396
+        $search_criteria['end_date'] = ($adjust_tz && !empty($curr_end)) ? get_gmt_from_date($curr_end) : $curr_end;
397 397
 
398 398
 
399 399
 		// search for a specific entry ID
400
-		if ( ! empty( $_GET[ 'gv_id' ] ) ) {
400
+		if (!empty($_GET['gv_id'])) {
401 401
 			$search_criteria['field_filters'][] = array(
402 402
 				'key' => 'id',
403
-				'value' => absint( $_GET[ 'gv_id' ] ),
403
+				'value' => absint($_GET['gv_id']),
404 404
 				'operator' => '=',
405 405
 			);
406 406
 		}
407 407
 
408 408
 		// search for a specific Created_by ID
409
-		if ( ! empty( $_GET[ 'gv_by' ] ) ) {
409
+		if (!empty($_GET['gv_by'])) {
410 410
 			$search_criteria['field_filters'][] = array(
411 411
 				'key' => 'created_by',
412
-				'value' => absint( $_GET['gv_by'] ),
412
+				'value' => absint($_GET['gv_by']),
413 413
 				'operator' => '=',
414 414
 			);
415 415
 		}
416 416
 
417 417
 
418 418
 		// Get search mode passed in URL
419
-		$mode = in_array( rgget( 'mode' ), array( 'any', 'all' ) ) ? esc_attr( rgget( 'mode' ) ) : 'any';
419
+		$mode = in_array(rgget('mode'), array('any', 'all')) ? esc_attr(rgget('mode')) : 'any';
420 420
 
421 421
 		// get the other search filters
422
-		foreach ( $_GET as $key => $value ) {
422
+		foreach ($_GET as $key => $value) {
423 423
 
424
-			if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) {
424
+			if (0 !== strpos($key, 'filter_') || empty($value) || (is_array($value) && count($value) === 1 && empty($value[0]))) {
425 425
 				continue;
426 426
 			}
427 427
 
428 428
 			// could return simple filter or multiple filters
429
-			$filter = $this->prepare_field_filter( $key, $value );
429
+			$filter = $this->prepare_field_filter($key, $value);
430 430
 
431
-			if ( isset( $filter[0]['value'] ) ) {
432
-				$search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter );
431
+			if (isset($filter[0]['value'])) {
432
+				$search_criteria['field_filters'] = array_merge($search_criteria['field_filters'], $filter);
433 433
 
434 434
 				// if date range type, set search mode to ALL
435
-				if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>', '<' ) ) ) {
435
+				if (!empty($filter[0]['operator']) && in_array($filter[0]['operator'], array('>', '<'))) {
436 436
 					$mode = 'all';
437 437
 				}
438
-			} elseif( !empty( $filter ) ) {
438
+			} elseif (!empty($filter)) {
439 439
 				$search_criteria['field_filters'][] = $filter;
440 440
 			}
441 441
 		}
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
 		 * @since 1.5.1
446 446
 		 * @param[out,in] string $mode Search mode (`any` vs `all`)
447 447
 		 */
448
-		$search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode );
448
+		$search_criteria['field_filters']['mode'] = apply_filters('gravityview/search/mode', $mode);
449 449
 
450
-		do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria );
450
+		do_action('gravityview_log_debug', sprintf('%s[filter_entries] Returned Search Criteria: ', get_class($this)), $search_criteria);
451 451
 
452 452
 		return $search_criteria;
453 453
 	}
@@ -462,16 +462,16 @@  discard block
 block discarded – undo
462 462
 	 * @param  string $value $_GET search value
463 463
 	 * @return array        1 or 2 deph levels
464 464
 	 */
465
-	public function prepare_field_filter( $key, $value ) {
465
+	public function prepare_field_filter($key, $value) {
466 466
 
467 467
 		$gravityview_view = GravityView_View::getInstance();
468 468
 
469 469
 		// calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox )
470
-		$field_id = str_replace( '_', '.', str_replace( 'filter_', '', $key ) );
470
+		$field_id = str_replace('_', '.', str_replace('filter_', '', $key));
471 471
 
472 472
 		// get form field array
473 473
 		$form = $gravityview_view->getForm();
474
-		$form_field = gravityview_get_field( $form, $field_id );
474
+		$form_field = gravityview_get_field($form, $field_id);
475 475
 
476 476
 		// default filter array
477 477
 		$filter = array(
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 			'value' => $value,
480 480
 		);
481 481
 
482
-		switch ( $form_field['type'] ) {
482
+		switch ($form_field['type']) {
483 483
 
484 484
 			case 'select':
485 485
 			case 'radio':
@@ -488,18 +488,18 @@  discard block
 block discarded – undo
488 488
 
489 489
 			case 'post_category':
490 490
 
491
-				if ( ! is_array( $value ) ) {
492
-					$value = array( $value );
491
+				if (!is_array($value)) {
492
+					$value = array($value);
493 493
 				}
494 494
 
495 495
 				// Reset filter variable
496 496
 				$filter = array();
497 497
 
498
-				foreach ( $value as $val ) {
499
-					$cat = get_term( $val, 'category' );
498
+				foreach ($value as $val) {
499
+					$cat = get_term($val, 'category');
500 500
 					$filter[] = array(
501 501
 						'key' => $field_id,
502
-						'value' => esc_attr( $cat->name ) . ':' . $val,
502
+						'value' => esc_attr($cat->name).':'.$val,
503 503
 						'operator' => 'is',
504 504
 					);
505 505
 				}
@@ -508,35 +508,35 @@  discard block
 block discarded – undo
508 508
 
509 509
 			case 'multiselect':
510 510
 
511
-				if ( ! is_array( $value ) ) {
511
+				if (!is_array($value)) {
512 512
 					break;
513 513
 				}
514 514
 
515 515
 				// Reset filter variable
516 516
 				$filter = array();
517 517
 
518
-				foreach ( $value as $val ) {
519
-					$filter[] = array( 'key' => $field_id, 'value' => $val );
518
+				foreach ($value as $val) {
519
+					$filter[] = array('key' => $field_id, 'value' => $val);
520 520
 				}
521 521
 
522 522
 				break;
523 523
 
524 524
 			case 'checkbox':
525 525
 				// convert checkbox on/off into the correct search filter
526
-				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) {
527
-					foreach ( $form_field['inputs'] as $k => $input ) {
528
-						if ( $input['id'] == $field_id ) {
529
-							$filter['value'] = $form_field['choices'][ $k ]['value'];
526
+				if (false !== strpos($field_id, '.') && !empty($form_field['inputs']) && !empty($form_field['choices'])) {
527
+					foreach ($form_field['inputs'] as $k => $input) {
528
+						if ($input['id'] == $field_id) {
529
+							$filter['value'] = $form_field['choices'][$k]['value'];
530 530
 							$filter['operator'] = 'is';
531 531
 							break;
532 532
 						}
533 533
 					}
534
-				} elseif ( is_array( $value ) ) {
534
+				} elseif (is_array($value)) {
535 535
 
536 536
 					// Reset filter variable
537 537
 					$filter = array();
538 538
 
539
-					foreach ( $value as $val ) {
539
+					foreach ($value as $val) {
540 540
 						$filter[] = array(
541 541
 								'key'   => $field_id,
542 542
 								'value' => $val,
@@ -550,13 +550,13 @@  discard block
 block discarded – undo
550 550
 			case 'name':
551 551
 			case 'address':
552 552
 
553
-				if ( false === strpos( $field_id, '.' ) ) {
553
+				if (false === strpos($field_id, '.')) {
554 554
 
555
-					$words = explode( ' ', $value );
555
+					$words = explode(' ', $value);
556 556
 
557 557
 					$filters = array();
558
-					foreach ( $words as $word ) {
559
-						if ( ! empty( $word ) && strlen( $word ) > 1 ) {
558
+					foreach ($words as $word) {
559
+						if (!empty($word) && strlen($word) > 1) {
560 560
 							// Keep the same key for each filter
561 561
 							$filter['value'] = $word;
562 562
 							// Add a search for the value
@@ -571,25 +571,25 @@  discard block
 block discarded – undo
571 571
 
572 572
 			case 'date':
573 573
 
574
-				if ( is_array( $value ) ) {
574
+				if (is_array($value)) {
575 575
 
576 576
 					// Reset filter variable
577 577
 					$filter = array();
578 578
 
579
-					foreach ( $value as $k => $date ) {
580
-						if ( empty( $date ) ) {
579
+					foreach ($value as $k => $date) {
580
+						if (empty($date)) {
581 581
 							continue;
582 582
 						}
583 583
 						$operator = 'start' === $k ? '>' : '<';
584 584
 
585 585
 						$filter[] = array(
586 586
 							'key' => $field_id,
587
-							'value' => self::get_formatted_date( $date, 'Y-m-d' ),
587
+							'value' => self::get_formatted_date($date, 'Y-m-d'),
588 588
 							'operator' => $operator,
589 589
 						);
590 590
 					}
591 591
 				} else {
592
-					$filter['value'] = self::get_formatted_date( $value, 'Y-m-d' );
592
+					$filter['value'] = self::get_formatted_date($value, 'Y-m-d');
593 593
 				}
594 594
 
595 595
 				break;
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 *
609 609
 	 * @return string Format of the date in the database
610 610
 	 */
611
-	public static function get_date_field_format( GF_Field_Date $field ) {
611
+	public static function get_date_field_format(GF_Field_Date $field) {
612 612
 		$format = 'm/d/Y';
613 613
 		$datepicker = array(
614 614
 			'mdy' => 'm/d/Y',
@@ -620,8 +620,8 @@  discard block
 block discarded – undo
620 620
 			'ymd_dot' => 'Y.m.d',
621 621
 		);
622 622
 
623
-		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){
624
-			$format = $datepicker[ $field->dateFormat ];
623
+		if (!empty($field->dateFormat) && isset($datepicker[$field->dateFormat])) {
624
+			$format = $datepicker[$field->dateFormat];
625 625
 		}
626 626
 
627 627
 		return $format;
@@ -634,13 +634,13 @@  discard block
 block discarded – undo
634 634
 	 * @param string $format Wanted formatted date
635 635
 	 * @return string
636 636
 	 */
637
-	public static function get_formatted_date( $value = '', $format = 'Y-m-d' ) {
638
-		$date = date_create( $value );
639
-		if ( empty( $date ) ) {
640
-			do_action( 'gravityview_log_debug', sprintf( '%s[get_formatted_date] Date format not valid: ', get_class( self::$instance ) ), $value );
637
+	public static function get_formatted_date($value = '', $format = 'Y-m-d') {
638
+		$date = date_create($value);
639
+		if (empty($date)) {
640
+			do_action('gravityview_log_debug', sprintf('%s[get_formatted_date] Date format not valid: ', get_class(self::$instance)), $value);
641 641
 			return '';
642 642
 		}
643
-		return $date->format( $format );
643
+		return $date->format($format);
644 644
 	}
645 645
 
646 646
 
@@ -648,10 +648,10 @@  discard block
 block discarded – undo
648 648
 	 * Include this extension templates path
649 649
 	 * @param array $file_paths List of template paths ordered
650 650
 	 */
651
-	public function add_template_path( $file_paths ) {
651
+	public function add_template_path($file_paths) {
652 652
 
653 653
 		// Index 100 is the default GravityView template path.
654
-		$file_paths[102] = self::$file . 'templates/';
654
+		$file_paths[102] = self::$file.'templates/';
655 655
 
656 656
 		return $file_paths;
657 657
 	}
@@ -663,50 +663,50 @@  discard block
 block discarded – undo
663 663
 	 * @param type $context
664 664
 	 * @return type
665 665
 	 */
666
-	public function render_frontend( $widget_args, $content = '', $context = '' ) {
666
+	public function render_frontend($widget_args, $content = '', $context = '') {
667 667
 		/** @var GravityView_View $gravityview_view */
668 668
 		$gravityview_view = GravityView_View::getInstance();
669 669
 
670
-		if ( empty( $gravityview_view ) ) {
671
-			do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class( $this ) ) );
670
+		if (empty($gravityview_view)) {
671
+			do_action('gravityview_log_debug', sprintf('%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this)));
672 672
 			return;
673 673
 		}
674 674
 
675 675
 		// get configured search fields
676
-		$search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : '';
676
+		$search_fields = !empty($widget_args['search_fields']) ? json_decode($widget_args['search_fields'], true) : '';
677 677
 
678
-		if ( empty( $search_fields ) || ! is_array( $search_fields ) ) {
679
-			do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args );
678
+		if (empty($search_fields) || !is_array($search_fields)) {
679
+			do_action('gravityview_log_debug', sprintf('%s[render_frontend] No search fields configured for widget:', get_class($this)), $widget_args);
680 680
 			return;
681 681
 		}
682 682
 
683 683
 		$has_date = false;
684 684
 
685 685
 		// prepare fields
686
-		foreach ( $search_fields as $k => $field ) {
686
+		foreach ($search_fields as $k => $field) {
687 687
 
688 688
 			$updated_field = $field;
689 689
 
690
-			if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) {
690
+			if (in_array($field['input'], array('date', 'date_range'))) {
691 691
 				$has_date = true;
692 692
 			}
693 693
 
694
-			$updated_field = $this->get_search_filter_details( $updated_field );
694
+			$updated_field = $this->get_search_filter_details($updated_field);
695 695
 
696
-			switch ( $field['field'] ) {
696
+			switch ($field['field']) {
697 697
 
698 698
 				case 'search_all':
699 699
 					$updated_field['key'] = 'search_all';
700 700
 					$updated_field['input'] = 'search_all';
701
-					$updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_search' ) ) );
701
+					$updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_search')));
702 702
 					break;
703 703
 
704 704
 				case 'entry_date':
705 705
 					$updated_field['key'] = 'entry_date';
706 706
 					$updated_field['input'] = 'entry_date';
707 707
 					$updated_field['value'] = array(
708
-						'start' => esc_attr( stripslashes_deep( rgget( 'gv_start' ) ) ),
709
-						'end' => esc_attr( stripslashes_deep( rgget( 'gv_end' ) ) ),
708
+						'start' => esc_attr(stripslashes_deep(rgget('gv_start'))),
709
+						'end' => esc_attr(stripslashes_deep(rgget('gv_end'))),
710 710
 					);
711 711
 					$has_date = true;
712 712
 					break;
@@ -714,21 +714,21 @@  discard block
 block discarded – undo
714 714
 				case 'entry_id':
715 715
 					$updated_field['key'] = 'entry_id';
716 716
 					$updated_field['input'] = 'entry_id';
717
-					$updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_id' ) ) );
717
+					$updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_id')));
718 718
 					break;
719 719
 
720 720
 				case 'created_by':
721 721
 					$updated_field['key'] = 'created_by';
722 722
 					$updated_field['name'] = 'gv_by';
723
-					$updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_by' ) ) );
723
+					$updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_by')));
724 724
 					$updated_field['choices'] = self::get_created_by_choices();
725 725
 					break;
726 726
 			}
727 727
 
728
-			$search_fields[ $k ] = $updated_field;
728
+			$search_fields[$k] = $updated_field;
729 729
 		}
730 730
 
731
-		do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] Calculated Search Fields: ', get_class( $this ) ), $search_fields );
731
+		do_action('gravityview_log_debug', sprintf('%s[render_frontend] Calculated Search Fields: ', get_class($this)), $search_fields);
732 732
 
733 733
 		/**
734 734
 		 * @filter `gravityview_widget_search_filters` Modify what fields are shown. The order of the fields in the $search_filters array controls the order as displayed in the search bar widget.
@@ -737,25 +737,25 @@  discard block
 block discarded – undo
737 737
 		 * @param array $widget_args Args passed to this method. {@since 1.8}
738 738
 		 * @var array
739 739
 		 */
740
-		$gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args );
740
+		$gravityview_view->search_fields = apply_filters('gravityview_widget_search_filters', $search_fields, $this, $widget_args);
741 741
 
742
-		$gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal';
742
+		$gravityview_view->search_layout = !empty($widget_args['search_layout']) ? $widget_args['search_layout'] : 'horizontal';
743 743
 
744 744
 		/** @since 1.14 */
745
-		$gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any';
745
+		$gravityview_view->search_mode = !empty($widget_args['search_mode']) ? $widget_args['search_mode'] : 'any';
746 746
 
747
-		$custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
747
+		$custom_class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : '';
748 748
 
749
-		$gravityview_view->search_class = self::get_search_class( $custom_class );
749
+		$gravityview_view->search_class = self::get_search_class($custom_class);
750 750
 
751
-		$gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false;
751
+		$gravityview_view->search_clear = !empty($widget_args['search_clear']) ? $widget_args['search_clear'] : false;
752 752
 
753
-		if ( $has_date ) {
753
+		if ($has_date) {
754 754
 			// enqueue datepicker stuff only if needed!
755 755
 			$this->enqueue_datepicker();
756 756
 		}
757 757
 
758
-		$gravityview_view->render( 'widget', 'search', false );
758
+		$gravityview_view->render('widget', 'search', false);
759 759
 	}
760 760
 
761 761
 	/**
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
 	 *
766 766
 	 * @return string Sanitized CSS class for the search form
767 767
 	 */
768
-	public static function get_search_class( $custom_class = '' ) {
768
+	public static function get_search_class($custom_class = '') {
769 769
 		$gravityview_view = GravityView_View::getInstance();
770 770
 
771 771
 		$search_class = 'gv-search-'.$gravityview_view->search_layout;
772 772
 
773
-		if ( ! empty( $custom_class )  ) {
773
+		if (!empty($custom_class)) {
774 774
 			$search_class .= ' '.$custom_class;
775 775
 		}
776 776
 
@@ -779,12 +779,12 @@  discard block
 block discarded – undo
779 779
 		 *
780 780
 		 * @param string $search_class The CSS class for the search form
781 781
 		 */
782
-		$search_class = apply_filters( 'gravityview_search_class', $search_class );
782
+		$search_class = apply_filters('gravityview_search_class', $search_class);
783 783
 
784 784
 		// Is there an active search being performed? Used by fe-views.js
785 785
 		$search_class .= GravityView_frontend::getInstance()->isSearch() ? ' gv-is-search' : '';
786 786
 
787
-		return gravityview_sanitize_html_class( $search_class );
787
+		return gravityview_sanitize_html_class($search_class);
788 788
 	}
789 789
 
790 790
 
@@ -799,9 +799,9 @@  discard block
 block discarded – undo
799 799
 
800 800
 		$post_id = $gravityview_view->getPostId() ? $gravityview_view->getPostId() : $gravityview_view->getViewId();
801 801
 
802
-		$url = add_query_arg( array(), get_permalink( $post_id ) );
802
+		$url = add_query_arg(array(), get_permalink($post_id));
803 803
 
804
-		return esc_url( $url );
804
+		return esc_url($url);
805 805
 	}
806 806
 
807 807
 	/**
@@ -810,42 +810,42 @@  discard block
 block discarded – undo
810 810
 	 * @param  array $form_field Form field data, as fetched by `gravityview_get_field()`
811 811
 	 * @return string             Label for the search form
812 812
 	 */
813
-	private static function get_field_label( $field, $form_field = array() ) {
813
+	private static function get_field_label($field, $form_field = array()) {
814 814
 
815
-		$label = rgget( 'label', $field );
815
+		$label = rgget('label', $field);
816 816
 
817
-		if( '' === $label ) {
817
+		if ('' === $label) {
818 818
 
819
-			$label = isset( $form_field['label'] ) ? $form_field['label'] : '';
819
+			$label = isset($form_field['label']) ? $form_field['label'] : '';
820 820
 
821
-			switch( $field['field'] ) {
821
+			switch ($field['field']) {
822 822
 				case 'search_all':
823
-					$label = __( 'Search Entries:', 'gravityview' );
823
+					$label = __('Search Entries:', 'gravityview');
824 824
 					break;
825 825
 				case 'entry_date':
826
-					$label = __( 'Filter by date:', 'gravityview' );
826
+					$label = __('Filter by date:', 'gravityview');
827 827
 					break;
828 828
 				case 'entry_id':
829
-					$label = __( 'Entry ID:', 'gravityview' );
829
+					$label = __('Entry ID:', 'gravityview');
830 830
 					break;
831 831
 				case 'created_by':
832
-					$label = __( 'Submitted by:', 'gravityview' );
832
+					$label = __('Submitted by:', 'gravityview');
833 833
 					break;
834 834
 				case 'is_fulfilled':
835
-					$label = __( 'Is Fulfilled', 'gravityview' );
835
+					$label = __('Is Fulfilled', 'gravityview');
836 836
 					break;
837 837
 				default:
838 838
 					// If this is a field input, not a field
839
-					if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) {
839
+					if (strpos($field['field'], '.') > 0 && !empty($form_field['inputs'])) {
840 840
 
841 841
 						// Get the label for the field in question, which returns an array
842
-						$items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) );
842
+						$items = wp_list_filter($form_field['inputs'], array('id' => $field['field']));
843 843
 
844 844
 						// Get the item with the `label` key
845
-						$values = wp_list_pluck( $items, 'label' );
845
+						$values = wp_list_pluck($items, 'label');
846 846
 
847 847
 						// There will only one item in the array, but this is easier
848
-						foreach ( $values as $value ) {
848
+						foreach ($values as $value) {
849 849
 							$label = $value;
850 850
 							break;
851 851
 						}
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 		 * @param[in,out] string $label Existing label text, sanitized.
859 859
 		 * @param[in] array $form_field Gravity Forms field array, as returned by `GFFormsModel::get_field()`
860 860
 		 */
861
-		$label = apply_filters( 'gravityview_search_field_label', esc_attr( $label ), $form_field );
861
+		$label = apply_filters('gravityview_search_field_label', esc_attr($label), $form_field);
862 862
 
863 863
 		return $label;
864 864
 	}
@@ -869,39 +869,39 @@  discard block
 block discarded – undo
869 869
 	 * @param array $field
870 870
 	 * @return array
871 871
 	 */
872
-	private function get_search_filter_details( $field ) {
872
+	private function get_search_filter_details($field) {
873 873
 
874 874
 		$gravityview_view = GravityView_View::getInstance();
875 875
 
876 876
 		$form = $gravityview_view->getForm();
877 877
 
878 878
 		// for advanced field ids (eg, first name / last name )
879
-		$name = 'filter_' . str_replace( '.', '_', $field['field'] );
879
+		$name = 'filter_'.str_replace('.', '_', $field['field']);
880 880
 
881 881
 		// get searched value from $_GET (string or array)
882
-		$value = rgget( $name );
882
+		$value = rgget($name);
883 883
 
884 884
 		// get form field details
885
-		$form_field = gravityview_get_field( $form, $field['field'] );
885
+		$form_field = gravityview_get_field($form, $field['field']);
886 886
 
887 887
 		$filter = array(
888 888
 			'key' => $field['field'],
889 889
 			'name' => $name,
890
-			'label' => self::get_field_label( $field, $form_field ),
890
+			'label' => self::get_field_label($field, $form_field),
891 891
 			'input' => $field['input'],
892 892
 			'value' => $value,
893 893
 			'type' => $form_field['type'],
894 894
 		);
895 895
 
896 896
 		// collect choices
897
-		if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) {
897
+		if ('post_category' === $form_field['type'] && !empty($form_field['displayAllCategories']) && empty($form_field['choices'])) {
898 898
 			$filter['choices'] = gravityview_get_terms_choices();
899
-		} elseif ( ! empty( $form_field['choices'] ) ) {
899
+		} elseif (!empty($form_field['choices'])) {
900 900
 			$filter['choices'] = $form_field['choices'];
901 901
 		}
902 902
 
903
-		if ( 'date_range' === $field['input'] && empty( $value ) ) {
904
-			$filter['value'] = array( 'start' => '', 'end' => '' );
903
+		if ('date_range' === $field['input'] && empty($value)) {
904
+			$filter['value'] = array('start' => '', 'end' => '');
905 905
 		}
906 906
 
907 907
 		return $filter;
@@ -921,10 +921,10 @@  discard block
 block discarded – undo
921 921
 		 * filter gravityview/get_users/search_widget
922 922
 		 * @see \GVCommon::get_users
923 923
 		 */
924
-		$users = GVCommon::get_users( 'search_widget', array( 'fields' => array( 'ID', 'display_name' ) ) );
924
+		$users = GVCommon::get_users('search_widget', array('fields' => array('ID', 'display_name')));
925 925
 
926 926
 		$choices = array();
927
-		foreach ( $users as $user ) {
927
+		foreach ($users as $user) {
928 928
 			$choices[] = array(
929 929
 				'value' => $user->ID,
930 930
 				'text' => $user->display_name,
@@ -942,11 +942,11 @@  discard block
 block discarded – undo
942 942
 	public static function the_clear_search_button() {
943 943
 		$gravityview_view = GravityView_View::getInstance();
944 944
 
945
-		if ( $gravityview_view->search_clear ) {
945
+		if ($gravityview_view->search_clear) {
946 946
 
947
-			$url = strtok( add_query_arg( array() ), '?' );
947
+			$url = strtok(add_query_arg(array()), '?');
948 948
 
949
-			echo gravityview_get_link( $url, esc_html__( 'Clear', 'gravityview' ), 'class=button gv-search-clear' );
949
+			echo gravityview_get_link($url, esc_html__('Clear', 'gravityview'), 'class=button gv-search-clear');
950 950
 
951 951
 		}
952 952
 	}
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
 	 * Require the datepicker script for the frontend GV script
958 958
 	 * @param array $js_dependencies Array of existing required scripts for the fe-views.js script
959 959
 	 */
960
-	public function add_datepicker_js_dependency( $js_dependencies ) {
960
+	public function add_datepicker_js_dependency($js_dependencies) {
961 961
 
962 962
 		$js_dependencies[] = 'jquery-ui-datepicker';
963 963
 
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 	 *
973 973
 	 * @return array
974 974
 	 */
975
-	public function add_datepicker_localization( $localizations = array(), $view_data = array() ) {
975
+	public function add_datepicker_localization($localizations = array(), $view_data = array()) {
976 976
 		global $wp_locale;
977 977
 
978 978
 		/**
@@ -982,26 +982,26 @@  discard block
 block discarded – undo
982 982
 		 * @param array $js_localization The data padded to the Javascript file
983 983
 		 * @param array $view_data View data array with View settings
984 984
 		 */
985
-		$datepicker_settings = apply_filters( 'gravityview_datepicker_settings', array(
985
+		$datepicker_settings = apply_filters('gravityview_datepicker_settings', array(
986 986
 			'yearRange' => '-5:+5',
987 987
 			'changeMonth' => true,
988 988
 			'changeYear' => true,
989
-			'closeText' => esc_attr_x( 'Close', 'Close calendar', 'gravityview' ),
990
-			'prevText' => esc_attr_x( 'Prev', 'Previous month in calendar', 'gravityview' ),
991
-			'nextText' => esc_attr_x( 'Next', 'Next month in calendar', 'gravityview' ),
992
-			'currentText' => esc_attr_x( 'Today', 'Today in calendar', 'gravityview' ),
993
-			'weekHeader' => esc_attr_x( 'Week', 'Week in calendar', 'gravityview' ),
994
-			'monthStatus'       => __( 'Show a different month', 'gravityview' ),
995
-			'monthNames'        => array_values( $wp_locale->month ),
996
-			'monthNamesShort'   => array_values( $wp_locale->month_abbrev ),
997
-			'dayNames'          => array_values( $wp_locale->weekday ),
998
-			'dayNamesShort'     => array_values( $wp_locale->weekday_abbrev ),
999
-			'dayNamesMin'       => array_values( $wp_locale->weekday_initial ),
989
+			'closeText' => esc_attr_x('Close', 'Close calendar', 'gravityview'),
990
+			'prevText' => esc_attr_x('Prev', 'Previous month in calendar', 'gravityview'),
991
+			'nextText' => esc_attr_x('Next', 'Next month in calendar', 'gravityview'),
992
+			'currentText' => esc_attr_x('Today', 'Today in calendar', 'gravityview'),
993
+			'weekHeader' => esc_attr_x('Week', 'Week in calendar', 'gravityview'),
994
+			'monthStatus'       => __('Show a different month', 'gravityview'),
995
+			'monthNames'        => array_values($wp_locale->month),
996
+			'monthNamesShort'   => array_values($wp_locale->month_abbrev),
997
+			'dayNames'          => array_values($wp_locale->weekday),
998
+			'dayNamesShort'     => array_values($wp_locale->weekday_abbrev),
999
+			'dayNamesMin'       => array_values($wp_locale->weekday_initial),
1000 1000
 			// get the start of week from WP general setting
1001
-			'firstDay'          => get_option( 'start_of_week' ),
1001
+			'firstDay'          => get_option('start_of_week'),
1002 1002
 			// is Right to left language? default is false
1003 1003
 			'isRTL'             => is_rtl(),
1004
-		), $view_data );
1004
+		), $view_data);
1005 1005
 
1006 1006
 		$localizations['datepicker'] = $datepicker_settings;
1007 1007
 
@@ -1020,13 +1020,13 @@  discard block
 block discarded – undo
1020 1020
 	public function enqueue_datepicker() {
1021 1021
 		$gravityview_view = GravityView_View::getInstance();
1022 1022
 
1023
-		wp_enqueue_script( 'jquery-ui-datepicker' );
1023
+		wp_enqueue_script('jquery-ui-datepicker');
1024 1024
 
1025
-		add_filter( 'gravityview_js_dependencies', array( $this, 'add_datepicker_js_dependency' ) );
1026
-		add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 );
1025
+		add_filter('gravityview_js_dependencies', array($this, 'add_datepicker_js_dependency'));
1026
+		add_filter('gravityview_js_localization', array($this, 'add_datepicker_localization'), 10, 2);
1027 1027
 
1028 1028
 		$scheme = is_ssl() ? 'https://' : 'http://';
1029
-		wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1029
+		wp_enqueue_style('jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css');
1030 1030
 
1031 1031
 		/**
1032 1032
 		 * @filter `gravityview_search_datepicker_class`
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 		 * - `ymd_dash` (yyyy-mm-dd)
1042 1042
 		 * - `ymp_dot` (yyyy.mm.dd)
1043 1043
 		 */
1044
-		$datepicker_class = apply_filters( 'gravityview_search_datepicker_class', 'gv-datepicker datepicker mdy' );
1044
+		$datepicker_class = apply_filters('gravityview_search_datepicker_class', 'gv-datepicker datepicker mdy');
1045 1045
 
1046 1046
 		$gravityview_view->datepicker_class = $datepicker_class;
1047 1047
 
Please login to merge, or discard this patch.
includes/class-common.php 1 patch
Spacing   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 /** If this file is called directly, abort. */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	die;
17 17
 }
18 18
 
@@ -25,18 +25,18 @@  discard block
 block discarded – undo
25 25
 	 * @param mixed $form_id
26 26
 	 * @return mixed False: no form ID specified or Gravity Forms isn't active. Array: Form returned from Gravity Forms
27 27
 	 */
28
-	public static function get_form( $form_id ) {
29
-		if ( empty( $form_id ) ) {
28
+	public static function get_form($form_id) {
29
+		if (empty($form_id)) {
30 30
 			return false;
31 31
 		}
32 32
 
33 33
 		// Only get_form_meta is cached. ::facepalm::
34
-		if ( class_exists( 'RGFormsModel' ) ) {
35
-			return GFFormsModel::get_form_meta( $form_id );
34
+		if (class_exists('RGFormsModel')) {
35
+			return GFFormsModel::get_form_meta($form_id);
36 36
 		}
37 37
 
38
-		if ( class_exists( 'GFAPI' ) ) {
39
-			return GFAPI::get_form( $form_id );
38
+		if (class_exists('GFAPI')) {
39
+			return GFAPI::get_form($form_id);
40 40
 		}
41 41
 
42 42
 		return false;
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities
57 57
 	 */
58
-	public static function has_cap( $caps = '', $object_id = null, $user_id = null ) {
59
-		return GravityView_Roles_Capabilities::has_cap( $caps, $object_id, $user_id );
58
+	public static function has_cap($caps = '', $object_id = null, $user_id = null) {
59
+		return GravityView_Roles_Capabilities::has_cap($caps, $object_id, $user_id);
60 60
 	}
61 61
 
62 62
 	/**
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 	 * @param array|GF_Fields $field Gravity Forms field or array
68 68
 	 * @return array Array version of $field
69 69
 	 */
70
-	public static function get_field_array( $field ) {
70
+	public static function get_field_array($field) {
71 71
 
72
-		if ( class_exists( 'GF_Fields' ) ) {
72
+		if (class_exists('GF_Fields')) {
73 73
 
74
-			$field_object = GF_Fields::create( $field );
74
+			$field_object = GF_Fields::create($field);
75 75
 
76 76
 			// Convert the field object in 1.9 to an array for backward compatibility
77
-			$field_array = get_object_vars( $field_object );
77
+			$field_array = get_object_vars($field_object);
78 78
 
79 79
 		} else {
80 80
 			$field_array = $field;
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 		 * @filter `gravityview/get_all_views/params` Modify the parameters sent to get all views.
102 102
 		 * @param[in,out]  array $params Array of parameters to pass to `get_posts()`
103 103
 		 */
104
-		$views_params = apply_filters( 'gravityview/get_all_views/params', $params );
104
+		$views_params = apply_filters('gravityview/get_all_views/params', $params);
105 105
 
106
-		$views = get_posts( $views_params );
106
+		$views = get_posts($views_params);
107 107
 
108 108
 		return $views;
109 109
 	}
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 	 * @param  int|string $entry_slug Entry slug
115 115
 	 * @return array           Gravity Forms form array
116 116
 	 */
117
-	public static function get_form_from_entry_id( $entry_slug ) {
117
+	public static function get_form_from_entry_id($entry_slug) {
118 118
 
119
-		$entry = self::get_entry( $entry_slug, true );
119
+		$entry = self::get_entry($entry_slug, true);
120 120
 
121
-		$form = self::get_form( $entry['form_id'] );
121
+		$form = self::get_form($entry['form_id']);
122 122
 
123 123
 		return $form;
124 124
 	}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @param  string $slug The entry slug, as returned by GravityView_API::get_entry_slug()
131 131
 	 * @return int|null       The entry ID, if exists; `NULL` if not
132 132
 	 */
133
-	public static function get_entry_id_from_slug( $slug ) {
133
+	public static function get_entry_id_from_slug($slug) {
134 134
 		global $wpdb;
135 135
 
136 136
 		$search_criteria = array(
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
 			'page_size' => 1,
150 150
 		);
151 151
 
152
-		$results = GFAPI::get_entries( 0, $search_criteria, null, $paging );
152
+		$results = GFAPI::get_entries(0, $search_criteria, null, $paging);
153 153
 
154
-		$result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null;
154
+		$result = (!empty($results) && !empty($results[0]['id'])) ? $results[0]['id'] : null;
155 155
 
156 156
 		return $result;
157 157
 	}
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 	 * @return array (id, title)
166 166
 	 */
167 167
 	public static function get_forms() {
168
-		if ( class_exists( 'RGFormsModel' ) ) {
169
-			$gf_forms = RGFormsModel::get_forms( null, 'title' );
168
+		if (class_exists('RGFormsModel')) {
169
+			$gf_forms = RGFormsModel::get_forms(null, 'title');
170 170
 			$forms = array();
171
-			foreach ( $gf_forms as $form ) {
172
-				$forms[] = array( 'id' => $form->id, 'title' => $form->title );
171
+			foreach ($gf_forms as $form) {
172
+				$forms[] = array('id' => $form->id, 'title' => $form->title);
173 173
 			}
174 174
 			return $forms;
175 175
 		}
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
 	 * @param string|array $form_id (default: '') or $form object
184 184
 	 * @return array
185 185
 	 */
186
-	public static function get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) {
186
+	public static function get_form_fields($form = '', $add_default_properties = false, $include_parent_field = true) {
187 187
 
188
-		if ( ! is_array( $form ) ) {
189
-			$form = self::get_form( $form );
188
+		if (!is_array($form)) {
189
+			$form = self::get_form($form);
190 190
 		}
191 191
 
192 192
 		$fields = array();
@@ -196,56 +196,56 @@  discard block
 block discarded – undo
196 196
 		$has_poll_fields = false;
197 197
 
198 198
 		// If GF_Field exists, we're using GF 1.9+, where add_default_properties has been deprecated.
199
-		if ( false === class_exists( 'GF_Field' ) && $add_default_properties ) {
200
-			$form = RGFormsModel::add_default_properties( $form );
199
+		if (false === class_exists('GF_Field') && $add_default_properties) {
200
+			$form = RGFormsModel::add_default_properties($form);
201 201
 		}
202 202
 
203
-		if ( $form ) {
204
-			foreach ( $form['fields'] as $field ) {
205
-				if ( $include_parent_field || empty( $field['inputs'] ) ) {
206
-					$fields[ $field['id'] ] = array(
207
-						'label' => rgar( $field, 'label' ),
203
+		if ($form) {
204
+			foreach ($form['fields'] as $field) {
205
+				if ($include_parent_field || empty($field['inputs'])) {
206
+					$fields[$field['id']] = array(
207
+						'label' => rgar($field, 'label'),
208 208
 						'parent' => null,
209
-						'type' => rgar( $field, 'type' ),
210
-						'adminLabel' => rgar( $field, 'adminLabel' ),
211
-						'adminOnly' => rgar( $field, 'adminOnly' ),
209
+						'type' => rgar($field, 'type'),
210
+						'adminLabel' => rgar($field, 'adminLabel'),
211
+						'adminOnly' => rgar($field, 'adminOnly'),
212 212
 					);
213 213
 				}
214 214
 
215
-				if ( $add_default_properties && ! empty( $field['inputs'] ) ) {
216
-					foreach ( $field['inputs'] as $input ) {
215
+				if ($add_default_properties && !empty($field['inputs'])) {
216
+					foreach ($field['inputs'] as $input) {
217 217
                         /**
218 218
                          * @hack
219 219
                          * In case of email/email confirmation, the input for email has the same id as the parent field
220 220
                          */
221
-                        if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) {
221
+                        if ('email' == rgar($field, 'type') && false === strpos($input['id'], '.')) {
222 222
                             continue;
223 223
                         }
224
-						$fields[ (string)$input['id'] ] = array(
225
-							'label' => rgar( $input, 'label' ),
226
-							'customLabel' => rgar( $input, 'customLabel' ),
224
+						$fields[(string)$input['id']] = array(
225
+							'label' => rgar($input, 'label'),
226
+							'customLabel' => rgar($input, 'customLabel'),
227 227
 							'parent' => $field,
228
-							'type' => rgar( $field, 'type' ),
229
-							'adminLabel' => rgar( $field, 'adminLabel' ),
230
-							'adminOnly' => rgar( $field, 'adminOnly' ),
228
+							'type' => rgar($field, 'type'),
229
+							'adminLabel' => rgar($field, 'adminLabel'),
230
+							'adminOnly' => rgar($field, 'adminOnly'),
231 231
 						);
232 232
 					}
233 233
 				}
234 234
 
235 235
 				/** @since 1.14 */
236
-				if( 'list' === $field['type'] && !empty( $field['enableColumns'] ) ) {
236
+				if ('list' === $field['type'] && !empty($field['enableColumns'])) {
237 237
 
238
-					foreach ( (array)$field['choices'] as $key => $input ) {
238
+					foreach ((array)$field['choices'] as $key => $input) {
239 239
 
240
-						$input_id = sprintf( '%d.%d', $field['id'], $key ); // {field_id}.{column_key}
240
+						$input_id = sprintf('%d.%d', $field['id'], $key); // {field_id}.{column_key}
241 241
 
242
-						$fields[ $input_id ] = array(
243
-							'label'       => rgar( $input, 'text' ),
242
+						$fields[$input_id] = array(
243
+							'label'       => rgar($input, 'text'),
244 244
 							'customLabel' => '',
245 245
 							'parent'      => $field,
246
-							'type'        => rgar( $field, 'type' ),
247
-							'adminLabel'  => rgar( $field, 'adminLabel' ),
248
-							'adminOnly'   => rgar( $field, 'adminOnly' ),
246
+							'type'        => rgar($field, 'type'),
247
+							'adminLabel'  => rgar($field, 'adminLabel'),
248
+							'adminOnly'   => rgar($field, 'adminOnly'),
249 249
 						);
250 250
 					}
251 251
 				}
@@ -253,27 +253,27 @@  discard block
 block discarded – undo
253 253
 				/**
254 254
 				 * @since 1.8
255 255
 				 */
256
-				if( 'quiz' === $field['type'] ) {
256
+				if ('quiz' === $field['type']) {
257 257
 					$has_quiz_fields = true;
258 258
 				}
259 259
 
260 260
 				/**
261 261
 				 * @since 1.8
262 262
 				 */
263
-				if( 'poll' === $field['type'] ) {
263
+				if ('poll' === $field['type']) {
264 264
 					$has_poll_fields = true;
265 265
 				}
266 266
 
267
-				if( GFCommon::is_product_field( $field['type'] ) ){
267
+				if (GFCommon::is_product_field($field['type'])) {
268 268
 					$has_product_fields = true;
269 269
 				}
270 270
 
271 271
 				/**
272 272
 				 * @hack Version 1.9
273 273
 				 */
274
-				$field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object) $field : (array) $field;
274
+				$field_for_is_post_field = class_exists('GF_Fields') ? (object)$field : (array)$field;
275 275
 
276
-				if ( GFCommon::is_post_field( $field_for_is_post_field ) ) {
276
+				if (GFCommon::is_post_field($field_for_is_post_field)) {
277 277
 					$has_post_fields = true;
278 278
 				}
279 279
 			}
@@ -282,47 +282,47 @@  discard block
 block discarded – undo
282 282
 		/**
283 283
 		 * @since 1.7
284 284
 		 */
285
-		if ( $has_post_fields ) {
285
+		if ($has_post_fields) {
286 286
 			$fields['post_id'] = array(
287
-				'label' => __( 'Post ID', 'gravityview' ),
287
+				'label' => __('Post ID', 'gravityview'),
288 288
 				'type' => 'post_id',
289 289
 			);
290 290
 		}
291 291
 
292
-		if ( $has_product_fields ) {
292
+		if ($has_product_fields) {
293 293
 
294 294
 			$fields['payment_status'] = array(
295
-				'label' => __( 'Payment Status', 'gravityview' ),
295
+				'label' => __('Payment Status', 'gravityview'),
296 296
 				'type' => 'payment_status',
297 297
 			);
298 298
 
299 299
 			$fields['payment_date'] = array(
300
-				'label' => __( 'Payment Date', 'gravityview' ),
300
+				'label' => __('Payment Date', 'gravityview'),
301 301
 				'type' => 'payment_date',
302 302
 			);
303 303
 
304 304
 			$fields['payment_amount'] = array(
305
-				'label' => __( 'Payment Amount', 'gravityview' ),
305
+				'label' => __('Payment Amount', 'gravityview'),
306 306
 				'type' => 'payment_amount',
307 307
 			);
308 308
 
309 309
 			$fields['payment_method'] = array(
310
-				'label' => __( 'Payment Method', 'gravityview' ),
310
+				'label' => __('Payment Method', 'gravityview'),
311 311
 				'type' => 'payment_method',
312 312
 			);
313 313
 
314 314
 			$fields['is_fulfilled'] = array(
315
-				'label' => __( 'Is Fulfilled', 'gravityview' ),
315
+				'label' => __('Is Fulfilled', 'gravityview'),
316 316
 				'type' => 'is_fulfilled',
317 317
 			);
318 318
 
319 319
 			$fields['transaction_id'] = array(
320
-				'label' => __( 'Transaction ID', 'gravityview' ),
320
+				'label' => __('Transaction ID', 'gravityview'),
321 321
 				'type' => 'transaction_id',
322 322
 			);
323 323
 
324 324
 			$fields['transaction_type'] = array(
325
-				'label' => __( 'Transaction Type', 'gravityview' ),
325
+				'label' => __('Transaction Type', 'gravityview'),
326 326
 				'type' => 'transaction_type',
327 327
 			);
328 328
 
@@ -331,27 +331,27 @@  discard block
 block discarded – undo
331 331
 		/**
332 332
 		 * @since 1.8
333 333
 		 */
334
-		if( $has_quiz_fields ) {
334
+		if ($has_quiz_fields) {
335 335
 
336
-			$fields['gquiz_score']   = array(
337
-				'label' => __( 'Quiz Score Total', 'gravityview' ),
336
+			$fields['gquiz_score'] = array(
337
+				'label' => __('Quiz Score Total', 'gravityview'),
338 338
 				'type'  => 'quiz_score',
339
-				'desc'  => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ),
339
+				'desc'  => __('Displays the number of correct Quiz answers the user submitted.', 'gravityview'),
340 340
 			);
341 341
 			$fields['gquiz_percent'] = array(
342
-				'label' => __( 'Quiz Percentage Grade', 'gravityview' ),
342
+				'label' => __('Quiz Percentage Grade', 'gravityview'),
343 343
 				'type'  => 'quiz_percent',
344
-				'desc'  => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ),
344
+				'desc'  => __('Displays the percentage of correct Quiz answers the user submitted.', 'gravityview'),
345 345
 			);
346
-			$fields['gquiz_grade']   = array(
347
-				'label' => __( 'Quiz Letter Grade', 'gravityview' ),
346
+			$fields['gquiz_grade'] = array(
347
+				'label' => __('Quiz Letter Grade', 'gravityview'),
348 348
 				'type'  => 'quiz_grade',
349
-				'desc'  => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ),
349
+				'desc'  => __('Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview'),
350 350
 			);
351 351
 			$fields['gquiz_is_pass'] = array(
352
-				'label' => __( 'Quiz Pass/Fail', 'gravityview' ),
352
+				'label' => __('Quiz Pass/Fail', 'gravityview'),
353 353
 				'type'  => 'quiz_is_pass',
354
-				'desc'  => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ),
354
+				'desc'  => __('Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview'),
355 355
 			);
356 356
 		}
357 357
 
@@ -365,15 +365,15 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $form_id (default: '')
366 366
 	 * @return array
367 367
 	 */
368
-	public static function get_entry_meta( $form_id, $only_default_column = true ) {
368
+	public static function get_entry_meta($form_id, $only_default_column = true) {
369 369
 
370
-		$extra_fields = GFFormsModel::get_entry_meta( $form_id );
370
+		$extra_fields = GFFormsModel::get_entry_meta($form_id);
371 371
 
372 372
 		$fields = array();
373 373
 
374
-		foreach ( $extra_fields as $key => $field ){
375
-			if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) {
376
-				$fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' );
374
+		foreach ($extra_fields as $key => $field) {
375
+			if (!empty($only_default_column) && !empty($field['is_default_column'])) {
376
+				$fields[$key] = array('label' => $field['label'], 'type' => 'entry_meta');
377 377
 			}
378 378
 		}
379 379
 
@@ -389,13 +389,13 @@  discard block
 block discarded – undo
389 389
 	 * @since  1.1.6
390 390
 	 * @return array          Array of entry IDs
391 391
 	 */
392
-	public static function get_entry_ids( $form_id, $search_criteria = array() ) {
392
+	public static function get_entry_ids($form_id, $search_criteria = array()) {
393 393
 
394
-		if ( ! class_exists( 'GFFormsModel' ) ) {
394
+		if (!class_exists('GFFormsModel')) {
395 395
 			return;
396 396
 		}
397 397
 
398
-		return GFFormsModel::search_lead_ids( $form_id, $search_criteria );
398
+		return GFFormsModel::search_lead_ids($form_id, $search_criteria);
399 399
 	}
400 400
 
401 401
 	/**
@@ -407,33 +407,33 @@  discard block
 block discarded – undo
407 407
 	 * @param null $form_ids array Gravity Forms form IDs
408 408
 	 * @return array|mixed|void
409 409
 	 */
410
-	public static function calculate_get_entries_criteria( $passed_criteria = null, $form_ids = null ) {
410
+	public static function calculate_get_entries_criteria($passed_criteria = null, $form_ids = null) {
411 411
 
412 412
 		$search_criteria_defaults = array(
413 413
 			'search_criteria' => null,
414 414
 			'sorting' => null,
415 415
 			'paging' => null,
416
-			'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true),
416
+			'cache' => (isset($passed_criteria['cache']) ? $passed_criteria['cache'] : true),
417 417
 		);
418 418
 
419
-		$criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults );
419
+		$criteria = wp_parse_args($passed_criteria, $search_criteria_defaults);
420 420
 
421
-		if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) {
422
-			foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) {
421
+		if (!empty($criteria['search_criteria']['field_filters'])) {
422
+			foreach ($criteria['search_criteria']['field_filters'] as &$filter) {
423 423
 
424
-				if ( ! is_array( $filter ) ) {
424
+				if (!is_array($filter)) {
425 425
 					continue;
426 426
 				}
427 427
 
428 428
 				// By default, we want searches to be wildcard for each field.
429
-				$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
429
+				$filter['operator'] = empty($filter['operator']) ? 'contains' : $filter['operator'];
430 430
 
431 431
 				/**
432 432
 				 * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc)
433 433
 				 * @param string $operator Existing search operator
434 434
 				 * @param array $filter array with `key`, `value`, `operator`, `type` keys
435 435
 				 */
436
-				$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );
436
+				$filter['operator'] = apply_filters('gravityview_search_operator', $filter['operator'], $filter);
437 437
 			}
438 438
 		}
439 439
 
@@ -441,32 +441,32 @@  discard block
 block discarded – undo
441 441
 		 * Prepare date formats to be in Gravity Forms DB format;
442 442
 		 * $passed_criteria may include date formats incompatible with Gravity Forms.
443 443
 		 */
444
-		foreach ( array('start_date', 'end_date' ) as $key ) {
444
+		foreach (array('start_date', 'end_date') as $key) {
445 445
 
446
-			if ( ! empty( $criteria['search_criteria'][ $key ] ) ) {
446
+			if (!empty($criteria['search_criteria'][$key])) {
447 447
 
448 448
 				// Use date_create instead of new DateTime so it returns false if invalid date format.
449
-				$date = date_create( $criteria['search_criteria'][ $key ] );
449
+				$date = date_create($criteria['search_criteria'][$key]);
450 450
 
451
-				if ( $date ) {
451
+				if ($date) {
452 452
 					// Gravity Forms wants dates in the `Y-m-d H:i:s` format.
453
-					$criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' );
453
+					$criteria['search_criteria'][$key] = $date->format('Y-m-d H:i:s');
454 454
 				} else {
455 455
 					// If it's an invalid date, unset it. Gravity Forms freaks out otherwise.
456
-					unset( $criteria['search_criteria'][ $key ] );
456
+					unset($criteria['search_criteria'][$key]);
457 457
 
458
-					do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] );
458
+					do_action('gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][$key]);
459 459
 				}
460 460
 			}
461 461
 		}
462 462
 
463 463
 
464 464
 		// When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter
465
-		if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) {
465
+		if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry()) {
466 466
 			$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();
467
-		} elseif ( 'delete' === RGForms::get( 'action' ) ) {
468
-			$criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null;
469
-		} elseif( !isset( $criteria['context_view_id'] ) ) {
467
+		} elseif ('delete' === RGForms::get('action')) {
468
+			$criteria['context_view_id'] = isset($_GET['view_id']) ? $_GET['view_id'] : null;
469
+		} elseif (!isset($criteria['context_view_id'])) {
470 470
             // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget)
471 471
 			$criteria['context_view_id'] = null;
472 472
 		}
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 		 * @param array $form_ids Forms to search
478 478
 		 * @param int $view_id ID of the view being used to search
479 479
 		 */
480
-		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] );
480
+		$criteria = apply_filters('gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id']);
481 481
 
482 482
 		return $criteria;
483 483
 
@@ -495,32 +495,32 @@  discard block
 block discarded – undo
495 495
 	 * @param mixed &$total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate the total count. (default: null)
496 496
 	 * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays
497 497
 	 */
498
-	public static function get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) {
498
+	public static function get_entries($form_ids = null, $passed_criteria = null, &$total = null) {
499 499
 
500 500
 		// Filter the criteria before query (includes Adv Filter)
501
-		$criteria = self::calculate_get_entries_criteria( $passed_criteria, $form_ids );
501
+		$criteria = self::calculate_get_entries_criteria($passed_criteria, $form_ids);
502 502
 
503
-		do_action( 'gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria );
503
+		do_action('gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria);
504 504
 
505 505
 		// Return value
506 506
 		$return = null;
507 507
 
508
-		if ( ! empty( $criteria['cache'] ) ) {
508
+		if (!empty($criteria['cache'])) {
509 509
 
510
-			$Cache = new GravityView_Cache( $form_ids, $criteria );
510
+			$Cache = new GravityView_Cache($form_ids, $criteria);
511 511
 
512
-			if ( $entries = $Cache->get() ) {
512
+			if ($entries = $Cache->get()) {
513 513
 
514 514
 				// Still update the total count when using cached results
515
-				if ( ! is_null( $total ) ) {
516
-					$total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] );
515
+				if (!is_null($total)) {
516
+					$total = GFAPI::count_entries($form_ids, $criteria['search_criteria']);
517 517
 				}
518 518
 
519 519
 				$return = $entries;
520 520
 			}
521 521
 		}
522 522
 
523
-		if ( is_null( $return ) && class_exists( 'GFAPI' ) && ( is_numeric( $form_ids ) || is_array( $form_ids ) ) ) {
523
+		if (is_null($return) && class_exists('GFAPI') && (is_numeric($form_ids) || is_array($form_ids))) {
524 524
 
525 525
 			/**
526 526
 			 * @filter `gravityview_pre_get_entries` Define entries to be used before GFAPI::get_entries() is called
@@ -530,24 +530,24 @@  discard block
 block discarded – undo
530 530
 			 * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()`
531 531
 			 * @param  int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate
532 532
 			 */
533
-			$entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total );
533
+			$entries = apply_filters('gravityview_before_get_entries', null, $criteria, $passed_criteria, $total);
534 534
 
535 535
 			// No entries returned from gravityview_before_get_entries
536
-			if( is_null( $entries ) ) {
536
+			if (is_null($entries)) {
537 537
 
538
-				$entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total );
538
+				$entries = GFAPI::get_entries($form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total);
539 539
 
540
-				if ( is_wp_error( $entries ) ) {
541
-					do_action( 'gravityview_log_error', $entries->get_error_message(), $entries );
540
+				if (is_wp_error($entries)) {
541
+					do_action('gravityview_log_error', $entries->get_error_message(), $entries);
542 542
 
543 543
 					return false;
544 544
 				}
545 545
 			}
546 546
 
547
-			if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) {
547
+			if (!empty($criteria['cache']) && isset($Cache)) {
548 548
 
549 549
 				// Cache results
550
-				$Cache->set( $entries, 'entries' );
550
+				$Cache->set($entries, 'entries');
551 551
 
552 552
 			}
553 553
 
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 		 * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()`
562 562
 		 * @param  int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate
563 563
 		 */
564
-		$return = apply_filters( 'gravityview_entries', $return, $criteria, $passed_criteria, $total );
564
+		$return = apply_filters('gravityview_entries', $return, $criteria, $passed_criteria, $total);
565 565
 
566 566
 		return $return;
567 567
 	}
@@ -578,15 +578,15 @@  discard block
 block discarded – undo
578 578
 	 * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true. {@since 1.14}
579 579
 	 * @return array|boolean
580 580
 	 */
581
-	public static function get_entry( $entry_slug, $force_allow_ids = false, $check_entry_display = true ) {
581
+	public static function get_entry($entry_slug, $force_allow_ids = false, $check_entry_display = true) {
582 582
 
583
-		if ( class_exists( 'GFAPI' ) && ! empty( $entry_slug ) ) {
583
+		if (class_exists('GFAPI') && !empty($entry_slug)) {
584 584
 
585 585
 			/**
586 586
 			 * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs.
587 587
 			 * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default)
588 588
 			 */
589
-			$custom_slug = apply_filters( 'gravityview_custom_entry_slug', false );
589
+			$custom_slug = apply_filters('gravityview_custom_entry_slug', false);
590 590
 
591 591
 			/**
592 592
 			 * @filter `gravityview_custom_entry_slug_allow_id` When using a custom slug, allow access to the entry using the original slug (the Entry ID).
@@ -594,38 +594,38 @@  discard block
 block discarded – undo
594 594
 			 * - If enabled, you could access using the custom slug OR the entry id (example: `/entry/custom-slug/` OR `/entry/123/`)
595 595
 			 * @param boolean $custom_slug_id_access True: allow accessing the slug by ID; False: only use the slug passed to the method.
596 596
 			 */
597
-			$custom_slug_id_access = $force_allow_ids || apply_filters( 'gravityview_custom_entry_slug_allow_id', false );
597
+			$custom_slug_id_access = $force_allow_ids || apply_filters('gravityview_custom_entry_slug_allow_id', false);
598 598
 
599 599
 			/**
600 600
 			 * If we're using custom entry slugs, we do a meta value search
601 601
 			 * instead of doing a straightup ID search.
602 602
 			 */
603
-			if ( $custom_slug ) {
603
+			if ($custom_slug) {
604 604
 
605
-				$entry_id = self::get_entry_id_from_slug( $entry_slug );
605
+				$entry_id = self::get_entry_id_from_slug($entry_slug);
606 606
 
607 607
 			}
608 608
 
609 609
 			// If custom slug is off, search using the entry ID
610 610
 			// ID allow ID access is on, also use entry ID as a backup
611
-			if ( empty( $custom_slug ) || ! empty( $custom_slug_id_access ) ) {
611
+			if (empty($custom_slug) || !empty($custom_slug_id_access)) {
612 612
 				// Search for IDs matching $entry_slug
613 613
 				$entry_id = $entry_slug;
614 614
 			}
615 615
 
616
-			if ( empty( $entry_id ) ) {
616
+			if (empty($entry_id)) {
617 617
 				return false;
618 618
 			}
619 619
 
620 620
 			// fetch the entry
621
-			$entry = GFAPI::get_entry( $entry_id );
621
+			$entry = GFAPI::get_entry($entry_id);
622 622
 
623
-			if( $check_entry_display ) {
623
+			if ($check_entry_display) {
624 624
 				// Is the entry allowed
625
-				$entry = self::check_entry_display( $entry );
625
+				$entry = self::check_entry_display($entry);
626 626
 			}
627 627
 
628
-			return is_wp_error( $entry ) ? false : $entry;
628
+			return is_wp_error($entry) ? false : $entry;
629 629
 
630 630
 		}
631 631
 
@@ -649,51 +649,51 @@  discard block
 block discarded – undo
649 649
 	 *
650 650
 	 * @return bool True: matches, false: not matches
651 651
 	 */
652
-	public static function matches_operation( $val1, $val2, $operation ) {
652
+	public static function matches_operation($val1, $val2, $operation) {
653 653
 
654 654
 		$value = false;
655 655
 
656
-		if( 'context' === $val1 ) {
656
+		if ('context' === $val1) {
657 657
 
658
-			$matching_contexts = array( $val2 );
658
+			$matching_contexts = array($val2);
659 659
 
660 660
 			// We allow for non-standard contexts.
661
-			switch( $val2 ) {
661
+			switch ($val2) {
662 662
 				// Check for either single or edit
663 663
 				case 'singular':
664
-					$matching_contexts = array( 'single', 'edit' );
664
+					$matching_contexts = array('single', 'edit');
665 665
 					break;
666 666
 				// Use multiple as alias for directory for consistency
667 667
 				case 'multiple':
668
-					$matching_contexts = array( 'directory' );
668
+					$matching_contexts = array('directory');
669 669
 					break;
670 670
 			}
671 671
 
672
-			$val1 = in_array( gravityview_get_context(), $matching_contexts ) ? $val2 : false;
672
+			$val1 = in_array(gravityview_get_context(), $matching_contexts) ? $val2 : false;
673 673
 		}
674 674
 
675
-		switch ( $operation ) {
675
+		switch ($operation) {
676 676
 			case 'equals':
677
-				$value = GFFormsModel::matches_operation( $val1, $val2, 'is' );
677
+				$value = GFFormsModel::matches_operation($val1, $val2, 'is');
678 678
 				break;
679 679
 			case 'greater_than_or_is':
680 680
 			case 'greater_than_or_equals':
681
-				$is    = GFFormsModel::matches_operation( $val1, $val2, 'is' );
682
-				$gt    = GFFormsModel::matches_operation( $val1, $val2, 'greater_than' );
683
-				$value = ( $is || $gt );
681
+				$is    = GFFormsModel::matches_operation($val1, $val2, 'is');
682
+				$gt    = GFFormsModel::matches_operation($val1, $val2, 'greater_than');
683
+				$value = ($is || $gt);
684 684
 				break;
685 685
 			case 'less_than_or_is':
686 686
 			case 'less_than_or_equals':
687
-				$is    = GFFormsModel::matches_operation( $val1, $val2, 'is' );
688
-				$gt    = GFFormsModel::matches_operation( $val1, $val2, 'less_than' );
689
-				$value = ( $is || $gt );
687
+				$is    = GFFormsModel::matches_operation($val1, $val2, 'is');
688
+				$gt    = GFFormsModel::matches_operation($val1, $val2, 'less_than');
689
+				$value = ($is || $gt);
690 690
 				break;
691 691
 			case 'not_contains':
692
-				$contains = GFFormsModel::matches_operation( $val1, $val2, 'contains' );
693
-				$value    = ! $contains;
692
+				$contains = GFFormsModel::matches_operation($val1, $val2, 'contains');
693
+				$value    = !$contains;
694 694
 				break;
695 695
 			default:
696
-				$value = GFFormsModel::matches_operation( $val1, $val2, $operation );
696
+				$value = GFFormsModel::matches_operation($val1, $val2, $operation);
697 697
 		}
698 698
 
699 699
 		return $value;
@@ -710,31 +710,31 @@  discard block
 block discarded – undo
710 710
 	 * @param array $entry Gravity Forms Entry object
711 711
 	 * @return bool|array Returns 'false' if entry is not valid according to the view search filters (Adv Filter)
712 712
 	 */
713
-	public static function check_entry_display( $entry ) {
713
+	public static function check_entry_display($entry) {
714 714
 
715
-		if ( ! $entry || is_wp_error( $entry ) ) {
716
-			do_action( 'gravityview_log_debug', __METHOD__ . ' Entry was not found.', $entry );
715
+		if (!$entry || is_wp_error($entry)) {
716
+			do_action('gravityview_log_debug', __METHOD__.' Entry was not found.', $entry);
717 717
 			return false;
718 718
 		}
719 719
 
720
-		if ( empty( $entry['form_id'] ) ) {
721
-			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry );
720
+		if (empty($entry['form_id'])) {
721
+			do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry);
722 722
 			return false;
723 723
 		}
724 724
 
725 725
 		$criteria = self::calculate_get_entries_criteria();
726 726
 
727
-		if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) {
728
-			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria );
727
+		if (empty($criteria['search_criteria']) || !is_array($criteria['search_criteria'])) {
728
+			do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria);
729 729
 			return $entry;
730 730
 		}
731 731
 
732 732
 		$search_criteria = $criteria['search_criteria'];
733
-		unset( $criteria );
733
+		unset($criteria);
734 734
 
735 735
 		// check entry status
736
-		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) {
737
-			do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria );
736
+		if (array_key_exists('status', $search_criteria) && $search_criteria['status'] != $entry['status']) {
737
+			do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status']), $search_criteria);
738 738
 			return false;
739 739
 		}
740 740
 
@@ -742,53 +742,53 @@  discard block
 block discarded – undo
742 742
 		// @todo: Does it make sense to apply the Date create filters to the single entry?
743 743
 
744 744
 		// field_filters
745
-		if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) {
746
-			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria );
745
+		if (empty($search_criteria['field_filters']) || !is_array($search_criteria['field_filters'])) {
746
+			do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria);
747 747
 			return $entry;
748 748
 		}
749 749
 
750 750
 		$filters = $search_criteria['field_filters'];
751
-		unset( $search_criteria );
751
+		unset($search_criteria);
752 752
 
753
-		$mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all';
754
-		unset( $filters['mode'] );
753
+		$mode = array_key_exists('mode', $filters) ? strtolower($filters['mode']) : 'all';
754
+		unset($filters['mode']);
755 755
 
756
-		$form = self::get_form( $entry['form_id'] );
756
+		$form = self::get_form($entry['form_id']);
757 757
 
758
-		foreach ( $filters as $filter ) {
758
+		foreach ($filters as $filter) {
759 759
 
760
-			if ( ! isset( $filter['key'] ) ) {
760
+			if (!isset($filter['key'])) {
761 761
 				continue;
762 762
 			}
763 763
 
764 764
 			$k = $filter['key'];
765 765
 
766
-			if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) {
767
-				$field_value = $entry[ $k ];
766
+			if (in_array($k, array('created_by', 'payment_status'))) {
767
+				$field_value = $entry[$k];
768 768
 				$field = null;
769 769
 			} else {
770
-				$field = self::get_field( $form, $k );
771
-				$field_value  = GFFormsModel::get_lead_field_value( $entry, $field );
770
+				$field = self::get_field($form, $k);
771
+				$field_value = GFFormsModel::get_lead_field_value($entry, $field);
772 772
 			}
773 773
 
774
-			$operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is';
775
-			$is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field );
774
+			$operator = isset($filter['operator']) ? strtolower($filter['operator']) : 'is';
775
+			$is_value_match = GFFormsModel::is_value_match($field_value, $filter['value'], $operator, $field);
776 776
 
777 777
 			// verify if we are already free to go!
778
-			if ( ! $is_value_match && 'all' === $mode ) {
779
-				do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter );
778
+			if (!$is_value_match && 'all' === $mode) {
779
+				do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter);
780 780
 				return false;
781
-			} elseif ( $is_value_match && 'any' === $mode ) {
781
+			} elseif ($is_value_match && 'any' === $mode) {
782 782
 				return $entry;
783 783
 			}
784 784
 		}
785 785
 
786 786
 		// at this point, if in ALL mode, then entry is approved - all conditions were met.
787 787
 		// Or, for ANY mode, means none of the conditions were satisfied, so entry is not approved
788
-		if ( 'all' === $mode ) {
788
+		if ('all' === $mode) {
789 789
 			return $entry;
790 790
 		} else {
791
-			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters );
791
+			do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters);
792 792
 			return false;
793 793
 		}
794 794
 
@@ -803,14 +803,14 @@  discard block
 block discarded – undo
803 803
 	 * @param string $field_id
804 804
 	 * @return string
805 805
 	 */
806
-	public static function get_field_label( $form = array(), $field_id = '' ) {
806
+	public static function get_field_label($form = array(), $field_id = '') {
807 807
 
808
-		if ( empty( $form ) || empty( $field_id ) ) {
808
+		if (empty($form) || empty($field_id)) {
809 809
 			return '';
810 810
 		}
811 811
 
812
-		$field = self::get_field( $form, $field_id );
813
-		return isset( $field['label'] ) ?  $field['label'] : '';
812
+		$field = self::get_field($form, $field_id);
813
+		return isset($field['label']) ? $field['label'] : '';
814 814
 
815 815
 	}
816 816
 
@@ -827,9 +827,9 @@  discard block
 block discarded – undo
827 827
 	 * @param string|int $field_id
828 828
 	 * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist
829 829
 	 */
830
-	public static function get_field( $form, $field_id ) {
831
-		if ( class_exists( 'GFFormsModel' ) ){
832
-			return GFFormsModel::get_field( $form, $field_id );
830
+	public static function get_field($form, $field_id) {
831
+		if (class_exists('GFFormsModel')) {
832
+			return GFFormsModel::get_field($form, $field_id);
833 833
 		} else {
834 834
 			return null;
835 835
 		}
@@ -845,16 +845,16 @@  discard block
 block discarded – undo
845 845
 	 * @param  WP_Post      $post WordPress post object
846 846
 	 * @return boolean           True: yep, GravityView; No: not!
847 847
 	 */
848
-	public static function has_gravityview_shortcode( $post = null ) {
849
-		if ( ! is_a( $post, 'WP_Post' ) ) {
848
+	public static function has_gravityview_shortcode($post = null) {
849
+		if (!is_a($post, 'WP_Post')) {
850 850
 			return false;
851 851
 		}
852 852
 
853
-		if ( 'gravityview' === get_post_type( $post ) ) {
853
+		if ('gravityview' === get_post_type($post)) {
854 854
 			return true;
855 855
 		}
856 856
 
857
-		return self::has_shortcode_r( $post->post_content, 'gravityview' ) ? true : false;
857
+		return self::has_shortcode_r($post->post_content, 'gravityview') ? true : false;
858 858
 
859 859
 	}
860 860
 
@@ -865,27 +865,27 @@  discard block
 block discarded – undo
865 865
 	 * @param string $content Content to check whether there's a shortcode
866 866
 	 * @param string $tag Current shortcode tag
867 867
 	 */
868
-	public static function has_shortcode_r( $content, $tag = 'gravityview' ) {
869
-		if ( false === strpos( $content, '[' ) ) {
868
+	public static function has_shortcode_r($content, $tag = 'gravityview') {
869
+		if (false === strpos($content, '[')) {
870 870
 			return false;
871 871
 		}
872 872
 
873
-		if ( shortcode_exists( $tag ) ) {
873
+		if (shortcode_exists($tag)) {
874 874
 
875 875
 			$shortcodes = array();
876 876
 
877
-			preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
878
-			if ( empty( $matches ) ){
877
+			preg_match_all('/'.get_shortcode_regex().'/s', $content, $matches, PREG_SET_ORDER);
878
+			if (empty($matches)) {
879 879
 				return false;
880 880
 			}
881 881
 
882
-			foreach ( $matches as $shortcode ) {
883
-				if ( $tag === $shortcode[2] ) {
882
+			foreach ($matches as $shortcode) {
883
+				if ($tag === $shortcode[2]) {
884 884
 
885 885
 					// Changed this to $shortcode instead of true so we get the parsed atts.
886 886
 					$shortcodes[] = $shortcode;
887 887
 
888
-				} else if ( isset( $shortcode[5] ) && $result = self::has_shortcode_r( $shortcode[5], $tag ) ) {
888
+				} else if (isset($shortcode[5]) && $result = self::has_shortcode_r($shortcode[5], $tag)) {
889 889
 					$shortcodes = $result;
890 890
 				}
891 891
 			}
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 	 *
910 910
 	 * @return array          Array with view details, as returned by get_posts()
911 911
 	 */
912
-	public static function get_connected_views( $form_id, $args = array() ) {
912
+	public static function get_connected_views($form_id, $args = array()) {
913 913
 
914 914
 		$defaults = array(
915 915
 			'post_type' => 'gravityview',
@@ -918,9 +918,9 @@  discard block
 block discarded – undo
918 918
 			'meta_value' => (int)$form_id,
919 919
 		);
920 920
 
921
-		$args = wp_parse_args( $args, $defaults );
921
+		$args = wp_parse_args($args, $defaults);
922 922
 
923
-		$views = get_posts( $args );
923
+		$views = get_posts($args);
924 924
 
925 925
 		return $views;
926 926
 	}
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
 	 *
933 933
 	 * @return string ID of the connected Form, if exists. Empty string if not.
934 934
 	 */
935
-	public static function get_meta_form_id( $view_id ) {
936
-		return get_post_meta( $view_id, '_gravityview_form_id', true );
935
+	public static function get_meta_form_id($view_id) {
936
+		return get_post_meta($view_id, '_gravityview_form_id', true);
937 937
 	}
938 938
 
939 939
 	/**
@@ -945,8 +945,8 @@  discard block
 block discarded – undo
945 945
 	 *
946 946
 	 * @return string GravityView_Template::template_id value. Empty string if not.
947 947
 	 */
948
-	public static function get_meta_template_id( $view_id ) {
949
-		return get_post_meta( $view_id, '_gravityview_directory_template', true );
948
+	public static function get_meta_template_id($view_id) {
949
+		return get_post_meta($view_id, '_gravityview_directory_template', true);
950 950
 	}
951 951
 
952 952
 
@@ -957,15 +957,15 @@  discard block
 block discarded – undo
957 957
 	 * @param  int $post_id View ID
958 958
 	 * @return array          Associative array of settings with plugin defaults used if not set by the View
959 959
 	 */
960
-	public static function get_template_settings( $post_id ) {
960
+	public static function get_template_settings($post_id) {
961 961
 
962
-		$settings = get_post_meta( $post_id, '_gravityview_template_settings', true );
962
+		$settings = get_post_meta($post_id, '_gravityview_template_settings', true);
963 963
 
964
-		if ( class_exists( 'GravityView_View_Data' ) ) {
964
+		if (class_exists('GravityView_View_Data')) {
965 965
 
966 966
 			$defaults = GravityView_View_Data::get_default_args();
967 967
 
968
-			return wp_parse_args( (array)$settings, $defaults );
968
+			return wp_parse_args((array)$settings, $defaults);
969 969
 
970 970
 		}
971 971
 
@@ -982,12 +982,12 @@  discard block
 block discarded – undo
982 982
 	 * @param  string $key     Key for the setting
983 983
 	 * @return mixed|null          Setting value, or NULL if not set.
984 984
 	 */
985
-	public static function get_template_setting( $post_id, $key ) {
985
+	public static function get_template_setting($post_id, $key) {
986 986
 
987
-		$settings = self::get_template_settings( $post_id );
987
+		$settings = self::get_template_settings($post_id);
988 988
 
989
-		if ( isset( $settings[ $key ] ) ) {
990
-			return $settings[ $key ];
989
+		if (isset($settings[$key])) {
990
+			return $settings[$key];
991 991
 		}
992 992
 
993 993
 		return null;
@@ -1023,8 +1023,8 @@  discard block
 block discarded – undo
1023 1023
 	 * @param  int $post_id View ID
1024 1024
 	 * @return array          Multi-array of fields with first level being the field zones. See code comment.
1025 1025
 	 */
1026
-	public static function get_directory_fields( $post_id ) {
1027
-		return get_post_meta( $post_id, '_gravityview_directory_fields', true );
1026
+	public static function get_directory_fields($post_id) {
1027
+		return get_post_meta($post_id, '_gravityview_directory_fields', true);
1028 1028
 	}
1029 1029
 
1030 1030
 
@@ -1035,25 +1035,25 @@  discard block
 block discarded – undo
1035 1035
 	 * @param  int $formid Form ID
1036 1036
 	 * @return string         html
1037 1037
 	 */
1038
-	public static function get_sortable_fields( $formid, $current = '' ) {
1039
-		$output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>';
1038
+	public static function get_sortable_fields($formid, $current = '') {
1039
+		$output = '<option value="" '.selected('', $current, false).'>'.esc_html__('Default', 'gravityview').'</option>';
1040 1040
 
1041
-		if ( empty( $formid ) ) {
1041
+		if (empty($formid)) {
1042 1042
 			return $output;
1043 1043
 		}
1044 1044
 
1045
-		$fields = self::get_sortable_fields_array( $formid );
1045
+		$fields = self::get_sortable_fields_array($formid);
1046 1046
 
1047
-		if ( ! empty( $fields ) ) {
1047
+		if (!empty($fields)) {
1048 1048
 
1049
-			$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null );
1049
+			$blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('list', 'textarea'), null);
1050 1050
 
1051
-			foreach ( $fields as $id => $field ) {
1052
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
1051
+			foreach ($fields as $id => $field) {
1052
+				if (in_array($field['type'], $blacklist_field_types)) {
1053 1053
 					continue;
1054 1054
 				}
1055 1055
 
1056
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>';
1056
+				$output .= '<option value="'.$id.'" '.selected($id, $current, false).'>'.esc_attr($field['label']).'</option>';
1057 1057
 			}
1058 1058
 		}
1059 1059
 
@@ -1071,27 +1071,27 @@  discard block
 block discarded – undo
1071 1071
 	 *
1072 1072
 	 * @return array
1073 1073
 	 */
1074
-	public static function get_sortable_fields_array( $formid, $blacklist = array( 'list', 'textarea' ) ) {
1074
+	public static function get_sortable_fields_array($formid, $blacklist = array('list', 'textarea')) {
1075 1075
 
1076 1076
 		// Get fields with sub-inputs and no parent
1077
-		$fields = self::get_form_fields( $formid, true, false );
1077
+		$fields = self::get_form_fields($formid, true, false);
1078 1078
 
1079 1079
 		$date_created = array(
1080 1080
 			'date_created' => array(
1081 1081
 				'type' => 'date_created',
1082
-				'label' => __( 'Date Created', 'gravityview' ),
1082
+				'label' => __('Date Created', 'gravityview'),
1083 1083
 			),
1084 1084
 		);
1085 1085
 
1086 1086
         $fields = $date_created + $fields;
1087 1087
 
1088
-		$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL );
1088
+		$blacklist_field_types = apply_filters('gravityview_blacklist_field_types', $blacklist, NULL);
1089 1089
 
1090 1090
 		// TODO: Convert to using array_filter
1091
-		foreach( $fields as $id => $field ) {
1091
+		foreach ($fields as $id => $field) {
1092 1092
 
1093
-			if( in_array( $field['type'], $blacklist_field_types ) ) {
1094
-				unset( $fields[ $id ] );
1093
+			if (in_array($field['type'], $blacklist_field_types)) {
1094
+				unset($fields[$id]);
1095 1095
 			}
1096 1096
 		}
1097 1097
 
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
          * @param array $fields Sub-set of GF form fields that are sortable
1102 1102
          * @param int $formid The Gravity Forms form ID that the fields are from
1103 1103
          */
1104
-        $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid );
1104
+        $fields = apply_filters('gravityview/common/sortable_fields', $fields, $formid);
1105 1105
 
1106 1106
 		return $fields;
1107 1107
 	}
@@ -1112,15 +1112,15 @@  discard block
 block discarded – undo
1112 1112
 	 * @param  mixed $field_id Field ID or Field array
1113 1113
 	 * @return string field type
1114 1114
 	 */
1115
-	public static function get_field_type( $form = null, $field_id = '' ) {
1115
+	public static function get_field_type($form = null, $field_id = '') {
1116 1116
 
1117
-		if ( ! empty( $field_id ) && ! is_array( $field_id ) ) {
1118
-			$field = self::get_field( $form, $field_id );
1117
+		if (!empty($field_id) && !is_array($field_id)) {
1118
+			$field = self::get_field($form, $field_id);
1119 1119
 		} else {
1120 1120
 			$field = $field_id;
1121 1121
 		}
1122 1122
 
1123
-		return class_exists( 'RGFormsModel' ) ? RGFormsModel::get_input_type( $field ) : '';
1123
+		return class_exists('RGFormsModel') ? RGFormsModel::get_input_type($field) : '';
1124 1124
 
1125 1125
 	}
1126 1126
 
@@ -1131,22 +1131,22 @@  discard block
 block discarded – undo
1131 1131
 	 * @param  int|array  $field field key or field array
1132 1132
 	 * @return boolean
1133 1133
 	 */
1134
-	public static function is_field_numeric(  $form = null, $field = '' ) {
1134
+	public static function is_field_numeric($form = null, $field = '') {
1135 1135
 
1136 1136
 		/**
1137 1137
 		 * @filter `gravityview/common/numeric_types` What types of fields are numeric?
1138 1138
 		 * @since 1.5.2
1139 1139
 		 * @param array $numeric_types Fields that are numeric. Default: `[ number, time ]`
1140 1140
 		 */
1141
-		$numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) );
1141
+		$numeric_types = apply_filters('gravityview/common/numeric_types', array('number', 'time'));
1142 1142
 
1143
-		if ( ! is_array( $form ) && ! is_array( $field ) ) {
1144
-			$form = self::get_form( $form );
1143
+		if (!is_array($form) && !is_array($field)) {
1144
+			$form = self::get_form($form);
1145 1145
 		}
1146 1146
 
1147
-		$type = self::get_field_type( $form, $field );
1147
+		$type = self::get_field_type($form, $field);
1148 1148
 
1149
-		return in_array( $type, $numeric_types );
1149
+		return in_array($type, $numeric_types);
1150 1150
 
1151 1151
 	}
1152 1152
 
@@ -1164,19 +1164,19 @@  discard block
 block discarded – undo
1164 1164
 	 *
1165 1165
 	 * @return string Content, encrypted
1166 1166
 	 */
1167
-	public static function js_encrypt( $content, $message = '' ) {
1167
+	public static function js_encrypt($content, $message = '') {
1168 1168
 
1169 1169
 		$output = $content;
1170 1170
 
1171
-		if ( ! class_exists( 'StandalonePHPEnkoder' ) ) {
1172
-			include_once( GRAVITYVIEW_DIR . 'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php' );
1171
+		if (!class_exists('StandalonePHPEnkoder')) {
1172
+			include_once(GRAVITYVIEW_DIR.'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php');
1173 1173
 		}
1174 1174
 
1175
-		if ( class_exists( 'StandalonePHPEnkoder' ) ) {
1175
+		if (class_exists('StandalonePHPEnkoder')) {
1176 1176
 
1177 1177
 			$enkoder = new StandalonePHPEnkoder;
1178 1178
 
1179
-			$message = empty( $message ) ? __( 'Email hidden; Javascript is required.', 'gravityview' ) : $message;
1179
+			$message = empty($message) ? __('Email hidden; Javascript is required.', 'gravityview') : $message;
1180 1180
 
1181 1181
 			/**
1182 1182
 			 * @filter `gravityview/phpenkoder/msg` Modify the message shown when Javascript is disabled and an encrypted email field is displayed
@@ -1184,9 +1184,9 @@  discard block
 block discarded – undo
1184 1184
 			 * @param string $message Existing message
1185 1185
 			 * @param string $content Content to encrypt
1186 1186
 			 */
1187
-			$enkoder->enkode_msg = apply_filters( 'gravityview/phpenkoder/msg', $message, $content );
1187
+			$enkoder->enkode_msg = apply_filters('gravityview/phpenkoder/msg', $message, $content);
1188 1188
 
1189
-			$output = $enkoder->enkode( $content );
1189
+			$output = $enkoder->enkode($content);
1190 1190
 		}
1191 1191
 
1192 1192
 		return $output;
@@ -1203,25 +1203,25 @@  discard block
 block discarded – undo
1203 1203
 	 *
1204 1204
 	 * @author rubo77 at https://gist.github.com/rubo77/6821632
1205 1205
 	 **/
1206
-	public static function gv_parse_str( $string, &$result ) {
1207
-		if ( empty( $string ) ) {
1206
+	public static function gv_parse_str($string, &$result) {
1207
+		if (empty($string)) {
1208 1208
 			return false;
1209 1209
 		}
1210 1210
 
1211 1211
 		$result = array();
1212 1212
 
1213 1213
 		// find the pairs "name=value"
1214
-		$pairs = explode( '&', $string );
1214
+		$pairs = explode('&', $string);
1215 1215
 
1216
-		foreach ( $pairs as $pair ) {
1216
+		foreach ($pairs as $pair) {
1217 1217
 			// use the original parse_str() on each element
1218
-			parse_str( $pair, $params );
1218
+			parse_str($pair, $params);
1219 1219
 
1220
-			$k = key( $params );
1221
-			if ( ! isset( $result[ $k ] ) ) {
1220
+			$k = key($params);
1221
+			if (!isset($result[$k])) {
1222 1222
 				$result += $params;
1223
-			} elseif ( array_key_exists( $k, $params ) && is_array( $params[ $k ] ) ) {
1224
-				$result[ $k ] = self::array_merge_recursive_distinct( $result[ $k ], $params[ $k ] );
1223
+			} elseif (array_key_exists($k, $params) && is_array($params[$k])) {
1224
+				$result[$k] = self::array_merge_recursive_distinct($result[$k], $params[$k]);
1225 1225
 			}
1226 1226
 		}
1227 1227
 		return true;
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
 	 *
1244 1244
 	 * @return string HTML output of anchor link. If empty $href, returns NULL
1245 1245
 	 */
1246
-	public static function get_link_html( $href = '', $anchor_text = '', $atts = array() ) {
1246
+	public static function get_link_html($href = '', $anchor_text = '', $atts = array()) {
1247 1247
 
1248 1248
 		// Supported attributes for anchor tags. HREF left out intentionally.
1249 1249
 		$allowed_atts = array(
@@ -1279,31 +1279,31 @@  discard block
 block discarded – undo
1279 1279
 		 * @filter `gravityview/get_link/allowed_atts` Modify the attributes that are allowed to be used in generating links
1280 1280
 		 * @param array $allowed_atts Array of attributes allowed
1281 1281
 		 */
1282
-		$allowed_atts = apply_filters( 'gravityview/get_link/allowed_atts', $allowed_atts );
1282
+		$allowed_atts = apply_filters('gravityview/get_link/allowed_atts', $allowed_atts);
1283 1283
 
1284 1284
 		// Make sure the attributes are formatted as array
1285
-		$passed_atts = wp_parse_args( $atts );
1285
+		$passed_atts = wp_parse_args($atts);
1286 1286
 
1287 1287
 		// Make sure the allowed attributes are only the ones in the $allowed_atts list
1288
-		$final_atts = shortcode_atts( $allowed_atts, $passed_atts );
1288
+		$final_atts = shortcode_atts($allowed_atts, $passed_atts);
1289 1289
 
1290 1290
 		// Remove attributes with empty values
1291
-		$final_atts = array_filter( $final_atts );
1291
+		$final_atts = array_filter($final_atts);
1292 1292
 
1293 1293
 		// If the href wasn't passed as an attribute, use the value passed to the function
1294
-		if ( empty( $final_atts['href'] ) && ! empty( $href ) ) {
1294
+		if (empty($final_atts['href']) && !empty($href)) {
1295 1295
 			$final_atts['href'] = $href;
1296 1296
 		}
1297 1297
 
1298
-		$final_atts['href'] = esc_url_raw( $href );
1298
+		$final_atts['href'] = esc_url_raw($href);
1299 1299
 
1300 1300
 		// For each attribute, generate the code
1301 1301
 		$output = '';
1302
-		foreach ( $final_atts as $attr => $value ) {
1303
-			$output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) );
1302
+		foreach ($final_atts as $attr => $value) {
1303
+			$output .= sprintf(' %s="%s"', $attr, esc_attr($value));
1304 1304
 		}
1305 1305
 
1306
-		$output = '<a'. $output .'>'. $anchor_text .'</a>';
1306
+		$output = '<a'.$output.'>'.$anchor_text.'</a>';
1307 1307
 
1308 1308
 		return $output;
1309 1309
 	}
@@ -1322,14 +1322,14 @@  discard block
 block discarded – undo
1322 1322
 	 * @author Daniel <daniel (at) danielsmedegaardbuus (dot) dk>
1323 1323
 	 * @author Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com>
1324 1324
 	 */
1325
-	public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) {
1325
+	public static function array_merge_recursive_distinct(array &$array1, array &$array2) {
1326 1326
 		$merged = $array1;
1327 1327
 
1328
-		foreach ( $array2 as $key => &$value )  {
1329
-			if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
1330
-				$merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
1328
+		foreach ($array2 as $key => &$value) {
1329
+			if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
1330
+				$merged[$key] = self::array_merge_recursive_distinct($merged[$key], $value);
1331 1331
 			} else {
1332
-				$merged[ $key ] = $value;
1332
+				$merged[$key] = $value;
1333 1333
 			}
1334 1334
 		}
1335 1335
 
@@ -1343,26 +1343,26 @@  discard block
 block discarded – undo
1343 1343
 	 * @param array $args Arguments to modify the user query. See get_users() {@since 1.14}
1344 1344
 	 * @return array Array of WP_User objects.
1345 1345
 	 */
1346
-	public static function get_users( $context = 'change_entry_creator', $args = array() ) {
1346
+	public static function get_users($context = 'change_entry_creator', $args = array()) {
1347 1347
 
1348 1348
 		$default_args = array(
1349 1349
 			'number' => 2000,
1350 1350
 			'orderby' => 'display_name',
1351 1351
 			'order' => 'ASC',
1352
-			'fields' => array( 'ID', 'display_name', 'user_login', 'user_nicename' )
1352
+			'fields' => array('ID', 'display_name', 'user_login', 'user_nicename')
1353 1353
 		);
1354 1354
 
1355 1355
 		// Merge in the passed arg
1356
-		$get_users_settings = wp_parse_args( $args, $default_args );
1356
+		$get_users_settings = wp_parse_args($args, $default_args);
1357 1357
 
1358 1358
 		/**
1359 1359
 		 * @filter `gravityview/get_users/{$context}` There are issues with too many users using [get_users()](http://codex.wordpress.org/Function_Reference/get_users) where it breaks the select. We try to keep it at a reasonable number. \n
1360 1360
 		 * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..)
1361 1361
 		 * @param array $settings Settings array, with `number` key defining the # of users to display
1362 1362
 		 */
1363
-		$get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1363
+		$get_users_settings = apply_filters('gravityview/get_users/'.$context, apply_filters('gravityview_change_entry_creator_user_parameters', $get_users_settings));
1364 1364
 
1365
-		return get_users( $get_users_settings );
1365
+		return get_users($get_users_settings);
1366 1366
 	}
1367 1367
 
1368 1368
 
@@ -1374,8 +1374,8 @@  discard block
 block discarded – undo
1374 1374
      *
1375 1375
      * @return string
1376 1376
      */
1377
-    public static function generate_notice( $notice, $class = '' ) {
1378
-        return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>';
1377
+    public static function generate_notice($notice, $class = '') {
1378
+        return '<div class="gv-notice '.gravityview_sanitize_html_class($class).'">'.$notice.'</div>';
1379 1379
     }
1380 1380
 
1381 1381
 
@@ -1397,6 +1397,6 @@  discard block
 block discarded – undo
1397 1397
  *
1398 1398
  * @return string HTML output of anchor link. If empty $href, returns NULL
1399 1399
  */
1400
-function gravityview_get_link( $href = '', $anchor_text = '', $atts = array() ) {
1401
-	return GVCommon::get_link_html( $href, $anchor_text, $atts );
1400
+function gravityview_get_link($href = '', $anchor_text = '', $atts = array()) {
1401
+	return GVCommon::get_link_html($href, $anchor_text, $atts);
1402 1402
 }
Please login to merge, or discard this patch.
includes/admin/metaboxes/class-gravityview-admin-metaboxes.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 	 */
18 18
 	function __construct() {
19 19
 
20
-		if( !GravityView_Compatibility::is_valid() ) { return; }
20
+		if (!GravityView_Compatibility::is_valid()) { return; }
21 21
 
22
-        self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/';
22
+        self::$metaboxes_dir = GRAVITYVIEW_DIR.'includes/admin/metaboxes/';
23 23
 
24
-		include_once self::$metaboxes_dir . 'class-gravityview-metabox-tab.php';
24
+		include_once self::$metaboxes_dir.'class-gravityview-metabox-tab.php';
25 25
 
26
-		include_once self::$metaboxes_dir . 'class-gravityview-metabox-tabs.php';
26
+		include_once self::$metaboxes_dir.'class-gravityview-metabox-tabs.php';
27 27
 
28 28
 		$this->initialize();
29 29
 
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	function initialize() {
37 37
 
38
-		add_action( 'add_meta_boxes', array( $this, 'register_metaboxes' ));
38
+		add_action('add_meta_boxes', array($this, 'register_metaboxes'));
39 39
 
40
-		add_action( 'add_meta_boxes_gravityview' , array( $this, 'update_priority' ) );
40
+		add_action('add_meta_boxes_gravityview', array($this, 'update_priority'));
41 41
 
42 42
 		// information box
43
-		add_action( 'post_submitbox_misc_actions', array( $this, 'render_shortcode_hint' ) );
43
+		add_action('post_submitbox_misc_actions', array($this, 'render_shortcode_hint'));
44 44
 
45 45
 	}
46 46
 
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
 	function update_priority() {
52 52
 		global $wp_meta_boxes;
53 53
 
54
-		if( ! empty( $wp_meta_boxes['gravityview'] ) ) {
55
-			foreach( array( 'high', 'core', 'low' ) as $position ) {
56
-				if( isset( $wp_meta_boxes['gravityview']['normal'][ $position ] ) ) {
57
-					foreach( $wp_meta_boxes['gravityview']['normal'][ $position ] as $key => $meta_box ) {
58
-						if( ! preg_match( '/^gravityview_/ism', $key ) ) {
59
-							$wp_meta_boxes['gravityview']['advanced'][ $position ][ $key ] = $meta_box;
60
-							unset( $wp_meta_boxes['gravityview']['normal'][ $position ][ $key ] );
54
+		if (!empty($wp_meta_boxes['gravityview'])) {
55
+			foreach (array('high', 'core', 'low') as $position) {
56
+				if (isset($wp_meta_boxes['gravityview']['normal'][$position])) {
57
+					foreach ($wp_meta_boxes['gravityview']['normal'][$position] as $key => $meta_box) {
58
+						if (!preg_match('/^gravityview_/ism', $key)) {
59
+							$wp_meta_boxes['gravityview']['advanced'][$position][$key] = $meta_box;
60
+							unset($wp_meta_boxes['gravityview']['normal'][$position][$key]);
61 61
 						}
62 62
 					}
63 63
 				}
@@ -69,23 +69,23 @@  discard block
 block discarded – undo
69 69
 		global $post;
70 70
 
71 71
 		// On Comment Edit, for example, $post isn't set.
72
-		if( empty( $post ) || !is_object( $post ) || !isset( $post->ID ) ) {
72
+		if (empty($post) || !is_object($post) || !isset($post->ID)) {
73 73
 			return;
74 74
 		}
75 75
 
76 76
 		// select data source for this view
77
-		add_meta_box( 'gravityview_select_form', $this->get_data_source_header( $post->ID ), array( $this, 'render_data_source_metabox' ), 'gravityview', 'normal', 'high' );
77
+		add_meta_box('gravityview_select_form', $this->get_data_source_header($post->ID), array($this, 'render_data_source_metabox'), 'gravityview', 'normal', 'high');
78 78
 
79 79
 		// select view type/template
80
-		add_meta_box( 'gravityview_select_template', __( 'Choose a View Type', 'gravityview' ), array( $this, 'render_select_template_metabox' ), 'gravityview', 'normal', 'high' );
80
+		add_meta_box('gravityview_select_template', __('Choose a View Type', 'gravityview'), array($this, 'render_select_template_metabox'), 'gravityview', 'normal', 'high');
81 81
 
82 82
 		// View Configuration box
83
-		add_meta_box( 'gravityview_view_config', __( 'View Configuration', 'gravityview' ), array( $this, 'render_view_configuration_metabox' ), 'gravityview', 'normal', 'high' );
83
+		add_meta_box('gravityview_view_config', __('View Configuration', 'gravityview'), array($this, 'render_view_configuration_metabox'), 'gravityview', 'normal', 'high');
84 84
 
85 85
 		$this->add_settings_metabox_tabs();
86 86
 
87 87
 		// Other Settings box
88
-		add_meta_box( 'gravityview_settings', __( 'View Settings', 'gravityview' ), array( $this, 'settings_metabox_render' ), 'gravityview', 'normal', 'core' );
88
+		add_meta_box('gravityview_settings', __('View Settings', 'gravityview'), array($this, 'settings_metabox_render'), 'gravityview', 'normal', 'core');
89 89
 
90 90
 	}
91 91
 
@@ -94,22 +94,22 @@  discard block
 block discarded – undo
94 94
 	 * @since 1.8
95 95
 	 * @param WP_Post $post
96 96
 	 */
97
-	function settings_metabox_render( $post ) {
97
+	function settings_metabox_render($post) {
98 98
 
99 99
 		/**
100 100
 		 * @param WP_Post $post
101 101
 		 */
102
-		do_action( 'gravityview/metaboxes/before_render', $post );
102
+		do_action('gravityview/metaboxes/before_render', $post);
103 103
 
104 104
 		$metaboxes = GravityView_Metabox_Tabs::get_all();
105 105
 
106
-		include self::$metaboxes_dir . 'views/gravityview-navigation.php';
107
-		include self::$metaboxes_dir . 'views/gravityview-content.php';
106
+		include self::$metaboxes_dir.'views/gravityview-navigation.php';
107
+		include self::$metaboxes_dir.'views/gravityview-content.php';
108 108
 
109 109
 		/**
110 110
 		 * @param WP_Post $post
111 111
 		 */
112
-		do_action( 'gravityview/metaboxes/after_render', $post );
112
+		do_action('gravityview/metaboxes/after_render', $post);
113 113
 	}
114 114
 
115 115
 	/**
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		$metaboxes = array(
122 122
 			array(
123 123
 				'id' => 'template_settings',
124
-				'title' => __( 'View Settings', 'gravityview' ),
124
+				'title' => __('View Settings', 'gravityview'),
125 125
 				'file' => 'view-settings.php',
126 126
 				'icon-class' => 'dashicons-admin-generic',
127 127
 				'callback' => '',
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 			),
130 130
 			array(
131 131
 				'id' => 'single_entry', // Use the same ID as View Settings for backward compatibility
132
-				'title' => __( 'Single Entry', 'gravityview' ),
132
+				'title' => __('Single Entry', 'gravityview'),
133 133
 				'file' => 'single-entry.php',
134 134
 				'icon-class' => 'dashicons-media-default',
135 135
 				'callback' => '',
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 			),
138 138
 			array(
139 139
 				'id' => 'sort_filter',
140
-				'title' => __( 'Filter &amp; Sort', 'gravityview' ),
140
+				'title' => __('Filter &amp; Sort', 'gravityview'),
141 141
 				'file' => 'sort-filter.php',
142 142
 				'icon-class' => 'dashicons-sort',
143 143
 				'callback' => '',
@@ -150,17 +150,17 @@  discard block
 block discarded – undo
150 150
 		 * @param array $metaboxes
151 151
 		 * @since 1.8
152 152
 		 */
153
-		$metaboxes = apply_filters( 'gravityview/metaboxes/default', $metaboxes );
153
+		$metaboxes = apply_filters('gravityview/metaboxes/default', $metaboxes);
154 154
 
155
-		foreach( $metaboxes as $m ) {
155
+		foreach ($metaboxes as $m) {
156 156
 
157
-			$tab = new GravityView_Metabox_Tab( $m['id'], $m['title'], $m['file'], $m['icon-class'], $m['callback'], $m['callback_args'] );
157
+			$tab = new GravityView_Metabox_Tab($m['id'], $m['title'], $m['file'], $m['icon-class'], $m['callback'], $m['callback_args']);
158 158
 
159
-			GravityView_Metabox_Tabs::add( $tab );
159
+			GravityView_Metabox_Tabs::add($tab);
160 160
 
161 161
 		}
162 162
 
163
-		unset( $tab );
163
+		unset($tab);
164 164
 
165 165
 	}
166 166
 
@@ -173,18 +173,18 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @return string "Data Source", plus links if any
175 175
 	 */
176
-	private function get_data_source_header( $post_id ) {
176
+	private function get_data_source_header($post_id) {
177 177
 
178 178
 		//current value
179
-		$current_form = gravityview_get_form_id( $post_id );
179
+		$current_form = gravityview_get_form_id($post_id);
180 180
 
181
-		$links = GravityView_Admin_Views::get_connected_form_links( $current_form, false );
181
+		$links = GravityView_Admin_Views::get_connected_form_links($current_form, false);
182 182
 
183
-		if( !empty( $links ) ) {
184
-			$links = '<span class="alignright gv-form-links">'. $links .'</span>';
183
+		if (!empty($links)) {
184
+			$links = '<span class="alignright gv-form-links">'.$links.'</span>';
185 185
 		}
186 186
 
187
-		return __( 'Data Source', 'gravityview' ) . $links;
187
+		return __('Data Source', 'gravityview').$links;
188 188
 	}
189 189
 
190 190
 	/**
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
 	 * @param object $post
195 195
 	 * @return void
196 196
 	 */
197
-	function render_data_source_metabox( $post ) {
197
+	function render_data_source_metabox($post) {
198 198
 
199
-		include self::$metaboxes_dir . 'views/data-source.php';
199
+		include self::$metaboxes_dir.'views/data-source.php';
200 200
 
201 201
 	}
202 202
 
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
 	 * @param object $post
208 208
 	 * @return void
209 209
 	 */
210
-	function render_select_template_metabox( $post ) {
210
+	function render_select_template_metabox($post) {
211 211
 
212
-		include self::$metaboxes_dir . 'views/select-template.php';
212
+		include self::$metaboxes_dir.'views/select-template.php';
213 213
 	}
214 214
 
215 215
 	/**
@@ -218,18 +218,18 @@  discard block
 block discarded – undo
218 218
 	 * @param  mixed      $curr_form Form ID
219 219
 	 * @return null|string     Merge tags html; NULL if $curr_form isn't defined.
220 220
 	 */
221
-	public static function render_merge_tags_scripts( $curr_form ) {
221
+	public static function render_merge_tags_scripts($curr_form) {
222 222
 
223
-		if( empty( $curr_form )) {
223
+		if (empty($curr_form)) {
224 224
 			return NULL;
225 225
 		}
226 226
 
227
-		$form = gravityview_get_form( $curr_form );
227
+		$form = gravityview_get_form($curr_form);
228 228
 
229 229
 		$get_id_backup = isset($_GET['id']) ? $_GET['id'] : NULL;
230 230
 
231
-		if( isset( $form['id'] ) ) {
232
-		    $form_script = 'var form = ' . GFCommon::json_encode($form) . ';';
231
+		if (isset($form['id'])) {
232
+		    $form_script = 'var form = '.GFCommon::json_encode($form).';';
233 233
 
234 234
 		    // The `gf_vars()` method needs a $_GET[id] variable set with the form ID.
235 235
 		    $_GET['id'] = $form['id'];
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		    $form_script = 'var form = new Form();';
239 239
 		}
240 240
 
241
-		$output = '<script type="text/javascript" data-gv-merge-tags="1">' . $form_script . "\n" . GFCommon::gf_vars(false) . '</script>';
241
+		$output = '<script type="text/javascript" data-gv-merge-tags="1">'.$form_script."\n".GFCommon::gf_vars(false).'</script>';
242 242
 
243 243
 		// Restore previous $_GET setting
244 244
 		$_GET['id'] = $get_id_backup;
@@ -253,20 +253,20 @@  discard block
 block discarded – undo
253 253
 	 * @param mixed $post
254 254
 	 * @return void
255 255
 	 */
256
-	function render_view_configuration_metabox( $post ) {
256
+	function render_view_configuration_metabox($post) {
257 257
 
258 258
 		// Use nonce for verification
259
-		wp_nonce_field( 'gravityview_view_configuration', 'gravityview_view_configuration_nonce' );
259
+		wp_nonce_field('gravityview_view_configuration', 'gravityview_view_configuration_nonce');
260 260
 
261 261
 		// Selected Form
262
-		$curr_form = gravityview_get_form_id( $post->ID );
262
+		$curr_form = gravityview_get_form_id($post->ID);
263 263
 
264 264
 		// Selected template
265
-		$curr_template = gravityview_get_template_id( $post->ID );
265
+		$curr_template = gravityview_get_template_id($post->ID);
266 266
 
267
-		echo self::render_merge_tags_scripts( $curr_form );
267
+		echo self::render_merge_tags_scripts($curr_form);
268 268
 
269
-		include self::$metaboxes_dir . 'views/view-configuration.php';
269
+		include self::$metaboxes_dir.'views/view-configuration.php';
270 270
 	}
271 271
 
272 272
 	/**
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
 	 * @param object $post
277 277
 	 * @return void
278 278
 	 */
279
-	function render_view_settings_metabox( $post ) {
279
+	function render_view_settings_metabox($post) {
280 280
 
281 281
 		// View template settings
282
-		$current_settings = gravityview_get_template_settings( $post->ID );
282
+		$current_settings = gravityview_get_template_settings($post->ID);
283 283
 
284
-		include self::$metaboxes_dir . 'views/view-settings.php';
284
+		include self::$metaboxes_dir.'views/view-settings.php';
285 285
 
286 286
 	}
287 287
 
@@ -298,12 +298,12 @@  discard block
 block discarded – undo
298 298
 		global $post;
299 299
 
300 300
 		// Only show this on GravityView post types.
301
-		if( false === gravityview_is_admin_page() ) { return; }
301
+		if (false === gravityview_is_admin_page()) { return; }
302 302
 
303 303
 		// If the View hasn't been configured yet, don't show embed shortcode
304
-		if( !gravityview_get_directory_fields( $post->ID ) ) { return; }
304
+		if (!gravityview_get_directory_fields($post->ID)) { return; }
305 305
 
306
-		include self::$metaboxes_dir . 'views/shortcode-hint.php';
306
+		include self::$metaboxes_dir.'views/shortcode-hint.php';
307 307
 	}
308 308
 
309 309
 }
Please login to merge, or discard this patch.
includes/admin/metaboxes/class-gravityview-metabox-tab.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
 	 * @param array $callback_args Arguments passed to the callback
98 98
 	 * @return void
99 99
 	 */
100
-	function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array()  ) {
100
+	function __construct($id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array()) {
101 101
 
102 102
 		$this->id = $this->prefix.$id;
103 103
 		$this->title = $title;
104 104
 		$this->render_template_file = $file;
105 105
 		$this->callback = $callback;
106 106
 		$this->callback_args = $callback_args;
107
-		$this->icon_class_name = $this->parse_icon_class_name( $icon_class_name );
107
+		$this->icon_class_name = $this->parse_icon_class_name($icon_class_name);
108 108
 	}
109 109
 
110 110
 	/**
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @return string sanitized CSS class
118 118
 	 */
119
-	function parse_icon_class_name( $icon_class_name = '' ) {
119
+	function parse_icon_class_name($icon_class_name = '') {
120 120
 
121
-		if( preg_match( '/dashicon/i', $icon_class_name ) ) {
122
-			$icon_class_name = 'dashicons ' . $icon_class_name;
121
+		if (preg_match('/dashicon/i', $icon_class_name)) {
122
+			$icon_class_name = 'dashicons '.$icon_class_name;
123 123
 		}
124 124
 
125
-		return esc_attr( $icon_class_name );
125
+		return esc_attr($icon_class_name);
126 126
 	}
127 127
 
128 128
 	/**
@@ -140,38 +140,38 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @param WP_Post $post Currently edited post object
142 142
 	 */
143
-	function render( $post ) {
143
+	function render($post) {
144 144
 
145
-		if( !empty( $this->render_template_file ) ) {
145
+		if (!empty($this->render_template_file)) {
146 146
 
147 147
 			$file = $this->render_template_file;
148 148
 
149 149
 			// If the full path exists, use it
150
-			if( file_exists( $file ) ) {
150
+			if (file_exists($file)) {
151 151
 				$path = $file;
152 152
 			} else {
153
-				$path = GRAVITYVIEW_DIR .'includes/admin/metaboxes/views/'.$file;
153
+				$path = GRAVITYVIEW_DIR.'includes/admin/metaboxes/views/'.$file;
154 154
 			}
155 155
 
156
-			if( file_exists( $path ) ) {
156
+			if (file_exists($path)) {
157 157
 				include $path;
158 158
 			} else {
159
-				do_action( 'gravityview_log_error', 'Metabox template file not found', $this );
159
+				do_action('gravityview_log_error', 'Metabox template file not found', $this);
160 160
 			}
161 161
 
162
-		} else if( !empty( $this->callback ) ) {
162
+		} else if (!empty($this->callback)) {
163 163
 
164
-			if( is_callable( $this->callback ) ) {
164
+			if (is_callable($this->callback)) {
165 165
 
166 166
 				/** @see do_accordion_sections() */
167
-				call_user_func( $this->callback, $post, (array) $this );
167
+				call_user_func($this->callback, $post, (array)$this);
168 168
 
169 169
 			} else {
170
-				do_action( 'gravityview_log_error', 'Metabox callback was not callable', $this );
170
+				do_action('gravityview_log_error', 'Metabox callback was not callable', $this);
171 171
 			}
172 172
 
173 173
 		} else {
174
-			do_action( 'gravityview_log_error', 'Metabox file and callback were not found', $this );
174
+			do_action('gravityview_log_error', 'Metabox file and callback were not found', $this);
175 175
 		}
176 176
 	}
177 177
 
Please login to merge, or discard this patch.
includes/admin/class.render.settings.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -23,53 +23,53 @@  discard block
 block discarded – undo
23 23
 	 * @param  string      $input_type  (textarea, list, select, etc.)
24 24
 	 * @return array       Array of field options with `label`, `value`, `type`, `default` keys
25 25
 	 */
26
-	public static function get_default_field_options( $field_type, $template_id, $field_id, $context, $input_type ) {
26
+	public static function get_default_field_options($field_type, $template_id, $field_id, $context, $input_type) {
27 27
 
28 28
 		$field_options = array();
29 29
 
30
-		if( 'field' === $field_type ) {
30
+		if ('field' === $field_type) {
31 31
 
32 32
 			// Default options - fields
33 33
 			$field_options = array(
34 34
 				'show_label' => array(
35 35
 					'type' => 'checkbox',
36
-					'label' => __( 'Show Label', 'gravityview' ),
36
+					'label' => __('Show Label', 'gravityview'),
37 37
 					'value' => true,
38 38
 				),
39 39
 				'custom_label' => array(
40 40
 					'type' => 'text',
41
-					'label' => __( 'Custom Label:', 'gravityview' ),
41
+					'label' => __('Custom Label:', 'gravityview'),
42 42
 					'value' => '',
43 43
 					'merge_tags' => true,
44 44
 				),
45 45
 				'custom_class' => array(
46 46
 					'type' => 'text',
47
-					'label' => __( 'Custom CSS Class:', 'gravityview' ),
48
-					'desc' => __( 'This class will be added to the field container', 'gravityview'),
47
+					'label' => __('Custom CSS Class:', 'gravityview'),
48
+					'desc' => __('This class will be added to the field container', 'gravityview'),
49 49
 					'value' => '',
50 50
 					'merge_tags' => true,
51 51
 					'tooltip' => 'gv_css_merge_tags',
52 52
 				),
53 53
 				'only_loggedin' => array(
54 54
 					'type' => 'checkbox',
55
-					'label' => __( 'Make visible only to logged-in users?', 'gravityview' ),
55
+					'label' => __('Make visible only to logged-in users?', 'gravityview'),
56 56
 					'value' => ''
57 57
 				),
58 58
 				'only_loggedin_cap' => array(
59 59
 					'type' => 'select',
60
-					'label' => __( 'Make visible for:', 'gravityview' ),
61
-					'options' => self::get_cap_choices( $template_id, $field_id, $context, $input_type ),
60
+					'label' => __('Make visible for:', 'gravityview'),
61
+					'options' => self::get_cap_choices($template_id, $field_id, $context, $input_type),
62 62
 					'class' => 'widefat',
63 63
 					'value' => 'read',
64 64
 				),
65 65
 			);
66 66
 
67 67
 			// Match Table as well as DataTables
68
-			if( preg_match( '/table/ism', $template_id ) && 'single' !== $context ) {
68
+			if (preg_match('/table/ism', $template_id) && 'single' !== $context) {
69 69
 				$field_options['width'] = array(
70 70
 					'type' => 'number',
71 71
 					'label' => __('Percent Width', 'gravityview'),
72
-					'desc' => __( 'Leave blank for column width to be based on the field content.', 'gravityview'),
72
+					'desc' => __('Leave blank for column width to be based on the field content.', 'gravityview'),
73 73
 					'class' => 'code widefat',
74 74
 					'value' => '',
75 75
 				);
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		 * @param[in]  string      $context     What context are we in? Example: `single` or `directory`
86 86
 		 * @param[in]  string      $input_type  (textarea, list, select, etc.)
87 87
 		 */
88
-		$field_options = apply_filters( "gravityview_template_{$field_type}_options", $field_options, $template_id, $field_id, $context, $input_type );
88
+		$field_options = apply_filters("gravityview_template_{$field_type}_options", $field_options, $template_id, $field_id, $context, $input_type);
89 89
 
90 90
 		/**
91 91
 		 * @filter `gravityview_template_{$input_type}_options` Filter the field options by input type (`$input_type` examples: `textarea`, `list`, `select`, etc.)
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		 * @param[in]  string      $context     What context are we in? Example: `single` or `directory`
96 96
 		 * @param[in]  string      $input_type  (textarea, list, select, etc.)
97 97
 		 */
98
-		$field_options = apply_filters( "gravityview_template_{$input_type}_options", $field_options, $template_id, $field_id, $context, $input_type );
98
+		$field_options = apply_filters("gravityview_template_{$input_type}_options", $field_options, $template_id, $field_id, $context, $input_type);
99 99
 
100 100
 		return $field_options;
101 101
 	}
@@ -111,19 +111,19 @@  discard block
 block discarded – undo
111 111
 	 * @param  string $input_type  Optional. (textarea, list, select, etc.)
112 112
 	 * @return array Associative array, with the key being the capability and the value being the label shown.
113 113
 	 */
114
-	static public function get_cap_choices( $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
114
+	static public function get_cap_choices($template_id = '', $field_id = '', $context = '', $input_type = '') {
115 115
 
116 116
 		$select_cap_choices = array(
117
-			'read' => __( 'Any Logged-In User', 'gravityview' ),
118
-			'publish_posts' => __( 'Author Or Higher', 'gravityview' ),
119
-			'gravityforms_view_entries' => __( 'Can View Gravity Forms Entries', 'gravityview' ),
120
-			'delete_others_posts' => __( 'Editor Or Higher', 'gravityview' ),
121
-			'gravityforms_edit_entries' => __( 'Can Edit Gravity Forms Entries', 'gravityview' ),
122
-			'manage_options' => __( 'Administrator', 'gravityview' ),
117
+			'read' => __('Any Logged-In User', 'gravityview'),
118
+			'publish_posts' => __('Author Or Higher', 'gravityview'),
119
+			'gravityforms_view_entries' => __('Can View Gravity Forms Entries', 'gravityview'),
120
+			'delete_others_posts' => __('Editor Or Higher', 'gravityview'),
121
+			'gravityforms_edit_entries' => __('Can Edit Gravity Forms Entries', 'gravityview'),
122
+			'manage_options' => __('Administrator', 'gravityview'),
123 123
 		);
124 124
 
125
-		if( is_multisite() ) {
126
-			$select_cap_choices['manage_network'] = __('Multisite Super Admin', 'gravityview' );
125
+		if (is_multisite()) {
126
+			$select_cap_choices['manage_network'] = __('Multisite Super Admin', 'gravityview');
127 127
 		}
128 128
 
129 129
 		/**
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		 * @param  string $context     Optional. What context are we in? Example: `single` or `directory`
137 137
 		 * @param  string $input_type  Optional. (textarea, list, select, etc.)
138 138
 		 */
139
-		$select_cap_choices = apply_filters('gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type );
139
+		$select_cap_choices = apply_filters('gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type);
140 140
 
141 141
 		return $select_cap_choices;
142 142
 	}
@@ -161,26 +161,26 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @return string HTML of dialog box
163 163
 	 */
164
-	public static function render_field_options( $field_type, $template_id, $field_id, $field_label, $area, $input_type = NULL, $uniqid = '', $current = '', $context = 'single', $item = array() ) {
164
+	public static function render_field_options($field_type, $template_id, $field_id, $field_label, $area, $input_type = NULL, $uniqid = '', $current = '', $context = 'single', $item = array()) {
165 165
 
166
-		if( empty( $uniqid ) ) {
166
+		if (empty($uniqid)) {
167 167
 			//generate a unique field id
168 168
 			$uniqid = uniqid('', false);
169 169
 		}
170 170
 
171 171
 		// get field/widget options
172
-		$options = self::get_default_field_options( $field_type, $template_id, $field_id, $context, $input_type );
172
+		$options = self::get_default_field_options($field_type, $template_id, $field_id, $context, $input_type);
173 173
 
174 174
 		// two different post arrays, depending of the field type
175
-		$name_prefix = $field_type .'s' .'['. $area .']['. $uniqid .']';
175
+		$name_prefix = $field_type.'s'.'['.$area.']['.$uniqid.']';
176 176
 
177 177
 		// build output
178 178
 		$output = '';
179
-		$output .= '<input type="hidden" class="field-key" name="'. $name_prefix .'[id]" value="'. esc_attr( $field_id ) .'">';
180
-		$output .= '<input type="hidden" class="field-label" name="'. $name_prefix .'[label]" value="'. esc_attr( $field_label ) .'">';
179
+		$output .= '<input type="hidden" class="field-key" name="'.$name_prefix.'[id]" value="'.esc_attr($field_id).'">';
180
+		$output .= '<input type="hidden" class="field-label" name="'.$name_prefix.'[label]" value="'.esc_attr($field_label).'">';
181 181
 
182 182
 		// If there are no options, return what we got.
183
-		if(empty($options)) {
183
+		if (empty($options)) {
184 184
 
185 185
 			// This is here for checking if the output is empty in render_label()
186 186
 			$output .= '<!-- No Options -->';
@@ -188,33 +188,33 @@  discard block
 block discarded – undo
188 188
 			return $output;
189 189
 		}
190 190
 
191
-		$output .= '<div class="gv-dialog-options" title="'. esc_attr( sprintf( __( 'Options: %s', 'gravityview' ) , strip_tags( html_entity_decode( $field_label ) ) ) ) .'">';
191
+		$output .= '<div class="gv-dialog-options" title="'.esc_attr(sprintf(__('Options: %s', 'gravityview'), strip_tags(html_entity_decode($field_label)))).'">';
192 192
 
193 193
 		/**
194 194
 		 * @since 1.8
195 195
 		 */
196
-		if( !empty( $item['subtitle'] ) ) {
197
-			$output .= '<div class="subtitle">' . $item['subtitle'] . '</div>';
196
+		if (!empty($item['subtitle'])) {
197
+			$output .= '<div class="subtitle">'.$item['subtitle'].'</div>';
198 198
 		}
199 199
 
200
-		foreach( $options as $key => $option ) {
200
+		foreach ($options as $key => $option) {
201 201
 
202
-			$value = isset( $current[ $key ] ) ? $current[ $key ] : NULL;
202
+			$value = isset($current[$key]) ? $current[$key] : NULL;
203 203
 
204
-			$field_output = self::render_field_option( $name_prefix . '['. $key .']' , $option, $value);
204
+			$field_output = self::render_field_option($name_prefix.'['.$key.']', $option, $value);
205 205
 
206 206
 			// The setting is empty
207
-			if( empty( $field_output ) ) {
207
+			if (empty($field_output)) {
208 208
 				continue;
209 209
 			}
210 210
 
211
-			switch( $option['type'] ) {
211
+			switch ($option['type']) {
212 212
 				// Hide hidden fields
213 213
 				case 'hidden':
214
-					$output .= '<div class="gv-setting-container gv-setting-container-'. esc_attr( $key ) . ' screen-reader-text">'. $field_output . '</div>';
214
+					$output .= '<div class="gv-setting-container gv-setting-container-'.esc_attr($key).' screen-reader-text">'.$field_output.'</div>';
215 215
 					break;
216 216
 				default:
217
-					$output .= '<div class="gv-setting-container gv-setting-container-'. esc_attr( $key ) . '">'. $field_output .'</div>';
217
+					$output .= '<div class="gv-setting-container gv-setting-container-'.esc_attr($key).'">'.$field_output.'</div>';
218 218
 			}
219 219
 		}
220 220
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @param  mixed      $curr_value Current value of option
236 236
 	 * @return string     HTML output of option
237 237
 	 */
238
-	public static function render_field_option( $name = '', $option, $curr_value = NULL ) {
238
+	public static function render_field_option($name = '', $option, $curr_value = NULL) {
239 239
 
240 240
 		$output = '';
241 241
 
@@ -243,19 +243,19 @@  discard block
 block discarded – undo
243 243
 		 * @deprecated setting index 'default' was replaced by 'value'
244 244
 		 * @see GravityView_FieldType::get_field_defaults
245 245
 		 */
246
-		if( !empty( $option['default'] ) && empty( $option['value'] ) ) {
246
+		if (!empty($option['default']) && empty($option['value'])) {
247 247
 			$option['value'] = $option['default'];
248
-			_deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting '. $name .' details' );
248
+			_deprecated_function('GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting '.$name.' details');
249 249
 		}
250 250
 
251 251
 		// prepare to render option field type
252
-		if( isset( $option['type'] ) ) {
252
+		if (isset($option['type'])) {
253 253
 
254
-			$type_class = self::load_type_class( $option );
254
+			$type_class = self::load_type_class($option);
255 255
 
256
-			if( class_exists( $type_class ) ) {
256
+			if (class_exists($type_class)) {
257 257
 
258
-				$render_type = new $type_class( $name, $option, $curr_value );
258
+				$render_type = new $type_class($name, $option, $curr_value);
259 259
 
260 260
 				ob_start();
261 261
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 				 * @param[in,out] string $output field class name
270 270
 				 * @param[in] array $option  option field data
271 271
 				 */
272
-				$output = apply_filters( "gravityview/option/output/{$option['type']}" , $output, $option );
272
+				$output = apply_filters("gravityview/option/output/{$option['type']}", $output, $option);
273 273
 			}
274 274
 
275 275
 		} // isset option[type]
@@ -291,35 +291,35 @@  discard block
 block discarded – undo
291 291
 	 * @param  string $id               [description]
292 292
 	 * @return void                   [description]
293 293
 	 */
294
-	public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) {
294
+	public static function render_setting_row($key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s') {
295 295
 
296
-		$setting = GravityView_View_Data::get_default_arg( $key, true );
296
+		$setting = GravityView_View_Data::get_default_arg($key, true);
297 297
 
298 298
 		// If the key doesn't exist, there's something wrong.
299
-		if( empty( $setting ) ) { return; }
299
+		if (empty($setting)) { return; }
300 300
 
301 301
 		/**
302 302
 		 * @deprecated setting index 'name' was replaced by 'label'
303 303
 		 * @see GravityView_FieldType::get_field_defaults
304 304
 		 */
305
-		if( isset( $setting['name'] ) && empty( $setting['label'] ) ) {
305
+		if (isset($setting['name']) && empty($setting['label'])) {
306 306
 			$setting['label'] = $setting['name'];
307
-			_deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting '. $key .' details' );
307
+			_deprecated_function('GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting '.$key.' details');
308 308
 		}
309 309
 
310
-		$name = esc_attr( sprintf( $name, $key ) );
311
-		$setting['id'] = esc_attr( sprintf( $id, $key ) );
312
-		$setting['tooltip'] = 'gv_' . $key;
310
+		$name = esc_attr(sprintf($name, $key));
311
+		$setting['id'] = esc_attr(sprintf($id, $key));
312
+		$setting['tooltip'] = 'gv_'.$key;
313 313
 
314 314
 		// Use default if current setting isn't set.
315
-		$curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting['value'];
315
+		$curr_value = isset($current_settings[$key]) ? $current_settings[$key] : $setting['value'];
316 316
 
317 317
 		// default setting type = text
318
-		$setting['type'] = empty( $setting['type'] ) ? 'text' : $setting['type'];
318
+		$setting['type'] = empty($setting['type']) ? 'text' : $setting['type'];
319 319
 
320 320
 		// merge tags
321
-		if( !isset( $setting['merge_tags'] ) ) {
322
-			if( $setting['type'] === 'text' ) {
321
+		if (!isset($setting['merge_tags'])) {
322
+			if ($setting['type'] === 'text') {
323 323
 				$setting['merge_tags'] = true;
324 324
 			} else {
325 325
 				$setting['merge_tags'] = false;
@@ -329,27 +329,27 @@  discard block
 block discarded – undo
329 329
 		$output = '';
330 330
 
331 331
 		// render the setting
332
-		$type_class = self::load_type_class( $setting );
333
-		if( class_exists( $type_class ) ) {
332
+		$type_class = self::load_type_class($setting);
333
+		if (class_exists($type_class)) {
334 334
 			/** @var GravityView_FieldType $render_type */
335
-			$render_type = new $type_class( $name, $setting, $curr_value );
335
+			$render_type = new $type_class($name, $setting, $curr_value);
336 336
 			ob_start();
337
-			$render_type->render_setting( $override_input );
337
+			$render_type->render_setting($override_input);
338 338
 			$output = ob_get_clean();
339 339
 		}
340 340
 
341 341
 		// Check if setting is specific for a template
342
-		if( !empty( $setting['show_in_template'] ) ) {
343
-			if( !is_array( $setting['show_in_template'] ) ) {
344
-				$setting['show_in_template'] = array( $setting['show_in_template'] );
342
+		if (!empty($setting['show_in_template'])) {
343
+			if (!is_array($setting['show_in_template'])) {
344
+				$setting['show_in_template'] = array($setting['show_in_template']);
345 345
 			}
346
-			$show_if = ' data-show-if="'. implode( ' ', $setting['show_in_template'] ).'"';
346
+			$show_if = ' data-show-if="'.implode(' ', $setting['show_in_template']).'"';
347 347
 		} else {
348 348
 			$show_if = '';
349 349
 		}
350 350
 
351 351
 		// output
352
-		echo '<tr valign="top" '. $show_if .'>' . $output . '</tr>';
352
+		echo '<tr valign="top" '.$show_if.'>'.$output.'</tr>';
353 353
 
354 354
 	}
355 355
 
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 	 * @param  array $field
360 360
 	 * @return string type class name
361 361
 	 */
362
-	public static function load_type_class( $field = NULL ) {
362
+	public static function load_type_class($field = NULL) {
363 363
 
364
-		if( empty( $field['type'] ) ) {
364
+		if (empty($field['type'])) {
365 365
 			return NULL;
366 366
 		}
367 367
 
@@ -370,20 +370,20 @@  discard block
 block discarded – undo
370 370
 		 * @param string $class_suffix  field class suffix; `GravityView_FieldType_{$class_suffix}`
371 371
 		 * @param array $field   field data
372 372
 		 */
373
-		$type_class = apply_filters( "gravityview/setting/class/{$field['type']}", 'GravityView_FieldType_' . $field['type'], $field );
373
+		$type_class = apply_filters("gravityview/setting/class/{$field['type']}", 'GravityView_FieldType_'.$field['type'], $field);
374 374
 
375
-		if( !class_exists( $type_class ) ) {
375
+		if (!class_exists($type_class)) {
376 376
 
377 377
 			/**
378 378
 			 * @filter `gravityview/setting/class_file/{field_type}`
379 379
 			 * @param string  $field_type_include_path field class file path
380 380
 			 * @param array $field  field data
381 381
 			 */
382
-			$class_file = apply_filters( "gravityview/setting/class_file/{$field['type']}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field['type']}.php", $field );
382
+			$class_file = apply_filters("gravityview/setting/class_file/{$field['type']}", GRAVITYVIEW_DIR."includes/admin/field-types/type_{$field['type']}.php", $field);
383 383
 
384
-			if( $class_file ) {
385
-				if( file_exists( $class_file ) ) {
386
-					require_once( $class_file );
384
+			if ($class_file) {
385
+				if (file_exists($class_file)) {
386
+					require_once($class_file);
387 387
 				}
388 388
 			}
389 389
 
@@ -403,10 +403,10 @@  discard block
 block discarded – undo
403 403
 	 * @param  string $current current value
404 404
 	 * @return string         html tags
405 405
 	 */
406
-	public static function render_checkbox_option( $name = '', $id = '', $current = '' ) {
406
+	public static function render_checkbox_option($name = '', $id = '', $current = '') {
407 407
 
408
-		$output  = '<input name="'. esc_attr( $name ) .'" type="hidden" value="0">';
409
-		$output .= '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="checkbox" value="1" '. checked( $current, '1', false ) .' >';
408
+		$output  = '<input name="'.esc_attr($name).'" type="hidden" value="0">';
409
+		$output .= '<input name="'.esc_attr($name).'" id="'.esc_attr($id).'" type="checkbox" value="1" '.checked($current, '1', false).' >';
410 410
 
411 411
 		return $output;
412 412
 	}
@@ -421,25 +421,25 @@  discard block
 block discarded – undo
421 421
 	 * @param array $args Field settings, including `class` key for CSS class
422 422
 	 * @return string         [html tags]
423 423
 	 */
424
-	public static function render_text_option( $name = '', $id = '', $current = '', $add_merge_tags = NULL, $args = array() ) {
424
+	public static function render_text_option($name = '', $id = '', $current = '', $add_merge_tags = NULL, $args = array()) {
425 425
 
426 426
 		// Show the merge tags if the field is a list view
427
-		$is_list = ( preg_match( '/_list-/ism', $name ));
427
+		$is_list = (preg_match('/_list-/ism', $name));
428 428
 
429 429
 		// Or is a single entry view
430
-		$is_single = ( preg_match( '/single_/ism', $name ));
431
-		$show = ( $is_single || $is_list );
430
+		$is_single = (preg_match('/single_/ism', $name));
431
+		$show = ($is_single || $is_list);
432 432
 
433 433
 		$class = '';
434 434
 		// and $add_merge_tags is not false
435
-		if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) {
435
+		if ($show && $add_merge_tags !== false || $add_merge_tags === 'force') {
436 436
 			$class = 'merge-tag-support mt-position-right mt-hide_all_fields ';
437 437
 		}
438 438
 
439
-		$class .= !empty( $args['class'] ) ? $args['class'] : 'widefat';
440
-		$type = !empty( $args['type'] ) ? $args['type'] : 'text';
439
+		$class .= !empty($args['class']) ? $args['class'] : 'widefat';
440
+		$type = !empty($args['type']) ? $args['type'] : 'text';
441 441
 
442
-		return '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="'.esc_attr($type).'" value="'. esc_attr( $current ) .'" class="'.esc_attr( $class ).'">';
442
+		return '<input name="'.esc_attr($name).'" id="'.esc_attr($id).'" type="'.esc_attr($type).'" value="'.esc_attr($current).'" class="'.esc_attr($class).'">';
443 443
 	}
444 444
 
445 445
 	/**
@@ -451,24 +451,24 @@  discard block
 block discarded – undo
451 451
 	 * @param array $args Field settings, including `class` key for CSS class
452 452
 	 * @return string         [html tags]
453 453
 	 */
454
-	public static function render_textarea_option( $name = '', $id = '', $current = '', $add_merge_tags = NULL, $args = array() ) {
454
+	public static function render_textarea_option($name = '', $id = '', $current = '', $add_merge_tags = NULL, $args = array()) {
455 455
 
456 456
 		// Show the merge tags if the field is a list view
457
-		$is_list = ( preg_match( '/_list-/ism', $name ));
457
+		$is_list = (preg_match('/_list-/ism', $name));
458 458
 
459 459
 		// Or is a single entry view
460
-		$is_single = ( preg_match( '/single_/ism', $name ));
461
-		$show = ( $is_single || $is_list );
460
+		$is_single = (preg_match('/single_/ism', $name));
461
+		$show = ($is_single || $is_list);
462 462
 
463 463
 		$class = '';
464 464
 		// and $add_merge_tags is not false
465
-		if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) {
465
+		if ($show && $add_merge_tags !== false || $add_merge_tags === 'force') {
466 466
 			$class = 'merge-tag-support mt-position-right mt-hide_all_fields ';
467 467
 		}
468 468
 
469
-		$class .= !empty( $args['class'] ) ? 'widefat '.$args['class'] : 'widefat';
469
+		$class .= !empty($args['class']) ? 'widefat '.$args['class'] : 'widefat';
470 470
 
471
-		return '<textarea name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" class="'.esc_attr( $class ).'">'. esc_textarea( $current ) .'</textarea>';
471
+		return '<textarea name="'.esc_attr($name).'" id="'.esc_attr($id).'" class="'.esc_attr($class).'">'.esc_textarea($current).'</textarea>';
472 472
 	}
473 473
 
474 474
 	/**
@@ -480,11 +480,11 @@  discard block
 block discarded – undo
480 480
 	 * @param  string $current [current value]
481 481
 	 * @return string          [html tags]
482 482
 	 */
483
-	public static function render_select_option( $name = '', $id = '', $choices, $current = '' ) {
483
+	public static function render_select_option($name = '', $id = '', $choices, $current = '') {
484 484
 
485
-		$output = '<select name="'. $name .'" id="'. $id .'">';
486
-		foreach( $choices as $value => $label ) {
487
-			$output .= '<option value="'. esc_attr( $value ) .'" '. selected( $value, $current, false ) .'>'. esc_html( $label ) .'</option>';
485
+		$output = '<select name="'.$name.'" id="'.$id.'">';
486
+		foreach ($choices as $value => $label) {
487
+			$output .= '<option value="'.esc_attr($value).'" '.selected($value, $current, false).'>'.esc_html($label).'</option>';
488 488
 		}
489 489
 		$output .= '</select>';
490 490
 
Please login to merge, or discard this patch.