@@ -7,17 +7,17 @@ |
||
| 7 | 7 | |
| 8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
| 9 | 9 | $view_id = $gravityview_view->getViewId(); |
| 10 | -$value = $gravityview_view->search_field['value']; |
|
| 11 | -$label = $gravityview_view->search_field['label']; |
|
| 12 | -$name = $gravityview_view->search_field['name']; |
|
| 10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
| 11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
| 12 | +$name = $gravityview_view->search_field[ 'name' ]; |
|
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | 15 | <div class="gv-search-box gv-search-date gv-search-date-range"> |
| 16 | - <?php if( ! gv_empty( $label, false, false ) ) { ?> |
|
| 17 | - <label for="search-box-<?php echo esc_attr( $name ).'-start'; ?>"><?php echo esc_html( $label ); ?></label> |
|
| 16 | + <?php if ( ! gv_empty( $label, false, false ) ) { ?> |
|
| 17 | + <label for="search-box-<?php echo esc_attr( $name ) . '-start'; ?>"><?php echo esc_html( $label ); ?></label> |
|
| 18 | 18 | <?php } ?> |
| 19 | 19 | <p> |
| 20 | - <input name="<?php echo esc_attr( $name ).'[start]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-start'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview' ); ?>" value="<?php echo $value['start']; ?>"> |
|
| 21 | - <input name="<?php echo esc_attr( $name ).'[end]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-end'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview' ); ?>" value="<?php echo $value['end']; ?>"> |
|
| 20 | + <input name="<?php echo esc_attr( $name ) . '[start]'; ?>" id="search-box-<?php echo esc_attr( $name ) . '-start'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'Start date', 'gravityview' ); ?>" value="<?php echo $value[ 'start' ]; ?>"> |
|
| 21 | + <input name="<?php echo esc_attr( $name ) . '[end]'; ?>" id="search-box-<?php echo esc_attr( $name ) . '-end'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'End date', 'gravityview' ); ?>" value="<?php echo $value[ 'end' ]; ?>"> |
|
| 22 | 22 | </p> |
| 23 | 23 | </div> |
| 24 | 24 | \ No newline at end of file |
@@ -10,10 +10,10 @@ |
||
| 10 | 10 | |
| 11 | 11 | ?> |
| 12 | 12 | <div class="gv-search-box gv-search-field-text"> |
| 13 | - <?php if( ! gv_empty( $search_field['label'], false, false ) ) { ?> |
|
| 14 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label> |
|
| 13 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { ?> |
|
| 14 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
| 15 | 15 | <?php } ?> |
| 16 | 16 | <p> |
| 17 | - <input type="text" name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" value="<?php echo esc_attr( $search_field['value'] ); ?>"> |
|
| 17 | + <input type="text" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" value="<?php echo esc_attr( $search_field[ 'value' ] ); ?>"> |
|
| 18 | 18 | </p> |
| 19 | 19 | </div> |
| 20 | 20 | \ No newline at end of file |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | 14 | <div class="gv-search-box gv-search-field-single_checkbox"> |
| 15 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" class="gv-check-radio"> |
|
| 16 | - <input type="checkbox" name="<?php echo esc_attr( $search_field['name'] ); ?>" value="1" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" <?php checked( '1', $search_field['value'], true ); ?>> |
|
| 17 | - <?php if( ! gv_empty( $search_field['label'], false, false ) ) { echo esc_html( $search_field['label'] ); } ?> |
|
| 15 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" class="gv-check-radio"> |
|
| 16 | + <input type="checkbox" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" value="1" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" <?php checked( '1', $search_field[ 'value' ], true ); ?>> |
|
| 17 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { echo esc_html( $search_field[ 'label' ] ); } ?> |
|
| 18 | 18 | </label> |
| 19 | 19 | </div> |
| 20 | 20 | \ No newline at end of file |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $sidebars_widgets = wp_get_sidebars_widgets(); |
| 82 | - if ( empty( $sidebars_widgets[ $matches[1] ] ) ) { |
|
| 82 | + if ( empty( $sidebars_widgets[ $matches[ 1 ] ] ) ) { |
|
| 83 | 83 | return $shortcodes; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - foreach ( $sidebars_widgets[ $matches[1] ] as $widgets ) { |
|
| 86 | + foreach ( $sidebars_widgets[ $matches[ 1 ] ] as $widgets ) { |
|
| 87 | 87 | if ( |
| 88 | 88 | /** |
| 89 | 89 | * Blacklisted widgets. |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | strpos( $widgets, 'gv_recent_entries' ) === 0 |
| 93 | 93 | ) { |
| 94 | 94 | |
| 95 | - $shortcodes []= 'et_pb_sidebar'; |
|
| 95 | + $shortcodes [ ] = 'et_pb_sidebar'; |
|
| 96 | 96 | break; |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -22,13 +22,13 @@ |
||
| 22 | 22 | |
| 23 | 23 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 24 | 24 | |
| 25 | - unset( $field_options['show_as_link'] ); |
|
| 25 | + unset( $field_options[ 'show_as_link' ] ); |
|
| 26 | 26 | |
| 27 | - if( 'edit' === $context ) { |
|
| 27 | + if ( 'edit' === $context ) { |
|
| 28 | 28 | return $field_options; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $this->add_field_support('dynamic_data', $field_options ); |
|
| 31 | + $this->add_field_support( 'dynamic_data', $field_options ); |
|
| 32 | 32 | |
| 33 | 33 | return $field_options; |
| 34 | 34 | } |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | |
| 943 | 943 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
| 944 | 944 | |
| 945 | - if( ! $this->is_valid ){ |
|
| 945 | + if( ! $this->is_valid ) { |
|
| 946 | 946 | |
| 947 | 947 | // Keeping this compatible with Gravity Forms. |
| 948 | 948 | $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
@@ -1996,9 +1996,7 @@ discard block |
||
| 1996 | 1996 | // Verify |
| 1997 | 1997 | else if( ! $this->is_edit_entry() ) { |
| 1998 | 1998 | $valid = false; |
| 1999 | - } |
|
| 2000 | - |
|
| 2001 | - else { |
|
| 1999 | + } else { |
|
| 2002 | 2000 | $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
| 2003 | 2001 | } |
| 2004 | 2002 | |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | public function prevent_maybe_process_form() { |
| 161 | 161 | |
| 162 | 162 | if( ! empty( $_POST ) ) { |
| 163 | - gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
| 163 | + gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | if( $this->is_edit_entry_submission() ) { |
| 167 | 167 | remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
| 168 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 168 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | $entries = $gravityview_view->getEntries(); |
| 200 | - self::$original_entry = $entries[0]; |
|
| 201 | - $this->entry = $entries[0]; |
|
| 200 | + self::$original_entry = $entries[0]; |
|
| 201 | + $this->entry = $entries[0]; |
|
| 202 | 202 | |
| 203 | 203 | self::$original_form = $gravityview_view->getForm(); |
| 204 | 204 | $this->form = $gravityview_view->getForm(); |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | GFFormsModel::save_lead( $form, $this->entry ); |
| 324 | 324 | |
| 325 | - // Delete the values for hidden inputs |
|
| 326 | - $this->unset_hidden_field_values(); |
|
| 325 | + // Delete the values for hidden inputs |
|
| 326 | + $this->unset_hidden_field_values(); |
|
| 327 | 327 | |
| 328 | 328 | $this->entry['date_created'] = $date_created; |
| 329 | 329 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | // Perform actions normally performed after updating a lead |
| 334 | 334 | $this->after_update(); |
| 335 | 335 | |
| 336 | - /** |
|
| 336 | + /** |
|
| 337 | 337 | * Must be AFTER after_update()! |
| 338 | 338 | * @see https://github.com/gravityview/GravityView/issues/764 |
| 339 | 339 | */ |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * @return void |
| 364 | 364 | */ |
| 365 | 365 | private function unset_hidden_field_values() { |
| 366 | - global $wpdb; |
|
| 366 | + global $wpdb; |
|
| 367 | 367 | |
| 368 | 368 | /** |
| 369 | 369 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -385,27 +385,27 @@ discard block |
||
| 385 | 385 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
| 388 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
| 389 | 389 | |
| 390 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 390 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 391 | 391 | |
| 392 | - // Reset fields that are hidden |
|
| 393 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 394 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 392 | + // Reset fields that are hidden |
|
| 393 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 394 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 395 | 395 | |
| 396 | - // List fields are stored as empty arrays when empty |
|
| 397 | - $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
| 396 | + // List fields are stored as empty arrays when empty |
|
| 397 | + $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
| 398 | 398 | |
| 399 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 399 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 400 | 400 | |
| 401 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 401 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 402 | 402 | |
| 403 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 403 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 404 | 404 | // after submission |
| 405 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 406 | - $_POST[ $post_input_id ] = ''; |
|
| 407 | - } |
|
| 408 | - } |
|
| 405 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 406 | + $_POST[ $post_input_id ] = ''; |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | |
| 500 | 500 | $form = $this->form; |
| 501 | 501 | |
| 502 | - /** @var GF_Field $field */ |
|
| 502 | + /** @var GF_Field $field */ |
|
| 503 | 503 | foreach( $form['fields'] as $k => &$field ) { |
| 504 | 504 | |
| 505 | 505 | /** |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | |
| 516 | 516 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
| 517 | 517 | foreach( $field->inputs as $key => $input ) { |
| 518 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 518 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 519 | 519 | } |
| 520 | 520 | } |
| 521 | 521 | } |
@@ -536,13 +536,13 @@ discard block |
||
| 536 | 536 | foreach ( $this->fields_with_calculation as $calc_field ) { |
| 537 | 537 | $inputs = $calc_field->get_entry_inputs(); |
| 538 | 538 | if ( is_array( $inputs ) ) { |
| 539 | - foreach ( $inputs as $input ) { |
|
| 540 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 541 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 542 | - } |
|
| 539 | + foreach ( $inputs as $input ) { |
|
| 540 | + $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 541 | + $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 542 | + } |
|
| 543 | 543 | } else { |
| 544 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
| 545 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 544 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
| 545 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
| 591 | 591 | |
| 592 | 592 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 593 | - $ary = stripslashes_deep( $ary ); |
|
| 593 | + $ary = stripslashes_deep( $ary ); |
|
| 594 | 594 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 595 | 595 | |
| 596 | 596 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | private function maybe_update_post_fields( $form ) { |
| 664 | 664 | |
| 665 | 665 | if( empty( $this->entry['post_id'] ) ) { |
| 666 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 666 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 667 | 667 | return; |
| 668 | 668 | } |
| 669 | 669 | |
@@ -698,51 +698,51 @@ discard block |
||
| 698 | 698 | |
| 699 | 699 | switch( $field->type ) { |
| 700 | 700 | |
| 701 | - case 'post_title': |
|
| 702 | - $post_title = $value; |
|
| 703 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 704 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 705 | - } |
|
| 706 | - $updated_post->post_title = $post_title; |
|
| 707 | - $updated_post->post_name = $post_title; |
|
| 708 | - unset( $post_title ); |
|
| 709 | - break; |
|
| 710 | - |
|
| 711 | - case 'post_content': |
|
| 712 | - $post_content = $value; |
|
| 713 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 714 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 715 | - } |
|
| 716 | - $updated_post->post_content = $post_content; |
|
| 717 | - unset( $post_content ); |
|
| 718 | - break; |
|
| 719 | - case 'post_excerpt': |
|
| 720 | - $updated_post->post_excerpt = $value; |
|
| 721 | - break; |
|
| 722 | - case 'post_tags': |
|
| 723 | - wp_set_post_tags( $post_id, $value, false ); |
|
| 724 | - break; |
|
| 725 | - case 'post_category': |
|
| 726 | - break; |
|
| 727 | - case 'post_custom_field': |
|
| 701 | + case 'post_title': |
|
| 702 | + $post_title = $value; |
|
| 703 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 704 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 705 | + } |
|
| 706 | + $updated_post->post_title = $post_title; |
|
| 707 | + $updated_post->post_name = $post_title; |
|
| 708 | + unset( $post_title ); |
|
| 709 | + break; |
|
| 710 | + |
|
| 711 | + case 'post_content': |
|
| 712 | + $post_content = $value; |
|
| 713 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 714 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 715 | + } |
|
| 716 | + $updated_post->post_content = $post_content; |
|
| 717 | + unset( $post_content ); |
|
| 718 | + break; |
|
| 719 | + case 'post_excerpt': |
|
| 720 | + $updated_post->post_excerpt = $value; |
|
| 721 | + break; |
|
| 722 | + case 'post_tags': |
|
| 723 | + wp_set_post_tags( $post_id, $value, false ); |
|
| 724 | + break; |
|
| 725 | + case 'post_category': |
|
| 726 | + break; |
|
| 727 | + case 'post_custom_field': |
|
| 728 | 728 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
| 729 | 729 | $value = $value[ $field_id ]; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 733 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 734 | - } |
|
| 732 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 733 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 734 | + } |
|
| 735 | 735 | |
| 736 | - if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
| 737 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 738 | - } |
|
| 736 | + if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
| 737 | + $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 738 | + } |
|
| 739 | 739 | |
| 740 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 741 | - break; |
|
| 740 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 741 | + break; |
|
| 742 | 742 | |
| 743 | - case 'post_image': |
|
| 744 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 745 | - break; |
|
| 743 | + case 'post_image': |
|
| 744 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 745 | + break; |
|
| 746 | 746 | |
| 747 | 747 | } |
| 748 | 748 | |
@@ -787,20 +787,20 @@ discard block |
||
| 787 | 787 | */ |
| 788 | 788 | private function is_field_json_encoded( $field ) { |
| 789 | 789 | |
| 790 | - $json_encoded = false; |
|
| 790 | + $json_encoded = false; |
|
| 791 | 791 | |
| 792 | 792 | $input_type = RGFormsModel::get_input_type( $field ); |
| 793 | 793 | |
| 794 | - // Only certain custom field types are supported |
|
| 795 | - switch( $input_type ) { |
|
| 796 | - case 'fileupload': |
|
| 797 | - case 'list': |
|
| 798 | - case 'multiselect': |
|
| 799 | - $json_encoded = true; |
|
| 800 | - break; |
|
| 801 | - } |
|
| 794 | + // Only certain custom field types are supported |
|
| 795 | + switch( $input_type ) { |
|
| 796 | + case 'fileupload': |
|
| 797 | + case 'list': |
|
| 798 | + case 'multiselect': |
|
| 799 | + $json_encoded = true; |
|
| 800 | + break; |
|
| 801 | + } |
|
| 802 | 802 | |
| 803 | - return $json_encoded; |
|
| 803 | + return $json_encoded; |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | /** |
@@ -890,14 +890,14 @@ discard block |
||
| 890 | 890 | ?><h2 class="gv-edit-entry-title"> |
| 891 | 891 | <span><?php |
| 892 | 892 | |
| 893 | - /** |
|
| 894 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 895 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 896 | - * @param GravityView_Edit_Entry_Render $this This object |
|
| 897 | - */ |
|
| 898 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 893 | + /** |
|
| 894 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 895 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 896 | + * @param GravityView_Edit_Entry_Render $this This object |
|
| 897 | + */ |
|
| 898 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 899 | 899 | |
| 900 | - echo esc_attr( $edit_entry_title ); |
|
| 900 | + echo esc_attr( $edit_entry_title ); |
|
| 901 | 901 | ?></span> |
| 902 | 902 | </h2> |
| 903 | 903 | |
@@ -1006,7 +1006,7 @@ discard block |
||
| 1006 | 1006 | |
| 1007 | 1007 | ob_get_clean(); |
| 1008 | 1008 | |
| 1009 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1009 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1010 | 1010 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
| 1011 | 1011 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1012 | 1012 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | |
| 1061 | 1061 | // for now we don't support Save and Continue feature. |
| 1062 | 1062 | if( ! self::$supports_save_and_continue ) { |
| 1063 | - unset( $form['save'] ); |
|
| 1063 | + unset( $form['save'] ); |
|
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | return $form; |
@@ -1135,7 +1135,7 @@ discard block |
||
| 1135 | 1135 | || ! empty( $field_content ) |
| 1136 | 1136 | || in_array( $field->type, array( 'honeypot' ) ) |
| 1137 | 1137 | ) { |
| 1138 | - return $field_content; |
|
| 1138 | + return $field_content; |
|
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1143,24 +1143,24 @@ discard block |
||
| 1143 | 1143 | |
| 1144 | 1144 | $field_value = $this->get_field_value( $field ); |
| 1145 | 1145 | |
| 1146 | - // Prevent any PHP warnings, like undefined index |
|
| 1147 | - ob_start(); |
|
| 1146 | + // Prevent any PHP warnings, like undefined index |
|
| 1147 | + ob_start(); |
|
| 1148 | 1148 | |
| 1149 | - $return = null; |
|
| 1149 | + $return = null; |
|
| 1150 | 1150 | |
| 1151 | 1151 | /** @var GravityView_Field $gv_field */ |
| 1152 | 1152 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
| 1153 | 1153 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1154 | 1154 | } else { |
| 1155 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1156 | - } |
|
| 1155 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1156 | + } |
|
| 1157 | 1157 | |
| 1158 | - // If there was output, it's an error |
|
| 1159 | - $warnings = ob_get_clean(); |
|
| 1158 | + // If there was output, it's an error |
|
| 1159 | + $warnings = ob_get_clean(); |
|
| 1160 | 1160 | |
| 1161 | - if( !empty( $warnings ) ) { |
|
| 1162 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1163 | - } |
|
| 1161 | + if( !empty( $warnings ) ) { |
|
| 1162 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1163 | + } |
|
| 1164 | 1164 | |
| 1165 | 1165 | return $return; |
| 1166 | 1166 | } |
@@ -1195,8 +1195,8 @@ discard block |
||
| 1195 | 1195 | $input_id = strval( $input['id'] ); |
| 1196 | 1196 | |
| 1197 | 1197 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1198 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1199 | - $allow_pre_populated = false; |
|
| 1198 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1199 | + $allow_pre_populated = false; |
|
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | 1202 | } |
@@ -1220,7 +1220,7 @@ discard block |
||
| 1220 | 1220 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
| 1221 | 1221 | $categories = array(); |
| 1222 | 1222 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1223 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1223 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1226 | 1226 | } |
@@ -1230,25 +1230,25 @@ discard block |
||
| 1230 | 1230 | // if value is empty get the default value if defined |
| 1231 | 1231 | $field_value = $field->get_value_default_if_empty( $field_value ); |
| 1232 | 1232 | |
| 1233 | - /** |
|
| 1234 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1235 | - * @since 1.11 |
|
| 1236 | - * @since 1.20 Added third param |
|
| 1237 | - * @param mixed $field_value field value used to populate the input |
|
| 1238 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1239 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1240 | - */ |
|
| 1241 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1242 | - |
|
| 1243 | - /** |
|
| 1244 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1245 | - * @since 1.17 |
|
| 1246 | - * @since 1.20 Added third param |
|
| 1247 | - * @param mixed $field_value field value used to populate the input |
|
| 1248 | - * @param GF_Field $field Gravity Forms field object |
|
| 1249 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1250 | - */ |
|
| 1251 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1233 | + /** |
|
| 1234 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1235 | + * @since 1.11 |
|
| 1236 | + * @since 1.20 Added third param |
|
| 1237 | + * @param mixed $field_value field value used to populate the input |
|
| 1238 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1239 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1240 | + */ |
|
| 1241 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1242 | + |
|
| 1243 | + /** |
|
| 1244 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1245 | + * @since 1.17 |
|
| 1246 | + * @since 1.20 Added third param |
|
| 1247 | + * @param mixed $field_value field value used to populate the input |
|
| 1248 | + * @param GF_Field $field Gravity Forms field object |
|
| 1249 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1250 | + */ |
|
| 1251 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1252 | 1252 | |
| 1253 | 1253 | return $field_value; |
| 1254 | 1254 | } |
@@ -1275,7 +1275,7 @@ discard block |
||
| 1275 | 1275 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1276 | 1276 | // expects certain field array items to be set. |
| 1277 | 1277 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
| 1278 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1278 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1289,61 +1289,61 @@ discard block |
||
| 1289 | 1289 | */ |
| 1290 | 1290 | case 'fileupload': |
| 1291 | 1291 | |
| 1292 | - // Set the previous value |
|
| 1293 | - $entry = $this->get_entry(); |
|
| 1292 | + // Set the previous value |
|
| 1293 | + $entry = $this->get_entry(); |
|
| 1294 | 1294 | |
| 1295 | - $input_name = 'input_'.$field->id; |
|
| 1296 | - $form_id = $form['id']; |
|
| 1295 | + $input_name = 'input_'.$field->id; |
|
| 1296 | + $form_id = $form['id']; |
|
| 1297 | 1297 | |
| 1298 | - $value = NULL; |
|
| 1298 | + $value = NULL; |
|
| 1299 | 1299 | |
| 1300 | - // Use the previous entry value as the default. |
|
| 1301 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1302 | - $value = $entry[ $field->id ]; |
|
| 1303 | - } |
|
| 1300 | + // Use the previous entry value as the default. |
|
| 1301 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1302 | + $value = $entry[ $field->id ]; |
|
| 1303 | + } |
|
| 1304 | 1304 | |
| 1305 | - // If this is a single upload file |
|
| 1306 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1307 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1308 | - $value = $file_path['url']; |
|
| 1305 | + // If this is a single upload file |
|
| 1306 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1307 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1308 | + $value = $file_path['url']; |
|
| 1309 | 1309 | |
| 1310 | - } else { |
|
| 1310 | + } else { |
|
| 1311 | 1311 | |
| 1312 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1313 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1314 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1312 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1313 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1314 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1315 | 1315 | |
| 1316 | - } |
|
| 1316 | + } |
|
| 1317 | 1317 | |
| 1318 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1318 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1319 | 1319 | |
| 1320 | - // If there are fresh uploads, process and merge them. |
|
| 1321 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1322 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1323 | - $value = empty( $value ) ? '[]' : $value; |
|
| 1324 | - $value = stripslashes_deep( $value ); |
|
| 1325 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1326 | - } |
|
| 1320 | + // If there are fresh uploads, process and merge them. |
|
| 1321 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1322 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1323 | + $value = empty( $value ) ? '[]' : $value; |
|
| 1324 | + $value = stripslashes_deep( $value ); |
|
| 1325 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1326 | + } |
|
| 1327 | 1327 | |
| 1328 | - } else { |
|
| 1328 | + } else { |
|
| 1329 | 1329 | |
| 1330 | - // A file already exists when editing an entry |
|
| 1331 | - // We set this to solve issue when file upload fields are required. |
|
| 1332 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1330 | + // A file already exists when editing an entry |
|
| 1331 | + // We set this to solve issue when file upload fields are required. |
|
| 1332 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1333 | 1333 | |
| 1334 | - } |
|
| 1334 | + } |
|
| 1335 | 1335 | |
| 1336 | - $this->entry[ $input_name ] = $value; |
|
| 1337 | - $_POST[ $input_name ] = $value; |
|
| 1336 | + $this->entry[ $input_name ] = $value; |
|
| 1337 | + $_POST[ $input_name ] = $value; |
|
| 1338 | 1338 | |
| 1339 | - break; |
|
| 1339 | + break; |
|
| 1340 | 1340 | |
| 1341 | 1341 | case 'number': |
| 1342 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1343 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1344 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1345 | - } |
|
| 1346 | - break; |
|
| 1342 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1343 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1344 | + $_POST['input_'.$field->id ] = NULL; |
|
| 1345 | + } |
|
| 1346 | + break; |
|
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | 1349 | } |
@@ -1428,42 +1428,42 @@ discard block |
||
| 1428 | 1428 | case 'fileupload' : |
| 1429 | 1429 | case 'post_image': |
| 1430 | 1430 | |
| 1431 | - // in case nothing is uploaded but there are already files saved |
|
| 1432 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1433 | - $field->failed_validation = false; |
|
| 1434 | - unset( $field->validation_message ); |
|
| 1435 | - } |
|
| 1431 | + // in case nothing is uploaded but there are already files saved |
|
| 1432 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1433 | + $field->failed_validation = false; |
|
| 1434 | + unset( $field->validation_message ); |
|
| 1435 | + } |
|
| 1436 | 1436 | |
| 1437 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1438 | - if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) { |
|
| 1437 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1438 | + if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) { |
|
| 1439 | 1439 | |
| 1440 | - $input_name = 'input_' . $field->id; |
|
| 1441 | - //uploaded |
|
| 1442 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1440 | + $input_name = 'input_' . $field->id; |
|
| 1441 | + //uploaded |
|
| 1442 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1443 | 1443 | |
| 1444 | - //existent |
|
| 1445 | - $entry = $this->get_entry(); |
|
| 1446 | - $value = NULL; |
|
| 1447 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1448 | - $value = json_decode( $entry[ $field->id ], true ); |
|
| 1449 | - } |
|
| 1444 | + //existent |
|
| 1445 | + $entry = $this->get_entry(); |
|
| 1446 | + $value = NULL; |
|
| 1447 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1448 | + $value = json_decode( $entry[ $field->id ], true ); |
|
| 1449 | + } |
|
| 1450 | 1450 | |
| 1451 | - // count uploaded files and existent entry files |
|
| 1452 | - $count_files = count( $file_names ) + count( $value ); |
|
| 1451 | + // count uploaded files and existent entry files |
|
| 1452 | + $count_files = count( $file_names ) + count( $value ); |
|
| 1453 | 1453 | |
| 1454 | - if( $count_files > $field->maxFiles ) { |
|
| 1455 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1456 | - $field->failed_validation = 1; |
|
| 1457 | - $gv_valid = false; |
|
| 1454 | + if( $count_files > $field->maxFiles ) { |
|
| 1455 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1456 | + $field->failed_validation = 1; |
|
| 1457 | + $gv_valid = false; |
|
| 1458 | 1458 | |
| 1459 | - // in case of error make sure the newest upload files are removed from the upload input |
|
| 1460 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1461 | - } |
|
| 1459 | + // in case of error make sure the newest upload files are removed from the upload input |
|
| 1460 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1461 | + } |
|
| 1462 | 1462 | |
| 1463 | - } |
|
| 1463 | + } |
|
| 1464 | 1464 | |
| 1465 | 1465 | |
| 1466 | - break; |
|
| 1466 | + break; |
|
| 1467 | 1467 | |
| 1468 | 1468 | } |
| 1469 | 1469 | |
@@ -1474,47 +1474,47 @@ discard block |
||
| 1474 | 1474 | |
| 1475 | 1475 | switch ( $field_type ) { |
| 1476 | 1476 | |
| 1477 | - // Captchas don't need to be re-entered. |
|
| 1478 | - case 'captcha': |
|
| 1477 | + // Captchas don't need to be re-entered. |
|
| 1478 | + case 'captcha': |
|
| 1479 | 1479 | |
| 1480 | - // Post Image fields aren't editable, so we un-fail them. |
|
| 1481 | - case 'post_image': |
|
| 1482 | - $field->failed_validation = false; |
|
| 1483 | - unset( $field->validation_message ); |
|
| 1484 | - break; |
|
| 1480 | + // Post Image fields aren't editable, so we un-fail them. |
|
| 1481 | + case 'post_image': |
|
| 1482 | + $field->failed_validation = false; |
|
| 1483 | + unset( $field->validation_message ); |
|
| 1484 | + break; |
|
| 1485 | 1485 | |
| 1486 | 1486 | } |
| 1487 | 1487 | |
| 1488 | 1488 | // You can't continue inside a switch, so we do it after. |
| 1489 | 1489 | if( empty( $field->failed_validation ) ) { |
| 1490 | - continue; |
|
| 1490 | + continue; |
|
| 1491 | 1491 | } |
| 1492 | 1492 | |
| 1493 | 1493 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1494 | 1494 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1495 | 1495 | if( !empty( $field->noDuplicates ) ) { |
| 1496 | 1496 | |
| 1497 | - $entry = $this->get_entry(); |
|
| 1497 | + $entry = $this->get_entry(); |
|
| 1498 | 1498 | |
| 1499 | - // If the value of the entry is the same as the stored value |
|
| 1500 | - // Then we can assume it's not a duplicate, it's the same. |
|
| 1501 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1502 | - //if value submitted was not changed, then don't validate |
|
| 1503 | - $field->failed_validation = false; |
|
| 1499 | + // If the value of the entry is the same as the stored value |
|
| 1500 | + // Then we can assume it's not a duplicate, it's the same. |
|
| 1501 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1502 | + //if value submitted was not changed, then don't validate |
|
| 1503 | + $field->failed_validation = false; |
|
| 1504 | 1504 | |
| 1505 | - unset( $field->validation_message ); |
|
| 1505 | + unset( $field->validation_message ); |
|
| 1506 | 1506 | |
| 1507 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1507 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1508 | 1508 | |
| 1509 | - continue; |
|
| 1510 | - } |
|
| 1509 | + continue; |
|
| 1510 | + } |
|
| 1511 | 1511 | } |
| 1512 | 1512 | |
| 1513 | 1513 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1514 | 1514 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
| 1515 | - unset( $field->validation_message ); |
|
| 1516 | - $field->validation_message = false; |
|
| 1517 | - continue; |
|
| 1515 | + unset( $field->validation_message ); |
|
| 1516 | + $field->validation_message = false; |
|
| 1517 | + continue; |
|
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | 1520 | $gv_valid = false; |
@@ -1578,8 +1578,8 @@ discard block |
||
| 1578 | 1578 | // Hide fields depending on admin settings |
| 1579 | 1579 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
| 1580 | 1580 | |
| 1581 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1582 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1581 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1582 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1583 | 1583 | |
| 1584 | 1584 | /** |
| 1585 | 1585 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1639,12 +1639,12 @@ discard block |
||
| 1639 | 1639 | // The edit tab has been configured, so we loop through to configured settings |
| 1640 | 1640 | foreach ( $configured_fields as $configured_field ) { |
| 1641 | 1641 | |
| 1642 | - /** @var GF_Field $field */ |
|
| 1643 | - foreach ( $fields as $field ) { |
|
| 1642 | + /** @var GF_Field $field */ |
|
| 1643 | + foreach ( $fields as $field ) { |
|
| 1644 | 1644 | |
| 1645 | 1645 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
| 1646 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1647 | - break; |
|
| 1646 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1647 | + break; |
|
| 1648 | 1648 | } |
| 1649 | 1649 | |
| 1650 | 1650 | } |
@@ -1700,28 +1700,28 @@ discard block |
||
| 1700 | 1700 | */ |
| 1701 | 1701 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
| 1702 | 1702 | |
| 1703 | - /** |
|
| 1703 | + /** |
|
| 1704 | 1704 | * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true |
| 1705 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1706 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1707 | - * @since 1.9.1 |
|
| 1708 | - * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
| 1709 | - * @param array $form GF Form array |
|
| 1710 | - * @param int $view_id View ID |
|
| 1711 | - */ |
|
| 1712 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1713 | - |
|
| 1714 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1705 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1706 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1707 | + * @since 1.9.1 |
|
| 1708 | + * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
| 1709 | + * @param array $form GF Form array |
|
| 1710 | + * @param int $view_id View ID |
|
| 1711 | + */ |
|
| 1712 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1713 | + |
|
| 1714 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1715 | 1715 | foreach( $fields as $k => $field ) { |
| 1716 | 1716 | if( $field->adminOnly ) { |
| 1717 | - unset( $fields[ $k ] ); |
|
| 1717 | + unset( $fields[ $k ] ); |
|
| 1718 | 1718 | } |
| 1719 | 1719 | } |
| 1720 | 1720 | return $fields; |
| 1721 | 1721 | } |
| 1722 | 1722 | |
| 1723 | - foreach( $fields as &$field ) { |
|
| 1724 | - $field->adminOnly = false; |
|
| 1723 | + foreach( $fields as &$field ) { |
|
| 1724 | + $field->adminOnly = false; |
|
| 1725 | 1725 | } |
| 1726 | 1726 | |
| 1727 | 1727 | return $fields; |
@@ -1754,36 +1754,36 @@ discard block |
||
| 1754 | 1754 | |
| 1755 | 1755 | if( 'checkbox' === $field->type ) { |
| 1756 | 1756 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1757 | - $input_id = $input['id']; |
|
| 1758 | - $choice = $field->choices[ $key ]; |
|
| 1759 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 1760 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 1761 | - if( $match ) { |
|
| 1762 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1763 | - } |
|
| 1757 | + $input_id = $input['id']; |
|
| 1758 | + $choice = $field->choices[ $key ]; |
|
| 1759 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 1760 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 1761 | + if( $match ) { |
|
| 1762 | + $field->choices[ $key ]['isSelected'] = true; |
|
| 1763 | + } |
|
| 1764 | 1764 | } |
| 1765 | 1765 | } else { |
| 1766 | 1766 | |
| 1767 | 1767 | // We need to run through each field to set the default values |
| 1768 | 1768 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1769 | 1769 | |
| 1770 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1770 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1771 | 1771 | |
| 1772 | - if( 'list' === $field->type ) { |
|
| 1773 | - $list_rows = maybe_unserialize( $field_value ); |
|
| 1772 | + if( 'list' === $field->type ) { |
|
| 1773 | + $list_rows = maybe_unserialize( $field_value ); |
|
| 1774 | 1774 | |
| 1775 | - $list_field_value = array(); |
|
| 1776 | - foreach ( (array) $list_rows as $row ) { |
|
| 1777 | - foreach ( (array) $row as $column ) { |
|
| 1778 | - $list_field_value[] = $column; |
|
| 1779 | - } |
|
| 1780 | - } |
|
| 1775 | + $list_field_value = array(); |
|
| 1776 | + foreach ( (array) $list_rows as $row ) { |
|
| 1777 | + foreach ( (array) $row as $column ) { |
|
| 1778 | + $list_field_value[] = $column; |
|
| 1779 | + } |
|
| 1780 | + } |
|
| 1781 | 1781 | |
| 1782 | - $field->defaultValue = serialize( $list_field_value ); |
|
| 1783 | - } else { |
|
| 1784 | - $field->defaultValue = $field_value; |
|
| 1785 | - } |
|
| 1786 | - } |
|
| 1782 | + $field->defaultValue = serialize( $list_field_value ); |
|
| 1783 | + } else { |
|
| 1784 | + $field->defaultValue = $field_value; |
|
| 1785 | + } |
|
| 1786 | + } |
|
| 1787 | 1787 | } |
| 1788 | 1788 | } |
| 1789 | 1789 | } |
@@ -1840,7 +1840,7 @@ discard block |
||
| 1840 | 1840 | return $has_conditional_logic; |
| 1841 | 1841 | } |
| 1842 | 1842 | |
| 1843 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 1843 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 1844 | 1844 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
| 1845 | 1845 | } |
| 1846 | 1846 | |
@@ -1907,14 +1907,14 @@ discard block |
||
| 1907 | 1907 | |
| 1908 | 1908 | if( $echo && $error !== true ) { |
| 1909 | 1909 | |
| 1910 | - $error = esc_html( $error ); |
|
| 1910 | + $error = esc_html( $error ); |
|
| 1911 | 1911 | |
| 1912 | - /** |
|
| 1913 | - * @since 1.9 |
|
| 1914 | - */ |
|
| 1915 | - if ( ! empty( $this->entry ) ) { |
|
| 1916 | - $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;" ) ); |
|
| 1917 | - } |
|
| 1912 | + /** |
|
| 1913 | + * @since 1.9 |
|
| 1914 | + */ |
|
| 1915 | + if ( ! empty( $this->entry ) ) { |
|
| 1916 | + $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;" ) ); |
|
| 1917 | + } |
|
| 1918 | 1918 | |
| 1919 | 1919 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
| 1920 | 1920 | } |
@@ -106,16 +106,16 @@ discard block |
||
| 106 | 106 | function load() { |
| 107 | 107 | |
| 108 | 108 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
| 109 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 109 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 110 | 110 | |
| 111 | 111 | // Don't display an embedded form when editing an entry |
| 112 | 112 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
| 113 | 113 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
| 114 | 114 | |
| 115 | 115 | // Stop Gravity Forms processing what is ours! |
| 116 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
| 116 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
| 117 | 117 | |
| 118 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
| 118 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
| 119 | 119 | |
| 120 | 120 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
| 121 | 121 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
| 127 | 127 | |
| 128 | 128 | // Add fields expected by GFFormDisplay::validate() |
| 129 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
| 129 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
| 130 | 130 | |
| 131 | 131 | // Fix multiselect value for GF 2.2 |
| 132 | 132 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | * @return void |
| 144 | 144 | */ |
| 145 | 145 | public function prevent_render_form() { |
| 146 | - if( $this->is_edit_entry() ) { |
|
| 147 | - if( 'wp_head' === current_filter() ) { |
|
| 146 | + if ( $this->is_edit_entry() ) { |
|
| 147 | + if ( 'wp_head' === current_filter() ) { |
|
| 148 | 148 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
| 149 | 149 | } else { |
| 150 | 150 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function prevent_maybe_process_form() { |
| 161 | 161 | |
| 162 | - if( ! empty( $_POST ) ) { |
|
| 162 | + if ( ! empty( $_POST ) ) { |
|
| 163 | 163 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if( $this->is_edit_entry_submission() ) { |
|
| 167 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 168 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 166 | + if ( $this->is_edit_entry_submission() ) { |
|
| 167 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 168 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public function is_edit_entry() { |
| 177 | 177 | |
| 178 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
| 178 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
| 179 | 179 | |
| 180 | 180 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
| 181 | 181 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @return boolean |
| 187 | 187 | */ |
| 188 | 188 | public function is_edit_entry_submission() { |
| 189 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
| 189 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -197,15 +197,15 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | $entries = $gravityview_view->getEntries(); |
| 200 | - self::$original_entry = $entries[0]; |
|
| 201 | - $this->entry = $entries[0]; |
|
| 200 | + self::$original_entry = $entries[ 0 ]; |
|
| 201 | + $this->entry = $entries[ 0 ]; |
|
| 202 | 202 | |
| 203 | 203 | self::$original_form = $gravityview_view->getForm(); |
| 204 | 204 | $this->form = $gravityview_view->getForm(); |
| 205 | 205 | $this->form_id = $gravityview_view->getFormId(); |
| 206 | 206 | $this->view_id = $gravityview_view->getViewId(); |
| 207 | 207 | |
| 208 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
| 208 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -229,13 +229,13 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // Multiple Views embedded, don't proceed if nonce fails |
| 232 | - if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
| 232 | + if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
| 233 | 233 | gravityview()->log->error( 'Nonce validation failed for the Edit Entry request; returning' ); |
| 234 | 234 | return; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | // Sorry, you're not allowed here. |
| 238 | - if( false === $this->user_can_edit_entry( true ) ) { |
|
| 238 | + if ( false === $this->user_can_edit_entry( true ) ) { |
|
| 239 | 239 | gravityview()->log->error( 'User is not allowed to edit this entry; returning', array( 'data' => $this->entry ) ); |
| 240 | 240 | return; |
| 241 | 241 | } |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | private function print_scripts() { |
| 257 | 257 | $gravityview_view = GravityView_View::getInstance(); |
| 258 | 258 | |
| 259 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 259 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 260 | 260 | |
| 261 | - GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false); |
|
| 261 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
| 262 | 262 | |
| 263 | 263 | // Sack is required for images |
| 264 | 264 | wp_print_scripts( array( 'sack', 'gform_gravityforms' ) ); |
@@ -270,19 +270,19 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | private function process_save() { |
| 272 | 272 | |
| 273 | - if( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 273 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 274 | 274 | return; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // Make sure the entry, view, and form IDs are all correct |
| 278 | 278 | $valid = $this->verify_nonce(); |
| 279 | 279 | |
| 280 | - if( !$valid ) { |
|
| 280 | + if ( ! $valid ) { |
|
| 281 | 281 | gravityview()->log->error( 'Nonce validation failed.' ); |
| 282 | 282 | return; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - if( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 285 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 286 | 286 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
| 287 | 287 | return; |
| 288 | 288 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | $this->validate(); |
| 295 | 295 | |
| 296 | - if( $this->is_valid ) { |
|
| 296 | + if ( $this->is_valid ) { |
|
| 297 | 297 | |
| 298 | 298 | gravityview()->log->debug( 'Submission is valid.' ); |
| 299 | 299 | |
@@ -310,22 +310,22 @@ discard block |
||
| 310 | 310 | /** |
| 311 | 311 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 312 | 312 | */ |
| 313 | - unset( $_GET['page'] ); |
|
| 313 | + unset( $_GET[ 'page' ] ); |
|
| 314 | 314 | |
| 315 | - $date_created = $this->entry['date_created']; |
|
| 315 | + $date_created = $this->entry[ 'date_created' ]; |
|
| 316 | 316 | |
| 317 | 317 | /** |
| 318 | 318 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
| 319 | 319 | * @since 1.17.2 |
| 320 | 320 | */ |
| 321 | - unset( $this->entry['date_created'] ); |
|
| 321 | + unset( $this->entry[ 'date_created' ] ); |
|
| 322 | 322 | |
| 323 | 323 | GFFormsModel::save_lead( $form, $this->entry ); |
| 324 | 324 | |
| 325 | 325 | // Delete the values for hidden inputs |
| 326 | 326 | $this->unset_hidden_field_values(); |
| 327 | 327 | |
| 328 | - $this->entry['date_created'] = $date_created; |
|
| 328 | + $this->entry[ 'date_created' ] = $date_created; |
|
| 329 | 329 | |
| 330 | 330 | // Process calculation fields |
| 331 | 331 | $this->update_calculation_fields(); |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | * @param string $entry_id Numeric ID of the entry that was updated |
| 346 | 346 | * @param GravityView_Edit_Entry_Render $this This object |
| 347 | 347 | */ |
| 348 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this ); |
|
| 348 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this ); |
|
| 349 | 349 | |
| 350 | 350 | } else { |
| 351 | 351 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -373,16 +373,16 @@ discard block |
||
| 373 | 373 | */ |
| 374 | 374 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
| 375 | 375 | |
| 376 | - if( ! $unset_hidden_field_values ) { |
|
| 376 | + if ( ! $unset_hidden_field_values ) { |
|
| 377 | 377 | return; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 381 | 381 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 382 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
| 382 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
| 383 | 383 | } else { |
| 384 | 384 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 385 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
| 385 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | /** No file is being uploaded. */ |
| 466 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 466 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 467 | 467 | /** So return the original upload */ |
| 468 | 468 | return $entry[ $input_id ]; |
| 469 | 469 | } |
@@ -481,11 +481,11 @@ discard block |
||
| 481 | 481 | * @return mixed |
| 482 | 482 | */ |
| 483 | 483 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 484 | - if( ! $this->is_edit_entry() ) { |
|
| 484 | + if ( ! $this->is_edit_entry() ) { |
|
| 485 | 485 | return $plupload_init; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 488 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 489 | 489 | |
| 490 | 490 | return $plupload_init; |
| 491 | 491 | } |
@@ -500,22 +500,22 @@ discard block |
||
| 500 | 500 | $form = $this->form; |
| 501 | 501 | |
| 502 | 502 | /** @var GF_Field $field */ |
| 503 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 503 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 504 | 504 | |
| 505 | 505 | /** |
| 506 | 506 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 507 | 507 | * @since 1.16.3 |
| 508 | 508 | * @var GF_Field $field |
| 509 | 509 | */ |
| 510 | - if( $field->has_calculation() ) { |
|
| 511 | - unset( $form['fields'][ $k ] ); |
|
| 510 | + if ( $field->has_calculation() ) { |
|
| 511 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | $field->adminOnly = false; |
| 515 | 515 | |
| 516 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 517 | - foreach( $field->inputs as $key => $input ) { |
|
| 518 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 516 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 517 | + foreach ( $field->inputs as $key => $input ) { |
|
| 518 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 519 | 519 | } |
| 520 | 520 | } |
| 521 | 521 | } |
@@ -529,30 +529,30 @@ discard block |
||
| 529 | 529 | $update = false; |
| 530 | 530 | |
| 531 | 531 | // get the most up to date entry values |
| 532 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 532 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 533 | 533 | |
| 534 | - if( !empty( $this->fields_with_calculation ) ) { |
|
| 534 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
| 535 | 535 | $update = true; |
| 536 | 536 | foreach ( $this->fields_with_calculation as $calc_field ) { |
| 537 | 537 | $inputs = $calc_field->get_entry_inputs(); |
| 538 | 538 | if ( is_array( $inputs ) ) { |
| 539 | 539 | foreach ( $inputs as $input ) { |
| 540 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 541 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 540 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
| 541 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
| 542 | 542 | } |
| 543 | 543 | } else { |
| 544 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
| 545 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 544 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
| 545 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - if( $update ) { |
|
| 551 | + if ( $update ) { |
|
| 552 | 552 | |
| 553 | 553 | $return_entry = GFAPI::update_entry( $entry ); |
| 554 | 554 | |
| 555 | - if( is_wp_error( $return_entry ) ) { |
|
| 555 | + if ( is_wp_error( $return_entry ) ) { |
|
| 556 | 556 | gravityview()->log->error( 'Updating the entry calculation fields failed', array( 'data' => $return_entry ) ); |
| 557 | 557 | } else { |
| 558 | 558 | gravityview()->log->debug( 'Updating the entry calculation fields succeeded' ); |
@@ -583,19 +583,19 @@ discard block |
||
| 583 | 583 | |
| 584 | 584 | $input_name = 'input_' . $field_id; |
| 585 | 585 | |
| 586 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 586 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 587 | 587 | |
| 588 | 588 | // We have a new image |
| 589 | 589 | |
| 590 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 590 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 591 | 591 | |
| 592 | 592 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 593 | 593 | $ary = stripslashes_deep( $ary ); |
| 594 | 594 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 595 | 595 | |
| 596 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 597 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 598 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 596 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 597 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 598 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 599 | 599 | |
| 600 | 600 | $image_meta = array( |
| 601 | 601 | 'post_excerpt' => $img_caption, |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | |
| 605 | 605 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 606 | 606 | if ( ! empty( $img_title ) ) { |
| 607 | - $image_meta['post_title'] = $img_title; |
|
| 607 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | /** |
@@ -662,15 +662,15 @@ discard block |
||
| 662 | 662 | */ |
| 663 | 663 | private function maybe_update_post_fields( $form ) { |
| 664 | 664 | |
| 665 | - if( empty( $this->entry['post_id'] ) ) { |
|
| 665 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
| 666 | 666 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
| 667 | 667 | return; |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | - $post_id = $this->entry['post_id']; |
|
| 670 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 671 | 671 | |
| 672 | 672 | // Security check |
| 673 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 673 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 674 | 674 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
| 675 | 675 | return; |
| 676 | 676 | } |
@@ -683,25 +683,25 @@ discard block |
||
| 683 | 683 | |
| 684 | 684 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 685 | 685 | |
| 686 | - if( ! $field ) { |
|
| 686 | + if ( ! $field ) { |
|
| 687 | 687 | continue; |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 690 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 691 | 691 | |
| 692 | 692 | // Get the value of the field, including $_POSTed value |
| 693 | 693 | $value = RGFormsModel::get_field_value( $field ); |
| 694 | 694 | |
| 695 | 695 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 696 | 696 | $entry_tmp = $this->entry; |
| 697 | - $entry_tmp["{$field_id}"] = $value; |
|
| 697 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 698 | 698 | |
| 699 | - switch( $field->type ) { |
|
| 699 | + switch ( $field->type ) { |
|
| 700 | 700 | |
| 701 | 701 | case 'post_title': |
| 702 | 702 | $post_title = $value; |
| 703 | 703 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
| 704 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 704 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 705 | 705 | } |
| 706 | 706 | $updated_post->post_title = $post_title; |
| 707 | 707 | $updated_post->post_name = $post_title; |
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | case 'post_content': |
| 712 | 712 | $post_content = $value; |
| 713 | 713 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
| 714 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 714 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 715 | 715 | } |
| 716 | 716 | $updated_post->post_content = $post_content; |
| 717 | 717 | unset( $post_content ); |
@@ -729,12 +729,12 @@ discard block |
||
| 729 | 729 | $value = $value[ $field_id ]; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 732 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 733 | 733 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
| 737 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 737 | + $value = function_exists( 'wp_json_encode' ) ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | // update entry after |
| 750 | - $this->entry["{$field_id}"] = $value; |
|
| 750 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 751 | 751 | |
| 752 | 752 | $update_entry = true; |
| 753 | 753 | |
@@ -756,11 +756,11 @@ discard block |
||
| 756 | 756 | |
| 757 | 757 | } |
| 758 | 758 | |
| 759 | - if( $update_entry ) { |
|
| 759 | + if ( $update_entry ) { |
|
| 760 | 760 | |
| 761 | 761 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 762 | 762 | |
| 763 | - if( is_wp_error( $return_entry ) ) { |
|
| 763 | + if ( is_wp_error( $return_entry ) ) { |
|
| 764 | 764 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
| 765 | 765 | } else { |
| 766 | 766 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | |
| 771 | 771 | $return_post = wp_update_post( $updated_post, true ); |
| 772 | 772 | |
| 773 | - if( is_wp_error( $return_post ) ) { |
|
| 773 | + if ( is_wp_error( $return_post ) ) { |
|
| 774 | 774 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 775 | 775 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
| 776 | 776 | } else { |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | $input_type = RGFormsModel::get_input_type( $field ); |
| 793 | 793 | |
| 794 | 794 | // Only certain custom field types are supported |
| 795 | - switch( $input_type ) { |
|
| 795 | + switch ( $input_type ) { |
|
| 796 | 796 | case 'fileupload': |
| 797 | 797 | case 'list': |
| 798 | 798 | case 'multiselect': |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 830 | 830 | |
| 831 | 831 | // replace conditional shortcodes |
| 832 | - if( $do_shortcode ) { |
|
| 832 | + if ( $do_shortcode ) { |
|
| 833 | 833 | $output = do_shortcode( $output ); |
| 834 | 834 | } |
| 835 | 835 | |
@@ -848,19 +848,19 @@ discard block |
||
| 848 | 848 | */ |
| 849 | 849 | private function after_update() { |
| 850 | 850 | |
| 851 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
| 852 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
| 851 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 852 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 853 | 853 | |
| 854 | 854 | // Re-define the entry now that we've updated it. |
| 855 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 855 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 856 | 856 | |
| 857 | 857 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
| 858 | 858 | |
| 859 | 859 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
| 860 | 860 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 861 | 861 | // we have just updated. |
| 862 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 863 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 862 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 863 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 864 | 864 | } |
| 865 | 865 | } |
| 866 | 866 | |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | |
| 880 | 880 | <div class="gv-edit-entry-wrapper"><?php |
| 881 | 881 | |
| 882 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 882 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 883 | 883 | |
| 884 | 884 | /** |
| 885 | 885 | * Fixes weird wpautop() issue |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 896 | 896 | * @param GravityView_Edit_Entry_Render $this This object |
| 897 | 897 | */ |
| 898 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 898 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 899 | 899 | |
| 900 | 900 | echo esc_attr( $edit_entry_title ); |
| 901 | 901 | ?></span> |
@@ -945,16 +945,16 @@ discard block |
||
| 945 | 945 | |
| 946 | 946 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
| 947 | 947 | |
| 948 | - if( ! $this->is_valid ){ |
|
| 948 | + if ( ! $this->is_valid ) { |
|
| 949 | 949 | |
| 950 | 950 | // Keeping this compatible with Gravity Forms. |
| 951 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 952 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 951 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 952 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 953 | 953 | |
| 954 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 954 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 955 | 955 | |
| 956 | 956 | } else { |
| 957 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
| 957 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
| 958 | 958 | |
| 959 | 959 | /** |
| 960 | 960 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | * @param array $entry Gravity Forms entry array |
| 965 | 965 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 966 | 966 | */ |
| 967 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 967 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 968 | 968 | |
| 969 | 969 | echo GVCommon::generate_notice( $message ); |
| 970 | 970 | } |
@@ -988,21 +988,21 @@ discard block |
||
| 988 | 988 | */ |
| 989 | 989 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 990 | 990 | |
| 991 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 992 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 991 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 992 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 993 | 993 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
| 994 | 994 | |
| 995 | 995 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
| 996 | 996 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 997 | 997 | |
| 998 | 998 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 999 | - unset( $_GET['page'] ); |
|
| 999 | + unset( $_GET[ 'page' ] ); |
|
| 1000 | 1000 | |
| 1001 | 1001 | // TODO: Verify multiple-page forms |
| 1002 | 1002 | |
| 1003 | 1003 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1004 | 1004 | |
| 1005 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1005 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1006 | 1006 | |
| 1007 | 1007 | ob_get_clean(); |
| 1008 | 1008 | |
@@ -1028,7 +1028,7 @@ discard block |
||
| 1028 | 1028 | * @return string |
| 1029 | 1029 | */ |
| 1030 | 1030 | public function render_form_buttons() { |
| 1031 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1031 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | |
@@ -1048,10 +1048,10 @@ discard block |
||
| 1048 | 1048 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1049 | 1049 | |
| 1050 | 1050 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1051 | - if( isset( $this->form_after_validation ) ) { |
|
| 1051 | + if ( isset( $this->form_after_validation ) ) { |
|
| 1052 | 1052 | $form = $this->form_after_validation; |
| 1053 | 1053 | } else { |
| 1054 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1054 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | 1057 | $form = $this->filter_conditional_logic( $form ); |
@@ -1059,8 +1059,8 @@ discard block |
||
| 1059 | 1059 | $form = $this->prefill_conditional_logic( $form ); |
| 1060 | 1060 | |
| 1061 | 1061 | // for now we don't support Save and Continue feature. |
| 1062 | - if( ! self::$supports_save_and_continue ) { |
|
| 1063 | - unset( $form['save'] ); |
|
| 1062 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1063 | + unset( $form[ 'save' ] ); |
|
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | return $form; |
@@ -1081,29 +1081,29 @@ discard block |
||
| 1081 | 1081 | */ |
| 1082 | 1082 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
| 1083 | 1083 | |
| 1084 | - if( GFCommon::is_post_field( $field ) ) { |
|
| 1084 | + if ( GFCommon::is_post_field( $field ) ) { |
|
| 1085 | 1085 | |
| 1086 | 1086 | $message = null; |
| 1087 | 1087 | |
| 1088 | 1088 | // First, make sure they have the capability to edit the post. |
| 1089 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1089 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1090 | 1090 | |
| 1091 | 1091 | /** |
| 1092 | 1092 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1093 | 1093 | * @param string $message The existing "You don't have permission..." text |
| 1094 | 1094 | */ |
| 1095 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1095 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1096 | 1096 | |
| 1097 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1097 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1098 | 1098 | /** |
| 1099 | 1099 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1100 | 1100 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1101 | 1101 | */ |
| 1102 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1102 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | - if( $message ) { |
|
| 1106 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1105 | + if ( $message ) { |
|
| 1106 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | } |
| 1109 | 1109 | |
@@ -1128,8 +1128,8 @@ discard block |
||
| 1128 | 1128 | |
| 1129 | 1129 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1130 | 1130 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1131 | - if( |
|
| 1132 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1131 | + if ( |
|
| 1132 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1133 | 1133 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1134 | 1134 | && ! GFCommon::is_product_field( $field->type ) |
| 1135 | 1135 | || ! empty( $field_content ) |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | $return = null; |
| 1150 | 1150 | |
| 1151 | 1151 | /** @var GravityView_Field $gv_field */ |
| 1152 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1152 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1153 | 1153 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1154 | 1154 | } else { |
| 1155 | 1155 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | // If there was output, it's an error |
| 1159 | 1159 | $warnings = ob_get_clean(); |
| 1160 | 1160 | |
| 1161 | - if( !empty( $warnings ) ) { |
|
| 1161 | + if ( ! empty( $warnings ) ) { |
|
| 1162 | 1162 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
| 1163 | 1163 | } |
| 1164 | 1164 | |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1184 | 1184 | |
| 1185 | 1185 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1186 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1186 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1187 | 1187 | |
| 1188 | 1188 | $field_value = array(); |
| 1189 | 1189 | |
@@ -1192,10 +1192,10 @@ discard block |
||
| 1192 | 1192 | |
| 1193 | 1193 | foreach ( (array)$field->inputs as $input ) { |
| 1194 | 1194 | |
| 1195 | - $input_id = strval( $input['id'] ); |
|
| 1195 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1196 | 1196 | |
| 1197 | 1197 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1198 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1198 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1199 | 1199 | $allow_pre_populated = false; |
| 1200 | 1200 | } |
| 1201 | 1201 | |
@@ -1203,7 +1203,7 @@ discard block |
||
| 1203 | 1203 | |
| 1204 | 1204 | $pre_value = $field->get_value_submission( array(), false ); |
| 1205 | 1205 | |
| 1206 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1206 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1207 | 1207 | |
| 1208 | 1208 | } else { |
| 1209 | 1209 | |
@@ -1214,13 +1214,13 @@ discard block |
||
| 1214 | 1214 | |
| 1215 | 1215 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1216 | 1216 | // or pre-populated value if not empty and set to override saved value |
| 1217 | - $field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1217 | + $field_value = ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1218 | 1218 | |
| 1219 | 1219 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1220 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1220 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1221 | 1221 | $categories = array(); |
| 1222 | 1222 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1223 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1223 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1226 | 1226 | } |
@@ -1248,7 +1248,7 @@ discard block |
||
| 1248 | 1248 | * @param GF_Field $field Gravity Forms field object |
| 1249 | 1249 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1250 | 1250 | */ |
| 1251 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1251 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1252 | 1252 | |
| 1253 | 1253 | return $field_value; |
| 1254 | 1254 | } |
@@ -1265,12 +1265,12 @@ discard block |
||
| 1265 | 1265 | */ |
| 1266 | 1266 | public function gform_pre_validation( $form ) { |
| 1267 | 1267 | |
| 1268 | - if( ! $this->verify_nonce() ) { |
|
| 1268 | + if ( ! $this->verify_nonce() ) { |
|
| 1269 | 1269 | return $form; |
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | 1272 | // Fix PHP warning regarding undefined index. |
| 1273 | - foreach ( $form['fields'] as &$field) { |
|
| 1273 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1274 | 1274 | |
| 1275 | 1275 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1276 | 1276 | // expects certain field array items to be set. |
@@ -1278,7 +1278,7 @@ discard block |
||
| 1278 | 1278 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1281 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1282 | 1282 | |
| 1283 | 1283 | /** |
| 1284 | 1284 | * 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. |
@@ -1292,26 +1292,26 @@ discard block |
||
| 1292 | 1292 | // Set the previous value |
| 1293 | 1293 | $entry = $this->get_entry(); |
| 1294 | 1294 | |
| 1295 | - $input_name = 'input_'.$field->id; |
|
| 1296 | - $form_id = $form['id']; |
|
| 1295 | + $input_name = 'input_' . $field->id; |
|
| 1296 | + $form_id = $form[ 'id' ]; |
|
| 1297 | 1297 | |
| 1298 | 1298 | $value = NULL; |
| 1299 | 1299 | |
| 1300 | 1300 | // Use the previous entry value as the default. |
| 1301 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1301 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1302 | 1302 | $value = $entry[ $field->id ]; |
| 1303 | 1303 | } |
| 1304 | 1304 | |
| 1305 | 1305 | // If this is a single upload file |
| 1306 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1307 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1308 | - $value = $file_path['url']; |
|
| 1306 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1307 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1308 | + $value = $file_path[ 'url' ]; |
|
| 1309 | 1309 | |
| 1310 | 1310 | } else { |
| 1311 | 1311 | |
| 1312 | 1312 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1313 | 1313 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1314 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1314 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1315 | 1315 | |
| 1316 | 1316 | } |
| 1317 | 1317 | |
@@ -1319,10 +1319,10 @@ discard block |
||
| 1319 | 1319 | |
| 1320 | 1320 | // If there are fresh uploads, process and merge them. |
| 1321 | 1321 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
| 1322 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1322 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
| 1323 | 1323 | $value = empty( $value ) ? '[]' : $value; |
| 1324 | 1324 | $value = stripslashes_deep( $value ); |
| 1325 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1325 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | 1328 | } else { |
@@ -1340,8 +1340,8 @@ discard block |
||
| 1340 | 1340 | |
| 1341 | 1341 | case 'number': |
| 1342 | 1342 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1343 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1344 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1343 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1344 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1345 | 1345 | } |
| 1346 | 1346 | break; |
| 1347 | 1347 | } |
@@ -1378,7 +1378,7 @@ discard block |
||
| 1378 | 1378 | * You can enter whatever you want! |
| 1379 | 1379 | * We try validating, and customize the results using `self::custom_validation()` |
| 1380 | 1380 | */ |
| 1381 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1381 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1382 | 1382 | |
| 1383 | 1383 | // Needed by the validate funtion |
| 1384 | 1384 | $failed_validation_page = NULL; |
@@ -1386,14 +1386,14 @@ discard block |
||
| 1386 | 1386 | |
| 1387 | 1387 | // Prevent entry limit from running when editing an entry, also |
| 1388 | 1388 | // prevent form scheduling from preventing editing |
| 1389 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1389 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1390 | 1390 | |
| 1391 | 1391 | // Hide fields depending on Edit Entry settings |
| 1392 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1392 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1393 | 1393 | |
| 1394 | 1394 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1395 | 1395 | |
| 1396 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1396 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1397 | 1397 | } |
| 1398 | 1398 | |
| 1399 | 1399 | |
@@ -1416,7 +1416,7 @@ discard block |
||
| 1416 | 1416 | |
| 1417 | 1417 | $gv_valid = true; |
| 1418 | 1418 | |
| 1419 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1419 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1420 | 1420 | |
| 1421 | 1421 | $value = RGFormsModel::get_field_value( $field ); |
| 1422 | 1422 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1429,35 +1429,35 @@ discard block |
||
| 1429 | 1429 | case 'post_image': |
| 1430 | 1430 | |
| 1431 | 1431 | // in case nothing is uploaded but there are already files saved |
| 1432 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1432 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
| 1433 | 1433 | $field->failed_validation = false; |
| 1434 | 1434 | unset( $field->validation_message ); |
| 1435 | 1435 | } |
| 1436 | 1436 | |
| 1437 | 1437 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
| 1438 | - if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) { |
|
| 1438 | + if ( rgobj( $field, 'maxFiles' ) && rgobj( $field, 'multipleFiles' ) ) { |
|
| 1439 | 1439 | |
| 1440 | 1440 | $input_name = 'input_' . $field->id; |
| 1441 | 1441 | //uploaded |
| 1442 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1442 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1443 | 1443 | |
| 1444 | 1444 | //existent |
| 1445 | 1445 | $entry = $this->get_entry(); |
| 1446 | 1446 | $value = NULL; |
| 1447 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1447 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1448 | 1448 | $value = json_decode( $entry[ $field->id ], true ); |
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | 1451 | // count uploaded files and existent entry files |
| 1452 | 1452 | $count_files = count( $file_names ) + count( $value ); |
| 1453 | 1453 | |
| 1454 | - if( $count_files > $field->maxFiles ) { |
|
| 1454 | + if ( $count_files > $field->maxFiles ) { |
|
| 1455 | 1455 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
| 1456 | 1456 | $field->failed_validation = 1; |
| 1457 | 1457 | $gv_valid = false; |
| 1458 | 1458 | |
| 1459 | 1459 | // in case of error make sure the newest upload files are removed from the upload input |
| 1460 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1460 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | 1463 | } |
@@ -1468,7 +1468,7 @@ discard block |
||
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | 1470 | // This field has failed validation. |
| 1471 | - if( !empty( $field->failed_validation ) ) { |
|
| 1471 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1472 | 1472 | |
| 1473 | 1473 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
| 1474 | 1474 | |
@@ -1486,19 +1486,19 @@ discard block |
||
| 1486 | 1486 | } |
| 1487 | 1487 | |
| 1488 | 1488 | // You can't continue inside a switch, so we do it after. |
| 1489 | - if( empty( $field->failed_validation ) ) { |
|
| 1489 | + if ( empty( $field->failed_validation ) ) { |
|
| 1490 | 1490 | continue; |
| 1491 | 1491 | } |
| 1492 | 1492 | |
| 1493 | 1493 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1494 | 1494 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1495 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1495 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1496 | 1496 | |
| 1497 | 1497 | $entry = $this->get_entry(); |
| 1498 | 1498 | |
| 1499 | 1499 | // If the value of the entry is the same as the stored value |
| 1500 | 1500 | // Then we can assume it's not a duplicate, it's the same. |
| 1501 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1501 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1502 | 1502 | //if value submitted was not changed, then don't validate |
| 1503 | 1503 | $field->failed_validation = false; |
| 1504 | 1504 | |
@@ -1511,7 +1511,7 @@ discard block |
||
| 1511 | 1511 | } |
| 1512 | 1512 | |
| 1513 | 1513 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1514 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1514 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1515 | 1515 | unset( $field->validation_message ); |
| 1516 | 1516 | $field->validation_message = false; |
| 1517 | 1517 | continue; |
@@ -1523,12 +1523,12 @@ discard block |
||
| 1523 | 1523 | |
| 1524 | 1524 | } |
| 1525 | 1525 | |
| 1526 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1526 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1527 | 1527 | |
| 1528 | 1528 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
| 1529 | 1529 | |
| 1530 | 1530 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1531 | - $this->form_after_validation = $validation_results['form']; |
|
| 1531 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1532 | 1532 | |
| 1533 | 1533 | return $validation_results; |
| 1534 | 1534 | } |
@@ -1541,7 +1541,7 @@ discard block |
||
| 1541 | 1541 | */ |
| 1542 | 1542 | public function get_entry() { |
| 1543 | 1543 | |
| 1544 | - if( empty( $this->entry ) ) { |
|
| 1544 | + if ( empty( $this->entry ) ) { |
|
| 1545 | 1545 | // Get the database value of the entry that's being edited |
| 1546 | 1546 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1547 | 1547 | } |
@@ -1573,10 +1573,10 @@ discard block |
||
| 1573 | 1573 | } |
| 1574 | 1574 | |
| 1575 | 1575 | // If edit tab not yet configured, show all fields |
| 1576 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1576 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1577 | 1577 | |
| 1578 | 1578 | // Hide fields depending on admin settings |
| 1579 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1579 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1580 | 1580 | |
| 1581 | 1581 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1582 | 1582 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1608,7 +1608,7 @@ discard block |
||
| 1608 | 1608 | */ |
| 1609 | 1609 | private function filter_fields( $fields, $configured_fields ) { |
| 1610 | 1610 | |
| 1611 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1611 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1612 | 1612 | return $fields; |
| 1613 | 1613 | } |
| 1614 | 1614 | |
@@ -1621,18 +1621,18 @@ discard block |
||
| 1621 | 1621 | |
| 1622 | 1622 | // Remove the fields that have calculation properties and keep them to be used later |
| 1623 | 1623 | // @since 1.16.2 |
| 1624 | - if( $field->has_calculation() ) { |
|
| 1625 | - $this->fields_with_calculation[] = $field; |
|
| 1624 | + if ( $field->has_calculation() ) { |
|
| 1625 | + $this->fields_with_calculation[ ] = $field; |
|
| 1626 | 1626 | // don't remove the calculation fields on form render. |
| 1627 | 1627 | } |
| 1628 | 1628 | |
| 1629 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1629 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1630 | 1630 | unset( $fields[ $key ] ); |
| 1631 | 1631 | } |
| 1632 | 1632 | } |
| 1633 | 1633 | |
| 1634 | 1634 | // The Edit tab has not been configured, so we return all fields by default. |
| 1635 | - if( empty( $configured_fields ) ) { |
|
| 1635 | + if ( empty( $configured_fields ) ) { |
|
| 1636 | 1636 | return $fields; |
| 1637 | 1637 | } |
| 1638 | 1638 | |
@@ -1642,8 +1642,8 @@ discard block |
||
| 1642 | 1642 | /** @var GF_Field $field */ |
| 1643 | 1643 | foreach ( $fields as $field ) { |
| 1644 | 1644 | |
| 1645 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1646 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1645 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1646 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1647 | 1647 | break; |
| 1648 | 1648 | } |
| 1649 | 1649 | |
@@ -1666,14 +1666,14 @@ discard block |
||
| 1666 | 1666 | |
| 1667 | 1667 | $return_field = $field; |
| 1668 | 1668 | |
| 1669 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 1669 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 1670 | 1670 | $return_field->label = ''; |
| 1671 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 1672 | - $return_field->label = $field_setting['custom_label']; |
|
| 1671 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 1672 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 1673 | 1673 | } |
| 1674 | 1674 | |
| 1675 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 1676 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 1675 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 1676 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 1677 | 1677 | } |
| 1678 | 1678 | |
| 1679 | 1679 | /** |
@@ -1711,16 +1711,16 @@ discard block |
||
| 1711 | 1711 | */ |
| 1712 | 1712 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 1713 | 1713 | |
| 1714 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1715 | - foreach( $fields as $k => $field ) { |
|
| 1716 | - if( $field->adminOnly ) { |
|
| 1714 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 1715 | + foreach ( $fields as $k => $field ) { |
|
| 1716 | + if ( $field->adminOnly ) { |
|
| 1717 | 1717 | unset( $fields[ $k ] ); |
| 1718 | 1718 | } |
| 1719 | 1719 | } |
| 1720 | 1720 | return $fields; |
| 1721 | 1721 | } |
| 1722 | 1722 | |
| 1723 | - foreach( $fields as &$field ) { |
|
| 1723 | + foreach ( $fields as &$field ) { |
|
| 1724 | 1724 | $field->adminOnly = false; |
| 1725 | 1725 | } |
| 1726 | 1726 | |
@@ -1744,22 +1744,22 @@ discard block |
||
| 1744 | 1744 | */ |
| 1745 | 1745 | function prefill_conditional_logic( $form ) { |
| 1746 | 1746 | |
| 1747 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1747 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1748 | 1748 | return $form; |
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | 1751 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 1752 | 1752 | /** @var GF_Field $field */ |
| 1753 | - foreach ( $form['fields'] as &$field ) { |
|
| 1753 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1754 | 1754 | |
| 1755 | - if( 'checkbox' === $field->type ) { |
|
| 1755 | + if ( 'checkbox' === $field->type ) { |
|
| 1756 | 1756 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1757 | - $input_id = $input['id']; |
|
| 1757 | + $input_id = $input[ 'id' ]; |
|
| 1758 | 1758 | $choice = $field->choices[ $key ]; |
| 1759 | 1759 | $value = \GV\Utils::get( $this->entry, $input_id ); |
| 1760 | 1760 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 1761 | - if( $match ) { |
|
| 1762 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1761 | + if ( $match ) { |
|
| 1762 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 1763 | 1763 | } |
| 1764 | 1764 | } |
| 1765 | 1765 | } else { |
@@ -1767,15 +1767,15 @@ discard block |
||
| 1767 | 1767 | // We need to run through each field to set the default values |
| 1768 | 1768 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1769 | 1769 | |
| 1770 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1770 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1771 | 1771 | |
| 1772 | - if( 'list' === $field->type ) { |
|
| 1772 | + if ( 'list' === $field->type ) { |
|
| 1773 | 1773 | $list_rows = maybe_unserialize( $field_value ); |
| 1774 | 1774 | |
| 1775 | 1775 | $list_field_value = array(); |
| 1776 | - foreach ( (array) $list_rows as $row ) { |
|
| 1777 | - foreach ( (array) $row as $column ) { |
|
| 1778 | - $list_field_value[] = $column; |
|
| 1776 | + foreach ( (array)$list_rows as $row ) { |
|
| 1777 | + foreach ( (array)$row as $column ) { |
|
| 1778 | + $list_field_value[ ] = $column; |
|
| 1779 | 1779 | } |
| 1780 | 1780 | } |
| 1781 | 1781 | |
@@ -1810,16 +1810,16 @@ discard block |
||
| 1810 | 1810 | */ |
| 1811 | 1811 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 1812 | 1812 | |
| 1813 | - if( $use_conditional_logic ) { |
|
| 1813 | + if ( $use_conditional_logic ) { |
|
| 1814 | 1814 | return $form; |
| 1815 | 1815 | } |
| 1816 | 1816 | |
| 1817 | - foreach( $form['fields'] as &$field ) { |
|
| 1817 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1818 | 1818 | /* @var GF_Field $field */ |
| 1819 | 1819 | $field->conditionalLogic = null; |
| 1820 | 1820 | } |
| 1821 | 1821 | |
| 1822 | - unset( $form['button']['conditionalLogic'] ); |
|
| 1822 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 1823 | 1823 | |
| 1824 | 1824 | return $form; |
| 1825 | 1825 | |
@@ -1836,7 +1836,7 @@ discard block |
||
| 1836 | 1836 | */ |
| 1837 | 1837 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 1838 | 1838 | |
| 1839 | - if( ! $this->is_edit_entry() ) { |
|
| 1839 | + if ( ! $this->is_edit_entry() ) { |
|
| 1840 | 1840 | return $has_conditional_logic; |
| 1841 | 1841 | } |
| 1842 | 1842 | |
@@ -1868,44 +1868,44 @@ discard block |
||
| 1868 | 1868 | * 2. There are two entries embedded using oEmbed |
| 1869 | 1869 | * 3. One of the entries has just been saved |
| 1870 | 1870 | */ |
| 1871 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 1871 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 1872 | 1872 | |
| 1873 | 1873 | $error = true; |
| 1874 | 1874 | |
| 1875 | 1875 | } |
| 1876 | 1876 | |
| 1877 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 1877 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 1878 | 1878 | |
| 1879 | 1879 | $error = true; |
| 1880 | 1880 | |
| 1881 | - } elseif( ! $this->verify_nonce() ) { |
|
| 1881 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 1882 | 1882 | |
| 1883 | 1883 | /** |
| 1884 | 1884 | * If the Entry is embedded, there may be two entries on the same page. |
| 1885 | 1885 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 1886 | 1886 | */ |
| 1887 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1887 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1888 | 1888 | $error = true; |
| 1889 | 1889 | } else { |
| 1890 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 1890 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | 1893 | } |
| 1894 | 1894 | |
| 1895 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1896 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 1895 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1896 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 1897 | 1897 | } |
| 1898 | 1898 | |
| 1899 | - if( $this->entry['status'] === 'trash' ) { |
|
| 1900 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1899 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 1900 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1901 | 1901 | } |
| 1902 | 1902 | |
| 1903 | 1903 | // No errors; everything's fine here! |
| 1904 | - if( empty( $error ) ) { |
|
| 1904 | + if ( empty( $error ) ) { |
|
| 1905 | 1905 | return true; |
| 1906 | 1906 | } |
| 1907 | 1907 | |
| 1908 | - if( $echo && $error !== true ) { |
|
| 1908 | + if ( $echo && $error !== true ) { |
|
| 1909 | 1909 | |
| 1910 | 1910 | $error = esc_html( $error ); |
| 1911 | 1911 | |
@@ -1913,10 +1913,10 @@ discard block |
||
| 1913 | 1913 | * @since 1.9 |
| 1914 | 1914 | */ |
| 1915 | 1915 | if ( ! empty( $this->entry ) ) { |
| 1916 | - $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;" ) ); |
|
| 1916 | + $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;" ) ); |
|
| 1917 | 1917 | } |
| 1918 | 1918 | |
| 1919 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 1919 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 1920 | 1920 | } |
| 1921 | 1921 | |
| 1922 | 1922 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1936,17 +1936,17 @@ discard block |
||
| 1936 | 1936 | |
| 1937 | 1937 | $error = NULL; |
| 1938 | 1938 | |
| 1939 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 1940 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 1939 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 1940 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 1941 | 1941 | } |
| 1942 | 1942 | |
| 1943 | 1943 | // No errors; everything's fine here! |
| 1944 | - if( empty( $error ) ) { |
|
| 1944 | + if ( empty( $error ) ) { |
|
| 1945 | 1945 | return true; |
| 1946 | 1946 | } |
| 1947 | 1947 | |
| 1948 | - if( $echo ) { |
|
| 1949 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 1948 | + if ( $echo ) { |
|
| 1949 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 1950 | 1950 | } |
| 1951 | 1951 | |
| 1952 | 1952 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1967,14 +1967,14 @@ discard block |
||
| 1967 | 1967 | private function check_user_cap_edit_field( $field ) { |
| 1968 | 1968 | |
| 1969 | 1969 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 1970 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 1970 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 1971 | 1971 | return true; |
| 1972 | 1972 | } |
| 1973 | 1973 | |
| 1974 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 1974 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 1975 | 1975 | |
| 1976 | - if( $field_cap ) { |
|
| 1977 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 1976 | + if ( $field_cap ) { |
|
| 1977 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | 1980 | return false; |
@@ -1988,17 +1988,17 @@ discard block |
||
| 1988 | 1988 | public function verify_nonce() { |
| 1989 | 1989 | |
| 1990 | 1990 | // Verify form submitted for editing single |
| 1991 | - if( $this->is_edit_entry_submission() ) { |
|
| 1991 | + if ( $this->is_edit_entry_submission() ) { |
|
| 1992 | 1992 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 1993 | 1993 | } |
| 1994 | 1994 | |
| 1995 | 1995 | // Verify |
| 1996 | - else if( ! $this->is_edit_entry() ) { |
|
| 1996 | + else if ( ! $this->is_edit_entry() ) { |
|
| 1997 | 1997 | $valid = false; |
| 1998 | 1998 | } |
| 1999 | 1999 | |
| 2000 | 2000 | else { |
| 2001 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2001 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2002 | 2002 | } |
| 2003 | 2003 | |
| 2004 | 2004 | /** |
@@ -42,16 +42,16 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $args = wp_parse_args( $args, $defaults ); |
| 44 | 44 | |
| 45 | - $forms = gravityview_get_forms( (bool) $args['active'], (bool) $args['trash'] ); |
|
| 45 | + $forms = gravityview_get_forms( (bool)$args[ 'active' ], (bool)$args[ 'trash' ] ); |
|
| 46 | 46 | |
| 47 | - if( array() === $args['options'] ) { |
|
| 47 | + if ( array() === $args[ 'options' ] ) { |
|
| 48 | 48 | foreach ( $forms as $form ) { |
| 49 | 49 | |
| 50 | - if ( in_array( $form['id'], $args['exclude'] ) ) { |
|
| 50 | + if ( in_array( $form[ 'id' ], $args[ 'exclude' ] ) ) { |
|
| 51 | 51 | continue; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $args['options'][ $form['id'] ] = esc_html( $form['title'] ); |
|
| 54 | + $args[ 'options' ][ $form[ 'id' ] ] = esc_html( $form[ 'title' ] ); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | $args = wp_parse_args( $args, $defaults ); |
| 85 | 85 | |
| 86 | - if( empty( $args['form_id'] ) ) { |
|
| 86 | + if ( empty( $args[ 'form_id' ] ) ) { |
|
| 87 | 87 | return ''; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $fields = GVCommon::get_sortable_fields_array( $args['form_id'] ); |
|
| 90 | + $fields = GVCommon::get_sortable_fields_array( $args[ 'form_id' ] ); |
|
| 91 | 91 | |
| 92 | - if( array() === $args['options'] ) { |
|
| 92 | + if ( array() === $args[ 'options' ] ) { |
|
| 93 | 93 | foreach ( $fields as $field_id => $field ) { |
| 94 | - $args['options'][ $field_id ] = esc_html( $field['label'] ); |
|
| 94 | + $args[ 'options' ][ $field_id ] = esc_html( $field[ 'label' ] ); |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
@@ -127,43 +127,43 @@ discard block |
||
| 127 | 127 | $args = wp_parse_args( $args, $defaults ); |
| 128 | 128 | |
| 129 | 129 | $data_elements = ''; |
| 130 | - foreach ( $args['data'] as $key => $value ) { |
|
| 130 | + foreach ( $args[ 'data' ] as $key => $value ) { |
|
| 131 | 131 | $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if( $args['multiple'] ) { |
|
| 134 | + if ( $args[ 'multiple' ] ) { |
|
| 135 | 135 | $multiple = ' MULTIPLE'; |
| 136 | 136 | } else { |
| 137 | 137 | $multiple = ''; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if( $args['placeholder'] ) { |
|
| 141 | - $placeholder = $args['placeholder']; |
|
| 140 | + if ( $args[ 'placeholder' ] ) { |
|
| 141 | + $placeholder = $args[ 'placeholder' ]; |
|
| 142 | 142 | } else { |
| 143 | 143 | $placeholder = ''; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $disabled = $args['disabled'] ? ' disabled="disabled"' : ''; |
|
| 147 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 148 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( str_replace( '-', '_', $args['id'] ) ) . '" class="gravityview-select ' . $class . '"' . $multiple . $disabled . ' data-placeholder="' . $placeholder . '"'. $data_elements . '>'; |
|
| 146 | + $disabled = $args[ 'disabled' ] ? ' disabled="disabled"' : ''; |
|
| 147 | + $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args[ 'class' ] ) ) ); |
|
| 148 | + $output = '<select name="' . esc_attr( $args[ 'name' ] ) . '" id="' . esc_attr( str_replace( '-', '_', $args[ 'id' ] ) ) . '" class="gravityview-select ' . $class . '"' . $multiple . $disabled . ' data-placeholder="' . $placeholder . '"' . $data_elements . '>'; |
|
| 149 | 149 | |
| 150 | - if ( ! empty( $args['options'] ) ) { |
|
| 150 | + if ( ! empty( $args[ 'options' ] ) ) { |
|
| 151 | 151 | |
| 152 | - if ( $args['show_option_none'] ) { |
|
| 153 | - if( $args['multiple'] ) { |
|
| 154 | - $selected = selected( true, in_array( -1, $args['selected'] ), false ); |
|
| 152 | + if ( $args[ 'show_option_none' ] ) { |
|
| 153 | + if ( $args[ 'multiple' ] ) { |
|
| 154 | + $selected = selected( true, in_array( -1, $args[ 'selected' ] ), false ); |
|
| 155 | 155 | } else { |
| 156 | - $selected = selected( $args['selected'], -1, false ); |
|
| 156 | + $selected = selected( $args[ 'selected' ], -1, false ); |
|
| 157 | 157 | } |
| 158 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 158 | + $output .= '<option value="-1"' . $selected . '>' . esc_html( $args[ 'show_option_none' ] ) . '</option>'; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - foreach( $args['options'] as $key => $option ) { |
|
| 161 | + foreach ( $args[ 'options' ] as $key => $option ) { |
|
| 162 | 162 | |
| 163 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 164 | - $selected = selected( true, in_array( $key, $args['selected'], true ), false ); |
|
| 163 | + if ( $args[ 'multiple' ] && is_array( $args[ 'selected' ] ) ) { |
|
| 164 | + $selected = selected( true, in_array( $key, $args[ 'selected' ], true ), false ); |
|
| 165 | 165 | } else { |
| 166 | - $selected = selected( $args['selected'], $key, false ); |
|
| 166 | + $selected = selected( $args[ 'selected' ], $key, false ); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | function parse_um_profile_post_content( $args = array() ) { |
| 44 | 44 | global $ultimatemember; |
| 45 | 45 | |
| 46 | - if( ! $ultimatemember || ! is_object( $ultimatemember ) || ! class_exists( 'GravityView_View_Data' ) ) { |
|
| 46 | + if ( ! $ultimatemember || ! is_object( $ultimatemember ) || ! class_exists( 'GravityView_View_Data' ) ) { |
|
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // @todo Support Ultimate Member 2.0 - for now, prevent fatal error |
| 51 | - if( ! isset( $ultimatemember->profile ) ) { |
|
| 51 | + if ( ! isset( $ultimatemember->profile ) ) { |
|
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | return; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - GravityView_View_Data::getInstance()->parse_post_content( $active_tab[0]->post_content ); |
|
| 67 | + GravityView_View_Data::getInstance()->parse_post_content( $active_tab[ 0 ]->post_content ); |
|
| 68 | 68 | |
| 69 | 69 | wp_reset_postdata(); |
| 70 | 70 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $acf_keys = get_field_objects( $post_id, array( 'load_value' => false ) ); |
| 57 | 57 | |
| 58 | - if( $acf_keys ) { |
|
| 58 | + if ( $acf_keys ) { |
|
| 59 | 59 | return array_merge( array_keys( $acf_keys ), $meta_keys ); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | * @return void |
| 71 | 71 | */ |
| 72 | 72 | private function fix_posted_fields() { |
| 73 | - if( is_admin() && isset( $_POST['action'] ) && isset( $_POST['post_type'] ) ) { |
|
| 74 | - if( 'editpost' === $_POST['action'] && 'gravityview' === $_POST['post_type'] ) { |
|
| 75 | - $_POST['fields'] = _gravityview_process_posted_fields(); |
|
| 73 | + if ( is_admin() && isset( $_POST[ 'action' ] ) && isset( $_POST[ 'post_type' ] ) ) { |
|
| 74 | + if ( 'editpost' === $_POST[ 'action' ] && 'gravityview' === $_POST[ 'post_type' ] ) { |
|
| 75 | + $_POST[ 'fields' ] = _gravityview_process_posted_fields(); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | } |