@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | |
103 | 103 | /** |
104 | 104 | * ID of the current post. May also be ID of the current View. |
105 | - * |
|
106 | - * @since 2.0.13 |
|
107 | 105 | * |
108 | - * @var int |
|
106 | + * @since 2.0.13 |
|
107 | + * |
|
108 | + * @var int |
|
109 | 109 | */ |
110 | 110 | public $post_id; |
111 | 111 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function prevent_maybe_process_form() { |
191 | 191 | |
192 | - if( ! $this->is_edit_entry_submission() ) { |
|
192 | + if( ! $this->is_edit_entry_submission() ) { |
|
193 | 193 | return; |
194 | 194 | } |
195 | 195 | |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | * When Edit entry view is requested setup the vars |
229 | 229 | */ |
230 | 230 | private function setup_vars() { |
231 | - global $post; |
|
231 | + global $post; |
|
232 | 232 | |
233 | 233 | $gravityview_view = GravityView_View::getInstance(); |
234 | 234 | |
235 | 235 | |
236 | 236 | $entries = $gravityview_view->getEntries(); |
237 | - self::$original_entry = $entries[0]; |
|
238 | - $this->entry = $entries[0]; |
|
237 | + self::$original_entry = $entries[0]; |
|
238 | + $this->entry = $entries[0]; |
|
239 | 239 | |
240 | 240 | self::$original_form = GFAPI::get_form( $this->entry['form_id'] ); |
241 | 241 | $this->form = self::$original_form; |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | |
381 | 381 | GFFormsModel::save_lead( $form, $this->entry ); |
382 | 382 | |
383 | - // Delete the values for hidden inputs |
|
384 | - $this->unset_hidden_field_values(); |
|
383 | + // Delete the values for hidden inputs |
|
384 | + $this->unset_hidden_field_values(); |
|
385 | 385 | |
386 | 386 | $this->entry['date_created'] = $date_created; |
387 | 387 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | // Perform actions normally performed after updating a lead |
395 | 395 | $this->after_update(); |
396 | 396 | |
397 | - /** |
|
397 | + /** |
|
398 | 398 | * Must be AFTER after_update()! |
399 | 399 | * @see https://github.com/gravityview/GravityView/issues/764 |
400 | 400 | */ |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | |
403 | 403 | /** |
404 | 404 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
405 | - * @since 2.1 Added $gv_data parameter |
|
405 | + * @since 2.1 Added $gv_data parameter |
|
406 | 406 | * @param array $form Gravity Forms form array |
407 | 407 | * @param string $entry_id Numeric ID of the entry that was updated |
408 | 408 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @return void |
427 | 427 | */ |
428 | 428 | private function unset_hidden_field_values() { |
429 | - global $wpdb; |
|
429 | + global $wpdb; |
|
430 | 430 | |
431 | 431 | /** |
432 | 432 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
451 | 451 | } |
452 | 452 | |
453 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
453 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
454 | 454 | |
455 | 455 | if ( ! is_numeric( $input_id ) ) { |
456 | 456 | continue; |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | continue; |
461 | 461 | } |
462 | 462 | |
463 | - // Reset fields that are or would be hidden |
|
464 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
463 | + // Reset fields that are or would be hidden |
|
464 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
465 | 465 | |
466 | 466 | $empty_value = $field->get_value_save_entry( |
467 | 467 | is_array( $field->get_entry_inputs() ) ? array() : '', |
@@ -473,16 +473,16 @@ discard block |
||
473 | 473 | $empty_value = ''; |
474 | 474 | } |
475 | 475 | |
476 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
476 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
477 | 477 | |
478 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
478 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
479 | 479 | |
480 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
480 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
481 | 481 | // after submission |
482 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
483 | - $_POST[ $post_input_id ] = ''; |
|
484 | - } |
|
485 | - } |
|
482 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
483 | + $_POST[ $post_input_id ] = ''; |
|
484 | + } |
|
485 | + } |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | |
638 | 638 | $form = $this->filter_conditional_logic( $this->form ); |
639 | 639 | |
640 | - /** @type GF_Field $field */ |
|
640 | + /** @type GF_Field $field */ |
|
641 | 641 | foreach( $form['fields'] as $k => &$field ) { |
642 | 642 | |
643 | 643 | /** |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | |
653 | 653 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
654 | 654 | foreach( $field->inputs as $key => $input ) { |
655 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
655 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
656 | 656 | } |
657 | 657 | } |
658 | 658 | } |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | |
693 | 693 | $inputs = $field->get_entry_inputs(); |
694 | 694 | if ( is_array( $inputs ) ) { |
695 | - foreach ( $inputs as $input ) { |
|
695 | + foreach ( $inputs as $input ) { |
|
696 | 696 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
697 | 697 | |
698 | 698 | if ( 'product' === $field->type ) { |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | } |
712 | 712 | |
713 | 713 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
714 | - } |
|
714 | + } |
|
715 | 715 | } else { |
716 | 716 | // Set to what it previously was if it's not editable |
717 | 717 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
758 | 758 | |
759 | 759 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
760 | - $ary = stripslashes_deep( $ary ); |
|
760 | + $ary = stripslashes_deep( $ary ); |
|
761 | 761 | $img_url = \GV\Utils::get( $ary, 0 ); |
762 | 762 | |
763 | 763 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | private function maybe_update_post_fields( $form ) { |
831 | 831 | |
832 | 832 | if( empty( $this->entry['post_id'] ) ) { |
833 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
833 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
834 | 834 | return; |
835 | 835 | } |
836 | 836 | |
@@ -865,49 +865,49 @@ discard block |
||
865 | 865 | |
866 | 866 | switch( $field->type ) { |
867 | 867 | |
868 | - case 'post_title': |
|
869 | - $post_title = $value; |
|
870 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
871 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
872 | - } |
|
873 | - $updated_post->post_title = $post_title; |
|
874 | - $updated_post->post_name = $post_title; |
|
875 | - unset( $post_title ); |
|
876 | - break; |
|
877 | - |
|
878 | - case 'post_content': |
|
879 | - $post_content = $value; |
|
880 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
881 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
882 | - } |
|
883 | - $updated_post->post_content = $post_content; |
|
884 | - unset( $post_content ); |
|
885 | - break; |
|
886 | - case 'post_excerpt': |
|
887 | - $updated_post->post_excerpt = $value; |
|
888 | - break; |
|
889 | - case 'post_tags': |
|
890 | - wp_set_post_tags( $post_id, $value, false ); |
|
891 | - break; |
|
892 | - case 'post_category': |
|
893 | - break; |
|
894 | - case 'post_custom_field': |
|
868 | + case 'post_title': |
|
869 | + $post_title = $value; |
|
870 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
871 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
872 | + } |
|
873 | + $updated_post->post_title = $post_title; |
|
874 | + $updated_post->post_name = $post_title; |
|
875 | + unset( $post_title ); |
|
876 | + break; |
|
877 | + |
|
878 | + case 'post_content': |
|
879 | + $post_content = $value; |
|
880 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
881 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
882 | + } |
|
883 | + $updated_post->post_content = $post_content; |
|
884 | + unset( $post_content ); |
|
885 | + break; |
|
886 | + case 'post_excerpt': |
|
887 | + $updated_post->post_excerpt = $value; |
|
888 | + break; |
|
889 | + case 'post_tags': |
|
890 | + wp_set_post_tags( $post_id, $value, false ); |
|
891 | + break; |
|
892 | + case 'post_category': |
|
893 | + break; |
|
894 | + case 'post_custom_field': |
|
895 | 895 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
896 | 896 | $value = $value[ $field_id ]; |
897 | 897 | } |
898 | 898 | |
899 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
900 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
901 | - } |
|
899 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
900 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
901 | + } |
|
902 | 902 | |
903 | 903 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
904 | 904 | |
905 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
906 | - break; |
|
905 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
906 | + break; |
|
907 | 907 | |
908 | - case 'post_image': |
|
909 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
910 | - break; |
|
908 | + case 'post_image': |
|
909 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
910 | + break; |
|
911 | 911 | |
912 | 912 | } |
913 | 913 | |
@@ -1077,14 +1077,14 @@ discard block |
||
1077 | 1077 | ?><h2 class="gv-edit-entry-title"> |
1078 | 1078 | <span><?php |
1079 | 1079 | |
1080 | - /** |
|
1081 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
1082 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
1083 | - * @param GravityView_Edit_Entry_Render $this This object |
|
1084 | - */ |
|
1085 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1080 | + /** |
|
1081 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
1082 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
1083 | + * @param GravityView_Edit_Entry_Render $this This object |
|
1084 | + */ |
|
1085 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1086 | 1086 | |
1087 | - echo esc_attr( $edit_entry_title ); |
|
1087 | + echo esc_attr( $edit_entry_title ); |
|
1088 | 1088 | ?></span> |
1089 | 1089 | </h2> |
1090 | 1090 | |
@@ -1150,13 +1150,13 @@ discard block |
||
1150 | 1150 | ); |
1151 | 1151 | |
1152 | 1152 | /** |
1153 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1154 | - * @since 1.16.3 |
|
1155 | - * @param array $labels Default button labels associative array |
|
1156 | - * @param array $form The Gravity Forms form |
|
1157 | - * @param array $entry The Gravity Forms entry |
|
1158 | - * @param int $view_id The current View ID |
|
1159 | - */ |
|
1153 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1154 | + * @since 1.16.3 |
|
1155 | + * @param array $labels Default button labels associative array |
|
1156 | + * @param array $form The Gravity Forms form |
|
1157 | + * @param array $entry The Gravity Forms entry |
|
1158 | + * @param int $view_id The current View ID |
|
1159 | + */ |
|
1160 | 1160 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1161 | 1161 | |
1162 | 1162 | $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
@@ -1276,13 +1276,13 @@ discard block |
||
1276 | 1276 | ); |
1277 | 1277 | |
1278 | 1278 | /** |
1279 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1280 | - * @since 1.16.3 |
|
1281 | - * @param array $labels Default button labels associative array |
|
1282 | - * @param array $form The Gravity Forms form |
|
1283 | - * @param array $entry The Gravity Forms entry |
|
1284 | - * @param int $view_id The current View ID |
|
1285 | - */ |
|
1279 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1280 | + * @since 1.16.3 |
|
1281 | + * @param array $labels Default button labels associative array |
|
1282 | + * @param array $form The Gravity Forms form |
|
1283 | + * @param array $entry The Gravity Forms entry |
|
1284 | + * @param int $view_id The current View ID |
|
1285 | + */ |
|
1286 | 1286 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1287 | 1287 | |
1288 | 1288 | GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | |
1329 | 1329 | ob_get_clean(); |
1330 | 1330 | |
1331 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1331 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1332 | 1332 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1333 | 1333 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
1334 | 1334 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1388,7 +1388,7 @@ discard block |
||
1388 | 1388 | |
1389 | 1389 | // for now we don't support Save and Continue feature. |
1390 | 1390 | if( ! self::$supports_save_and_continue ) { |
1391 | - unset( $form['save'] ); |
|
1391 | + unset( $form['save'] ); |
|
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | $form = $this->unselect_default_values( $form ); |
@@ -1415,30 +1415,30 @@ discard block |
||
1415 | 1415 | return $field_content; |
1416 | 1416 | } |
1417 | 1417 | |
1418 | - $message = null; |
|
1418 | + $message = null; |
|
1419 | 1419 | |
1420 | - // First, make sure they have the capability to edit the post. |
|
1421 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1420 | + // First, make sure they have the capability to edit the post. |
|
1421 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1422 | 1422 | |
1423 | - /** |
|
1424 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1425 | - * @param string $message The existing "You don't have permission..." text |
|
1426 | - */ |
|
1427 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1423 | + /** |
|
1424 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1425 | + * @param string $message The existing "You don't have permission..." text |
|
1426 | + */ |
|
1427 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1428 | 1428 | |
1429 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1430 | - /** |
|
1431 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1432 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1433 | - */ |
|
1434 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1435 | - } |
|
1429 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1430 | + /** |
|
1431 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1432 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1433 | + */ |
|
1434 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1435 | + } |
|
1436 | 1436 | |
1437 | - if( $message ) { |
|
1438 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1439 | - } |
|
1437 | + if( $message ) { |
|
1438 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1439 | + } |
|
1440 | 1440 | |
1441 | - return $field_content; |
|
1441 | + return $field_content; |
|
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | /** |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | || ! empty( $field_content ) |
1467 | 1467 | || in_array( $field->type, array( 'honeypot' ) ) |
1468 | 1468 | ) { |
1469 | - return $field_content; |
|
1469 | + return $field_content; |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1474,24 +1474,24 @@ discard block |
||
1474 | 1474 | |
1475 | 1475 | $field_value = $this->get_field_value( $field ); |
1476 | 1476 | |
1477 | - // Prevent any PHP warnings, like undefined index |
|
1478 | - ob_start(); |
|
1477 | + // Prevent any PHP warnings, like undefined index |
|
1478 | + ob_start(); |
|
1479 | 1479 | |
1480 | - $return = null; |
|
1480 | + $return = null; |
|
1481 | 1481 | |
1482 | 1482 | /** @var GravityView_Field $gv_field */ |
1483 | 1483 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1484 | 1484 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1485 | 1485 | } else { |
1486 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1487 | - } |
|
1486 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1487 | + } |
|
1488 | 1488 | |
1489 | - // If there was output, it's an error |
|
1490 | - $warnings = ob_get_clean(); |
|
1489 | + // If there was output, it's an error |
|
1490 | + $warnings = ob_get_clean(); |
|
1491 | 1491 | |
1492 | - if( !empty( $warnings ) ) { |
|
1493 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1494 | - } |
|
1492 | + if( !empty( $warnings ) ) { |
|
1493 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1494 | + } |
|
1495 | 1495 | |
1496 | 1496 | return $return; |
1497 | 1497 | } |
@@ -1526,8 +1526,8 @@ discard block |
||
1526 | 1526 | $input_id = strval( $input['id'] ); |
1527 | 1527 | |
1528 | 1528 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1529 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1530 | - $allow_pre_populated = false; |
|
1529 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1530 | + $allow_pre_populated = false; |
|
1531 | 1531 | } |
1532 | 1532 | |
1533 | 1533 | } |
@@ -1551,7 +1551,7 @@ discard block |
||
1551 | 1551 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1552 | 1552 | $categories = array(); |
1553 | 1553 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1554 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1554 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1555 | 1555 | } |
1556 | 1556 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1557 | 1557 | } |
@@ -1561,25 +1561,25 @@ discard block |
||
1561 | 1561 | // if value is empty get the default value if defined |
1562 | 1562 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1563 | 1563 | |
1564 | - /** |
|
1565 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1566 | - * @since 1.11 |
|
1567 | - * @since 1.20 Added third param |
|
1568 | - * @param mixed $field_value field value used to populate the input |
|
1569 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1570 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1571 | - */ |
|
1572 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1573 | - |
|
1574 | - /** |
|
1575 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1576 | - * @since 1.17 |
|
1577 | - * @since 1.20 Added third param |
|
1578 | - * @param mixed $field_value field value used to populate the input |
|
1579 | - * @param GF_Field $field Gravity Forms field object |
|
1580 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1581 | - */ |
|
1582 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1564 | + /** |
|
1565 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1566 | + * @since 1.11 |
|
1567 | + * @since 1.20 Added third param |
|
1568 | + * @param mixed $field_value field value used to populate the input |
|
1569 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1570 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1571 | + */ |
|
1572 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1573 | + |
|
1574 | + /** |
|
1575 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1576 | + * @since 1.17 |
|
1577 | + * @since 1.20 Added third param |
|
1578 | + * @param mixed $field_value field value used to populate the input |
|
1579 | + * @param GF_Field $field Gravity Forms field object |
|
1580 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1581 | + */ |
|
1582 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1583 | 1583 | |
1584 | 1584 | return $field_value; |
1585 | 1585 | } |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1607 | 1607 | // expects certain field array items to be set. |
1608 | 1608 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1609 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1609 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1610 | 1610 | } |
1611 | 1611 | |
1612 | 1612 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1620,31 +1620,31 @@ discard block |
||
1620 | 1620 | */ |
1621 | 1621 | case 'fileupload': |
1622 | 1622 | |
1623 | - // Set the previous value |
|
1624 | - $entry = $this->get_entry(); |
|
1623 | + // Set the previous value |
|
1624 | + $entry = $this->get_entry(); |
|
1625 | 1625 | |
1626 | - $input_name = 'input_'.$field->id; |
|
1627 | - $form_id = $form['id']; |
|
1626 | + $input_name = 'input_'.$field->id; |
|
1627 | + $form_id = $form['id']; |
|
1628 | 1628 | |
1629 | - $value = NULL; |
|
1629 | + $value = NULL; |
|
1630 | 1630 | |
1631 | - // Use the previous entry value as the default. |
|
1632 | - if( isset( $entry[ $field->id ] ) ) { |
|
1633 | - $value = $entry[ $field->id ]; |
|
1634 | - } |
|
1631 | + // Use the previous entry value as the default. |
|
1632 | + if( isset( $entry[ $field->id ] ) ) { |
|
1633 | + $value = $entry[ $field->id ]; |
|
1634 | + } |
|
1635 | 1635 | |
1636 | - // If this is a single upload file |
|
1637 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1638 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1639 | - $value = $file_path['url']; |
|
1636 | + // If this is a single upload file |
|
1637 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1638 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1639 | + $value = $file_path['url']; |
|
1640 | 1640 | |
1641 | - } else { |
|
1641 | + } else { |
|
1642 | 1642 | |
1643 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1644 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1645 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1643 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1644 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1645 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1646 | 1646 | |
1647 | - } |
|
1647 | + } |
|
1648 | 1648 | |
1649 | 1649 | if ( \GV\Utils::get( $field, 'multipleFiles' ) ) { |
1650 | 1650 | // If there are fresh uploads, process and merge them. |
@@ -1665,17 +1665,17 @@ discard block |
||
1665 | 1665 | GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
1666 | 1666 | } |
1667 | 1667 | |
1668 | - $this->entry[ $input_name ] = $value; |
|
1669 | - $_POST[ $input_name ] = $value; |
|
1668 | + $this->entry[ $input_name ] = $value; |
|
1669 | + $_POST[ $input_name ] = $value; |
|
1670 | 1670 | |
1671 | - break; |
|
1671 | + break; |
|
1672 | 1672 | |
1673 | 1673 | case 'number': |
1674 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1675 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1676 | - $_POST['input_'.$field->id ] = NULL; |
|
1677 | - } |
|
1678 | - break; |
|
1674 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1675 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1676 | + $_POST['input_'.$field->id ] = NULL; |
|
1677 | + } |
|
1678 | + break; |
|
1679 | 1679 | } |
1680 | 1680 | |
1681 | 1681 | } |
@@ -1796,7 +1796,7 @@ discard block |
||
1796 | 1796 | |
1797 | 1797 | // count uploaded files and existent entry files |
1798 | 1798 | $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
1799 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
1799 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
1800 | 1800 | |
1801 | 1801 | if ( $count_files > $field->maxFiles ) { |
1802 | 1802 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
@@ -1818,47 +1818,47 @@ discard block |
||
1818 | 1818 | |
1819 | 1819 | switch ( $field_type ) { |
1820 | 1820 | |
1821 | - // Captchas don't need to be re-entered. |
|
1822 | - case 'captcha': |
|
1821 | + // Captchas don't need to be re-entered. |
|
1822 | + case 'captcha': |
|
1823 | 1823 | |
1824 | - // Post Image fields aren't editable, so we un-fail them. |
|
1825 | - case 'post_image': |
|
1826 | - $field->failed_validation = false; |
|
1827 | - unset( $field->validation_message ); |
|
1828 | - break; |
|
1824 | + // Post Image fields aren't editable, so we un-fail them. |
|
1825 | + case 'post_image': |
|
1826 | + $field->failed_validation = false; |
|
1827 | + unset( $field->validation_message ); |
|
1828 | + break; |
|
1829 | 1829 | |
1830 | 1830 | } |
1831 | 1831 | |
1832 | 1832 | // You can't continue inside a switch, so we do it after. |
1833 | 1833 | if( empty( $field->failed_validation ) ) { |
1834 | - continue; |
|
1834 | + continue; |
|
1835 | 1835 | } |
1836 | 1836 | |
1837 | 1837 | // checks if the No Duplicates option is not validating entry against itself, since |
1838 | 1838 | // we're editing a stored entry, it would also assume it's a duplicate. |
1839 | 1839 | if( !empty( $field->noDuplicates ) ) { |
1840 | 1840 | |
1841 | - $entry = $this->get_entry(); |
|
1841 | + $entry = $this->get_entry(); |
|
1842 | 1842 | |
1843 | - // If the value of the entry is the same as the stored value |
|
1844 | - // Then we can assume it's not a duplicate, it's the same. |
|
1845 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1846 | - //if value submitted was not changed, then don't validate |
|
1847 | - $field->failed_validation = false; |
|
1843 | + // If the value of the entry is the same as the stored value |
|
1844 | + // Then we can assume it's not a duplicate, it's the same. |
|
1845 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1846 | + //if value submitted was not changed, then don't validate |
|
1847 | + $field->failed_validation = false; |
|
1848 | 1848 | |
1849 | - unset( $field->validation_message ); |
|
1849 | + unset( $field->validation_message ); |
|
1850 | 1850 | |
1851 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1851 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1852 | 1852 | |
1853 | - continue; |
|
1854 | - } |
|
1853 | + continue; |
|
1854 | + } |
|
1855 | 1855 | } |
1856 | 1856 | |
1857 | 1857 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1858 | 1858 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1859 | - unset( $field->validation_message ); |
|
1859 | + unset( $field->validation_message ); |
|
1860 | 1860 | $field->failed_validation = false; |
1861 | - continue; |
|
1861 | + continue; |
|
1862 | 1862 | } |
1863 | 1863 | |
1864 | 1864 | $gv_valid = false; |
@@ -1922,8 +1922,8 @@ discard block |
||
1922 | 1922 | // Hide fields depending on admin settings |
1923 | 1923 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1924 | 1924 | |
1925 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1926 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1925 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1926 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1927 | 1927 | |
1928 | 1928 | /** |
1929 | 1929 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -2014,11 +2014,11 @@ discard block |
||
2014 | 2014 | // The edit tab has been configured, so we loop through to configured settings |
2015 | 2015 | foreach ( $configured_fields as $configured_field ) { |
2016 | 2016 | |
2017 | - /** @var GF_Field $field */ |
|
2018 | - foreach ( $fields as $field ) { |
|
2017 | + /** @var GF_Field $field */ |
|
2018 | + foreach ( $fields as $field ) { |
|
2019 | 2019 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
2020 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
2021 | - break; |
|
2020 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
2021 | + break; |
|
2022 | 2022 | } |
2023 | 2023 | |
2024 | 2024 | } |
@@ -2074,28 +2074,28 @@ discard block |
||
2074 | 2074 | */ |
2075 | 2075 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
2076 | 2076 | |
2077 | - /** |
|
2077 | + /** |
|
2078 | 2078 | * @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 |
2079 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
2080 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
2081 | - * @since 1.9.1 |
|
2082 | - * @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. |
|
2083 | - * @param array $form GF Form array |
|
2084 | - * @param int $view_id View ID |
|
2085 | - */ |
|
2086 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
2087 | - |
|
2088 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2079 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
2080 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
2081 | + * @since 1.9.1 |
|
2082 | + * @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. |
|
2083 | + * @param array $form GF Form array |
|
2084 | + * @param int $view_id View ID |
|
2085 | + */ |
|
2086 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
2087 | + |
|
2088 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2089 | 2089 | foreach( $fields as $k => $field ) { |
2090 | 2090 | if( $field->adminOnly ) { |
2091 | - unset( $fields[ $k ] ); |
|
2091 | + unset( $fields[ $k ] ); |
|
2092 | 2092 | } |
2093 | 2093 | } |
2094 | 2094 | return array_values( $fields ); |
2095 | 2095 | } |
2096 | 2096 | |
2097 | - foreach( $fields as &$field ) { |
|
2098 | - $field->adminOnly = false; |
|
2097 | + foreach( $fields as &$field ) { |
|
2098 | + $field->adminOnly = false; |
|
2099 | 2099 | } |
2100 | 2100 | |
2101 | 2101 | return $fields; |
@@ -2115,13 +2115,13 @@ discard block |
||
2115 | 2115 | */ |
2116 | 2116 | private function unselect_default_values( $form ) { |
2117 | 2117 | |
2118 | - foreach ( $form['fields'] as &$field ) { |
|
2118 | + foreach ( $form['fields'] as &$field ) { |
|
2119 | 2119 | |
2120 | 2120 | if ( empty( $field->choices ) ) { |
2121 | - continue; |
|
2121 | + continue; |
|
2122 | 2122 | } |
2123 | 2123 | |
2124 | - foreach ( $field->choices as &$choice ) { |
|
2124 | + foreach ( $field->choices as &$choice ) { |
|
2125 | 2125 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
2126 | 2126 | $choice['isSelected'] = false; |
2127 | 2127 | } |
@@ -2158,36 +2158,36 @@ discard block |
||
2158 | 2158 | |
2159 | 2159 | if( 'checkbox' === $field->type ) { |
2160 | 2160 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
2161 | - $input_id = $input['id']; |
|
2162 | - $choice = $field->choices[ $key ]; |
|
2163 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
2164 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
2165 | - if( $match ) { |
|
2166 | - $field->choices[ $key ]['isSelected'] = true; |
|
2167 | - } |
|
2161 | + $input_id = $input['id']; |
|
2162 | + $choice = $field->choices[ $key ]; |
|
2163 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
2164 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
2165 | + if( $match ) { |
|
2166 | + $field->choices[ $key ]['isSelected'] = true; |
|
2167 | + } |
|
2168 | 2168 | } |
2169 | 2169 | } else { |
2170 | 2170 | |
2171 | 2171 | // We need to run through each field to set the default values |
2172 | 2172 | foreach ( $this->entry as $field_id => $field_value ) { |
2173 | 2173 | |
2174 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2174 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2175 | 2175 | |
2176 | - if( 'list' === $field->type ) { |
|
2177 | - $list_rows = maybe_unserialize( $field_value ); |
|
2176 | + if( 'list' === $field->type ) { |
|
2177 | + $list_rows = maybe_unserialize( $field_value ); |
|
2178 | 2178 | |
2179 | - $list_field_value = array(); |
|
2180 | - foreach ( (array) $list_rows as $row ) { |
|
2181 | - foreach ( (array) $row as $column ) { |
|
2182 | - $list_field_value[] = $column; |
|
2183 | - } |
|
2184 | - } |
|
2179 | + $list_field_value = array(); |
|
2180 | + foreach ( (array) $list_rows as $row ) { |
|
2181 | + foreach ( (array) $row as $column ) { |
|
2182 | + $list_field_value[] = $column; |
|
2183 | + } |
|
2184 | + } |
|
2185 | 2185 | |
2186 | - $field->defaultValue = serialize( $list_field_value ); |
|
2187 | - } else { |
|
2188 | - $field->defaultValue = $field_value; |
|
2189 | - } |
|
2190 | - } |
|
2186 | + $field->defaultValue = serialize( $list_field_value ); |
|
2187 | + } else { |
|
2188 | + $field->defaultValue = $field_value; |
|
2189 | + } |
|
2190 | + } |
|
2191 | 2191 | } |
2192 | 2192 | } |
2193 | 2193 | } |
@@ -2248,7 +2248,7 @@ discard block |
||
2248 | 2248 | foreach ( $form['fields'] as &$field ) { |
2249 | 2249 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2250 | 2250 | |
2251 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2251 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2252 | 2252 | |
2253 | 2253 | if ( $field['id'] == $rule_field_id ) { |
2254 | 2254 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2299,7 +2299,7 @@ discard block |
||
2299 | 2299 | return $has_conditional_logic; |
2300 | 2300 | } |
2301 | 2301 | |
2302 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2302 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2303 | 2303 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
2304 | 2304 | } |
2305 | 2305 | |
@@ -2366,14 +2366,14 @@ discard block |
||
2366 | 2366 | |
2367 | 2367 | if( $echo && $error !== true ) { |
2368 | 2368 | |
2369 | - $error = esc_html( $error ); |
|
2369 | + $error = esc_html( $error ); |
|
2370 | 2370 | |
2371 | - /** |
|
2372 | - * @since 1.9 |
|
2373 | - */ |
|
2374 | - if ( ! empty( $this->entry ) ) { |
|
2375 | - $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;" ) ); |
|
2376 | - } |
|
2371 | + /** |
|
2372 | + * @since 1.9 |
|
2373 | + */ |
|
2374 | + if ( ! empty( $this->entry ) ) { |
|
2375 | + $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;" ) ); |
|
2376 | + } |
|
2377 | 2377 | |
2378 | 2378 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
2379 | 2379 | } |