@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | |
125 | 125 | $form = false; |
126 | 126 | |
127 | - if( $entry ) { |
|
128 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
127 | + if ( $entry ) { |
|
128 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | return $form; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - return (bool) $has_transaction_data; |
|
204 | + return (bool)$has_transaction_data; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | |
240 | 240 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
241 | 241 | |
242 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
242 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
243 | 243 | |
244 | 244 | return $result; |
245 | 245 | } |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
261 | 261 | */ |
262 | - public static function get_forms( $active = true, $trash = false, $order_by = 'id', $order = 'ASC' ) { |
|
262 | + public static function get_forms( $active = true, $trash = false, $order_by = 'id', $order = 'ASC' ) { |
|
263 | 263 | $forms = array(); |
264 | 264 | if ( ! class_exists( 'GFAPI' ) ) { |
265 | 265 | return array(); |
266 | 266 | } |
267 | 267 | |
268 | - if( 'any' === $active ) { |
|
268 | + if ( 'any' === $active ) { |
|
269 | 269 | $active_forms = GFAPI::get_forms( true, $trash ); |
270 | 270 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
271 | 271 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | $has_post_fields = false; |
298 | 298 | |
299 | 299 | if ( $form ) { |
300 | - foreach ( $form['fields'] as $field ) { |
|
301 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
302 | - $fields["{$field['id']}"] = array( |
|
300 | + foreach ( $form[ 'fields' ] as $field ) { |
|
301 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
302 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
303 | 303 | 'label' => \GV\Utils::get( $field, 'label' ), |
304 | 304 | 'parent' => null, |
305 | 305 | 'type' => \GV\Utils::get( $field, 'type' ), |
@@ -308,10 +308,10 @@ discard block |
||
308 | 308 | ); |
309 | 309 | } |
310 | 310 | |
311 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
312 | - foreach ( $field['inputs'] as $input ) { |
|
311 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
312 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
313 | 313 | |
314 | - if( ! empty( $input['isHidden'] ) ) { |
|
314 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
315 | 315 | continue; |
316 | 316 | } |
317 | 317 | |
@@ -319,10 +319,10 @@ discard block |
||
319 | 319 | * @hack |
320 | 320 | * In case of email/email confirmation, the input for email has the same id as the parent field |
321 | 321 | */ |
322 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
322 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
323 | 323 | continue; |
324 | 324 | } |
325 | - $fields["{$input['id']}"] = array( |
|
325 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
326 | 326 | 'label' => \GV\Utils::get( $input, 'label' ), |
327 | 327 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
328 | 328 | 'parent' => $field, |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | } |
335 | 335 | |
336 | 336 | |
337 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
337 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
338 | 338 | $has_product_fields = true; |
339 | 339 | } |
340 | 340 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @since 1.7 |
349 | 349 | */ |
350 | 350 | if ( $has_post_fields ) { |
351 | - $fields['post_id'] = array( |
|
351 | + $fields[ 'post_id' ] = array( |
|
352 | 352 | 'label' => __( 'Post ID', 'gravityview' ), |
353 | 353 | 'type' => 'post_id', |
354 | 354 | ); |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | foreach ( $payment_fields as $payment_field ) { |
362 | 362 | |
363 | 363 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
364 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
364 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
365 | 365 | continue; |
366 | 366 | } |
367 | 367 | |
368 | - $fields["{$payment_field->name}"] = array( |
|
368 | + $fields[ "{$payment_field->name}" ] = array( |
|
369 | 369 | 'label' => $payment_field->label, |
370 | 370 | 'desc' => $payment_field->description, |
371 | 371 | 'type' => $payment_field->name, |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | |
398 | 398 | $fields = array(); |
399 | 399 | |
400 | - foreach ( $extra_fields as $key => $field ){ |
|
401 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
402 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
400 | + foreach ( $extra_fields as $key => $field ) { |
|
401 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
402 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -439,33 +439,33 @@ discard block |
||
439 | 439 | 'search_criteria' => null, |
440 | 440 | 'sorting' => null, |
441 | 441 | 'paging' => null, |
442 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
442 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
443 | 443 | 'context_view_id' => null, |
444 | 444 | ); |
445 | 445 | |
446 | 446 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
447 | 447 | |
448 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) && is_array( $criteria['search_criteria']['field_filters'] ) ) { |
|
449 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
448 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) && is_array( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
449 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
450 | 450 | |
451 | 451 | if ( ! is_array( $filter ) ) { |
452 | 452 | continue; |
453 | 453 | } |
454 | 454 | |
455 | 455 | // By default, we want searches to be wildcard for each field. |
456 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
456 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
457 | 457 | |
458 | 458 | /** |
459 | 459 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
460 | 460 | * @param string $operator Existing search operator |
461 | 461 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
462 | 462 | */ |
463 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
463 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | // don't send just the [mode] without any field filter. |
467 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
468 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
467 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
468 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | } |
@@ -476,33 +476,33 @@ discard block |
||
476 | 476 | * Prepare date formats to be in Gravity Forms DB format; |
477 | 477 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
478 | 478 | */ |
479 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
479 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
480 | 480 | |
481 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
481 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
482 | 482 | |
483 | 483 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
484 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
484 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
485 | 485 | |
486 | 486 | if ( $date ) { |
487 | 487 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
488 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
488 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
489 | 489 | } else { |
490 | - gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria['search_criteria'][ $key ] ) ); |
|
490 | + gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria[ 'search_criteria' ][ $key ] ) ); |
|
491 | 491 | |
492 | 492 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
493 | - unset( $criteria['search_criteria'][ $key ] ); |
|
493 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | } |
497 | 497 | |
498 | - if ( empty( $criteria['context_view_id'] ) ) { |
|
498 | + if ( empty( $criteria[ 'context_view_id' ] ) ) { |
|
499 | 499 | // Calculate the context view id and send it to the advanced filter |
500 | 500 | if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
501 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
501 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
502 | 502 | } else if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
503 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
503 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
504 | 504 | } else if ( 'delete' === GFForms::get( 'action' ) ) { |
505 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
505 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | * @param array $form_ids Forms to search |
513 | 513 | * @param int $view_id ID of the view being used to search |
514 | 514 | */ |
515 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
515 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
516 | 516 | |
517 | 517 | return (array)$criteria; |
518 | 518 | } |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | /** Reduce # of database calls */ |
547 | 547 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
548 | 548 | |
549 | - if ( ! empty( $criteria['cache'] ) ) { |
|
549 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
550 | 550 | |
551 | 551 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
552 | 552 | |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | |
555 | 555 | // Still update the total count when using cached results |
556 | 556 | if ( ! is_null( $total ) ) { |
557 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
557 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | $return = $entries; |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | $entries = apply_filters_ref_array( 'gravityview_before_get_entries', array( null, $criteria, $passed_criteria, &$total ) ); |
577 | 577 | |
578 | 578 | // No entries returned from gravityview_before_get_entries |
579 | - if( is_null( $entries ) ) { |
|
579 | + if ( is_null( $entries ) ) { |
|
580 | 580 | |
581 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
581 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
582 | 582 | |
583 | 583 | if ( is_wp_error( $entries ) ) { |
584 | 584 | gravityview()->log->error( '{error}', array( 'error' => $entries->get_error_message(), 'data' => $entries ) ); |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
592 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
592 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
593 | 593 | |
594 | 594 | // Cache results |
595 | 595 | $Cache->set( $entries, 'entries' ); |
@@ -706,18 +706,18 @@ discard block |
||
706 | 706 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry, $view ); |
707 | 707 | |
708 | 708 | // Is the entry allowed |
709 | - if( $check_entry_display ) { |
|
709 | + if ( $check_entry_display ) { |
|
710 | 710 | |
711 | 711 | $gvid = \GV\Utils::_GET( 'gvid' ); |
712 | 712 | |
713 | - if( $gvid ) { |
|
713 | + if ( $gvid ) { |
|
714 | 714 | $view = \GV\View::by_id( $gvid ); |
715 | 715 | } |
716 | 716 | |
717 | 717 | $entry = self::check_entry_display( $entry, $view ); |
718 | 718 | } |
719 | 719 | |
720 | - if( is_wp_error( $entry ) ) { |
|
720 | + if ( is_wp_error( $entry ) ) { |
|
721 | 721 | gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) ); |
722 | 722 | return false; |
723 | 723 | } |
@@ -751,12 +751,12 @@ discard block |
||
751 | 751 | |
752 | 752 | $value = false; |
753 | 753 | |
754 | - if( 'context' === $val1 ) { |
|
754 | + if ( 'context' === $val1 ) { |
|
755 | 755 | |
756 | 756 | $matching_contexts = array( $val2 ); |
757 | 757 | |
758 | 758 | // We allow for non-standard contexts. |
759 | - switch( $val2 ) { |
|
759 | + switch ( $val2 ) { |
|
760 | 760 | // Check for either single or edit |
761 | 761 | case 'singular': |
762 | 762 | $matching_contexts = array( 'single', 'edit' ); |
@@ -776,8 +776,8 @@ discard block |
||
776 | 776 | |
777 | 777 | // If both are timestamps, cast to string so we can use the > and < comparisons below. |
778 | 778 | if ( $timestamp_1 && $timestamp_2 ) { |
779 | - $val1 = (string) $timestamp_1; |
|
780 | - $val2 = (string) $timestamp_2; |
|
779 | + $val1 = (string)$timestamp_1; |
|
780 | + $val2 = (string)$timestamp_2; |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | switch ( $operation ) { |
@@ -809,18 +809,18 @@ discard block |
||
809 | 809 | $json_val_1 = json_decode( $val1, true ); |
810 | 810 | $json_val_2 = json_decode( $val2, true ); |
811 | 811 | |
812 | - if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
812 | + if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
813 | 813 | |
814 | 814 | $json_in = false; |
815 | - $json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 ); |
|
816 | - $json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 ); |
|
815 | + $json_val_1 = $json_val_1 ? (array)$json_val_1 : array( $val1 ); |
|
816 | + $json_val_2 = $json_val_2 ? (array)$json_val_2 : array( $val2 ); |
|
817 | 817 | |
818 | 818 | // For JSON, we want to compare as "in" or "not in" rather than "contains" |
819 | 819 | foreach ( $json_val_1 as $item_1 ) { |
820 | 820 | foreach ( $json_val_2 as $item_2 ) { |
821 | 821 | $json_in = self::matches_operation( $item_1, $item_2, 'is' ); |
822 | 822 | |
823 | - if( $json_in ) { |
|
823 | + if ( $json_in ) { |
|
824 | 824 | break 2; |
825 | 825 | } |
826 | 826 | } |
@@ -871,10 +871,10 @@ discard block |
||
871 | 871 | public static function check_entry_display( $entry, $view = null ) { |
872 | 872 | |
873 | 873 | if ( ! $entry || is_wp_error( $entry ) ) { |
874 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
874 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
875 | 875 | } |
876 | 876 | |
877 | - if ( empty( $entry['form_id'] ) ) { |
|
877 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
878 | 878 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
879 | 879 | } |
880 | 880 | |
@@ -889,19 +889,19 @@ discard block |
||
889 | 889 | |
890 | 890 | $_gvid = \GV\Utils::_GET( 'gvid' ); |
891 | 891 | |
892 | - if ( $_gvid && $view->ID !== (int) $_gvid ) { |
|
892 | + if ( $_gvid && $view->ID !== (int)$_gvid ) { |
|
893 | 893 | return new WP_Error( 'view_id_not_match_gvid', 'View does not match passed $_GET["gvid"].', $view->ID ); |
894 | 894 | } |
895 | 895 | |
896 | 896 | $view_form_id = $view->form->ID; |
897 | 897 | |
898 | 898 | if ( $view->joins ) { |
899 | - if ( in_array( (int) $entry['form_id'], array_keys( $view::get_joined_forms( $view->ID ) ), true ) ) { |
|
900 | - $view_form_id = $entry['form_id']; |
|
899 | + if ( in_array( (int)$entry[ 'form_id' ], array_keys( $view::get_joined_forms( $view->ID ) ), true ) ) { |
|
900 | + $view_form_id = $entry[ 'form_id' ]; |
|
901 | 901 | } |
902 | 902 | } |
903 | 903 | |
904 | - if ( (int) $view_form_id !== (int) $entry['form_id'] ) { |
|
904 | + if ( (int)$view_form_id !== (int)$entry[ 'form_id' ] ) { |
|
905 | 905 | return new WP_Error( 'view_id_not_match', 'View form source does not match entry form source ID.', $entry ); |
906 | 906 | } |
907 | 907 | |
@@ -909,13 +909,13 @@ discard block |
||
909 | 909 | * Check whether the entry is in the entries subset by running a modified query. |
910 | 910 | */ |
911 | 911 | add_action( 'gravityview/view/query', $entry_subset_callback = function( &$query, $view, $request ) use ( $entry, $view_form_id ) { |
912 | - $_tmp_query = new \GF_Query( $view_form_id, array( |
|
912 | + $_tmp_query = new \GF_Query( $view_form_id, array( |
|
913 | 913 | 'field_filters' => array( |
914 | 914 | 'mode' => 'all', |
915 | 915 | array( |
916 | 916 | 'key' => 'id', |
917 | 917 | 'operation' => 'is', |
918 | - 'value' => $entry['id'] |
|
918 | + 'value' => $entry[ 'id' ] |
|
919 | 919 | ) |
920 | 920 | ) |
921 | 921 | ) ); |
@@ -925,14 +925,14 @@ discard block |
||
925 | 925 | /** @type \GF_Query $query */ |
926 | 926 | $query_parts = $query->_introspect(); |
927 | 927 | |
928 | - $query->where( \GF_Query_Condition::_and( $_tmp_query_parts['where'], $query_parts['where'] ) ); |
|
928 | + $query->where( \GF_Query_Condition::_and( $_tmp_query_parts[ 'where' ], $query_parts[ 'where' ] ) ); |
|
929 | 929 | |
930 | 930 | }, 10, 3 ); |
931 | 931 | |
932 | 932 | // Prevent page offset from being applied to the single entry query; it's used to return to the referring page number |
933 | 933 | add_filter( 'gravityview_search_criteria', $remove_pagenum = function( $criteria ) { |
934 | 934 | |
935 | - $criteria['paging'] = array( |
|
935 | + $criteria[ 'paging' ] = array( |
|
936 | 936 | 'offset' => 0, |
937 | 937 | 'page_size' => 25 |
938 | 938 | ); |
@@ -951,20 +951,20 @@ discard block |
||
951 | 951 | } |
952 | 952 | |
953 | 953 | // This entry is on a View with joins |
954 | - if ( $entries[0]->is_multi() ) { |
|
954 | + if ( $entries[ 0 ]->is_multi() ) { |
|
955 | 955 | |
956 | 956 | $multi_entry_ids = array(); |
957 | 957 | |
958 | - foreach ( $entries[0]->entries as $multi_entry ) { |
|
959 | - $multi_entry_ids[] = (int) $multi_entry->ID; |
|
958 | + foreach ( $entries[ 0 ]->entries as $multi_entry ) { |
|
959 | + $multi_entry_ids[ ] = (int)$multi_entry->ID; |
|
960 | 960 | } |
961 | 961 | |
962 | - if ( ! in_array( (int) $entry['id'], $multi_entry_ids, true ) ) { |
|
962 | + if ( ! in_array( (int)$entry[ 'id' ], $multi_entry_ids, true ) ) { |
|
963 | 963 | remove_action( 'gravityview/view/query', $entry_subset_callback ); |
964 | 964 | return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' ); |
965 | 965 | } |
966 | 966 | |
967 | - } elseif ( (int) $entries[0]->ID !== (int) $entry['id'] ) { |
|
967 | + } elseif ( (int)$entries[ 0 ]->ID !== (int)$entry[ 'id' ] ) { |
|
968 | 968 | remove_action( 'gravityview/view/query', $entry_subset_callback ); |
969 | 969 | return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' ); |
970 | 970 | } |
@@ -1009,18 +1009,18 @@ discard block |
||
1009 | 1009 | * Gravity Forms code to adjust date to locally-configured Time Zone |
1010 | 1010 | * @see GFCommon::format_date() for original code |
1011 | 1011 | */ |
1012 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
1012 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
1013 | 1013 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
1014 | 1014 | |
1015 | - $format = \GV\Utils::get( $atts, 'format' ); |
|
1016 | - $is_human = ! empty( $atts['human'] ); |
|
1017 | - $is_diff = ! empty( $atts['diff'] ); |
|
1018 | - $is_raw = ! empty( $atts['raw'] ); |
|
1019 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
1020 | - $include_time = ! empty( $atts['time'] ); |
|
1015 | + $format = \GV\Utils::get( $atts, 'format' ); |
|
1016 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
1017 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
1018 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
1019 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
1020 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
1021 | 1021 | |
1022 | 1022 | // If we're using time diff, we want to have a different default format |
1023 | - if( empty( $format ) ) { |
|
1023 | + if ( empty( $format ) ) { |
|
1024 | 1024 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
1025 | 1025 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
1026 | 1026 | } |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | // If raw was specified, don't modify the stored value |
1029 | 1029 | if ( $is_raw ) { |
1030 | 1030 | $formatted_date = $date_string; |
1031 | - } elseif( $is_timestamp ) { |
|
1031 | + } elseif ( $is_timestamp ) { |
|
1032 | 1032 | $formatted_date = $date_local_timestamp; |
1033 | 1033 | } elseif ( $is_diff ) { |
1034 | 1034 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | |
1062 | 1062 | $label = \GV\Utils::get( $field, 'label' ); |
1063 | 1063 | |
1064 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
1064 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
1065 | 1065 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
1066 | 1066 | } |
1067 | 1067 | |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | $form = GFAPI::get_form( $form ); |
1089 | 1089 | } |
1090 | 1090 | |
1091 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
1091 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
1092 | 1092 | return GFFormsModel::get_field( $form, $field_id ); |
1093 | 1093 | } else { |
1094 | 1094 | return null; |
@@ -1135,19 +1135,19 @@ discard block |
||
1135 | 1135 | $shortcodes = array(); |
1136 | 1136 | |
1137 | 1137 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
1138 | - if ( empty( $matches ) ){ |
|
1138 | + if ( empty( $matches ) ) { |
|
1139 | 1139 | return false; |
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | foreach ( $matches as $shortcode ) { |
1143 | - if ( $tag === $shortcode[2] ) { |
|
1143 | + if ( $tag === $shortcode[ 2 ] ) { |
|
1144 | 1144 | |
1145 | 1145 | // Changed this to $shortcode instead of true so we get the parsed atts. |
1146 | - $shortcodes[] = $shortcode; |
|
1146 | + $shortcodes[ ] = $shortcode; |
|
1147 | 1147 | |
1148 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
1149 | - foreach( $results as $result ) { |
|
1150 | - $shortcodes[] = $result; |
|
1148 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
1149 | + foreach ( $results as $result ) { |
|
1150 | + $shortcodes[ ] = $result; |
|
1151 | 1151 | } |
1152 | 1152 | } |
1153 | 1153 | } |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | 'post_type' => 'gravityview', |
1180 | 1180 | 'posts_per_page' => 100, |
1181 | 1181 | 'meta_key' => '_gravityview_form_id', |
1182 | - 'meta_value' => (int) $form_id, |
|
1182 | + 'meta_value' => (int)$form_id, |
|
1183 | 1183 | ); |
1184 | 1184 | $args = wp_parse_args( $args, $defaults ); |
1185 | 1185 | $views = get_posts( $args ); |
@@ -1191,21 +1191,21 @@ discard block |
||
1191 | 1191 | |
1192 | 1192 | $data = unserialize( $view->meta_value ); |
1193 | 1193 | |
1194 | - if( ! $data || ! is_array( $data ) ) { |
|
1194 | + if ( ! $data || ! is_array( $data ) ) { |
|
1195 | 1195 | continue; |
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | foreach ( $data as $datum ) { |
1199 | - if ( ! empty( $datum[2] ) && (int) $datum[2] === (int) $form_id ) { |
|
1200 | - $joined_forms[] = $view->post_id; |
|
1199 | + if ( ! empty( $datum[ 2 ] ) && (int)$datum[ 2 ] === (int)$form_id ) { |
|
1200 | + $joined_forms[ ] = $view->post_id; |
|
1201 | 1201 | } |
1202 | 1202 | } |
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | if ( $joined_forms ) { |
1206 | - $joined_args = array( |
|
1206 | + $joined_args = array( |
|
1207 | 1207 | 'post_type' => 'gravityview', |
1208 | - 'posts_per_page' => $args['posts_per_page'], |
|
1208 | + 'posts_per_page' => $args[ 'posts_per_page' ], |
|
1209 | 1209 | 'post__in' => $joined_forms, |
1210 | 1210 | ); |
1211 | 1211 | $views = array_merge( $views, get_posts( $joined_args ) ); |
@@ -1361,7 +1361,7 @@ discard block |
||
1361 | 1361 | |
1362 | 1362 | $directory_widgets = wp_parse_args( $view_widgets, $defaults ); |
1363 | 1363 | |
1364 | - if( $json_decode ) { |
|
1364 | + if ( $json_decode ) { |
|
1365 | 1365 | $directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' ); |
1366 | 1366 | } |
1367 | 1367 | |
@@ -1376,7 +1376,7 @@ discard block |
||
1376 | 1376 | * @return string html |
1377 | 1377 | */ |
1378 | 1378 | public static function get_sortable_fields( $formid, $current = '' ) { |
1379 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default (Entry ID)', 'gravityview' ) .'</option>'; |
|
1379 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default (Entry ID)', 'gravityview' ) . '</option>'; |
|
1380 | 1380 | |
1381 | 1381 | if ( empty( $formid ) ) { |
1382 | 1382 | return $output; |
@@ -1393,11 +1393,11 @@ discard block |
||
1393 | 1393 | $blocklist_field_types = apply_filters( 'gravityview_blocklist_field_types', $blocklist_field_types, null ); |
1394 | 1394 | |
1395 | 1395 | foreach ( $fields as $id => $field ) { |
1396 | - if ( in_array( $field['type'], $blocklist_field_types ) ) { |
|
1396 | + if ( in_array( $field[ 'type' ], $blocklist_field_types ) ) { |
|
1397 | 1397 | continue; |
1398 | 1398 | } |
1399 | 1399 | |
1400 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1400 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1401 | 1401 | } |
1402 | 1402 | } |
1403 | 1403 | |
@@ -1440,16 +1440,16 @@ discard block |
||
1440 | 1440 | $blocklist_field_types = apply_filters( 'gravityview_blocklist_field_types', $blocklist_field_types, null ); |
1441 | 1441 | |
1442 | 1442 | // TODO: Convert to using array_filter |
1443 | - foreach( $fields as $id => $field ) { |
|
1443 | + foreach ( $fields as $id => $field ) { |
|
1444 | 1444 | |
1445 | - if( in_array( $field['type'], $blocklist_field_types ) ) { |
|
1445 | + if ( in_array( $field[ 'type' ], $blocklist_field_types ) ) { |
|
1446 | 1446 | unset( $fields[ $id ] ); |
1447 | 1447 | } |
1448 | 1448 | |
1449 | 1449 | /** |
1450 | 1450 | * Merge date and time subfields. |
1451 | 1451 | */ |
1452 | - if ( in_array( $field['type'], array( 'date', 'time' ) ) && ! empty( $field['parent'] ) ) { |
|
1452 | + if ( in_array( $field[ 'type' ], array( 'date', 'time' ) ) && ! empty( $field[ 'parent' ] ) ) { |
|
1453 | 1453 | $fields[ intval( $id ) ] = array( |
1454 | 1454 | 'label' => \GV\Utils::get( $field, 'parent/label' ), |
1455 | 1455 | 'parent' => null, |
@@ -1499,14 +1499,14 @@ discard block |
||
1499 | 1499 | * @param int|array $field field key or field array |
1500 | 1500 | * @return boolean |
1501 | 1501 | */ |
1502 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1502 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1503 | 1503 | |
1504 | 1504 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1505 | 1505 | $form = self::get_form( $form ); |
1506 | 1506 | } |
1507 | 1507 | |
1508 | 1508 | // If entry meta, it's a string. Otherwise, numeric |
1509 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1509 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1510 | 1510 | $type = $field; |
1511 | 1511 | } else { |
1512 | 1512 | $type = self::get_field_type( $form, $field ); |
@@ -1520,9 +1520,9 @@ discard block |
||
1520 | 1520 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1521 | 1521 | |
1522 | 1522 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1523 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1524 | - if( true === $gv_field->is_numeric ) { |
|
1525 | - $numeric_types[] = $gv_field->is_numeric; |
|
1523 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1524 | + if ( true === $gv_field->is_numeric ) { |
|
1525 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1526 | 1526 | } |
1527 | 1527 | } |
1528 | 1528 | |
@@ -1673,20 +1673,20 @@ discard block |
||
1673 | 1673 | $final_atts = array_filter( $final_atts ); |
1674 | 1674 | |
1675 | 1675 | // If the href wasn't passed as an attribute, use the value passed to the function |
1676 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1677 | - $final_atts['href'] = $href; |
|
1676 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1677 | + $final_atts[ 'href' ] = $href; |
|
1678 | 1678 | } |
1679 | 1679 | |
1680 | - if ( isset( $final_atts['href'] ) ) { |
|
1681 | - $final_atts['href'] = esc_url_raw( $final_atts['href'] ); |
|
1680 | + if ( isset( $final_atts[ 'href' ] ) ) { |
|
1681 | + $final_atts[ 'href' ] = esc_url_raw( $final_atts[ 'href' ] ); |
|
1682 | 1682 | } |
1683 | 1683 | |
1684 | 1684 | /** |
1685 | 1685 | * Fix potential security issue with target=_blank |
1686 | 1686 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
1687 | 1687 | */ |
1688 | - if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
1689 | - $final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1688 | + if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
1689 | + $final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1690 | 1690 | } |
1691 | 1691 | |
1692 | 1692 | // Sort the attributes alphabetically, to help testing |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1699 | 1699 | } |
1700 | 1700 | |
1701 | - if( '' !== $output ) { |
|
1701 | + if ( '' !== $output ) { |
|
1702 | 1702 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1703 | 1703 | } |
1704 | 1704 | |
@@ -1725,7 +1725,7 @@ discard block |
||
1725 | 1725 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1726 | 1726 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1727 | 1727 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
1728 | - $merged[] = $value; |
|
1728 | + $merged[ ] = $value; |
|
1729 | 1729 | } else { |
1730 | 1730 | $merged[ $key ] = $value; |
1731 | 1731 | } |
@@ -1758,7 +1758,7 @@ discard block |
||
1758 | 1758 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1759 | 1759 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1760 | 1760 | */ |
1761 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1761 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1762 | 1762 | |
1763 | 1763 | return get_users( $get_users_settings ); |
1764 | 1764 | } |
@@ -1778,11 +1778,11 @@ discard block |
||
1778 | 1778 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
1779 | 1779 | |
1780 | 1780 | // If $cap is defined, only show notice if user has capability |
1781 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1781 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1782 | 1782 | return ''; |
1783 | 1783 | } |
1784 | 1784 | |
1785 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1785 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1786 | 1786 | } |
1787 | 1787 | |
1788 | 1788 | /** |