@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @see GVCommon::get_form_fields() |
| 59 | 59 | * @access public |
| 60 | - * @param string|array $form_id (default: '') or $form object |
|
| 60 | + * @param string|array $form (default: '') or $form object |
|
| 61 | 61 | * @return array |
| 62 | 62 | */ |
| 63 | 63 | function gravityview_get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
@@ -219,7 +219,6 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @see GravityView_Template::template_id |
| 221 | 221 | * |
| 222 | - * @param int $view_id The ID of the View to get the layout of |
|
| 223 | 222 | * |
| 224 | 223 | * @return string GravityView_Template::template_id value. Empty string if not. |
| 225 | 224 | */ |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | $form = false; |
| 127 | 127 | |
| 128 | - if( $entry ) { |
|
| 129 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
| 128 | + if ( $entry ) { |
|
| 129 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | return $form; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - return (bool) $has_transaction_data; |
|
| 205 | + return (bool)$has_transaction_data; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
| 242 | 242 | |
| 243 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
| 243 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
| 244 | 244 | |
| 245 | 245 | return $result; |
| 246 | 246 | } |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
| 259 | 259 | */ |
| 260 | - public static function get_forms( $active = true, $trash = false ) { |
|
| 260 | + public static function get_forms( $active = true, $trash = false ) { |
|
| 261 | 261 | $forms = array(); |
| 262 | 262 | if ( class_exists( 'GFAPI' ) ) { |
| 263 | - if( 'any' === $active ) { |
|
| 263 | + if ( 'any' === $active ) { |
|
| 264 | 264 | $active_forms = GFAPI::get_forms( true, $trash ); |
| 265 | 265 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
| 266 | 266 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | $has_post_fields = false; |
| 292 | 292 | |
| 293 | 293 | if ( $form ) { |
| 294 | - foreach ( $form['fields'] as $field ) { |
|
| 295 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
| 296 | - $fields["{$field['id']}"] = array( |
|
| 294 | + foreach ( $form[ 'fields' ] as $field ) { |
|
| 295 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
| 296 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
| 297 | 297 | 'label' => \GV\Utils::get( $field, 'label' ), |
| 298 | 298 | 'parent' => null, |
| 299 | 299 | 'type' => \GV\Utils::get( $field, 'type' ), |
@@ -302,10 +302,10 @@ discard block |
||
| 302 | 302 | ); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
| 306 | - foreach ( $field['inputs'] as $input ) { |
|
| 305 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
| 306 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
| 307 | 307 | |
| 308 | - if( ! empty( $input['isHidden'] ) ) { |
|
| 308 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
| 309 | 309 | continue; |
| 310 | 310 | } |
| 311 | 311 | |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | * @hack |
| 314 | 314 | * In case of email/email confirmation, the input for email has the same id as the parent field |
| 315 | 315 | */ |
| 316 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
| 316 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
| 317 | 317 | continue; |
| 318 | 318 | } |
| 319 | - $fields["{$input['id']}"] = array( |
|
| 319 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
| 320 | 320 | 'label' => \GV\Utils::get( $input, 'label' ), |
| 321 | 321 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
| 322 | 322 | 'parent' => $field, |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | |
| 331 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
| 331 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
| 332 | 332 | $has_product_fields = true; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @since 1.7 |
| 343 | 343 | */ |
| 344 | 344 | if ( $has_post_fields ) { |
| 345 | - $fields['post_id'] = array( |
|
| 345 | + $fields[ 'post_id' ] = array( |
|
| 346 | 346 | 'label' => __( 'Post ID', 'gravityview' ), |
| 347 | 347 | 'type' => 'post_id', |
| 348 | 348 | ); |
@@ -355,11 +355,11 @@ discard block |
||
| 355 | 355 | foreach ( $payment_fields as $payment_field ) { |
| 356 | 356 | |
| 357 | 357 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
| 358 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
| 358 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
| 359 | 359 | continue; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $fields["{$payment_field->name}"] = array( |
|
| 362 | + $fields[ "{$payment_field->name}" ] = array( |
|
| 363 | 363 | 'label' => $payment_field->label, |
| 364 | 364 | 'desc' => $payment_field->description, |
| 365 | 365 | 'type' => $payment_field->name, |
@@ -391,9 +391,9 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | $fields = array(); |
| 393 | 393 | |
| 394 | - foreach ( $extra_fields as $key => $field ){ |
|
| 395 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
| 396 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
| 394 | + foreach ( $extra_fields as $key => $field ) { |
|
| 395 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
| 396 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | |
@@ -433,33 +433,33 @@ discard block |
||
| 433 | 433 | 'search_criteria' => null, |
| 434 | 434 | 'sorting' => null, |
| 435 | 435 | 'paging' => null, |
| 436 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
| 436 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
| 437 | 437 | 'context_view_id' => null, |
| 438 | 438 | ); |
| 439 | 439 | |
| 440 | 440 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
| 441 | 441 | |
| 442 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) && is_array( $criteria['search_criteria']['field_filters'] ) ) { |
|
| 443 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
| 442 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) && is_array( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 443 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
| 444 | 444 | |
| 445 | 445 | if ( ! is_array( $filter ) ) { |
| 446 | 446 | continue; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | // By default, we want searches to be wildcard for each field. |
| 450 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 450 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
| 451 | 451 | |
| 452 | 452 | /** |
| 453 | 453 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
| 454 | 454 | * @param string $operator Existing search operator |
| 455 | 455 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 456 | 456 | */ |
| 457 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
| 457 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | // don't send just the [mode] without any field filter. |
| 461 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
| 462 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
| 461 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 462 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | } |
@@ -470,33 +470,33 @@ discard block |
||
| 470 | 470 | * Prepare date formats to be in Gravity Forms DB format; |
| 471 | 471 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
| 472 | 472 | */ |
| 473 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
| 473 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
| 474 | 474 | |
| 475 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
| 475 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
| 476 | 476 | |
| 477 | 477 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
| 478 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
| 478 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 479 | 479 | |
| 480 | 480 | if ( $date ) { |
| 481 | 481 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
| 482 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 482 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 483 | 483 | } else { |
| 484 | - gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria['search_criteria'][ $key ] ) ); |
|
| 484 | + gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria[ 'search_criteria' ][ $key ] ) ); |
|
| 485 | 485 | |
| 486 | 486 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
| 487 | - unset( $criteria['search_criteria'][ $key ] ); |
|
| 487 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - if ( empty( $criteria['context_view_id'] ) ) { |
|
| 492 | + if ( empty( $criteria[ 'context_view_id' ] ) ) { |
|
| 493 | 493 | // Calculate the context view id and send it to the advanced filter |
| 494 | 494 | if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
| 495 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 495 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 496 | 496 | } else if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
| 497 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 497 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 498 | 498 | } else if ( 'delete' === GFForms::get( 'action' ) ) { |
| 499 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
| 499 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | 502 | |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * @param array $form_ids Forms to search |
| 507 | 507 | * @param int $view_id ID of the view being used to search |
| 508 | 508 | */ |
| 509 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
| 509 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
| 510 | 510 | |
| 511 | 511 | return (array)$criteria; |
| 512 | 512 | } |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | /** Reduce # of database calls */ |
| 542 | 542 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
| 543 | 543 | |
| 544 | - if ( ! empty( $criteria['cache'] ) ) { |
|
| 544 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
| 545 | 545 | |
| 546 | 546 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
| 547 | 547 | |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | |
| 550 | 550 | // Still update the total count when using cached results |
| 551 | 551 | if ( ! is_null( $total ) ) { |
| 552 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
| 552 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | $return = $entries; |
@@ -571,9 +571,9 @@ discard block |
||
| 571 | 571 | $entries = apply_filters_ref_array( 'gravityview_before_get_entries', array( null, $criteria, $passed_criteria, &$total ) ); |
| 572 | 572 | |
| 573 | 573 | // No entries returned from gravityview_before_get_entries |
| 574 | - if( is_null( $entries ) ) { |
|
| 574 | + if ( is_null( $entries ) ) { |
|
| 575 | 575 | |
| 576 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
| 576 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
| 577 | 577 | |
| 578 | 578 | if ( is_wp_error( $entries ) ) { |
| 579 | 579 | gravityview()->log->error( '{error}', array( 'error' => $entries->get_error_message(), 'data' => $entries ) ); |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
| 587 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
| 588 | 588 | |
| 589 | 589 | // Cache results |
| 590 | 590 | $Cache->set( $entries, 'entries' ); |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | */ |
| 697 | 697 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry, $view ); |
| 698 | 698 | |
| 699 | - if( $check_entry_display ) { |
|
| 699 | + if ( $check_entry_display ) { |
|
| 700 | 700 | if ( ! $view ) { |
| 701 | 701 | $view = \GV\View::by_id( \GravityView_View::getInstance()->getViewId() ); // @todo Bad legacy context, provide $view parameter! |
| 702 | 702 | gravityview()->log->warning( '$view parameter not provided! Context assumed from legacy context mocks. This is unreliable!' ); |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | $entry = self::check_entry_display( $entry, $view ); |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - if( is_wp_error( $entry ) ) { |
|
| 709 | + if ( is_wp_error( $entry ) ) { |
|
| 710 | 710 | gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) ); |
| 711 | 711 | return false; |
| 712 | 712 | } |
@@ -740,12 +740,12 @@ discard block |
||
| 740 | 740 | |
| 741 | 741 | $value = false; |
| 742 | 742 | |
| 743 | - if( 'context' === $val1 ) { |
|
| 743 | + if ( 'context' === $val1 ) { |
|
| 744 | 744 | |
| 745 | 745 | $matching_contexts = array( $val2 ); |
| 746 | 746 | |
| 747 | 747 | // We allow for non-standard contexts. |
| 748 | - switch( $val2 ) { |
|
| 748 | + switch ( $val2 ) { |
|
| 749 | 749 | // Check for either single or edit |
| 750 | 750 | case 'singular': |
| 751 | 751 | $matching_contexts = array( 'single', 'edit' ); |
@@ -788,18 +788,18 @@ discard block |
||
| 788 | 788 | $json_val_1 = json_decode( $val1, true ); |
| 789 | 789 | $json_val_2 = json_decode( $val2, true ); |
| 790 | 790 | |
| 791 | - if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
| 791 | + if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
| 792 | 792 | |
| 793 | 793 | $json_in = false; |
| 794 | - $json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 ); |
|
| 795 | - $json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 ); |
|
| 794 | + $json_val_1 = $json_val_1 ? (array)$json_val_1 : array( $val1 ); |
|
| 795 | + $json_val_2 = $json_val_2 ? (array)$json_val_2 : array( $val2 ); |
|
| 796 | 796 | |
| 797 | 797 | // For JSON, we want to compare as "in" or "not in" rather than "contains" |
| 798 | 798 | foreach ( $json_val_1 as $item_1 ) { |
| 799 | 799 | foreach ( $json_val_2 as $item_2 ) { |
| 800 | 800 | $json_in = self::matches_operation( $item_1, $item_2, 'is' ); |
| 801 | 801 | |
| 802 | - if( $json_in ) { |
|
| 802 | + if ( $json_in ) { |
|
| 803 | 803 | break 2; |
| 804 | 804 | } |
| 805 | 805 | } |
@@ -850,10 +850,10 @@ discard block |
||
| 850 | 850 | public static function check_entry_display( $entry, $view = null ) { |
| 851 | 851 | |
| 852 | 852 | if ( ! $entry || is_wp_error( $entry ) ) { |
| 853 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
| 853 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | - if ( empty( $entry['form_id'] ) ) { |
|
| 856 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
| 857 | 857 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
| 858 | 858 | } |
| 859 | 859 | |
@@ -869,12 +869,12 @@ discard block |
||
| 869 | 869 | $view_form_id = $view->form->ID; |
| 870 | 870 | |
| 871 | 871 | if ( $view->joins ) { |
| 872 | - if ( in_array( (int)$entry['form_id'], array_keys( $view::get_joined_forms( $view->ID ) ), true ) ) { |
|
| 873 | - $view_form_id = $entry['form_id']; |
|
| 872 | + if ( in_array( (int)$entry[ 'form_id' ], array_keys( $view::get_joined_forms( $view->ID ) ), true ) ) { |
|
| 873 | + $view_form_id = $entry[ 'form_id' ]; |
|
| 874 | 874 | } |
| 875 | 875 | } |
| 876 | 876 | |
| 877 | - if ( $view_form_id != $entry['form_id'] ) { |
|
| 877 | + if ( $view_form_id != $entry[ 'form_id' ] ) { |
|
| 878 | 878 | return new WP_Error( 'view_id_not_match', 'View form source does not match entry form source ID.', $entry ); |
| 879 | 879 | } |
| 880 | 880 | |
@@ -882,13 +882,13 @@ discard block |
||
| 882 | 882 | * Check whether the entry is in the entries subset by running a modified query. |
| 883 | 883 | */ |
| 884 | 884 | add_action( 'gravityview/view/query', $entry_subset_callback = function( &$query, $view, $request ) use ( $entry, $view_form_id ) { |
| 885 | - $_tmp_query = new \GF_Query( $view_form_id, array( |
|
| 885 | + $_tmp_query = new \GF_Query( $view_form_id, array( |
|
| 886 | 886 | 'field_filters' => array( |
| 887 | 887 | 'mode' => 'all', |
| 888 | 888 | array( |
| 889 | 889 | 'key' => 'id', |
| 890 | 890 | 'operation' => 'is', |
| 891 | - 'value' => $entry['id'] |
|
| 891 | + 'value' => $entry[ 'id' ] |
|
| 892 | 892 | ) |
| 893 | 893 | ) |
| 894 | 894 | ) ); |
@@ -898,14 +898,14 @@ discard block |
||
| 898 | 898 | /** @var \GF_Query $query */ |
| 899 | 899 | $query_parts = $query->_introspect(); |
| 900 | 900 | |
| 901 | - $query->where( \GF_Query_Condition::_and( $_tmp_query_parts['where'], $query_parts['where'] ) ); |
|
| 901 | + $query->where( \GF_Query_Condition::_and( $_tmp_query_parts[ 'where' ], $query_parts[ 'where' ] ) ); |
|
| 902 | 902 | |
| 903 | 903 | }, 10, 3 ); |
| 904 | 904 | |
| 905 | 905 | // Prevent page offset from being applied to the single entry query; it's used to return to the referring page number |
| 906 | 906 | add_filter( 'gravityview_search_criteria', $remove_pagenum = function( $criteria ) { |
| 907 | 907 | |
| 908 | - $criteria['paging'] = array( |
|
| 908 | + $criteria[ 'paging' ] = array( |
|
| 909 | 909 | 'offset' => 0, |
| 910 | 910 | 'page_size' => 25 |
| 911 | 911 | ); |
@@ -924,20 +924,20 @@ discard block |
||
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | // This entry is on a View with joins |
| 927 | - if ( $entries[0]->is_multi() ) { |
|
| 927 | + if ( $entries[ 0 ]->is_multi() ) { |
|
| 928 | 928 | |
| 929 | 929 | $multi_entry_ids = array(); |
| 930 | 930 | |
| 931 | - foreach ( $entries[0]->entries as $multi_entry ) { |
|
| 932 | - $multi_entry_ids[] = (int) $multi_entry->ID; |
|
| 931 | + foreach ( $entries[ 0 ]->entries as $multi_entry ) { |
|
| 932 | + $multi_entry_ids[ ] = (int)$multi_entry->ID; |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | - if ( ! in_array( (int) $entry['id'], $multi_entry_ids, true ) ) { |
|
| 935 | + if ( ! in_array( (int)$entry[ 'id' ], $multi_entry_ids, true ) ) { |
|
| 936 | 936 | remove_action( 'gravityview/view/query', $entry_subset_callback ); |
| 937 | 937 | return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' ); |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - } elseif ( (int) $entries[0]->ID !== (int) $entry['id'] ) { |
|
| 940 | + } elseif ( (int)$entries[ 0 ]->ID !== (int)$entry[ 'id' ] ) { |
|
| 941 | 941 | remove_action( 'gravityview/view/query', $entry_subset_callback ); |
| 942 | 942 | return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' ); |
| 943 | 943 | } |
@@ -982,18 +982,18 @@ discard block |
||
| 982 | 982 | * Gravity Forms code to adjust date to locally-configured Time Zone |
| 983 | 983 | * @see GFCommon::format_date() for original code |
| 984 | 984 | */ |
| 985 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 985 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 986 | 986 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
| 987 | 987 | |
| 988 | - $format = \GV\Utils::get( $atts, 'format' ); |
|
| 989 | - $is_human = ! empty( $atts['human'] ); |
|
| 990 | - $is_diff = ! empty( $atts['diff'] ); |
|
| 991 | - $is_raw = ! empty( $atts['raw'] ); |
|
| 992 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
| 993 | - $include_time = ! empty( $atts['time'] ); |
|
| 988 | + $format = \GV\Utils::get( $atts, 'format' ); |
|
| 989 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
| 990 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
| 991 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
| 992 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
| 993 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
| 994 | 994 | |
| 995 | 995 | // If we're using time diff, we want to have a different default format |
| 996 | - if( empty( $format ) ) { |
|
| 996 | + if ( empty( $format ) ) { |
|
| 997 | 997 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
| 998 | 998 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
| 999 | 999 | } |
@@ -1001,7 +1001,7 @@ discard block |
||
| 1001 | 1001 | // If raw was specified, don't modify the stored value |
| 1002 | 1002 | if ( $is_raw ) { |
| 1003 | 1003 | $formatted_date = $date_string; |
| 1004 | - } elseif( $is_timestamp ) { |
|
| 1004 | + } elseif ( $is_timestamp ) { |
|
| 1005 | 1005 | $formatted_date = $date_local_timestamp; |
| 1006 | 1006 | } elseif ( $is_diff ) { |
| 1007 | 1007 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | |
| 1036 | 1036 | $label = \GV\Utils::get( $field, 'label' ); |
| 1037 | 1037 | |
| 1038 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 1038 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 1039 | 1039 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
| 1040 | 1040 | } |
| 1041 | 1041 | |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | $form = GFAPI::get_form( $form ); |
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 1066 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
| 1067 | 1067 | return GFFormsModel::get_field( $form, $field_id ); |
| 1068 | 1068 | } else { |
| 1069 | 1069 | return null; |
@@ -1110,19 +1110,19 @@ discard block |
||
| 1110 | 1110 | $shortcodes = array(); |
| 1111 | 1111 | |
| 1112 | 1112 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
| 1113 | - if ( empty( $matches ) ){ |
|
| 1113 | + if ( empty( $matches ) ) { |
|
| 1114 | 1114 | return false; |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | 1117 | foreach ( $matches as $shortcode ) { |
| 1118 | - if ( $tag === $shortcode[2] ) { |
|
| 1118 | + if ( $tag === $shortcode[ 2 ] ) { |
|
| 1119 | 1119 | |
| 1120 | 1120 | // Changed this to $shortcode instead of true so we get the parsed atts. |
| 1121 | - $shortcodes[] = $shortcode; |
|
| 1121 | + $shortcodes[ ] = $shortcode; |
|
| 1122 | 1122 | |
| 1123 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
| 1124 | - foreach( $results as $result ) { |
|
| 1125 | - $shortcodes[] = $result; |
|
| 1123 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
| 1124 | + foreach ( $results as $result ) { |
|
| 1125 | + $shortcodes[ ] = $result; |
|
| 1126 | 1126 | } |
| 1127 | 1127 | } |
| 1128 | 1128 | } |
@@ -1154,7 +1154,7 @@ discard block |
||
| 1154 | 1154 | 'post_type' => 'gravityview', |
| 1155 | 1155 | 'posts_per_page' => 100, |
| 1156 | 1156 | 'meta_key' => '_gravityview_form_id', |
| 1157 | - 'meta_value' => (int) $form_id, |
|
| 1157 | + 'meta_value' => (int)$form_id, |
|
| 1158 | 1158 | ); |
| 1159 | 1159 | $args = wp_parse_args( $args, $defaults ); |
| 1160 | 1160 | $views = get_posts( $args ); |
@@ -1166,21 +1166,21 @@ discard block |
||
| 1166 | 1166 | |
| 1167 | 1167 | $data = unserialize( $view->meta_value ); |
| 1168 | 1168 | |
| 1169 | - if( ! $data || ! is_array( $data ) ) { |
|
| 1169 | + if ( ! $data || ! is_array( $data ) ) { |
|
| 1170 | 1170 | continue; |
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | 1173 | foreach ( $data as $datum ) { |
| 1174 | - if ( ! empty( $datum[2] ) && (int) $datum[2] === (int) $form_id ) { |
|
| 1175 | - $joined_forms[] = $view->post_id; |
|
| 1174 | + if ( ! empty( $datum[ 2 ] ) && (int)$datum[ 2 ] === (int)$form_id ) { |
|
| 1175 | + $joined_forms[ ] = $view->post_id; |
|
| 1176 | 1176 | } |
| 1177 | 1177 | } |
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | 1180 | if ( $joined_forms ) { |
| 1181 | - $joined_args = array( |
|
| 1181 | + $joined_args = array( |
|
| 1182 | 1182 | 'post_type' => 'gravityview', |
| 1183 | - 'posts_per_page' => $args['posts_per_page'], |
|
| 1183 | + 'posts_per_page' => $args[ 'posts_per_page' ], |
|
| 1184 | 1184 | 'post__in' => $joined_forms, |
| 1185 | 1185 | ); |
| 1186 | 1186 | $views = array_merge( $views, get_posts( $joined_args ) ); |
@@ -1336,7 +1336,7 @@ discard block |
||
| 1336 | 1336 | |
| 1337 | 1337 | $directory_widgets = wp_parse_args( $view_widgets, $defaults ); |
| 1338 | 1338 | |
| 1339 | - if( $json_decode ) { |
|
| 1339 | + if ( $json_decode ) { |
|
| 1340 | 1340 | $directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' ); |
| 1341 | 1341 | } |
| 1342 | 1342 | |
@@ -1352,7 +1352,7 @@ discard block |
||
| 1352 | 1352 | * @return string html |
| 1353 | 1353 | */ |
| 1354 | 1354 | public static function get_sortable_fields( $formid, $current = '' ) { |
| 1355 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
| 1355 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
| 1356 | 1356 | |
| 1357 | 1357 | if ( empty( $formid ) ) { |
| 1358 | 1358 | return $output; |
@@ -1365,11 +1365,11 @@ discard block |
||
| 1365 | 1365 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
| 1366 | 1366 | |
| 1367 | 1367 | foreach ( $fields as $id => $field ) { |
| 1368 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1368 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1369 | 1369 | continue; |
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
| 1372 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
| 1373 | 1373 | } |
| 1374 | 1374 | } |
| 1375 | 1375 | |
@@ -1404,16 +1404,16 @@ discard block |
||
| 1404 | 1404 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1405 | 1405 | |
| 1406 | 1406 | // TODO: Convert to using array_filter |
| 1407 | - foreach( $fields as $id => $field ) { |
|
| 1407 | + foreach ( $fields as $id => $field ) { |
|
| 1408 | 1408 | |
| 1409 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1409 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1410 | 1410 | unset( $fields[ $id ] ); |
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | 1413 | /** |
| 1414 | 1414 | * Merge date and time subfields. |
| 1415 | 1415 | */ |
| 1416 | - if ( in_array( $field['type'], array( 'date', 'time' ) ) && ! empty( $field['parent'] ) ) { |
|
| 1416 | + if ( in_array( $field[ 'type' ], array( 'date', 'time' ) ) && ! empty( $field[ 'parent' ] ) ) { |
|
| 1417 | 1417 | $fields[ intval( $id ) ] = array( |
| 1418 | 1418 | 'label' => \GV\Utils::get( $field, 'parent/label' ), |
| 1419 | 1419 | 'parent' => null, |
@@ -1463,14 +1463,14 @@ discard block |
||
| 1463 | 1463 | * @param int|array $field field key or field array |
| 1464 | 1464 | * @return boolean |
| 1465 | 1465 | */ |
| 1466 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1466 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1467 | 1467 | |
| 1468 | 1468 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
| 1469 | 1469 | $form = self::get_form( $form ); |
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | 1472 | // If entry meta, it's a string. Otherwise, numeric |
| 1473 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1473 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1474 | 1474 | $type = $field; |
| 1475 | 1475 | } else { |
| 1476 | 1476 | $type = self::get_field_type( $form, $field ); |
@@ -1484,9 +1484,9 @@ discard block |
||
| 1484 | 1484 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
| 1485 | 1485 | |
| 1486 | 1486 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
| 1487 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1488 | - if( true === $gv_field->is_numeric ) { |
|
| 1489 | - $numeric_types[] = $gv_field->is_numeric; |
|
| 1487 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1488 | + if ( true === $gv_field->is_numeric ) { |
|
| 1489 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
| 1490 | 1490 | } |
| 1491 | 1491 | } |
| 1492 | 1492 | |
@@ -1636,18 +1636,18 @@ discard block |
||
| 1636 | 1636 | $final_atts = array_filter( $final_atts ); |
| 1637 | 1637 | |
| 1638 | 1638 | // If the href wasn't passed as an attribute, use the value passed to the function |
| 1639 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
| 1640 | - $final_atts['href'] = $href; |
|
| 1639 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
| 1640 | + $final_atts[ 'href' ] = $href; |
|
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | - $final_atts['href'] = esc_url_raw( $href ); |
|
| 1643 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
| 1644 | 1644 | |
| 1645 | 1645 | /** |
| 1646 | 1646 | * Fix potential security issue with target=_blank |
| 1647 | 1647 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
| 1648 | 1648 | */ |
| 1649 | - if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
| 1650 | - $final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1649 | + if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
| 1650 | + $final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | 1653 | // Sort the attributes alphabetically, to help testing |
@@ -1659,7 +1659,7 @@ discard block |
||
| 1659 | 1659 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
| 1660 | 1660 | } |
| 1661 | 1661 | |
| 1662 | - if( '' !== $output ) { |
|
| 1662 | + if ( '' !== $output ) { |
|
| 1663 | 1663 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
| 1664 | 1664 | } |
| 1665 | 1665 | |
@@ -1686,7 +1686,7 @@ discard block |
||
| 1686 | 1686 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
| 1687 | 1687 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
| 1688 | 1688 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
| 1689 | - $merged[] = $value; |
|
| 1689 | + $merged[ ] = $value; |
|
| 1690 | 1690 | } else { |
| 1691 | 1691 | $merged[ $key ] = $value; |
| 1692 | 1692 | } |
@@ -1719,7 +1719,7 @@ discard block |
||
| 1719 | 1719 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
| 1720 | 1720 | * @param array $settings Settings array, with `number` key defining the # of users to display |
| 1721 | 1721 | */ |
| 1722 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1722 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1723 | 1723 | |
| 1724 | 1724 | return get_users( $get_users_settings ); |
| 1725 | 1725 | } |
@@ -1739,11 +1739,11 @@ discard block |
||
| 1739 | 1739 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
| 1740 | 1740 | |
| 1741 | 1741 | // If $cap is defined, only show notice if user has capability |
| 1742 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1742 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1743 | 1743 | return ''; |
| 1744 | 1744 | } |
| 1745 | 1745 | |
| 1746 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1746 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
| 1747 | 1747 | } |
| 1748 | 1748 | |
| 1749 | 1749 | /** |