@@ -32,19 +32,19 @@ discard block |
||
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 | 37 | gravityview()->log->debug( 'Stylesheet override ({css_file})', array( 'css_file' => 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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | gravityview()->log->error( 'File path does not exist. {path}', array( 'path' => $file_path ) ); |
190 | 190 | return ''; |
191 | 191 | } |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | |
210 | 210 | $width = $height * 0.7586206897; |
211 | 211 | |
212 | - if( function_exists('is_rtl') && is_rtl() ) { |
|
213 | - $style = 'margin:10px 10px 10px 0; height='. $height .'px; width: '. $width .'px;'; |
|
212 | + if ( function_exists( 'is_rtl' ) && is_rtl() ) { |
|
213 | + $style = 'margin:10px 10px 10px 0; height=' . $height . 'px; width: ' . $width . 'px;'; |
|
214 | 214 | $css_class = is_string( $css_class ) ? $css_class : 'alignright'; |
215 | 215 | } else { |
216 | - $style = 'margin:10px 10px 10px 0; height='. $height .'px; width: '. $width .'px;'; |
|
216 | + $style = 'margin:10px 10px 10px 0; height=' . $height . 'px; width: ' . $width . 'px;'; |
|
217 | 217 | $css_class = is_string( $css_class ) ? $css_class : 'alignleft'; |
218 | 218 | } |
219 | 219 | |
220 | - return '<img src="'. esc_url( plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) ) .'" class="'. gravityview_sanitize_html_class( $css_class ).'" height="'.intval( $height ).'" width="'.round( $width, 2 ).'" alt="The GravityView Astronaut Says:" style="'.$style.'" />'; |
|
220 | + return '<img src="' . esc_url( plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) ) . '" class="' . gravityview_sanitize_html_class( $css_class ) . '" height="' . intval( $height ) . '" width="' . round( $width, 2 ) . '" alt="The GravityView Astronaut Says:" style="' . $style . '" />'; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | function gravityview_number_format( $number, $decimals = '' ) { |
241 | 241 | global $wp_locale; |
242 | 242 | |
243 | - if( '' === $decimals ) { |
|
243 | + if ( '' === $decimals ) { |
|
244 | 244 | |
245 | - $decimal_point = isset( $wp_locale ) ? $wp_locale->number_format['decimal_point'] : '.'; |
|
245 | + $decimal_point = isset( $wp_locale ) ? $wp_locale->number_format[ 'decimal_point' ] : '.'; |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * Calculate the position of the decimal point in the number |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $parts = parse_url( $value ); |
272 | 272 | |
273 | 273 | // No domain? Strange...show the original text. |
274 | - if( empty( $parts['host'] ) ) { |
|
274 | + if ( empty( $parts[ 'host' ] ) ) { |
|
275 | 275 | return $value; |
276 | 276 | } |
277 | 277 | |
@@ -284,16 +284,16 @@ discard block |
||
284 | 284 | * @param boolean $enable Whether to strip the scheme. Return false to show scheme. (default: true)\n |
285 | 285 | * If true: `http://example.com => example.com` |
286 | 286 | */ |
287 | - if( false === apply_filters('gravityview_anchor_text_striphttp', true) ) { |
|
287 | + if ( false === apply_filters( 'gravityview_anchor_text_striphttp', true ) ) { |
|
288 | 288 | |
289 | - if( isset( $parts['scheme'] ) ) { |
|
290 | - $return .= $parts['scheme']; |
|
289 | + if ( isset( $parts[ 'scheme' ] ) ) { |
|
290 | + $return .= $parts[ 'scheme' ]; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | } |
294 | 294 | |
295 | 295 | // The domain, which may contain a subdomain |
296 | - $domain = $parts['host']; |
|
296 | + $domain = $parts[ 'host' ]; |
|
297 | 297 | |
298 | 298 | /** |
299 | 299 | * @filter `gravityview_anchor_text_stripwww` Strip www from the domain? |
@@ -301,10 +301,10 @@ discard block |
||
301 | 301 | * @param boolean $enable Whether to strip www. Return false to show www. (default: true)\n |
302 | 302 | * If true: `www.example.com => example.com` |
303 | 303 | */ |
304 | - $strip_www = apply_filters('gravityview_anchor_text_stripwww', true ); |
|
304 | + $strip_www = apply_filters( 'gravityview_anchor_text_stripwww', true ); |
|
305 | 305 | |
306 | - if( $strip_www ) { |
|
307 | - $domain = str_replace('www.', '', $domain ); |
|
306 | + if ( $strip_www ) { |
|
307 | + $domain = str_replace( 'www.', '', $domain ); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -314,11 +314,11 @@ discard block |
||
314 | 314 | * If true: `http://demo.example.com => example.com` \n |
315 | 315 | * If false: `http://demo.example.com => demo.example.com` |
316 | 316 | */ |
317 | - $strip_subdomains = apply_filters('gravityview_anchor_text_nosubdomain', true); |
|
317 | + $strip_subdomains = apply_filters( 'gravityview_anchor_text_nosubdomain', true ); |
|
318 | 318 | |
319 | - if( $strip_subdomains ) { |
|
319 | + if ( $strip_subdomains ) { |
|
320 | 320 | |
321 | - $domain = _gravityview_strip_subdomain( $parts['host'] ); |
|
321 | + $domain = _gravityview_strip_subdomain( $parts[ 'host' ] ); |
|
322 | 322 | |
323 | 323 | } |
324 | 324 | |
@@ -332,12 +332,12 @@ discard block |
||
332 | 332 | * If true: `http://example.com/sub/directory/page.html => example.com` \n |
333 | 333 | * If false: `http://example.com/sub/directory/page.html => example.com/sub/directory/page.html` |
334 | 334 | */ |
335 | - $root_only = apply_filters('gravityview_anchor_text_rootonly', true); |
|
335 | + $root_only = apply_filters( 'gravityview_anchor_text_rootonly', true ); |
|
336 | 336 | |
337 | - if( empty( $root_only ) ) { |
|
337 | + if ( empty( $root_only ) ) { |
|
338 | 338 | |
339 | - if( isset( $parts['path'] ) ) { |
|
340 | - $return .= $parts['path']; |
|
339 | + if ( isset( $parts[ 'path' ] ) ) { |
|
340 | + $return .= $parts[ 'path' ]; |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | * @param boolean $enable Whether to enable "root only". Return false to show full path. (default: true)\n |
348 | 348 | * If true: `http://example.com/?query=example => example.com` |
349 | 349 | */ |
350 | - $strip_query_string = apply_filters('gravityview_anchor_text_noquerystring', true ); |
|
350 | + $strip_query_string = apply_filters( 'gravityview_anchor_text_noquerystring', true ); |
|
351 | 351 | |
352 | - if( empty( $strip_query_string ) ) { |
|
352 | + if ( empty( $strip_query_string ) ) { |
|
353 | 353 | |
354 | - if( isset( $parts['query'] ) ) { |
|
355 | - $return .= '?'.$parts['query']; |
|
354 | + if ( isset( $parts[ 'query' ] ) ) { |
|
355 | + $return .= '?' . $parts[ 'query' ]; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | } |
@@ -369,8 +369,8 @@ discard block |
||
369 | 369 | */ |
370 | 370 | function _gravityview_strip_subdomain( $string_maybe_has_subdomain ) { |
371 | 371 | |
372 | - 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 ) ) { |
|
373 | - return $matches['domain']; |
|
372 | + 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 ) ) { |
|
373 | + return $matches[ 'domain' ]; |
|
374 | 374 | } else { |
375 | 375 | return $string_maybe_has_subdomain; |
376 | 376 | } |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | |
440 | 440 | if ( in_array( $value, array( 'yes', 'true' ), true ) ) { |
441 | 441 | $value = true; |
442 | - } else if( in_array( $value, array( 'no', 'false' ), true ) ) { |
|
442 | + } else if ( in_array( $value, array( 'no', 'false' ), true ) ) { |
|
443 | 443 | $value = false; |
444 | 444 | } |
445 | 445 | } |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | */ |
469 | 469 | function gv_maybe_json_decode( $value, $assoc = false, $depth = 512, $options = 0 ) { |
470 | 470 | |
471 | - if( ! is_string( $value ) ) { |
|
471 | + if ( ! is_string( $value ) ) { |
|
472 | 472 | return $value; |
473 | 473 | } |
474 | 474 | |
@@ -479,12 +479,12 @@ discard block |
||
479 | 479 | } |
480 | 480 | |
481 | 481 | // There was a JSON error (PHP 5.3+) |
482 | - if( function_exists('json_last_error') && JSON_ERROR_NONE !== json_last_error() ) { |
|
482 | + if ( function_exists( 'json_last_error' ) && JSON_ERROR_NONE !== json_last_error() ) { |
|
483 | 483 | return $value; |
484 | 484 | } |
485 | 485 | |
486 | 486 | // It wasn't JSON (PHP < 5.3 fallback) |
487 | - if( is_null( $decoded ) ) { |
|
487 | + if ( is_null( $decoded ) ) { |
|
488 | 488 | return $value; |
489 | 489 | } |
490 | 490 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | |
508 | 508 | // Use the original function, if exists. |
509 | 509 | // Requires WP 4.4+ |
510 | - if( function_exists( 'map_deep') ) { |
|
510 | + if ( function_exists( 'map_deep' ) ) { |
|
511 | 511 | return map_deep( $value, $callback ); |
512 | 512 | } |
513 | 513 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | $exploded = explode( '.', "{$field_id}" ); |
574 | 574 | |
575 | - return isset( $exploded[1] ) ? intval( $exploded[1] ) : false; |
|
575 | + return isset( $exploded[ 1 ] ) ? intval( $exploded[ 1 ] ) : false; |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -613,13 +613,13 @@ discard block |
||
613 | 613 | */ |
614 | 614 | $args = apply_filters( 'gravityview_get_terms_choices_args', $args ); |
615 | 615 | |
616 | - $terms = get_terms( $args['taxonomy'], $args ); |
|
616 | + $terms = get_terms( $args[ 'taxonomy' ], $args ); |
|
617 | 617 | |
618 | 618 | $choices = array(); |
619 | 619 | |
620 | 620 | if ( is_array( $terms ) ) { |
621 | 621 | foreach ( $terms as $term_id => $term_name ) { |
622 | - $choices[] = array( |
|
622 | + $choices[ ] = array( |
|
623 | 623 | 'text' => $term_name, |
624 | 624 | 'value' => $term_id |
625 | 625 | ); |
@@ -643,21 +643,21 @@ discard block |
||
643 | 643 | function _gravityview_process_posted_fields() { |
644 | 644 | $fields = array(); |
645 | 645 | |
646 | - if( !empty( $_POST['gv_fields'] ) ) { |
|
647 | - if ( ! is_array( $_POST['gv_fields'] ) ) { |
|
646 | + if ( ! empty( $_POST[ 'gv_fields' ] ) ) { |
|
647 | + if ( ! is_array( $_POST[ 'gv_fields' ] ) ) { |
|
648 | 648 | |
649 | 649 | // We are not using parse_str() due to max_input_vars limitation with large View configurations |
650 | 650 | $fields_holder = array(); |
651 | - GVCommon::gv_parse_str( stripslashes( $_POST['gv_fields'] ), $fields_holder ); |
|
651 | + GVCommon::gv_parse_str( stripslashes( $_POST[ 'gv_fields' ] ), $fields_holder ); |
|
652 | 652 | |
653 | - if ( isset( $fields_holder['fields'] ) ) { |
|
654 | - $fields = $fields_holder['fields']; |
|
653 | + if ( isset( $fields_holder[ 'fields' ] ) ) { |
|
654 | + $fields = $fields_holder[ 'fields' ]; |
|
655 | 655 | } else { |
656 | 656 | gravityview()->log->error( 'No `fields` key was found after parsing $fields string', array( 'data' => $fields_holder ) ); |
657 | 657 | } |
658 | 658 | |
659 | 659 | } else { |
660 | - $fields = $_POST['gv_fields']; |
|
660 | + $fields = $_POST[ 'gv_fields' ]; |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 |