@@ -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'] ) ) { |
|
| 443 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
| 442 | + if ( ! empty( $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' ); |
@@ -693,12 +693,12 @@ discard block |
||
| 693 | 693 | */ |
| 694 | 694 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
| 695 | 695 | |
| 696 | - if( $check_entry_display ) { |
|
| 696 | + if ( $check_entry_display ) { |
|
| 697 | 697 | // Is the entry allowed |
| 698 | 698 | $entry = self::check_entry_display( $entry ); |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - if( is_wp_error( $entry ) ) { |
|
| 701 | + if ( is_wp_error( $entry ) ) { |
|
| 702 | 702 | gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) ); |
| 703 | 703 | return false; |
| 704 | 704 | } |
@@ -732,12 +732,12 @@ discard block |
||
| 732 | 732 | |
| 733 | 733 | $value = false; |
| 734 | 734 | |
| 735 | - if( 'context' === $val1 ) { |
|
| 735 | + if ( 'context' === $val1 ) { |
|
| 736 | 736 | |
| 737 | 737 | $matching_contexts = array( $val2 ); |
| 738 | 738 | |
| 739 | 739 | // We allow for non-standard contexts. |
| 740 | - switch( $val2 ) { |
|
| 740 | + switch ( $val2 ) { |
|
| 741 | 741 | // Check for either single or edit |
| 742 | 742 | case 'singular': |
| 743 | 743 | $matching_contexts = array( 'single', 'edit' ); |
@@ -780,18 +780,18 @@ discard block |
||
| 780 | 780 | $json_val_1 = json_decode( $val1, true ); |
| 781 | 781 | $json_val_2 = json_decode( $val2, true ); |
| 782 | 782 | |
| 783 | - if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
| 783 | + if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
| 784 | 784 | |
| 785 | 785 | $json_in = false; |
| 786 | - $json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 ); |
|
| 787 | - $json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 ); |
|
| 786 | + $json_val_1 = $json_val_1 ? (array)$json_val_1 : array( $val1 ); |
|
| 787 | + $json_val_2 = $json_val_2 ? (array)$json_val_2 : array( $val2 ); |
|
| 788 | 788 | |
| 789 | 789 | // For JSON, we want to compare as "in" or "not in" rather than "contains" |
| 790 | 790 | foreach ( $json_val_1 as $item_1 ) { |
| 791 | 791 | foreach ( $json_val_2 as $item_2 ) { |
| 792 | 792 | $json_in = self::matches_operation( $item_1, $item_2, 'is' ); |
| 793 | 793 | |
| 794 | - if( $json_in ) { |
|
| 794 | + if ( $json_in ) { |
|
| 795 | 795 | break 2; |
| 796 | 796 | } |
| 797 | 797 | } |
@@ -843,10 +843,10 @@ discard block |
||
| 843 | 843 | public static function check_entry_display( $entry, $view = null ) { |
| 844 | 844 | |
| 845 | 845 | if ( ! $entry || is_wp_error( $entry ) ) { |
| 846 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
| 846 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - if ( empty( $entry['form_id'] ) ) { |
|
| 849 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
| 850 | 850 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
| 851 | 851 | } |
| 852 | 852 | |
@@ -854,55 +854,55 @@ discard block |
||
| 854 | 854 | 'context_view_id' => $view ? $view->ID : null, |
| 855 | 855 | ) ); |
| 856 | 856 | |
| 857 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
| 857 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
| 858 | 858 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No search criteria found:', array( 'data' => $criteria ) ); |
| 859 | 859 | return $entry; |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | // Make sure the current View is connected to the same form as the Entry |
| 863 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
| 864 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
| 863 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
| 864 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
| 865 | 865 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
| 866 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
| 867 | - return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
| 866 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
| 867 | + return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - $search_criteria = $criteria['search_criteria']; |
|
| 871 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
| 872 | 872 | |
| 873 | 873 | // check entry status |
| 874 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
| 875 | - return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
| 874 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
| 875 | + return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | // check entry date |
| 879 | 879 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
| 880 | 880 | |
| 881 | 881 | // field_filters |
| 882 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
| 882 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
| 883 | 883 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No field filters criteria found:', array( 'data' => $search_criteria ) ); |
| 884 | 884 | return $entry; |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - $filters = $search_criteria['field_filters']; |
|
| 887 | + $filters = $search_criteria[ 'field_filters' ]; |
|
| 888 | 888 | |
| 889 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
| 889 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
| 890 | 890 | |
| 891 | - $mode = $mode ? : 'all'; // If mode is an empty string, assume it's 'all' |
|
| 891 | + $mode = $mode ?: 'all'; // If mode is an empty string, assume it's 'all' |
|
| 892 | 892 | |
| 893 | 893 | // Prevent the mode from being processed below |
| 894 | - unset( $filters['mode'] ); |
|
| 894 | + unset( $filters[ 'mode' ] ); |
|
| 895 | 895 | |
| 896 | - $form = self::get_form( $entry['form_id'] ); |
|
| 896 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
| 897 | 897 | |
| 898 | 898 | foreach ( $filters as $filter ) { |
| 899 | 899 | |
| 900 | - if ( ! isset( $filter['key'] ) ) { |
|
| 900 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
| 901 | 901 | gravityview()->log->debug( '[apply_filters_to_entry] Filter key not set: {filter}', array( 'filter' => $filter ) ); |
| 902 | 902 | continue; |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - $k = $filter['key']; |
|
| 905 | + $k = $filter[ 'key' ]; |
|
| 906 | 906 | |
| 907 | 907 | $field = self::get_field( $form, $k ); |
| 908 | 908 | |
@@ -910,14 +910,14 @@ discard block |
||
| 910 | 910 | $field_value = isset( $entry[ $k ] ) ? $entry[ $k ] : null; |
| 911 | 911 | $field = $k; |
| 912 | 912 | } else { |
| 913 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 913 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 914 | 914 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
| 915 | 915 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? \GV\Utils::get( $field_value, $k ) : $field_value; |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
| 918 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
| 919 | 919 | |
| 920 | - $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
| 920 | + $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
| 921 | 921 | |
| 922 | 922 | // Any match is all we need to know |
| 923 | 923 | if ( $is_value_match && 'any' === $mode ) { |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | |
| 927 | 927 | // Any failed match is a total fail |
| 928 | 928 | if ( ! $is_value_match && 'all' === $mode ) { |
| 929 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
| 929 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
| 930 | 930 | } |
| 931 | 931 | } |
| 932 | 932 | |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved: all conditions were met' ); |
| 937 | 937 | return $entry; |
| 938 | 938 | } else { |
| 939 | - return new WP_Error('failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
| 939 | + return new WP_Error( 'failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | } |
@@ -977,18 +977,18 @@ discard block |
||
| 977 | 977 | * Gravity Forms code to adjust date to locally-configured Time Zone |
| 978 | 978 | * @see GFCommon::format_date() for original code |
| 979 | 979 | */ |
| 980 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 980 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 981 | 981 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
| 982 | 982 | |
| 983 | - $format = \GV\Utils::get( $atts, 'format' ); |
|
| 984 | - $is_human = ! empty( $atts['human'] ); |
|
| 985 | - $is_diff = ! empty( $atts['diff'] ); |
|
| 986 | - $is_raw = ! empty( $atts['raw'] ); |
|
| 987 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
| 988 | - $include_time = ! empty( $atts['time'] ); |
|
| 983 | + $format = \GV\Utils::get( $atts, 'format' ); |
|
| 984 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
| 985 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
| 986 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
| 987 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
| 988 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
| 989 | 989 | |
| 990 | 990 | // If we're using time diff, we want to have a different default format |
| 991 | - if( empty( $format ) ) { |
|
| 991 | + if ( empty( $format ) ) { |
|
| 992 | 992 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
| 993 | 993 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
| 994 | 994 | } |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | // If raw was specified, don't modify the stored value |
| 997 | 997 | if ( $is_raw ) { |
| 998 | 998 | $formatted_date = $date_string; |
| 999 | - } elseif( $is_timestamp ) { |
|
| 999 | + } elseif ( $is_timestamp ) { |
|
| 1000 | 1000 | $formatted_date = $date_local_timestamp; |
| 1001 | 1001 | } elseif ( $is_diff ) { |
| 1002 | 1002 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | |
| 1031 | 1031 | $label = \GV\Utils::get( $field, 'label' ); |
| 1032 | 1032 | |
| 1033 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 1033 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 1034 | 1034 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
| 1035 | 1035 | } |
| 1036 | 1036 | |
@@ -1058,7 +1058,7 @@ discard block |
||
| 1058 | 1058 | $form = GFAPI::get_form( $form ); |
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 1061 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
| 1062 | 1062 | return GFFormsModel::get_field( $form, $field_id ); |
| 1063 | 1063 | } else { |
| 1064 | 1064 | return null; |
@@ -1105,19 +1105,19 @@ discard block |
||
| 1105 | 1105 | $shortcodes = array(); |
| 1106 | 1106 | |
| 1107 | 1107 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
| 1108 | - if ( empty( $matches ) ){ |
|
| 1108 | + if ( empty( $matches ) ) { |
|
| 1109 | 1109 | return false; |
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | foreach ( $matches as $shortcode ) { |
| 1113 | - if ( $tag === $shortcode[2] ) { |
|
| 1113 | + if ( $tag === $shortcode[ 2 ] ) { |
|
| 1114 | 1114 | |
| 1115 | 1115 | // Changed this to $shortcode instead of true so we get the parsed atts. |
| 1116 | - $shortcodes[] = $shortcode; |
|
| 1116 | + $shortcodes[ ] = $shortcode; |
|
| 1117 | 1117 | |
| 1118 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
| 1119 | - foreach( $results as $result ) { |
|
| 1120 | - $shortcodes[] = $result; |
|
| 1118 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
| 1119 | + foreach ( $results as $result ) { |
|
| 1120 | + $shortcodes[ ] = $result; |
|
| 1121 | 1121 | } |
| 1122 | 1122 | } |
| 1123 | 1123 | } |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | 'post_type' => 'gravityview', |
| 1150 | 1150 | 'posts_per_page' => 100, |
| 1151 | 1151 | 'meta_key' => '_gravityview_form_id', |
| 1152 | - 'meta_value' => (int) $form_id, |
|
| 1152 | + 'meta_value' => (int)$form_id, |
|
| 1153 | 1153 | ); |
| 1154 | 1154 | $args = wp_parse_args( $args, $defaults ); |
| 1155 | 1155 | $views = get_posts( $args ); |
@@ -1161,21 +1161,21 @@ discard block |
||
| 1161 | 1161 | |
| 1162 | 1162 | $data = unserialize( $view->meta_value ); |
| 1163 | 1163 | |
| 1164 | - if( ! $data || ! is_array( $data ) ) { |
|
| 1164 | + if ( ! $data || ! is_array( $data ) ) { |
|
| 1165 | 1165 | continue; |
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | foreach ( $data as $datum ) { |
| 1169 | - if ( ! empty( $datum[2] ) && (int) $datum[2] === (int) $form_id ) { |
|
| 1170 | - $joined_forms[] = $view->post_id; |
|
| 1169 | + if ( ! empty( $datum[ 2 ] ) && (int)$datum[ 2 ] === (int)$form_id ) { |
|
| 1170 | + $joined_forms[ ] = $view->post_id; |
|
| 1171 | 1171 | } |
| 1172 | 1172 | } |
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | 1175 | if ( $joined_forms ) { |
| 1176 | - $joined_args = array( |
|
| 1176 | + $joined_args = array( |
|
| 1177 | 1177 | 'post_type' => 'gravityview', |
| 1178 | - 'posts_per_page' => $args['posts_per_page'], |
|
| 1178 | + 'posts_per_page' => $args[ 'posts_per_page' ], |
|
| 1179 | 1179 | 'post__in' => $joined_forms, |
| 1180 | 1180 | ); |
| 1181 | 1181 | $views = array_merge( $views, get_posts( $joined_args ) ); |
@@ -1331,7 +1331,7 @@ discard block |
||
| 1331 | 1331 | |
| 1332 | 1332 | $directory_widgets = wp_parse_args( $view_widgets, $defaults ); |
| 1333 | 1333 | |
| 1334 | - if( $json_decode ) { |
|
| 1334 | + if ( $json_decode ) { |
|
| 1335 | 1335 | $directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' ); |
| 1336 | 1336 | } |
| 1337 | 1337 | |
@@ -1347,7 +1347,7 @@ discard block |
||
| 1347 | 1347 | * @return string html |
| 1348 | 1348 | */ |
| 1349 | 1349 | public static function get_sortable_fields( $formid, $current = '' ) { |
| 1350 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
| 1350 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
| 1351 | 1351 | |
| 1352 | 1352 | if ( empty( $formid ) ) { |
| 1353 | 1353 | return $output; |
@@ -1360,11 +1360,11 @@ discard block |
||
| 1360 | 1360 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
| 1361 | 1361 | |
| 1362 | 1362 | foreach ( $fields as $id => $field ) { |
| 1363 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1363 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1364 | 1364 | continue; |
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
| 1367 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
| 1368 | 1368 | } |
| 1369 | 1369 | } |
| 1370 | 1370 | |
@@ -1399,9 +1399,9 @@ discard block |
||
| 1399 | 1399 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1400 | 1400 | |
| 1401 | 1401 | // TODO: Convert to using array_filter |
| 1402 | - foreach( $fields as $id => $field ) { |
|
| 1402 | + foreach ( $fields as $id => $field ) { |
|
| 1403 | 1403 | |
| 1404 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1404 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1405 | 1405 | unset( $fields[ $id ] ); |
| 1406 | 1406 | } |
| 1407 | 1407 | } |
@@ -1442,14 +1442,14 @@ discard block |
||
| 1442 | 1442 | * @param int|array $field field key or field array |
| 1443 | 1443 | * @return boolean |
| 1444 | 1444 | */ |
| 1445 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1445 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1446 | 1446 | |
| 1447 | 1447 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
| 1448 | 1448 | $form = self::get_form( $form ); |
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | 1451 | // If entry meta, it's a string. Otherwise, numeric |
| 1452 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1452 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1453 | 1453 | $type = $field; |
| 1454 | 1454 | } else { |
| 1455 | 1455 | $type = self::get_field_type( $form, $field ); |
@@ -1463,9 +1463,9 @@ discard block |
||
| 1463 | 1463 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
| 1464 | 1464 | |
| 1465 | 1465 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
| 1466 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1467 | - if( true === $gv_field->is_numeric ) { |
|
| 1468 | - $numeric_types[] = $gv_field->is_numeric; |
|
| 1466 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1467 | + if ( true === $gv_field->is_numeric ) { |
|
| 1468 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
| 1469 | 1469 | } |
| 1470 | 1470 | } |
| 1471 | 1471 | |
@@ -1615,18 +1615,18 @@ discard block |
||
| 1615 | 1615 | $final_atts = array_filter( $final_atts ); |
| 1616 | 1616 | |
| 1617 | 1617 | // If the href wasn't passed as an attribute, use the value passed to the function |
| 1618 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
| 1619 | - $final_atts['href'] = $href; |
|
| 1618 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
| 1619 | + $final_atts[ 'href' ] = $href; |
|
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | - $final_atts['href'] = esc_url_raw( $href ); |
|
| 1622 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
| 1623 | 1623 | |
| 1624 | 1624 | /** |
| 1625 | 1625 | * Fix potential security issue with target=_blank |
| 1626 | 1626 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
| 1627 | 1627 | */ |
| 1628 | - if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
| 1629 | - $final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1628 | + if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
| 1629 | + $final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | 1632 | // Sort the attributes alphabetically, to help testing |
@@ -1638,7 +1638,7 @@ discard block |
||
| 1638 | 1638 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
| 1639 | 1639 | } |
| 1640 | 1640 | |
| 1641 | - if( '' !== $output ) { |
|
| 1641 | + if ( '' !== $output ) { |
|
| 1642 | 1642 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
| 1643 | 1643 | } |
| 1644 | 1644 | |
@@ -1665,7 +1665,7 @@ discard block |
||
| 1665 | 1665 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
| 1666 | 1666 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
| 1667 | 1667 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
| 1668 | - $merged[] = $value; |
|
| 1668 | + $merged[ ] = $value; |
|
| 1669 | 1669 | } else { |
| 1670 | 1670 | $merged[ $key ] = $value; |
| 1671 | 1671 | } |
@@ -1698,7 +1698,7 @@ discard block |
||
| 1698 | 1698 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
| 1699 | 1699 | * @param array $settings Settings array, with `number` key defining the # of users to display |
| 1700 | 1700 | */ |
| 1701 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1701 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1702 | 1702 | |
| 1703 | 1703 | return get_users( $get_users_settings ); |
| 1704 | 1704 | } |
@@ -1718,11 +1718,11 @@ discard block |
||
| 1718 | 1718 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
| 1719 | 1719 | |
| 1720 | 1720 | // If $cap is defined, only show notice if user has capability |
| 1721 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1721 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1722 | 1722 | return ''; |
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1725 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | 1728 | /** |
@@ -115,16 +115,16 @@ discard block |
||
| 115 | 115 | function load() { |
| 116 | 116 | |
| 117 | 117 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
| 118 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 118 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 119 | 119 | |
| 120 | 120 | // Don't display an embedded form when editing an entry |
| 121 | 121 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
| 122 | 122 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
| 123 | 123 | |
| 124 | 124 | // Stop Gravity Forms processing what is ours! |
| 125 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
| 125 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
| 126 | 126 | |
| 127 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
| 127 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
| 128 | 128 | |
| 129 | 129 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
| 130 | 130 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
| 136 | 136 | |
| 137 | 137 | // Add fields expected by GFFormDisplay::validate() |
| 138 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
| 138 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
| 139 | 139 | |
| 140 | 140 | // Fix multiselect value for GF 2.2 |
| 141 | 141 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | * @return void |
| 153 | 153 | */ |
| 154 | 154 | public function prevent_render_form() { |
| 155 | - if( $this->is_edit_entry() ) { |
|
| 156 | - if( 'wp_head' === current_filter() ) { |
|
| 155 | + if ( $this->is_edit_entry() ) { |
|
| 156 | + if ( 'wp_head' === current_filter() ) { |
|
| 157 | 157 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
| 158 | 158 | } else { |
| 159 | 159 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -168,13 +168,13 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function prevent_maybe_process_form() { |
| 170 | 170 | |
| 171 | - if( ! empty( $_POST ) ) { |
|
| 171 | + if ( ! empty( $_POST ) ) { |
|
| 172 | 172 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if( $this->is_edit_entry_submission() ) { |
|
| 176 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 175 | + if ( $this->is_edit_entry_submission() ) { |
|
| 176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function is_edit_entry() { |
| 186 | 186 | |
| 187 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
| 187 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
| 188 | 188 | |
| 189 | 189 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
| 190 | 190 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @return boolean |
| 196 | 196 | */ |
| 197 | 197 | public function is_edit_entry_submission() { |
| 198 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
| 198 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | $entries = $gravityview_view->getEntries(); |
| 211 | - self::$original_entry = $entries[0]; |
|
| 212 | - $this->entry = $entries[0]; |
|
| 211 | + self::$original_entry = $entries[ 0 ]; |
|
| 212 | + $this->entry = $entries[ 0 ]; |
|
| 213 | 213 | |
| 214 | 214 | self::$original_form = $gravityview_view->getForm(); |
| 215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $this->view_id = $gravityview_view->getViewId(); |
| 218 | 218 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
| 219 | 219 | |
| 220 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
| 220 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
@@ -268,9 +268,9 @@ discard block |
||
| 268 | 268 | private function print_scripts() { |
| 269 | 269 | $gravityview_view = GravityView_View::getInstance(); |
| 270 | 270 | |
| 271 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 271 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 272 | 272 | |
| 273 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
| 273 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
| 274 | 274 | |
| 275 | 275 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
| 276 | 276 | |
@@ -286,19 +286,19 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | private function process_save( $gv_data ) { |
| 288 | 288 | |
| 289 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 289 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 290 | 290 | return; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // Make sure the entry, view, and form IDs are all correct |
| 294 | 294 | $valid = $this->verify_nonce(); |
| 295 | 295 | |
| 296 | - if ( !$valid ) { |
|
| 296 | + if ( ! $valid ) { |
|
| 297 | 297 | gravityview()->log->error( 'Nonce validation failed.' ); |
| 298 | 298 | return; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 301 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 302 | 302 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
| 303 | 303 | return; |
| 304 | 304 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | $this->validate(); |
| 311 | 311 | |
| 312 | - if( $this->is_valid ) { |
|
| 312 | + if ( $this->is_valid ) { |
|
| 313 | 313 | |
| 314 | 314 | gravityview()->log->debug( 'Submission is valid.' ); |
| 315 | 315 | |
@@ -321,22 +321,22 @@ discard block |
||
| 321 | 321 | /** |
| 322 | 322 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 323 | 323 | */ |
| 324 | - unset( $_GET['page'] ); |
|
| 324 | + unset( $_GET[ 'page' ] ); |
|
| 325 | 325 | |
| 326 | - $date_created = $this->entry['date_created']; |
|
| 326 | + $date_created = $this->entry[ 'date_created' ]; |
|
| 327 | 327 | |
| 328 | 328 | /** |
| 329 | 329 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
| 330 | 330 | * @since 1.17.2 |
| 331 | 331 | */ |
| 332 | - unset( $this->entry['date_created'] ); |
|
| 332 | + unset( $this->entry[ 'date_created' ] ); |
|
| 333 | 333 | |
| 334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
| 335 | 335 | |
| 336 | 336 | // Delete the values for hidden inputs |
| 337 | 337 | $this->unset_hidden_field_values(); |
| 338 | 338 | |
| 339 | - $this->entry['date_created'] = $date_created; |
|
| 339 | + $this->entry[ 'date_created' ] = $date_created; |
|
| 340 | 340 | |
| 341 | 341 | // Process calculation fields |
| 342 | 342 | $this->update_calculation_fields(); |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * @param GravityView_Edit_Entry_Render $this This object |
| 362 | 362 | * @param GravityView_View_Data $gv_data The View data |
| 363 | 363 | */ |
| 364 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
| 364 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 365 | 365 | |
| 366 | 366 | } else { |
| 367 | 367 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -389,16 +389,16 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
| 391 | 391 | |
| 392 | - if( ! $unset_hidden_field_values ) { |
|
| 392 | + if ( ! $unset_hidden_field_values ) { |
|
| 393 | 393 | return; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 397 | 397 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 398 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
| 398 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
| 399 | 399 | } else { |
| 400 | 400 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 401 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
| 401 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** No file is being uploaded. */ |
| 482 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 482 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 483 | 483 | /** So return the original upload */ |
| 484 | 484 | return $entry[ $input_id ]; |
| 485 | 485 | } |
@@ -497,11 +497,11 @@ discard block |
||
| 497 | 497 | * @return mixed |
| 498 | 498 | */ |
| 499 | 499 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 500 | - if( ! $this->is_edit_entry() ) { |
|
| 500 | + if ( ! $this->is_edit_entry() ) { |
|
| 501 | 501 | return $plupload_init; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 504 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 505 | 505 | |
| 506 | 506 | return $plupload_init; |
| 507 | 507 | } |
@@ -516,22 +516,22 @@ discard block |
||
| 516 | 516 | $form = $this->form; |
| 517 | 517 | |
| 518 | 518 | /** @var GF_Field $field */ |
| 519 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 519 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 520 | 520 | |
| 521 | 521 | /** |
| 522 | 522 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 523 | 523 | * @since 1.16.3 |
| 524 | 524 | * @var GF_Field $field |
| 525 | 525 | */ |
| 526 | - if( $field->has_calculation() ) { |
|
| 527 | - unset( $form['fields'][ $k ] ); |
|
| 526 | + if ( $field->has_calculation() ) { |
|
| 527 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | $field->adminOnly = false; |
| 531 | 531 | |
| 532 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 533 | - foreach( $field->inputs as $key => $input ) { |
|
| 534 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 532 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 533 | + foreach ( $field->inputs as $key => $input ) { |
|
| 534 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | 537 | } |
@@ -545,20 +545,20 @@ discard block |
||
| 545 | 545 | $update = false; |
| 546 | 546 | |
| 547 | 547 | // get the most up to date entry values |
| 548 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 548 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 549 | 549 | |
| 550 | - if( !empty( $this->fields_with_calculation ) ) { |
|
| 550 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
| 551 | 551 | $update = true; |
| 552 | 552 | foreach ( $this->fields_with_calculation as $calc_field ) { |
| 553 | 553 | $inputs = $calc_field->get_entry_inputs(); |
| 554 | 554 | if ( is_array( $inputs ) ) { |
| 555 | 555 | foreach ( $inputs as $input ) { |
| 556 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 557 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 556 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
| 557 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
| 558 | 558 | } |
| 559 | 559 | } else { |
| 560 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
| 561 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 560 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
| 561 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | } |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | |
| 568 | 568 | $return_entry = GFAPI::update_entry( $entry ); |
| 569 | 569 | |
| 570 | - if( is_wp_error( $return_entry ) ) { |
|
| 570 | + if ( is_wp_error( $return_entry ) ) { |
|
| 571 | 571 | gravityview()->log->error( 'Updating the entry calculation fields failed', array( 'data' => $return_entry ) ); |
| 572 | 572 | } else { |
| 573 | 573 | gravityview()->log->debug( 'Updating the entry calculation fields succeeded' ); |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | return; |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 587 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 588 | 588 | |
| 589 | 589 | foreach ( array( 'score', 'percent', 'grade', 'is_pass' ) as $meta ) { |
| 590 | 590 | GFQuiz::get_instance()->update_entry_meta( "gfquiz_$meta", $entry, self::$original_form ); |
@@ -614,19 +614,19 @@ discard block |
||
| 614 | 614 | |
| 615 | 615 | $input_name = 'input_' . $field_id; |
| 616 | 616 | |
| 617 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 617 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 618 | 618 | |
| 619 | 619 | // We have a new image |
| 620 | 620 | |
| 621 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 621 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 622 | 622 | |
| 623 | 623 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 624 | 624 | $ary = stripslashes_deep( $ary ); |
| 625 | 625 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 626 | 626 | |
| 627 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 628 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 629 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 627 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 628 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 629 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 630 | 630 | |
| 631 | 631 | $image_meta = array( |
| 632 | 632 | 'post_excerpt' => $img_caption, |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | |
| 636 | 636 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 637 | 637 | if ( ! empty( $img_title ) ) { |
| 638 | - $image_meta['post_title'] = $img_title; |
|
| 638 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | /** |
@@ -693,15 +693,15 @@ discard block |
||
| 693 | 693 | */ |
| 694 | 694 | private function maybe_update_post_fields( $form ) { |
| 695 | 695 | |
| 696 | - if( empty( $this->entry['post_id'] ) ) { |
|
| 696 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
| 697 | 697 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
| 698 | 698 | return; |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - $post_id = $this->entry['post_id']; |
|
| 701 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 702 | 702 | |
| 703 | 703 | // Security check |
| 704 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 704 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 705 | 705 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
| 706 | 706 | return; |
| 707 | 707 | } |
@@ -714,25 +714,25 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 716 | 716 | |
| 717 | - if( ! $field ) { |
|
| 717 | + if ( ! $field ) { |
|
| 718 | 718 | continue; |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 721 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 722 | 722 | |
| 723 | 723 | // Get the value of the field, including $_POSTed value |
| 724 | 724 | $value = RGFormsModel::get_field_value( $field ); |
| 725 | 725 | |
| 726 | 726 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 727 | 727 | $entry_tmp = $this->entry; |
| 728 | - $entry_tmp["{$field_id}"] = $value; |
|
| 728 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 729 | 729 | |
| 730 | - switch( $field->type ) { |
|
| 730 | + switch ( $field->type ) { |
|
| 731 | 731 | |
| 732 | 732 | case 'post_title': |
| 733 | 733 | $post_title = $value; |
| 734 | 734 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
| 735 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 735 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 736 | 736 | } |
| 737 | 737 | $updated_post->post_title = $post_title; |
| 738 | 738 | $updated_post->post_name = $post_title; |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | case 'post_content': |
| 743 | 743 | $post_content = $value; |
| 744 | 744 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
| 745 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 745 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 746 | 746 | } |
| 747 | 747 | $updated_post->post_content = $post_content; |
| 748 | 748 | unset( $post_content ); |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | $value = $value[ $field_id ]; |
| 761 | 761 | } |
| 762 | 762 | |
| 763 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 763 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 764 | 764 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 765 | 765 | } |
| 766 | 766 | |
@@ -778,7 +778,7 @@ discard block |
||
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | // update entry after |
| 781 | - $this->entry["{$field_id}"] = $value; |
|
| 781 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 782 | 782 | |
| 783 | 783 | $update_entry = true; |
| 784 | 784 | |
@@ -787,11 +787,11 @@ discard block |
||
| 787 | 787 | |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | - if( $update_entry ) { |
|
| 790 | + if ( $update_entry ) { |
|
| 791 | 791 | |
| 792 | 792 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 793 | 793 | |
| 794 | - if( is_wp_error( $return_entry ) ) { |
|
| 794 | + if ( is_wp_error( $return_entry ) ) { |
|
| 795 | 795 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
| 796 | 796 | } else { |
| 797 | 797 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | |
| 802 | 802 | $return_post = wp_update_post( $updated_post, true ); |
| 803 | 803 | |
| 804 | - if( is_wp_error( $return_post ) ) { |
|
| 804 | + if ( is_wp_error( $return_post ) ) { |
|
| 805 | 805 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 806 | 806 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
| 807 | 807 | } else { |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | $input_type = RGFormsModel::get_input_type( $field ); |
| 824 | 824 | |
| 825 | 825 | // Only certain custom field types are supported |
| 826 | - switch( $input_type ) { |
|
| 826 | + switch ( $input_type ) { |
|
| 827 | 827 | case 'fileupload': |
| 828 | 828 | case 'list': |
| 829 | 829 | case 'multiselect': |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 861 | 861 | |
| 862 | 862 | // replace conditional shortcodes |
| 863 | - if( $do_shortcode ) { |
|
| 863 | + if ( $do_shortcode ) { |
|
| 864 | 864 | $output = do_shortcode( $output ); |
| 865 | 865 | } |
| 866 | 866 | |
@@ -879,19 +879,19 @@ discard block |
||
| 879 | 879 | */ |
| 880 | 880 | private function after_update() { |
| 881 | 881 | |
| 882 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
| 883 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
| 882 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 883 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 884 | 884 | |
| 885 | 885 | // Re-define the entry now that we've updated it. |
| 886 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 886 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 887 | 887 | |
| 888 | 888 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
| 889 | 889 | |
| 890 | 890 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
| 891 | 891 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 892 | 892 | // we have just updated. |
| 893 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 894 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 893 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 894 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | 897 | |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | |
| 911 | 911 | <div class="gv-edit-entry-wrapper"><?php |
| 912 | 912 | |
| 913 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 913 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 914 | 914 | |
| 915 | 915 | /** |
| 916 | 916 | * Fixes weird wpautop() issue |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 927 | 927 | * @param GravityView_Edit_Entry_Render $this This object |
| 928 | 928 | */ |
| 929 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 929 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 930 | 930 | |
| 931 | 931 | echo esc_attr( $edit_entry_title ); |
| 932 | 932 | ?></span> |
@@ -976,16 +976,16 @@ discard block |
||
| 976 | 976 | |
| 977 | 977 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
| 978 | 978 | |
| 979 | - if( ! $this->is_valid ){ |
|
| 979 | + if ( ! $this->is_valid ) { |
|
| 980 | 980 | |
| 981 | 981 | // Keeping this compatible with Gravity Forms. |
| 982 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 983 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 982 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 983 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 984 | 984 | |
| 985 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 985 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 986 | 986 | |
| 987 | 987 | } else { |
| 988 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 988 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
| 989 | 989 | |
| 990 | 990 | /** |
| 991 | 991 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | * @param array $entry Gravity Forms entry array |
| 996 | 996 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 997 | 997 | */ |
| 998 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 998 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 999 | 999 | |
| 1000 | 1000 | echo GVCommon::generate_notice( $message ); |
| 1001 | 1001 | } |
@@ -1019,21 +1019,21 @@ discard block |
||
| 1019 | 1019 | */ |
| 1020 | 1020 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 1021 | 1021 | |
| 1022 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 1023 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 1022 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 1023 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 1024 | 1024 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1025 | 1025 | |
| 1026 | 1026 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
| 1027 | 1027 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 1028 | 1028 | |
| 1029 | 1029 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 1030 | - unset( $_GET['page'] ); |
|
| 1030 | + unset( $_GET[ 'page' ] ); |
|
| 1031 | 1031 | |
| 1032 | 1032 | // TODO: Verify multiple-page forms |
| 1033 | 1033 | |
| 1034 | 1034 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1035 | 1035 | |
| 1036 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1036 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1037 | 1037 | |
| 1038 | 1038 | ob_get_clean(); |
| 1039 | 1039 | |
@@ -1059,7 +1059,7 @@ discard block |
||
| 1059 | 1059 | * @return string |
| 1060 | 1060 | */ |
| 1061 | 1061 | public function render_form_buttons() { |
| 1062 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1062 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 1065 | |
@@ -1079,10 +1079,10 @@ discard block |
||
| 1079 | 1079 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1080 | 1080 | |
| 1081 | 1081 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1082 | - if( isset( $this->form_after_validation ) ) { |
|
| 1082 | + if ( isset( $this->form_after_validation ) ) { |
|
| 1083 | 1083 | $form = $this->form_after_validation; |
| 1084 | 1084 | } else { |
| 1085 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1085 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | $form = $this->filter_conditional_logic( $form ); |
@@ -1090,8 +1090,8 @@ discard block |
||
| 1090 | 1090 | $form = $this->prefill_conditional_logic( $form ); |
| 1091 | 1091 | |
| 1092 | 1092 | // for now we don't support Save and Continue feature. |
| 1093 | - if( ! self::$supports_save_and_continue ) { |
|
| 1094 | - unset( $form['save'] ); |
|
| 1093 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1094 | + unset( $form[ 'save' ] ); |
|
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | 1097 | $form = $this->unselect_default_values( $form ); |
@@ -1114,31 +1114,31 @@ discard block |
||
| 1114 | 1114 | */ |
| 1115 | 1115 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
| 1116 | 1116 | |
| 1117 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
| 1117 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
| 1118 | 1118 | return $field_content; |
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | 1121 | $message = null; |
| 1122 | 1122 | |
| 1123 | 1123 | // First, make sure they have the capability to edit the post. |
| 1124 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1124 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1125 | 1125 | |
| 1126 | 1126 | /** |
| 1127 | 1127 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1128 | 1128 | * @param string $message The existing "You don't have permission..." text |
| 1129 | 1129 | */ |
| 1130 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1130 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1131 | 1131 | |
| 1132 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1132 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1133 | 1133 | /** |
| 1134 | 1134 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1135 | 1135 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1136 | 1136 | */ |
| 1137 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1137 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | - if( $message ) { |
|
| 1141 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1140 | + if ( $message ) { |
|
| 1141 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | return $field_content; |
@@ -1162,8 +1162,8 @@ discard block |
||
| 1162 | 1162 | |
| 1163 | 1163 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1164 | 1164 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1165 | - if( |
|
| 1166 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1165 | + if ( |
|
| 1166 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1167 | 1167 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1168 | 1168 | && ! GFCommon::is_product_field( $field->type ) |
| 1169 | 1169 | || ! empty( $field_content ) |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | $return = null; |
| 1184 | 1184 | |
| 1185 | 1185 | /** @var GravityView_Field $gv_field */ |
| 1186 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1186 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1187 | 1187 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1188 | 1188 | } else { |
| 1189 | 1189 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | // If there was output, it's an error |
| 1193 | 1193 | $warnings = ob_get_clean(); |
| 1194 | 1194 | |
| 1195 | - if( !empty( $warnings ) ) { |
|
| 1195 | + if ( ! empty( $warnings ) ) { |
|
| 1196 | 1196 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
| 1197 | 1197 | } |
| 1198 | 1198 | |
@@ -1217,7 +1217,7 @@ discard block |
||
| 1217 | 1217 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1218 | 1218 | |
| 1219 | 1219 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1220 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1220 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1221 | 1221 | |
| 1222 | 1222 | $field_value = array(); |
| 1223 | 1223 | |
@@ -1226,10 +1226,10 @@ discard block |
||
| 1226 | 1226 | |
| 1227 | 1227 | foreach ( (array)$field->inputs as $input ) { |
| 1228 | 1228 | |
| 1229 | - $input_id = strval( $input['id'] ); |
|
| 1229 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1230 | 1230 | |
| 1231 | 1231 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1232 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1232 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1233 | 1233 | $allow_pre_populated = false; |
| 1234 | 1234 | } |
| 1235 | 1235 | |
@@ -1237,7 +1237,7 @@ discard block |
||
| 1237 | 1237 | |
| 1238 | 1238 | $pre_value = $field->get_value_submission( array(), false ); |
| 1239 | 1239 | |
| 1240 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1240 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1241 | 1241 | |
| 1242 | 1242 | } else { |
| 1243 | 1243 | |
@@ -1248,13 +1248,13 @@ discard block |
||
| 1248 | 1248 | |
| 1249 | 1249 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1250 | 1250 | // or pre-populated value if not empty and set to override saved value |
| 1251 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1251 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1252 | 1252 | |
| 1253 | 1253 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1254 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1254 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1255 | 1255 | $categories = array(); |
| 1256 | 1256 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1257 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1257 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1258 | 1258 | } |
| 1259 | 1259 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1260 | 1260 | } |
@@ -1282,7 +1282,7 @@ discard block |
||
| 1282 | 1282 | * @param GF_Field $field Gravity Forms field object |
| 1283 | 1283 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1284 | 1284 | */ |
| 1285 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1285 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1286 | 1286 | |
| 1287 | 1287 | return $field_value; |
| 1288 | 1288 | } |
@@ -1299,12 +1299,12 @@ discard block |
||
| 1299 | 1299 | */ |
| 1300 | 1300 | public function gform_pre_validation( $form ) { |
| 1301 | 1301 | |
| 1302 | - if( ! $this->verify_nonce() ) { |
|
| 1302 | + if ( ! $this->verify_nonce() ) { |
|
| 1303 | 1303 | return $form; |
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | 1306 | // Fix PHP warning regarding undefined index. |
| 1307 | - foreach ( $form['fields'] as &$field) { |
|
| 1307 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1308 | 1308 | |
| 1309 | 1309 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1310 | 1310 | // expects certain field array items to be set. |
@@ -1312,7 +1312,7 @@ discard block |
||
| 1312 | 1312 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1315 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1316 | 1316 | |
| 1317 | 1317 | /** |
| 1318 | 1318 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1326,26 +1326,26 @@ discard block |
||
| 1326 | 1326 | // Set the previous value |
| 1327 | 1327 | $entry = $this->get_entry(); |
| 1328 | 1328 | |
| 1329 | - $input_name = 'input_'.$field->id; |
|
| 1330 | - $form_id = $form['id']; |
|
| 1329 | + $input_name = 'input_' . $field->id; |
|
| 1330 | + $form_id = $form[ 'id' ]; |
|
| 1331 | 1331 | |
| 1332 | 1332 | $value = NULL; |
| 1333 | 1333 | |
| 1334 | 1334 | // Use the previous entry value as the default. |
| 1335 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1335 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1336 | 1336 | $value = $entry[ $field->id ]; |
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | 1339 | // If this is a single upload file |
| 1340 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1341 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1342 | - $value = $file_path['url']; |
|
| 1340 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1341 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1342 | + $value = $file_path[ 'url' ]; |
|
| 1343 | 1343 | |
| 1344 | 1344 | } else { |
| 1345 | 1345 | |
| 1346 | 1346 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1347 | 1347 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1348 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1348 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1349 | 1349 | |
| 1350 | 1350 | } |
| 1351 | 1351 | |
@@ -1353,10 +1353,10 @@ discard block |
||
| 1353 | 1353 | |
| 1354 | 1354 | // If there are fresh uploads, process and merge them. |
| 1355 | 1355 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
| 1356 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1356 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
| 1357 | 1357 | $value = empty( $value ) ? '[]' : $value; |
| 1358 | 1358 | $value = stripslashes_deep( $value ); |
| 1359 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1359 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1360 | 1360 | } |
| 1361 | 1361 | |
| 1362 | 1362 | } else { |
@@ -1374,8 +1374,8 @@ discard block |
||
| 1374 | 1374 | |
| 1375 | 1375 | case 'number': |
| 1376 | 1376 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1377 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1378 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1377 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1378 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1379 | 1379 | } |
| 1380 | 1380 | break; |
| 1381 | 1381 | } |
@@ -1412,7 +1412,7 @@ discard block |
||
| 1412 | 1412 | * You can enter whatever you want! |
| 1413 | 1413 | * We try validating, and customize the results using `self::custom_validation()` |
| 1414 | 1414 | */ |
| 1415 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1415 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1416 | 1416 | |
| 1417 | 1417 | // Needed by the validate funtion |
| 1418 | 1418 | $failed_validation_page = NULL; |
@@ -1420,14 +1420,14 @@ discard block |
||
| 1420 | 1420 | |
| 1421 | 1421 | // Prevent entry limit from running when editing an entry, also |
| 1422 | 1422 | // prevent form scheduling from preventing editing |
| 1423 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1423 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1424 | 1424 | |
| 1425 | 1425 | // Hide fields depending on Edit Entry settings |
| 1426 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1426 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1427 | 1427 | |
| 1428 | 1428 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1429 | 1429 | |
| 1430 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1430 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | |
@@ -1450,7 +1450,7 @@ discard block |
||
| 1450 | 1450 | |
| 1451 | 1451 | $gv_valid = true; |
| 1452 | 1452 | |
| 1453 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1453 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1454 | 1454 | |
| 1455 | 1455 | $value = RGFormsModel::get_field_value( $field ); |
| 1456 | 1456 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1463,35 +1463,35 @@ discard block |
||
| 1463 | 1463 | case 'post_image': |
| 1464 | 1464 | |
| 1465 | 1465 | // in case nothing is uploaded but there are already files saved |
| 1466 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1466 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
| 1467 | 1467 | $field->failed_validation = false; |
| 1468 | 1468 | unset( $field->validation_message ); |
| 1469 | 1469 | } |
| 1470 | 1470 | |
| 1471 | 1471 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
| 1472 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1472 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
| 1473 | 1473 | |
| 1474 | 1474 | $input_name = 'input_' . $field->id; |
| 1475 | 1475 | //uploaded |
| 1476 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1476 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1477 | 1477 | |
| 1478 | 1478 | //existent |
| 1479 | 1479 | $entry = $this->get_entry(); |
| 1480 | 1480 | $value = NULL; |
| 1481 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1481 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1482 | 1482 | $value = json_decode( $entry[ $field->id ], true ); |
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | 1485 | // count uploaded files and existent entry files |
| 1486 | 1486 | $count_files = count( $file_names ) + count( $value ); |
| 1487 | 1487 | |
| 1488 | - if( $count_files > $field->maxFiles ) { |
|
| 1488 | + if ( $count_files > $field->maxFiles ) { |
|
| 1489 | 1489 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
| 1490 | 1490 | $field->failed_validation = 1; |
| 1491 | 1491 | $gv_valid = false; |
| 1492 | 1492 | |
| 1493 | 1493 | // in case of error make sure the newest upload files are removed from the upload input |
| 1494 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1494 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | 1497 | } |
@@ -1502,7 +1502,7 @@ discard block |
||
| 1502 | 1502 | } |
| 1503 | 1503 | |
| 1504 | 1504 | // This field has failed validation. |
| 1505 | - if( !empty( $field->failed_validation ) ) { |
|
| 1505 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1506 | 1506 | |
| 1507 | 1507 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
| 1508 | 1508 | |
@@ -1520,19 +1520,19 @@ discard block |
||
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | // You can't continue inside a switch, so we do it after. |
| 1523 | - if( empty( $field->failed_validation ) ) { |
|
| 1523 | + if ( empty( $field->failed_validation ) ) { |
|
| 1524 | 1524 | continue; |
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1528 | 1528 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1529 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1529 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1530 | 1530 | |
| 1531 | 1531 | $entry = $this->get_entry(); |
| 1532 | 1532 | |
| 1533 | 1533 | // If the value of the entry is the same as the stored value |
| 1534 | 1534 | // Then we can assume it's not a duplicate, it's the same. |
| 1535 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1535 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1536 | 1536 | //if value submitted was not changed, then don't validate |
| 1537 | 1537 | $field->failed_validation = false; |
| 1538 | 1538 | |
@@ -1545,7 +1545,7 @@ discard block |
||
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1548 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1548 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1549 | 1549 | unset( $field->validation_message ); |
| 1550 | 1550 | $field->validation_message = false; |
| 1551 | 1551 | continue; |
@@ -1557,12 +1557,12 @@ discard block |
||
| 1557 | 1557 | |
| 1558 | 1558 | } |
| 1559 | 1559 | |
| 1560 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1560 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1561 | 1561 | |
| 1562 | 1562 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
| 1563 | 1563 | |
| 1564 | 1564 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1565 | - $this->form_after_validation = $validation_results['form']; |
|
| 1565 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1566 | 1566 | |
| 1567 | 1567 | return $validation_results; |
| 1568 | 1568 | } |
@@ -1575,7 +1575,7 @@ discard block |
||
| 1575 | 1575 | */ |
| 1576 | 1576 | public function get_entry() { |
| 1577 | 1577 | |
| 1578 | - if( empty( $this->entry ) ) { |
|
| 1578 | + if ( empty( $this->entry ) ) { |
|
| 1579 | 1579 | // Get the database value of the entry that's being edited |
| 1580 | 1580 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1581 | 1581 | } |
@@ -1607,10 +1607,10 @@ discard block |
||
| 1607 | 1607 | } |
| 1608 | 1608 | |
| 1609 | 1609 | // If edit tab not yet configured, show all fields |
| 1610 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1610 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1611 | 1611 | |
| 1612 | 1612 | // Hide fields depending on admin settings |
| 1613 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1613 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1614 | 1614 | |
| 1615 | 1615 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1616 | 1616 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1642,7 +1642,7 @@ discard block |
||
| 1642 | 1642 | */ |
| 1643 | 1643 | private function filter_fields( $fields, $configured_fields ) { |
| 1644 | 1644 | |
| 1645 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1645 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1646 | 1646 | return $fields; |
| 1647 | 1647 | } |
| 1648 | 1648 | |
@@ -1655,18 +1655,18 @@ discard block |
||
| 1655 | 1655 | |
| 1656 | 1656 | // Remove the fields that have calculation properties and keep them to be used later |
| 1657 | 1657 | // @since 1.16.2 |
| 1658 | - if( $field->has_calculation() ) { |
|
| 1659 | - $this->fields_with_calculation[] = $field; |
|
| 1658 | + if ( $field->has_calculation() ) { |
|
| 1659 | + $this->fields_with_calculation[ ] = $field; |
|
| 1660 | 1660 | // don't remove the calculation fields on form render. |
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1663 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1664 | 1664 | unset( $fields[ $key ] ); |
| 1665 | 1665 | } |
| 1666 | 1666 | } |
| 1667 | 1667 | |
| 1668 | 1668 | // The Edit tab has not been configured, so we return all fields by default. |
| 1669 | - if( empty( $configured_fields ) ) { |
|
| 1669 | + if ( empty( $configured_fields ) ) { |
|
| 1670 | 1670 | return $fields; |
| 1671 | 1671 | } |
| 1672 | 1672 | |
@@ -1675,8 +1675,8 @@ discard block |
||
| 1675 | 1675 | |
| 1676 | 1676 | /** @var GF_Field $field */ |
| 1677 | 1677 | foreach ( $fields as $field ) { |
| 1678 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1679 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1678 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1679 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1680 | 1680 | break; |
| 1681 | 1681 | } |
| 1682 | 1682 | |
@@ -1699,14 +1699,14 @@ discard block |
||
| 1699 | 1699 | |
| 1700 | 1700 | $return_field = $field; |
| 1701 | 1701 | |
| 1702 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 1702 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 1703 | 1703 | $return_field->label = ''; |
| 1704 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 1705 | - $return_field->label = $field_setting['custom_label']; |
|
| 1704 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 1705 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 1706 | 1706 | } |
| 1707 | 1707 | |
| 1708 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 1709 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 1708 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 1709 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 1710 | 1710 | } |
| 1711 | 1711 | |
| 1712 | 1712 | /** |
@@ -1744,16 +1744,16 @@ discard block |
||
| 1744 | 1744 | */ |
| 1745 | 1745 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 1746 | 1746 | |
| 1747 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1748 | - foreach( $fields as $k => $field ) { |
|
| 1749 | - if( $field->adminOnly ) { |
|
| 1747 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 1748 | + foreach ( $fields as $k => $field ) { |
|
| 1749 | + if ( $field->adminOnly ) { |
|
| 1750 | 1750 | unset( $fields[ $k ] ); |
| 1751 | 1751 | } |
| 1752 | 1752 | } |
| 1753 | 1753 | return $fields; |
| 1754 | 1754 | } |
| 1755 | 1755 | |
| 1756 | - foreach( $fields as &$field ) { |
|
| 1756 | + foreach ( $fields as &$field ) { |
|
| 1757 | 1757 | $field->adminOnly = false; |
| 1758 | 1758 | } |
| 1759 | 1759 | |
@@ -1774,7 +1774,7 @@ discard block |
||
| 1774 | 1774 | */ |
| 1775 | 1775 | private function unselect_default_values( $form ) { |
| 1776 | 1776 | |
| 1777 | - foreach ( $form['fields'] as &$field ) { |
|
| 1777 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1778 | 1778 | |
| 1779 | 1779 | if ( empty( $field->choices ) ) { |
| 1780 | 1780 | continue; |
@@ -1782,7 +1782,7 @@ discard block |
||
| 1782 | 1782 | |
| 1783 | 1783 | foreach ( $field->choices as &$choice ) { |
| 1784 | 1784 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1785 | - $choice['isSelected'] = false; |
|
| 1785 | + $choice[ 'isSelected' ] = false; |
|
| 1786 | 1786 | } |
| 1787 | 1787 | } |
| 1788 | 1788 | } |
@@ -1807,22 +1807,22 @@ discard block |
||
| 1807 | 1807 | */ |
| 1808 | 1808 | function prefill_conditional_logic( $form ) { |
| 1809 | 1809 | |
| 1810 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1810 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1811 | 1811 | return $form; |
| 1812 | 1812 | } |
| 1813 | 1813 | |
| 1814 | 1814 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 1815 | 1815 | /** @var GF_Field $field */ |
| 1816 | - foreach ( $form['fields'] as &$field ) { |
|
| 1816 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1817 | 1817 | |
| 1818 | - if( 'checkbox' === $field->type ) { |
|
| 1818 | + if ( 'checkbox' === $field->type ) { |
|
| 1819 | 1819 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1820 | - $input_id = $input['id']; |
|
| 1820 | + $input_id = $input[ 'id' ]; |
|
| 1821 | 1821 | $choice = $field->choices[ $key ]; |
| 1822 | 1822 | $value = \GV\Utils::get( $this->entry, $input_id ); |
| 1823 | 1823 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 1824 | - if( $match ) { |
|
| 1825 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1824 | + if ( $match ) { |
|
| 1825 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 1826 | 1826 | } |
| 1827 | 1827 | } |
| 1828 | 1828 | } else { |
@@ -1830,15 +1830,15 @@ discard block |
||
| 1830 | 1830 | // We need to run through each field to set the default values |
| 1831 | 1831 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1832 | 1832 | |
| 1833 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1833 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1834 | 1834 | |
| 1835 | - if( 'list' === $field->type ) { |
|
| 1835 | + if ( 'list' === $field->type ) { |
|
| 1836 | 1836 | $list_rows = maybe_unserialize( $field_value ); |
| 1837 | 1837 | |
| 1838 | 1838 | $list_field_value = array(); |
| 1839 | - foreach ( (array) $list_rows as $row ) { |
|
| 1840 | - foreach ( (array) $row as $column ) { |
|
| 1841 | - $list_field_value[] = $column; |
|
| 1839 | + foreach ( (array)$list_rows as $row ) { |
|
| 1840 | + foreach ( (array)$row as $column ) { |
|
| 1841 | + $list_field_value[ ] = $column; |
|
| 1842 | 1842 | } |
| 1843 | 1843 | } |
| 1844 | 1844 | |
@@ -1873,16 +1873,16 @@ discard block |
||
| 1873 | 1873 | */ |
| 1874 | 1874 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 1875 | 1875 | |
| 1876 | - if( $use_conditional_logic ) { |
|
| 1876 | + if ( $use_conditional_logic ) { |
|
| 1877 | 1877 | return $form; |
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | - foreach( $form['fields'] as &$field ) { |
|
| 1880 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1881 | 1881 | /* @var GF_Field $field */ |
| 1882 | 1882 | $field->conditionalLogic = null; |
| 1883 | 1883 | } |
| 1884 | 1884 | |
| 1885 | - unset( $form['button']['conditionalLogic'] ); |
|
| 1885 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 1886 | 1886 | |
| 1887 | 1887 | return $form; |
| 1888 | 1888 | |
@@ -1899,7 +1899,7 @@ discard block |
||
| 1899 | 1899 | */ |
| 1900 | 1900 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 1901 | 1901 | |
| 1902 | - if( ! $this->is_edit_entry() ) { |
|
| 1902 | + if ( ! $this->is_edit_entry() ) { |
|
| 1903 | 1903 | return $has_conditional_logic; |
| 1904 | 1904 | } |
| 1905 | 1905 | |
@@ -1931,44 +1931,44 @@ discard block |
||
| 1931 | 1931 | * 2. There are two entries embedded using oEmbed |
| 1932 | 1932 | * 3. One of the entries has just been saved |
| 1933 | 1933 | */ |
| 1934 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 1934 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 1935 | 1935 | |
| 1936 | 1936 | $error = true; |
| 1937 | 1937 | |
| 1938 | 1938 | } |
| 1939 | 1939 | |
| 1940 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 1940 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 1941 | 1941 | |
| 1942 | 1942 | $error = true; |
| 1943 | 1943 | |
| 1944 | - } elseif( ! $this->verify_nonce() ) { |
|
| 1944 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 1945 | 1945 | |
| 1946 | 1946 | /** |
| 1947 | 1947 | * If the Entry is embedded, there may be two entries on the same page. |
| 1948 | 1948 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 1949 | 1949 | */ |
| 1950 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1950 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1951 | 1951 | $error = true; |
| 1952 | 1952 | } else { |
| 1953 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 1953 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 1954 | 1954 | } |
| 1955 | 1955 | |
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1959 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 1958 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1959 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 1960 | 1960 | } |
| 1961 | 1961 | |
| 1962 | - if( $this->entry['status'] === 'trash' ) { |
|
| 1963 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1962 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 1963 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1964 | 1964 | } |
| 1965 | 1965 | |
| 1966 | 1966 | // No errors; everything's fine here! |
| 1967 | - if( empty( $error ) ) { |
|
| 1967 | + if ( empty( $error ) ) { |
|
| 1968 | 1968 | return true; |
| 1969 | 1969 | } |
| 1970 | 1970 | |
| 1971 | - if( $echo && $error !== true ) { |
|
| 1971 | + if ( $echo && $error !== true ) { |
|
| 1972 | 1972 | |
| 1973 | 1973 | $error = esc_html( $error ); |
| 1974 | 1974 | |
@@ -1976,10 +1976,10 @@ discard block |
||
| 1976 | 1976 | * @since 1.9 |
| 1977 | 1977 | */ |
| 1978 | 1978 | if ( ! empty( $this->entry ) ) { |
| 1979 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
| 1979 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
| 1980 | 1980 | } |
| 1981 | 1981 | |
| 1982 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 1982 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 1983 | 1983 | } |
| 1984 | 1984 | |
| 1985 | 1985 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1999,17 +1999,17 @@ discard block |
||
| 1999 | 1999 | |
| 2000 | 2000 | $error = NULL; |
| 2001 | 2001 | |
| 2002 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2003 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 2002 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2003 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 2004 | 2004 | } |
| 2005 | 2005 | |
| 2006 | 2006 | // No errors; everything's fine here! |
| 2007 | - if( empty( $error ) ) { |
|
| 2007 | + if ( empty( $error ) ) { |
|
| 2008 | 2008 | return true; |
| 2009 | 2009 | } |
| 2010 | 2010 | |
| 2011 | - if( $echo ) { |
|
| 2012 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 2011 | + if ( $echo ) { |
|
| 2012 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 2013 | 2013 | } |
| 2014 | 2014 | |
| 2015 | 2015 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2030,14 +2030,14 @@ discard block |
||
| 2030 | 2030 | private function check_user_cap_edit_field( $field ) { |
| 2031 | 2031 | |
| 2032 | 2032 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 2033 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2033 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2034 | 2034 | return true; |
| 2035 | 2035 | } |
| 2036 | 2036 | |
| 2037 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 2037 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 2038 | 2038 | |
| 2039 | - if( $field_cap ) { |
|
| 2040 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 2039 | + if ( $field_cap ) { |
|
| 2040 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 2041 | 2041 | } |
| 2042 | 2042 | |
| 2043 | 2043 | return false; |
@@ -2051,17 +2051,17 @@ discard block |
||
| 2051 | 2051 | public function verify_nonce() { |
| 2052 | 2052 | |
| 2053 | 2053 | // Verify form submitted for editing single |
| 2054 | - if( $this->is_edit_entry_submission() ) { |
|
| 2054 | + if ( $this->is_edit_entry_submission() ) { |
|
| 2055 | 2055 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 2056 | 2056 | } |
| 2057 | 2057 | |
| 2058 | 2058 | // Verify |
| 2059 | - else if( ! $this->is_edit_entry() ) { |
|
| 2059 | + else if ( ! $this->is_edit_entry() ) { |
|
| 2060 | 2060 | $valid = false; |
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | 2063 | else { |
| 2064 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2064 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | 2067 | /** |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | |
| 977 | 977 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
| 978 | 978 | |
| 979 | - if( ! $this->is_valid ){ |
|
| 979 | + if( ! $this->is_valid ) { |
|
| 980 | 980 | |
| 981 | 981 | // Keeping this compatible with Gravity Forms. |
| 982 | 982 | $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
@@ -2058,9 +2058,7 @@ discard block |
||
| 2058 | 2058 | // Verify |
| 2059 | 2059 | else if( ! $this->is_edit_entry() ) { |
| 2060 | 2060 | $valid = false; |
| 2061 | - } |
|
| 2062 | - |
|
| 2063 | - else { |
|
| 2061 | + } else { |
|
| 2064 | 2062 | $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
| 2065 | 2063 | } |
| 2066 | 2064 | |