Completed
Pull Request — master (#651)
by Zack
04:36
created
includes/helper-functions.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
 	// If there's an overriding CSS file in the current template folder, use it.
33 33
 	$template_css_path = trailingslashit( get_stylesheet_directory() ) . 'gravityview/css/' . $css_file;
34 34
 
35
-	if( file_exists( $template_css_path ) ) {
35
+	if ( file_exists( $template_css_path ) ) {
36 36
 		$path = trailingslashit( get_stylesheet_directory_uri() ) . 'gravityview/css/' . $css_file;
37
-		do_action( 'gravityview_log_debug', __FUNCTION__ . ': Stylesheet override ('. esc_attr( $css_file ) .')' );
37
+		do_action( 'gravityview_log_debug', __FUNCTION__ . ': Stylesheet override (' . esc_attr( $css_file ) . ')' );
38 38
 	} else {
39 39
 		// Default: use GravityView CSS file
40 40
 
41 41
 		// If no path is provided, assume default plugin templates CSS folder
42
-		if( '' === $dir_path ) {
42
+		if ( '' === $dir_path ) {
43 43
 			$dir_path = GRAVITYVIEW_DIR . 'templates/css/';
44 44
 		}
45 45
 		
46 46
 		// plugins_url() expects a path to a file, not directory. We append a file to be stripped.
47
-		$path = plugins_url( $css_file, trailingslashit( $dir_path )  . 'stripped-by-plugin_basename.php' );
47
+		$path = plugins_url( $css_file, trailingslashit( $dir_path ) . 'stripped-by-plugin_basename.php' );
48 48
 	}
49 49
 
50 50
 	return $path;
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 
83 83
 	$parsed_permalink = parse_url( get_permalink( $id ) );
84 84
 
85
-	$permalink_args =  isset( $parsed_permalink['query'] ) ? $parsed_permalink['query'] : false;
85
+	$permalink_args = isset( $parsed_permalink[ 'query' ] ) ? $parsed_permalink[ 'query' ] : false;
86 86
 
87
-	if( empty( $permalink_args ) ) {
87
+	if ( empty( $permalink_args ) ) {
88 88
 		return array();
89 89
 	}
90 90
 
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
 function gv_selected( $value, $current, $echo = true, $type = 'selected' ) {
110 110
 
111 111
 	$output = '';
112
-	if( is_array( $current ) ) {
113
-		if( in_array( $value, $current ) ) {
112
+	if ( is_array( $current ) ) {
113
+		if ( in_array( $value, $current ) ) {
114 114
 			$output = __checked_selected_helper( true, true, false, $type );
115 115
 		}
116 116
 	} else {
117 117
 		$output = __checked_selected_helper( $value, $current, false, $type );
118 118
 	}
119 119
 
120
-	if( $echo ) {
120
+	if ( $echo ) {
121 121
 		echo $output;
122 122
 	}
123 123
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 }
126 126
 
127 127
 
128
-if( ! function_exists( 'gravityview_sanitize_html_class' ) ) {
128
+if ( ! function_exists( 'gravityview_sanitize_html_class' ) ) {
129 129
 
130 130
 	/**
131 131
 	 * sanitize_html_class doesn't handle spaces (multiple classes). We remedy that.
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
  */
172 172
 function gravityview_strip_whitespace( $string ) {
173 173
 	$string = normalize_whitespace( $string );
174
-	return preg_replace('/[\r\n\t ]+/', ' ', $string );
174
+	return preg_replace( '/[\r\n\t ]+/', ' ', $string );
175 175
 }
176 176
 
177 177
 /**
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
  * @return string Included file contents
186 186
  */
187 187
 function gravityview_ob_include( $file_path, $object = NULL ) {
188
-	if( ! file_exists( $file_path ) ) {
188
+	if ( ! file_exists( $file_path ) ) {
189 189
 		do_action( 'gravityview_log_error', __FUNCTION__ . ': File path does not exist. ', $file_path );
190 190
 		return '';
191 191
 	}
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
  */
202 202
 function gravityview_get_floaty() {
203 203
 
204
-	if( function_exists('is_rtl') && is_rtl() ) {
204
+	if ( function_exists( 'is_rtl' ) && is_rtl() ) {
205 205
 		$style = 'margin:10px 10px 10px 0;';
206 206
 		$class = 'alignright';
207 207
 	} else {
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		$class = 'alignleft';
210 210
 	}
211 211
 
212
-	return '<img src="'.plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ).'" class="'.$class.'" height="87" width="66" alt="The GravityView Astronaut Says:" style="'.$style.'" />';
212
+	return '<img src="' . plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) . '" class="' . $class . '" height="87" width="66" alt="The GravityView Astronaut Says:" style="' . $style . '" />';
213 213
 }
214 214
 
215 215
 /**
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 function gravityview_number_format( $number, $decimals = '' ) {
233 233
 	global $wp_locale;
234 234
 
235
-	if( '' === $decimals ) {
235
+	if ( '' === $decimals ) {
236 236
 
237
-		$decimal_point = isset( $wp_locale ) ? $wp_locale->number_format['decimal_point'] : '.';
237
+		$decimal_point = isset( $wp_locale ) ? $wp_locale->number_format[ 'decimal_point' ] : '.';
238 238
 
239 239
 		/**
240 240
 		 * Calculate the position of the decimal point in the number
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	$parts = parse_url( $value );
264 264
 
265 265
 	// No domain? Strange...show the original text.
266
-	if( empty( $parts['host'] ) ) {
266
+	if ( empty( $parts[ 'host' ] ) ) {
267 267
 		return $value;
268 268
 	}
269 269
 
@@ -276,16 +276,16 @@  discard block
 block discarded – undo
276 276
 	 * @param boolean $enable Whether to strip the scheme. Return false to show scheme. (default: true)\n
277 277
 	 * If true: `http://example.com => example.com`
278 278
 	 */
279
-	if( false === apply_filters('gravityview_anchor_text_striphttp', true) ) {
279
+	if ( false === apply_filters( 'gravityview_anchor_text_striphttp', true ) ) {
280 280
 
281
-		if( isset( $parts['scheme'] ) ) {
282
-			$return .= $parts['scheme'];
281
+		if ( isset( $parts[ 'scheme' ] ) ) {
282
+			$return .= $parts[ 'scheme' ];
283 283
 		}
284 284
 
285 285
 	}
286 286
 
287 287
 	// The domain, which may contain a subdomain
288
-	$domain = $parts['host'];
288
+	$domain = $parts[ 'host' ];
289 289
 
290 290
 	/**
291 291
 	 * @filter `gravityview_anchor_text_stripwww` Strip www from the domain?
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 	 * @param boolean $enable Whether to strip www. Return false to show www. (default: true)\n
294 294
 	 * If true: `www.example.com => example.com`
295 295
 	 */
296
-	$strip_www = apply_filters('gravityview_anchor_text_stripwww', true );
296
+	$strip_www = apply_filters( 'gravityview_anchor_text_stripwww', true );
297 297
 
298
-	if( $strip_www ) {
299
-		$domain = str_replace('www.', '', $domain );
298
+	if ( $strip_www ) {
299
+		$domain = str_replace( 'www.', '', $domain );
300 300
 	}
301 301
 
302 302
 	/**
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 	 * If true: `http://demo.example.com => example.com` \n
307 307
 	 * If false: `http://demo.example.com => demo.example.com`
308 308
 	 */
309
-	$strip_subdomains = apply_filters('gravityview_anchor_text_nosubdomain', true);
309
+	$strip_subdomains = apply_filters( 'gravityview_anchor_text_nosubdomain', true );
310 310
 
311
-	if( $strip_subdomains ) {
311
+	if ( $strip_subdomains ) {
312 312
 
313
-		$domain = _gravityview_strip_subdomain( $parts['host'] );
313
+		$domain = _gravityview_strip_subdomain( $parts[ 'host' ] );
314 314
 
315 315
 	}
316 316
 
@@ -324,12 +324,12 @@  discard block
 block discarded – undo
324 324
 	 * If true: `http://example.com/sub/directory/page.html => example.com`  \n
325 325
 	 * If false: `http://example.com/sub/directory/page.html => example.com/sub/directory/page.html`
326 326
 	 */
327
-	$root_only = apply_filters('gravityview_anchor_text_rootonly', true);
327
+	$root_only = apply_filters( 'gravityview_anchor_text_rootonly', true );
328 328
 
329
-	if( empty( $root_only ) ) {
329
+	if ( empty( $root_only ) ) {
330 330
 
331
-		if( isset( $parts['path'] ) ) {
332
-			$return .= $parts['path'];
331
+		if ( isset( $parts[ 'path' ] ) ) {
332
+			$return .= $parts[ 'path' ];
333 333
 		}
334 334
 	}
335 335
 
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
 	 * @param boolean $enable Whether to enable "root only". Return false to show full path. (default: true)\n
340 340
 	 * If true: `http://example.com/?query=example => example.com`
341 341
 	 */
342
-	$strip_query_string = apply_filters('gravityview_anchor_text_noquerystring', true );
342
+	$strip_query_string = apply_filters( 'gravityview_anchor_text_noquerystring', true );
343 343
 
344
-	if( empty( $strip_query_string ) ) {
344
+	if ( empty( $strip_query_string ) ) {
345 345
 
346
-		if( isset( $parts['query'] ) ) {
347
-			$return .= '?'.$parts['query'];
346
+		if ( isset( $parts[ 'query' ] ) ) {
347
+			$return .= '?' . $parts[ 'query' ];
348 348
 		}
349 349
 
350 350
 	}
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
  */
362 362
 function _gravityview_strip_subdomain( $string_maybe_has_subdomain ) {
363 363
 
364
-	if( preg_match("/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) {
365
-		return $matches['domain'];
364
+	if ( preg_match( "/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) {
365
+		return $matches[ 'domain' ];
366 366
 	} else {
367 367
 		return $string_maybe_has_subdomain;
368 368
 	}
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
  */
384 384
 function gv_empty( $value, $zero_is_empty = true, $allow_string_booleans = true ) {
385 385
 
386
-	if(
386
+	if (
387 387
 		! isset( $value ) // If it's not set, it's empty!
388 388
 		|| false === $value
389 389
 		|| null === $value
@@ -394,20 +394,20 @@  discard block
 block discarded – undo
394 394
 		return true;
395 395
 	}
396 396
 
397
-	if( is_string( $value ) && $allow_string_booleans ) {
397
+	if ( is_string( $value ) && $allow_string_booleans ) {
398 398
 
399 399
 		$value = trim( $value );
400 400
 		$value = strtolower( $value );
401 401
 
402 402
 		if ( in_array( $value, array( 'yes', 'true' ), true ) ) {
403 403
 			$value = true;
404
-		} else if( in_array( $value, array( 'no', 'false' ), true ) ) {
404
+		} else if ( in_array( $value, array( 'no', 'false' ), true ) ) {
405 405
 			$value = false;
406 406
 		}
407 407
 	}
408 408
 
409 409
 	// If zero isn't empty, then if $value is a number and it's empty, it's zero. Thus, return false.
410
-	if( ! $zero_is_empty && is_numeric( $value ) && empty( $value ) ) {
410
+	if ( ! $zero_is_empty && is_numeric( $value ) && empty( $value ) ) {
411 411
 		return false;
412 412
 	}
413 413
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 
431 431
 	// Use the original function, if exists.
432 432
 	// Requires WP 4.4+
433
-	if( function_exists( 'map_deep') ) {
433
+	if ( function_exists( 'map_deep' ) ) {
434 434
 		return map_deep( $value, $callback );
435 435
 	}
436 436
 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 
496 496
 	$exploded = explode( '.', "{$field_id}" );
497 497
 
498
-	return isset( $exploded[1] ) ? intval( $exploded[1] ) : false;
498
+	return isset( $exploded[ 1 ] ) ? intval( $exploded[ 1 ] ) : false;
499 499
 }
500 500
 
501 501
 /**
@@ -536,13 +536,13 @@  discard block
 block discarded – undo
536 536
 	 */
537 537
 	$args = apply_filters( 'gravityview_get_terms_choices_args', $args );
538 538
 
539
-	$terms = get_terms( $args['taxonomy'], $args );
539
+	$terms = get_terms( $args[ 'taxonomy' ], $args );
540 540
 
541 541
 	$choices = array();
542 542
 
543 543
 	if ( is_array( $terms ) ) {
544 544
 		foreach ( $terms as $term_id => $term_name ) {
545
-			$choices[] = array(
545
+			$choices[ ] = array(
546 546
 				'text'  => $term_name,
547 547
 				'value' => $term_id
548 548
 			);
@@ -566,21 +566,21 @@  discard block
 block discarded – undo
566 566
 function _gravityview_process_posted_fields() {
567 567
 	$fields = array();
568 568
 
569
-	if( !empty( $_POST['fields'] ) ) {
570
-		if ( ! is_array( $_POST['fields'] ) ) {
569
+	if ( ! empty( $_POST[ 'fields' ] ) ) {
570
+		if ( ! is_array( $_POST[ 'fields' ] ) ) {
571 571
 
572 572
 			// We are not using parse_str() due to max_input_vars limitation with large View configurations
573 573
 			$fields_holder = array();
574
-			GVCommon::gv_parse_str( $_POST['fields'], $fields_holder );
574
+			GVCommon::gv_parse_str( $_POST[ 'fields' ], $fields_holder );
575 575
 
576
-			if ( isset( $fields_holder['fields'] ) ) {
577
-				$fields = $fields_holder['fields'];
576
+			if ( isset( $fields_holder[ 'fields' ] ) ) {
577
+				$fields = $fields_holder[ 'fields' ];
578 578
 			} else {
579 579
 				do_action( 'gravityview_log_error', '[save_postdata] No `fields` key was found after parsing $fields string', $fields_holder );
580 580
 			}
581 581
 
582 582
 		} else {
583
-			$fields = $_POST['fields'];
583
+			$fields = $_POST[ 'fields' ];
584 584
 		}
585 585
 	}
586 586
 
Please login to merge, or discard this patch.
includes/presets/default-edit/class-gravityview-default-template-edit.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 			'slug' => 'edit',
25 25
 			'type' => 'internal',
26 26
 			'label' =>  __( 'Edit Table', 'gravityview' ),
27
-			'description' => __('Display items in a table view.', 'gravityview'),
28
-			'logo' => plugins_url('includes/presets/default-table/logo-default-table.png', GRAVITYVIEW_FILE),
27
+			'description' => __( 'Display items in a table view.', 'gravityview' ),
28
+			'logo' => plugins_url( 'includes/presets/default-table/logo-default-table.png', GRAVITYVIEW_FILE ),
29 29
 			'css_source' => gravityview_css_url( 'table-view.css', GRAVITYVIEW_DIR . 'templates/css/' ),
30 30
 		);
31 31
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 				'1-1' => array(
43 43
 					array(
44 44
 						'areaid' => 'edit-fields',
45
-						'title' => __('Visible Edit Fields', 'gravityview' )
45
+						'title' => __( 'Visible Edit Fields', 'gravityview' )
46 46
 					)
47 47
 				)
48 48
 			)
Please login to merge, or discard this patch.