@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | |
127 | 127 | $form = false; |
128 | 128 | |
129 | - if( $entry ) { |
|
130 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
129 | + if ( $entry ) { |
|
130 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | return $form; |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | |
194 | 194 | $has_transaction_data = rgar( $entry, $meta, false ); |
195 | 195 | |
196 | - if( ! empty( $has_transaction_data ) ) { |
|
196 | + if ( ! empty( $has_transaction_data ) ) { |
|
197 | 197 | break; |
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | - return (bool) $has_transaction_data; |
|
201 | + return (bool)$has_transaction_data; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
238 | 238 | |
239 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
239 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
240 | 240 | |
241 | 241 | return $result; |
242 | 242 | } |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
255 | 255 | */ |
256 | - public static function get_forms( $active = true, $trash = false ) { |
|
256 | + public static function get_forms( $active = true, $trash = false ) { |
|
257 | 257 | $forms = array(); |
258 | 258 | if ( class_exists( 'GFAPI' ) ) { |
259 | - if( 'any' === $active ) { |
|
259 | + if ( 'any' === $active ) { |
|
260 | 260 | $active_forms = GFAPI::get_forms( true, $trash ); |
261 | 261 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
262 | 262 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | $has_post_fields = false; |
288 | 288 | |
289 | 289 | if ( $form ) { |
290 | - foreach ( $form['fields'] as $field ) { |
|
291 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
292 | - $fields["{$field['id']}"] = array( |
|
290 | + foreach ( $form[ 'fields' ] as $field ) { |
|
291 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
292 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
293 | 293 | 'label' => rgar( $field, 'label' ), |
294 | 294 | 'parent' => null, |
295 | 295 | 'type' => rgar( $field, 'type' ), |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | ); |
299 | 299 | } |
300 | 300 | |
301 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
302 | - foreach ( $field['inputs'] as $input ) { |
|
301 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
302 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
303 | 303 | |
304 | - if( ! empty( $input['isHidden'] ) ) { |
|
304 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
305 | 305 | continue; |
306 | 306 | } |
307 | 307 | |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | * @hack |
310 | 310 | * In case of email/email confirmation, the input for email has the same id as the parent field |
311 | 311 | */ |
312 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
312 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
313 | 313 | continue; |
314 | 314 | } |
315 | - $fields["{$input['id']}"] = array( |
|
315 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
316 | 316 | 'label' => rgar( $input, 'label' ), |
317 | 317 | 'customLabel' => rgar( $input, 'customLabel' ), |
318 | 318 | 'parent' => $field, |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | |
327 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
327 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
328 | 328 | $has_product_fields = true; |
329 | 329 | } |
330 | 330 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @since 1.7 |
339 | 339 | */ |
340 | 340 | if ( $has_post_fields ) { |
341 | - $fields['post_id'] = array( |
|
341 | + $fields[ 'post_id' ] = array( |
|
342 | 342 | 'label' => __( 'Post ID', 'gravityview' ), |
343 | 343 | 'type' => 'post_id', |
344 | 344 | ); |
@@ -349,10 +349,10 @@ discard block |
||
349 | 349 | $payment_fields = GravityView_Fields::get_all( 'pricing' ); |
350 | 350 | |
351 | 351 | foreach ( $payment_fields as $payment_field ) { |
352 | - if( isset( $fields["{$payment_field->name}"] ) ) { |
|
352 | + if ( isset( $fields[ "{$payment_field->name}" ] ) ) { |
|
353 | 353 | continue; |
354 | 354 | } |
355 | - $fields["{$payment_field->name}"] = array( |
|
355 | + $fields[ "{$payment_field->name}" ] = array( |
|
356 | 356 | 'label' => $payment_field->label, |
357 | 357 | 'desc' => $payment_field->description, |
358 | 358 | 'type' => $payment_field->name, |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | |
385 | 385 | $fields = array(); |
386 | 386 | |
387 | - foreach ( $extra_fields as $key => $field ){ |
|
388 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
389 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
387 | + foreach ( $extra_fields as $key => $field ) { |
|
388 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
389 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
@@ -426,32 +426,32 @@ discard block |
||
426 | 426 | 'search_criteria' => null, |
427 | 427 | 'sorting' => null, |
428 | 428 | 'paging' => null, |
429 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
429 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
430 | 430 | ); |
431 | 431 | |
432 | 432 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
433 | 433 | |
434 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
435 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
434 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
435 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
436 | 436 | |
437 | 437 | if ( ! is_array( $filter ) ) { |
438 | 438 | continue; |
439 | 439 | } |
440 | 440 | |
441 | 441 | // By default, we want searches to be wildcard for each field. |
442 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
442 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
443 | 443 | |
444 | 444 | /** |
445 | 445 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
446 | 446 | * @param string $operator Existing search operator |
447 | 447 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
448 | 448 | */ |
449 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
449 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | // don't send just the [mode] without any field filter. |
453 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
454 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
453 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
454 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | } |
@@ -462,36 +462,36 @@ discard block |
||
462 | 462 | * Prepare date formats to be in Gravity Forms DB format; |
463 | 463 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
464 | 464 | */ |
465 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
465 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
466 | 466 | |
467 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
467 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
468 | 468 | |
469 | 469 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
470 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
470 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
471 | 471 | |
472 | 472 | if ( $date ) { |
473 | 473 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
474 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
474 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
475 | 475 | } else { |
476 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
476 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
477 | 477 | |
478 | 478 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
479 | - unset( $criteria['search_criteria'][ $key ] ); |
|
479 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | } |
483 | 483 | |
484 | 484 | |
485 | 485 | // Calculate the context view id and send it to the advanced filter |
486 | - if( GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
487 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
486 | + if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
487 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
488 | 488 | } elseif ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
489 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
489 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
490 | 490 | } elseif ( 'delete' === GFForms::get( 'action' ) ) { |
491 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
492 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
491 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
492 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
493 | 493 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
494 | - $criteria['context_view_id'] = null; |
|
494 | + $criteria[ 'context_view_id' ] = null; |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | /** |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | * @param array $form_ids Forms to search |
501 | 501 | * @param int $view_id ID of the view being used to search |
502 | 502 | */ |
503 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
503 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
504 | 504 | |
505 | 505 | return (array)$criteria; |
506 | 506 | } |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | /** Reduce # of database calls */ |
531 | 531 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
532 | 532 | |
533 | - if ( ! empty( $criteria['cache'] ) ) { |
|
533 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
534 | 534 | |
535 | 535 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
536 | 536 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | |
539 | 539 | // Still update the total count when using cached results |
540 | 540 | if ( ! is_null( $total ) ) { |
541 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
541 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | $return = $entries; |
@@ -558,9 +558,9 @@ discard block |
||
558 | 558 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
559 | 559 | |
560 | 560 | // No entries returned from gravityview_before_get_entries |
561 | - if( is_null( $entries ) ) { |
|
561 | + if ( is_null( $entries ) ) { |
|
562 | 562 | |
563 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
563 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
564 | 564 | |
565 | 565 | if ( is_wp_error( $entries ) ) { |
566 | 566 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | } |
570 | 570 | } |
571 | 571 | |
572 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
572 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
573 | 573 | |
574 | 574 | // Cache results |
575 | 575 | $Cache->set( $entries, 'entries' ); |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | */ |
675 | 675 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
676 | 676 | |
677 | - if( $check_entry_display ) { |
|
677 | + if ( $check_entry_display ) { |
|
678 | 678 | // Is the entry allowed |
679 | 679 | $entry = self::check_entry_display( $entry ); |
680 | 680 | } |
@@ -707,12 +707,12 @@ discard block |
||
707 | 707 | |
708 | 708 | $value = false; |
709 | 709 | |
710 | - if( 'context' === $val1 ) { |
|
710 | + if ( 'context' === $val1 ) { |
|
711 | 711 | |
712 | 712 | $matching_contexts = array( $val2 ); |
713 | 713 | |
714 | 714 | // We allow for non-standard contexts. |
715 | - switch( $val2 ) { |
|
715 | + switch ( $val2 ) { |
|
716 | 716 | // Check for either single or edit |
717 | 717 | case 'singular': |
718 | 718 | $matching_contexts = array( 'single', 'edit' ); |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | return false; |
774 | 774 | } |
775 | 775 | |
776 | - if ( empty( $entry['form_id'] ) ) { |
|
776 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
777 | 777 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
778 | 778 | return false; |
779 | 779 | } |
@@ -781,26 +781,26 @@ discard block |
||
781 | 781 | $criteria = self::calculate_get_entries_criteria(); |
782 | 782 | |
783 | 783 | // Make sure the current View is connected to the same form as the Entry |
784 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
785 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
784 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
785 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
786 | 786 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
787 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
788 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
787 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
788 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
789 | 789 | return false; |
790 | 790 | } |
791 | 791 | } |
792 | 792 | |
793 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
793 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
794 | 794 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
795 | 795 | return $entry; |
796 | 796 | } |
797 | 797 | |
798 | - $search_criteria = $criteria['search_criteria']; |
|
798 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
799 | 799 | unset( $criteria ); |
800 | 800 | |
801 | 801 | // check entry status |
802 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
803 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
802 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
803 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
804 | 804 | return false; |
805 | 805 | } |
806 | 806 | |
@@ -808,41 +808,41 @@ discard block |
||
808 | 808 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
809 | 809 | |
810 | 810 | // field_filters |
811 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
811 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
812 | 812 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
813 | 813 | return $entry; |
814 | 814 | } |
815 | 815 | |
816 | - $filters = $search_criteria['field_filters']; |
|
816 | + $filters = $search_criteria[ 'field_filters' ]; |
|
817 | 817 | unset( $search_criteria ); |
818 | 818 | |
819 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
820 | - unset( $filters['mode'] ); |
|
819 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
820 | + unset( $filters[ 'mode' ] ); |
|
821 | 821 | |
822 | - $form = self::get_form( $entry['form_id'] ); |
|
822 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
823 | 823 | |
824 | 824 | foreach ( $filters as $filter ) { |
825 | 825 | |
826 | - if ( ! isset( $filter['key'] ) ) { |
|
826 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
827 | 827 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Filter key not set', $filter ); |
828 | 828 | continue; |
829 | 829 | } |
830 | 830 | |
831 | - $k = $filter['key']; |
|
831 | + $k = $filter[ 'key' ]; |
|
832 | 832 | |
833 | 833 | if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
834 | 834 | $field_value = $entry[ $k ]; |
835 | 835 | $field = null; |
836 | 836 | } else { |
837 | 837 | $field = self::get_field( $form, $k ); |
838 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
838 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
839 | 839 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
840 | 840 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? rgar( $field_value, $k ) : $field_value; |
841 | 841 | } |
842 | 842 | |
843 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
843 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
844 | 844 | |
845 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
845 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
846 | 846 | |
847 | 847 | // verify if we are already free to go! |
848 | 848 | if ( ! $is_value_match && 'all' === $mode ) { |
@@ -900,18 +900,18 @@ discard block |
||
900 | 900 | * Gravity Forms code to adjust date to locally-configured Time Zone |
901 | 901 | * @see GFCommon::format_date() for original code |
902 | 902 | */ |
903 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
903 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
904 | 904 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
905 | 905 | |
906 | - $format = rgar( $atts, 'format' ); |
|
907 | - $is_human = ! empty( $atts['human'] ); |
|
908 | - $is_diff = ! empty( $atts['diff'] ); |
|
909 | - $is_raw = ! empty( $atts['raw'] ); |
|
910 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
911 | - $include_time = ! empty( $atts['time'] ); |
|
906 | + $format = rgar( $atts, 'format' ); |
|
907 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
908 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
909 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
910 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
911 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
912 | 912 | |
913 | 913 | // If we're using time diff, we want to have a different default format |
914 | - if( empty( $format ) ) { |
|
914 | + if ( empty( $format ) ) { |
|
915 | 915 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
916 | 916 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
917 | 917 | } |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | // If raw was specified, don't modify the stored value |
920 | 920 | if ( $is_raw ) { |
921 | 921 | $formatted_date = $date_string; |
922 | - } elseif( $is_timestamp ) { |
|
922 | + } elseif ( $is_timestamp ) { |
|
923 | 923 | $formatted_date = $date_local_timestamp; |
924 | 924 | } elseif ( $is_diff ) { |
925 | 925 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -953,7 +953,7 @@ discard block |
||
953 | 953 | |
954 | 954 | $label = rgar( $field, 'label' ); |
955 | 955 | |
956 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
956 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
957 | 957 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
958 | 958 | } |
959 | 959 | |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | $form = GFAPI::get_form( $form ); |
982 | 982 | } |
983 | 983 | |
984 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
984 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
985 | 985 | return GFFormsModel::get_field( $form, $field_id ); |
986 | 986 | } else { |
987 | 987 | return null; |
@@ -1028,19 +1028,19 @@ discard block |
||
1028 | 1028 | $shortcodes = array(); |
1029 | 1029 | |
1030 | 1030 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
1031 | - if ( empty( $matches ) ){ |
|
1031 | + if ( empty( $matches ) ) { |
|
1032 | 1032 | return false; |
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | foreach ( $matches as $shortcode ) { |
1036 | - if ( $tag === $shortcode[2] ) { |
|
1036 | + if ( $tag === $shortcode[ 2 ] ) { |
|
1037 | 1037 | |
1038 | 1038 | // Changed this to $shortcode instead of true so we get the parsed atts. |
1039 | - $shortcodes[] = $shortcode; |
|
1039 | + $shortcodes[ ] = $shortcode; |
|
1040 | 1040 | |
1041 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
1042 | - foreach( $results as $result ) { |
|
1043 | - $shortcodes[] = $result; |
|
1041 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
1042 | + foreach ( $results as $result ) { |
|
1043 | + $shortcodes[ ] = $result; |
|
1044 | 1044 | } |
1045 | 1045 | } |
1046 | 1046 | } |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | public static function get_directory_fields( $post_id, $apply_filter = true ) { |
1185 | 1185 | $fields = get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
1186 | 1186 | |
1187 | - if( $apply_filter ) { |
|
1187 | + if ( $apply_filter ) { |
|
1188 | 1188 | /** |
1189 | 1189 | * @filter `gravityview/configuration/fields` Filter the View fields' configuration array |
1190 | 1190 | * @since 1.6.5 |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | * @return string html |
1208 | 1208 | */ |
1209 | 1209 | public static function get_sortable_fields( $formid, $current = '' ) { |
1210 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1210 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
1211 | 1211 | |
1212 | 1212 | if ( empty( $formid ) ) { |
1213 | 1213 | return $output; |
@@ -1220,11 +1220,11 @@ discard block |
||
1220 | 1220 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1221 | 1221 | |
1222 | 1222 | foreach ( $fields as $id => $field ) { |
1223 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1223 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1224 | 1224 | continue; |
1225 | 1225 | } |
1226 | 1226 | |
1227 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1227 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1228 | 1228 | } |
1229 | 1229 | } |
1230 | 1230 | |
@@ -1259,9 +1259,9 @@ discard block |
||
1259 | 1259 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1260 | 1260 | |
1261 | 1261 | // TODO: Convert to using array_filter |
1262 | - foreach( $fields as $id => $field ) { |
|
1262 | + foreach ( $fields as $id => $field ) { |
|
1263 | 1263 | |
1264 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1264 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1265 | 1265 | unset( $fields[ $id ] ); |
1266 | 1266 | } |
1267 | 1267 | } |
@@ -1302,14 +1302,14 @@ discard block |
||
1302 | 1302 | * @param int|array $field field key or field array |
1303 | 1303 | * @return boolean |
1304 | 1304 | */ |
1305 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1305 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1306 | 1306 | |
1307 | 1307 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1308 | 1308 | $form = self::get_form( $form ); |
1309 | 1309 | } |
1310 | 1310 | |
1311 | 1311 | // If entry meta, it's a string. Otherwise, numeric |
1312 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1312 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1313 | 1313 | $type = $field; |
1314 | 1314 | } else { |
1315 | 1315 | $type = self::get_field_type( $form, $field ); |
@@ -1323,9 +1323,9 @@ discard block |
||
1323 | 1323 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1324 | 1324 | |
1325 | 1325 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1326 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1327 | - if( true === $gv_field->is_numeric ) { |
|
1328 | - $numeric_types[] = $gv_field->is_numeric; |
|
1326 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1327 | + if ( true === $gv_field->is_numeric ) { |
|
1328 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1329 | 1329 | } |
1330 | 1330 | } |
1331 | 1331 | |
@@ -1475,18 +1475,18 @@ discard block |
||
1475 | 1475 | $final_atts = array_filter( $final_atts ); |
1476 | 1476 | |
1477 | 1477 | // If the href wasn't passed as an attribute, use the value passed to the function |
1478 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1479 | - $final_atts['href'] = $href; |
|
1478 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1479 | + $final_atts[ 'href' ] = $href; |
|
1480 | 1480 | } |
1481 | 1481 | |
1482 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1482 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1483 | 1483 | |
1484 | 1484 | /** |
1485 | 1485 | * Fix potential security issue with target=_blank |
1486 | 1486 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
1487 | 1487 | */ |
1488 | - if( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
1489 | - $final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1488 | + if ( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
1489 | + $final_atts[ 'rel' ] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | // Sort the attributes alphabetically, to help testing |
@@ -1498,7 +1498,7 @@ discard block |
||
1498 | 1498 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1499 | 1499 | } |
1500 | 1500 | |
1501 | - if( '' !== $output ) { |
|
1501 | + if ( '' !== $output ) { |
|
1502 | 1502 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1503 | 1503 | } |
1504 | 1504 | |
@@ -1525,7 +1525,7 @@ discard block |
||
1525 | 1525 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1526 | 1526 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1527 | 1527 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
1528 | - $merged[] = $value; |
|
1528 | + $merged[ ] = $value; |
|
1529 | 1529 | } else { |
1530 | 1530 | $merged[ $key ] = $value; |
1531 | 1531 | } |
@@ -1558,7 +1558,7 @@ discard block |
||
1558 | 1558 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1559 | 1559 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1560 | 1560 | */ |
1561 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1561 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1562 | 1562 | |
1563 | 1563 | return get_users( $get_users_settings ); |
1564 | 1564 | } |
@@ -1578,11 +1578,11 @@ discard block |
||
1578 | 1578 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
1579 | 1579 | |
1580 | 1580 | // If $cap is defined, only show notice if user has capability |
1581 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1581 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1582 | 1582 | return ''; |
1583 | 1583 | } |
1584 | 1584 | |
1585 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1585 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1586 | 1586 | } |
1587 | 1587 | |
1588 | 1588 | /** |