@@ -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 | - * |
|
108 | - * @var int |
|
105 | + * |
|
106 | + * @since 2.0.13 |
|
107 | + * |
|
108 | + * @var int |
|
109 | 109 | */ |
110 | 110 | public $post_id; |
111 | 111 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function prevent_maybe_process_form() { |
190 | 190 | |
191 | - if( ! $this->is_edit_entry_submission() ) { |
|
191 | + if( ! $this->is_edit_entry_submission() ) { |
|
192 | 192 | return; |
193 | 193 | } |
194 | 194 | |
@@ -222,14 +222,14 @@ discard block |
||
222 | 222 | * When Edit entry view is requested setup the vars |
223 | 223 | */ |
224 | 224 | private function setup_vars() { |
225 | - global $post; |
|
225 | + global $post; |
|
226 | 226 | |
227 | 227 | $gravityview_view = GravityView_View::getInstance(); |
228 | 228 | |
229 | 229 | |
230 | 230 | $entries = $gravityview_view->getEntries(); |
231 | - self::$original_entry = $entries[0]; |
|
232 | - $this->entry = $entries[0]; |
|
231 | + self::$original_entry = $entries[0]; |
|
232 | + $this->entry = $entries[0]; |
|
233 | 233 | |
234 | 234 | self::$original_form = $gravityview_view->getForm(); |
235 | 235 | $this->form = $gravityview_view->getForm(); |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | |
372 | 372 | GFFormsModel::save_lead( $form, $this->entry ); |
373 | 373 | |
374 | - // Delete the values for hidden inputs |
|
375 | - $this->unset_hidden_field_values(); |
|
374 | + // Delete the values for hidden inputs |
|
375 | + $this->unset_hidden_field_values(); |
|
376 | 376 | |
377 | 377 | $this->entry['date_created'] = $date_created; |
378 | 378 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | // Perform actions normally performed after updating a lead |
383 | 383 | $this->after_update(); |
384 | 384 | |
385 | - /** |
|
385 | + /** |
|
386 | 386 | * Must be AFTER after_update()! |
387 | 387 | * @see https://github.com/gravityview/GravityView/issues/764 |
388 | 388 | */ |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | |
391 | 391 | /** |
392 | 392 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
393 | - * @since 2.1 Added $gv_data parameter |
|
393 | + * @since 2.1 Added $gv_data parameter |
|
394 | 394 | * @param array $form Gravity Forms form array |
395 | 395 | * @param string $entry_id Numeric ID of the entry that was updated |
396 | 396 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | * @return void |
415 | 415 | */ |
416 | 416 | private function unset_hidden_field_values() { |
417 | - global $wpdb; |
|
417 | + global $wpdb; |
|
418 | 418 | |
419 | 419 | /** |
420 | 420 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -438,17 +438,17 @@ discard block |
||
438 | 438 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
439 | 439 | } |
440 | 440 | |
441 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
441 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
442 | 442 | |
443 | 443 | if ( ! is_numeric( $input_id ) ) { |
444 | 444 | continue; |
445 | 445 | } |
446 | 446 | |
447 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
447 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
448 | 448 | |
449 | - // Reset fields that are hidden |
|
450 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
451 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
449 | + // Reset fields that are hidden |
|
450 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
451 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
452 | 452 | |
453 | 453 | $empty_value = $field->get_value_save_entry( |
454 | 454 | is_array( $field->get_entry_inputs() ) ? array() : '', |
@@ -460,16 +460,16 @@ discard block |
||
460 | 460 | $empty_value = ''; |
461 | 461 | } |
462 | 462 | |
463 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
463 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
464 | 464 | |
465 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
465 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
466 | 466 | |
467 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
467 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
468 | 468 | // after submission |
469 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
470 | - $_POST[ $post_input_id ] = ''; |
|
471 | - } |
|
472 | - } |
|
469 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
470 | + $_POST[ $post_input_id ] = ''; |
|
471 | + } |
|
472 | + } |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | |
564 | 564 | $form = $this->filter_conditional_logic( $this->form ); |
565 | 565 | |
566 | - /** @var GF_Field $field */ |
|
566 | + /** @var GF_Field $field */ |
|
567 | 567 | foreach( $form['fields'] as $k => &$field ) { |
568 | 568 | |
569 | 569 | /** |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | |
580 | 580 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
581 | 581 | foreach( $field->inputs as $key => $input ) { |
582 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
582 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
583 | 583 | } |
584 | 584 | } |
585 | 585 | } |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | |
620 | 620 | $inputs = $field->get_entry_inputs(); |
621 | 621 | if ( is_array( $inputs ) ) { |
622 | - foreach ( $inputs as $input ) { |
|
622 | + foreach ( $inputs as $input ) { |
|
623 | 623 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
624 | 624 | |
625 | 625 | if ( 'product' === $field->type ) { |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | } |
639 | 639 | |
640 | 640 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
641 | - } |
|
641 | + } |
|
642 | 642 | } else { |
643 | 643 | // Set to what it previously was if it's not editable |
644 | 644 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
685 | 685 | |
686 | 686 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
687 | - $ary = stripslashes_deep( $ary ); |
|
687 | + $ary = stripslashes_deep( $ary ); |
|
688 | 688 | $img_url = \GV\Utils::get( $ary, 0 ); |
689 | 689 | |
690 | 690 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | private function maybe_update_post_fields( $form ) { |
758 | 758 | |
759 | 759 | if( empty( $this->entry['post_id'] ) ) { |
760 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
760 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
761 | 761 | return; |
762 | 762 | } |
763 | 763 | |
@@ -792,49 +792,49 @@ discard block |
||
792 | 792 | |
793 | 793 | switch( $field->type ) { |
794 | 794 | |
795 | - case 'post_title': |
|
796 | - $post_title = $value; |
|
797 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
798 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
799 | - } |
|
800 | - $updated_post->post_title = $post_title; |
|
801 | - $updated_post->post_name = $post_title; |
|
802 | - unset( $post_title ); |
|
803 | - break; |
|
804 | - |
|
805 | - case 'post_content': |
|
806 | - $post_content = $value; |
|
807 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
808 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
809 | - } |
|
810 | - $updated_post->post_content = $post_content; |
|
811 | - unset( $post_content ); |
|
812 | - break; |
|
813 | - case 'post_excerpt': |
|
814 | - $updated_post->post_excerpt = $value; |
|
815 | - break; |
|
816 | - case 'post_tags': |
|
817 | - wp_set_post_tags( $post_id, $value, false ); |
|
818 | - break; |
|
819 | - case 'post_category': |
|
820 | - break; |
|
821 | - case 'post_custom_field': |
|
795 | + case 'post_title': |
|
796 | + $post_title = $value; |
|
797 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
798 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
799 | + } |
|
800 | + $updated_post->post_title = $post_title; |
|
801 | + $updated_post->post_name = $post_title; |
|
802 | + unset( $post_title ); |
|
803 | + break; |
|
804 | + |
|
805 | + case 'post_content': |
|
806 | + $post_content = $value; |
|
807 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
808 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
809 | + } |
|
810 | + $updated_post->post_content = $post_content; |
|
811 | + unset( $post_content ); |
|
812 | + break; |
|
813 | + case 'post_excerpt': |
|
814 | + $updated_post->post_excerpt = $value; |
|
815 | + break; |
|
816 | + case 'post_tags': |
|
817 | + wp_set_post_tags( $post_id, $value, false ); |
|
818 | + break; |
|
819 | + case 'post_category': |
|
820 | + break; |
|
821 | + case 'post_custom_field': |
|
822 | 822 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
823 | 823 | $value = $value[ $field_id ]; |
824 | 824 | } |
825 | 825 | |
826 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
827 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
828 | - } |
|
826 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
827 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
828 | + } |
|
829 | 829 | |
830 | 830 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
831 | 831 | |
832 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
833 | - break; |
|
832 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
833 | + break; |
|
834 | 834 | |
835 | - case 'post_image': |
|
836 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
837 | - break; |
|
835 | + case 'post_image': |
|
836 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
837 | + break; |
|
838 | 838 | |
839 | 839 | } |
840 | 840 | |
@@ -991,14 +991,14 @@ discard block |
||
991 | 991 | ?><h2 class="gv-edit-entry-title"> |
992 | 992 | <span><?php |
993 | 993 | |
994 | - /** |
|
995 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
996 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
997 | - * @param GravityView_Edit_Entry_Render $this This object |
|
998 | - */ |
|
999 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
994 | + /** |
|
995 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
996 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
997 | + * @param GravityView_Edit_Entry_Render $this This object |
|
998 | + */ |
|
999 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1000 | 1000 | |
1001 | - echo esc_attr( $edit_entry_title ); |
|
1001 | + echo esc_attr( $edit_entry_title ); |
|
1002 | 1002 | ?></span> |
1003 | 1003 | </h2> |
1004 | 1004 | |
@@ -1053,13 +1053,13 @@ discard block |
||
1053 | 1053 | ); |
1054 | 1054 | |
1055 | 1055 | /** |
1056 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1057 | - * @since 1.16.3 |
|
1058 | - * @param array $labels Default button labels associative array |
|
1059 | - * @param array $form The Gravity Forms form |
|
1060 | - * @param array $entry The Gravity Forms entry |
|
1061 | - * @param int $view_id The current View ID |
|
1062 | - */ |
|
1056 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1057 | + * @since 1.16.3 |
|
1058 | + * @param array $labels Default button labels associative array |
|
1059 | + * @param array $form The Gravity Forms form |
|
1060 | + * @param array $entry The Gravity Forms entry |
|
1061 | + * @param int $view_id The current View ID |
|
1062 | + */ |
|
1063 | 1063 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1064 | 1064 | |
1065 | 1065 | $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
@@ -1096,26 +1096,26 @@ discard block |
||
1096 | 1096 | |
1097 | 1097 | switch ( $edit_redirect ) { |
1098 | 1098 | |
1099 | - case '0': |
|
1100 | - $redirect_url = $back_link; |
|
1101 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1102 | - break; |
|
1103 | - |
|
1104 | - case '1': |
|
1105 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1106 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1107 | - break; |
|
1108 | - |
|
1109 | - case '2': |
|
1110 | - $redirect_url = $edit_redirect_url; |
|
1111 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1112 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1113 | - break; |
|
1114 | - |
|
1115 | - case '': |
|
1116 | - default: |
|
1117 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1118 | - break; |
|
1099 | + case '0': |
|
1100 | + $redirect_url = $back_link; |
|
1101 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1102 | + break; |
|
1103 | + |
|
1104 | + case '1': |
|
1105 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1106 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1107 | + break; |
|
1108 | + |
|
1109 | + case '2': |
|
1110 | + $redirect_url = $edit_redirect_url; |
|
1111 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1112 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1113 | + break; |
|
1114 | + |
|
1115 | + case '': |
|
1116 | + default: |
|
1117 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1118 | + break; |
|
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | if ( isset( $redirect_url ) ) { |
@@ -1181,13 +1181,13 @@ discard block |
||
1181 | 1181 | ); |
1182 | 1182 | |
1183 | 1183 | /** |
1184 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1185 | - * @since 1.16.3 |
|
1186 | - * @param array $labels Default button labels associative array |
|
1187 | - * @param array $form The Gravity Forms form |
|
1188 | - * @param array $entry The Gravity Forms entry |
|
1189 | - * @param int $view_id The current View ID |
|
1190 | - */ |
|
1184 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1185 | + * @since 1.16.3 |
|
1186 | + * @param array $labels Default button labels associative array |
|
1187 | + * @param array $form The Gravity Forms form |
|
1188 | + * @param array $entry The Gravity Forms entry |
|
1189 | + * @param int $view_id The current View ID |
|
1190 | + */ |
|
1191 | 1191 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1192 | 1192 | |
1193 | 1193 | GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | |
1230 | 1230 | ob_get_clean(); |
1231 | 1231 | |
1232 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1232 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1233 | 1233 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1234 | 1234 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
1235 | 1235 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1285,7 +1285,7 @@ discard block |
||
1285 | 1285 | |
1286 | 1286 | // for now we don't support Save and Continue feature. |
1287 | 1287 | if( ! self::$supports_save_and_continue ) { |
1288 | - unset( $form['save'] ); |
|
1288 | + unset( $form['save'] ); |
|
1289 | 1289 | } |
1290 | 1290 | |
1291 | 1291 | $form = $this->unselect_default_values( $form ); |
@@ -1312,30 +1312,30 @@ discard block |
||
1312 | 1312 | return $field_content; |
1313 | 1313 | } |
1314 | 1314 | |
1315 | - $message = null; |
|
1315 | + $message = null; |
|
1316 | 1316 | |
1317 | - // First, make sure they have the capability to edit the post. |
|
1318 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1317 | + // First, make sure they have the capability to edit the post. |
|
1318 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1319 | 1319 | |
1320 | - /** |
|
1321 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1322 | - * @param string $message The existing "You don't have permission..." text |
|
1323 | - */ |
|
1324 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1320 | + /** |
|
1321 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1322 | + * @param string $message The existing "You don't have permission..." text |
|
1323 | + */ |
|
1324 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1325 | 1325 | |
1326 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1327 | - /** |
|
1328 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1329 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1330 | - */ |
|
1331 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1332 | - } |
|
1326 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1327 | + /** |
|
1328 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1329 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1330 | + */ |
|
1331 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1332 | + } |
|
1333 | 1333 | |
1334 | - if( $message ) { |
|
1335 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1336 | - } |
|
1334 | + if( $message ) { |
|
1335 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1336 | + } |
|
1337 | 1337 | |
1338 | - return $field_content; |
|
1338 | + return $field_content; |
|
1339 | 1339 | } |
1340 | 1340 | |
1341 | 1341 | /** |
@@ -1363,7 +1363,7 @@ discard block |
||
1363 | 1363 | || ! empty( $field_content ) |
1364 | 1364 | || in_array( $field->type, array( 'honeypot' ) ) |
1365 | 1365 | ) { |
1366 | - return $field_content; |
|
1366 | + return $field_content; |
|
1367 | 1367 | } |
1368 | 1368 | |
1369 | 1369 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1371,24 +1371,24 @@ discard block |
||
1371 | 1371 | |
1372 | 1372 | $field_value = $this->get_field_value( $field ); |
1373 | 1373 | |
1374 | - // Prevent any PHP warnings, like undefined index |
|
1375 | - ob_start(); |
|
1374 | + // Prevent any PHP warnings, like undefined index |
|
1375 | + ob_start(); |
|
1376 | 1376 | |
1377 | - $return = null; |
|
1377 | + $return = null; |
|
1378 | 1378 | |
1379 | 1379 | /** @var GravityView_Field $gv_field */ |
1380 | 1380 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1381 | 1381 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1382 | 1382 | } else { |
1383 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1384 | - } |
|
1383 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1384 | + } |
|
1385 | 1385 | |
1386 | - // If there was output, it's an error |
|
1387 | - $warnings = ob_get_clean(); |
|
1386 | + // If there was output, it's an error |
|
1387 | + $warnings = ob_get_clean(); |
|
1388 | 1388 | |
1389 | - if( !empty( $warnings ) ) { |
|
1390 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1391 | - } |
|
1389 | + if( !empty( $warnings ) ) { |
|
1390 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1391 | + } |
|
1392 | 1392 | |
1393 | 1393 | return $return; |
1394 | 1394 | } |
@@ -1423,8 +1423,8 @@ discard block |
||
1423 | 1423 | $input_id = strval( $input['id'] ); |
1424 | 1424 | |
1425 | 1425 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1426 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1427 | - $allow_pre_populated = false; |
|
1426 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1427 | + $allow_pre_populated = false; |
|
1428 | 1428 | } |
1429 | 1429 | |
1430 | 1430 | } |
@@ -1448,7 +1448,7 @@ discard block |
||
1448 | 1448 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1449 | 1449 | $categories = array(); |
1450 | 1450 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1451 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1451 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1452 | 1452 | } |
1453 | 1453 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1454 | 1454 | } |
@@ -1458,25 +1458,25 @@ discard block |
||
1458 | 1458 | // if value is empty get the default value if defined |
1459 | 1459 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1460 | 1460 | |
1461 | - /** |
|
1462 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1463 | - * @since 1.11 |
|
1464 | - * @since 1.20 Added third param |
|
1465 | - * @param mixed $field_value field value used to populate the input |
|
1466 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1467 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1468 | - */ |
|
1469 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1470 | - |
|
1471 | - /** |
|
1472 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1473 | - * @since 1.17 |
|
1474 | - * @since 1.20 Added third param |
|
1475 | - * @param mixed $field_value field value used to populate the input |
|
1476 | - * @param GF_Field $field Gravity Forms field object |
|
1477 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1478 | - */ |
|
1479 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1461 | + /** |
|
1462 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1463 | + * @since 1.11 |
|
1464 | + * @since 1.20 Added third param |
|
1465 | + * @param mixed $field_value field value used to populate the input |
|
1466 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1467 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1468 | + */ |
|
1469 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1470 | + |
|
1471 | + /** |
|
1472 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1473 | + * @since 1.17 |
|
1474 | + * @since 1.20 Added third param |
|
1475 | + * @param mixed $field_value field value used to populate the input |
|
1476 | + * @param GF_Field $field Gravity Forms field object |
|
1477 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1478 | + */ |
|
1479 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1480 | 1480 | |
1481 | 1481 | return $field_value; |
1482 | 1482 | } |
@@ -1503,7 +1503,7 @@ discard block |
||
1503 | 1503 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1504 | 1504 | // expects certain field array items to be set. |
1505 | 1505 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1506 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1506 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1507 | 1507 | } |
1508 | 1508 | |
1509 | 1509 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1517,61 +1517,61 @@ discard block |
||
1517 | 1517 | */ |
1518 | 1518 | case 'fileupload': |
1519 | 1519 | |
1520 | - // Set the previous value |
|
1521 | - $entry = $this->get_entry(); |
|
1520 | + // Set the previous value |
|
1521 | + $entry = $this->get_entry(); |
|
1522 | 1522 | |
1523 | - $input_name = 'input_'.$field->id; |
|
1524 | - $form_id = $form['id']; |
|
1523 | + $input_name = 'input_'.$field->id; |
|
1524 | + $form_id = $form['id']; |
|
1525 | 1525 | |
1526 | - $value = NULL; |
|
1526 | + $value = NULL; |
|
1527 | 1527 | |
1528 | - // Use the previous entry value as the default. |
|
1529 | - if( isset( $entry[ $field->id ] ) ) { |
|
1530 | - $value = $entry[ $field->id ]; |
|
1531 | - } |
|
1528 | + // Use the previous entry value as the default. |
|
1529 | + if( isset( $entry[ $field->id ] ) ) { |
|
1530 | + $value = $entry[ $field->id ]; |
|
1531 | + } |
|
1532 | 1532 | |
1533 | - // If this is a single upload file |
|
1534 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1535 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1536 | - $value = $file_path['url']; |
|
1533 | + // If this is a single upload file |
|
1534 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1535 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1536 | + $value = $file_path['url']; |
|
1537 | 1537 | |
1538 | - } else { |
|
1538 | + } else { |
|
1539 | 1539 | |
1540 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1541 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1542 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1540 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1541 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1542 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1543 | 1543 | |
1544 | - } |
|
1544 | + } |
|
1545 | 1545 | |
1546 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1546 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1547 | 1547 | |
1548 | - // If there are fresh uploads, process and merge them. |
|
1549 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1550 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1551 | - $value = empty( $value ) ? '[]' : $value; |
|
1552 | - $value = stripslashes_deep( $value ); |
|
1553 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1554 | - } |
|
1548 | + // If there are fresh uploads, process and merge them. |
|
1549 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1550 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1551 | + $value = empty( $value ) ? '[]' : $value; |
|
1552 | + $value = stripslashes_deep( $value ); |
|
1553 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1554 | + } |
|
1555 | 1555 | |
1556 | - } else { |
|
1556 | + } else { |
|
1557 | 1557 | |
1558 | - // A file already exists when editing an entry |
|
1559 | - // We set this to solve issue when file upload fields are required. |
|
1560 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1558 | + // A file already exists when editing an entry |
|
1559 | + // We set this to solve issue when file upload fields are required. |
|
1560 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1561 | 1561 | |
1562 | - } |
|
1562 | + } |
|
1563 | 1563 | |
1564 | - $this->entry[ $input_name ] = $value; |
|
1565 | - $_POST[ $input_name ] = $value; |
|
1564 | + $this->entry[ $input_name ] = $value; |
|
1565 | + $_POST[ $input_name ] = $value; |
|
1566 | 1566 | |
1567 | - break; |
|
1567 | + break; |
|
1568 | 1568 | |
1569 | 1569 | case 'number': |
1570 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1571 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1572 | - $_POST['input_'.$field->id ] = NULL; |
|
1573 | - } |
|
1574 | - break; |
|
1570 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1571 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1572 | + $_POST['input_'.$field->id ] = NULL; |
|
1573 | + } |
|
1574 | + break; |
|
1575 | 1575 | } |
1576 | 1576 | |
1577 | 1577 | } |
@@ -1656,43 +1656,43 @@ discard block |
||
1656 | 1656 | case 'fileupload' : |
1657 | 1657 | case 'post_image': |
1658 | 1658 | |
1659 | - // in case nothing is uploaded but there are already files saved |
|
1660 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1661 | - $field->failed_validation = false; |
|
1662 | - unset( $field->validation_message ); |
|
1663 | - } |
|
1659 | + // in case nothing is uploaded but there are already files saved |
|
1660 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1661 | + $field->failed_validation = false; |
|
1662 | + unset( $field->validation_message ); |
|
1663 | + } |
|
1664 | 1664 | |
1665 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1666 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1665 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1666 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1667 | 1667 | |
1668 | - $input_name = 'input_' . $field->id; |
|
1669 | - //uploaded |
|
1670 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1668 | + $input_name = 'input_' . $field->id; |
|
1669 | + //uploaded |
|
1670 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1671 | 1671 | |
1672 | - //existent |
|
1673 | - $entry = $this->get_entry(); |
|
1674 | - $value = NULL; |
|
1675 | - if( isset( $entry[ $field->id ] ) ) { |
|
1676 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1677 | - } |
|
1672 | + //existent |
|
1673 | + $entry = $this->get_entry(); |
|
1674 | + $value = NULL; |
|
1675 | + if( isset( $entry[ $field->id ] ) ) { |
|
1676 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1677 | + } |
|
1678 | 1678 | |
1679 | - // count uploaded files and existent entry files |
|
1680 | - $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1681 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
1679 | + // count uploaded files and existent entry files |
|
1680 | + $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1681 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
1682 | 1682 | |
1683 | - if( $count_files > $field->maxFiles ) { |
|
1684 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1685 | - $field->failed_validation = 1; |
|
1686 | - $gv_valid = false; |
|
1683 | + if( $count_files > $field->maxFiles ) { |
|
1684 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1685 | + $field->failed_validation = 1; |
|
1686 | + $gv_valid = false; |
|
1687 | 1687 | |
1688 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1689 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1690 | - } |
|
1688 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1689 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1690 | + } |
|
1691 | 1691 | |
1692 | - } |
|
1692 | + } |
|
1693 | 1693 | |
1694 | 1694 | |
1695 | - break; |
|
1695 | + break; |
|
1696 | 1696 | |
1697 | 1697 | } |
1698 | 1698 | |
@@ -1703,47 +1703,47 @@ discard block |
||
1703 | 1703 | |
1704 | 1704 | switch ( $field_type ) { |
1705 | 1705 | |
1706 | - // Captchas don't need to be re-entered. |
|
1707 | - case 'captcha': |
|
1706 | + // Captchas don't need to be re-entered. |
|
1707 | + case 'captcha': |
|
1708 | 1708 | |
1709 | - // Post Image fields aren't editable, so we un-fail them. |
|
1710 | - case 'post_image': |
|
1711 | - $field->failed_validation = false; |
|
1712 | - unset( $field->validation_message ); |
|
1713 | - break; |
|
1709 | + // Post Image fields aren't editable, so we un-fail them. |
|
1710 | + case 'post_image': |
|
1711 | + $field->failed_validation = false; |
|
1712 | + unset( $field->validation_message ); |
|
1713 | + break; |
|
1714 | 1714 | |
1715 | 1715 | } |
1716 | 1716 | |
1717 | 1717 | // You can't continue inside a switch, so we do it after. |
1718 | 1718 | if( empty( $field->failed_validation ) ) { |
1719 | - continue; |
|
1719 | + continue; |
|
1720 | 1720 | } |
1721 | 1721 | |
1722 | 1722 | // checks if the No Duplicates option is not validating entry against itself, since |
1723 | 1723 | // we're editing a stored entry, it would also assume it's a duplicate. |
1724 | 1724 | if( !empty( $field->noDuplicates ) ) { |
1725 | 1725 | |
1726 | - $entry = $this->get_entry(); |
|
1726 | + $entry = $this->get_entry(); |
|
1727 | 1727 | |
1728 | - // If the value of the entry is the same as the stored value |
|
1729 | - // Then we can assume it's not a duplicate, it's the same. |
|
1730 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1731 | - //if value submitted was not changed, then don't validate |
|
1732 | - $field->failed_validation = false; |
|
1728 | + // If the value of the entry is the same as the stored value |
|
1729 | + // Then we can assume it's not a duplicate, it's the same. |
|
1730 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1731 | + //if value submitted was not changed, then don't validate |
|
1732 | + $field->failed_validation = false; |
|
1733 | 1733 | |
1734 | - unset( $field->validation_message ); |
|
1734 | + unset( $field->validation_message ); |
|
1735 | 1735 | |
1736 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1736 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1737 | 1737 | |
1738 | - continue; |
|
1739 | - } |
|
1738 | + continue; |
|
1739 | + } |
|
1740 | 1740 | } |
1741 | 1741 | |
1742 | 1742 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1743 | 1743 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1744 | - unset( $field->validation_message ); |
|
1745 | - $field->validation_message = false; |
|
1746 | - continue; |
|
1744 | + unset( $field->validation_message ); |
|
1745 | + $field->validation_message = false; |
|
1746 | + continue; |
|
1747 | 1747 | } |
1748 | 1748 | |
1749 | 1749 | $gv_valid = false; |
@@ -1807,8 +1807,8 @@ discard block |
||
1807 | 1807 | // Hide fields depending on admin settings |
1808 | 1808 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1809 | 1809 | |
1810 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1811 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1810 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1811 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1812 | 1812 | |
1813 | 1813 | /** |
1814 | 1814 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1887,11 +1887,11 @@ discard block |
||
1887 | 1887 | // The edit tab has been configured, so we loop through to configured settings |
1888 | 1888 | foreach ( $configured_fields as $configured_field ) { |
1889 | 1889 | |
1890 | - /** @var GF_Field $field */ |
|
1891 | - foreach ( $fields as $field ) { |
|
1890 | + /** @var GF_Field $field */ |
|
1891 | + foreach ( $fields as $field ) { |
|
1892 | 1892 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
1893 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1894 | - break; |
|
1893 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1894 | + break; |
|
1895 | 1895 | } |
1896 | 1896 | |
1897 | 1897 | } |
@@ -1947,28 +1947,28 @@ discard block |
||
1947 | 1947 | */ |
1948 | 1948 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
1949 | 1949 | |
1950 | - /** |
|
1950 | + /** |
|
1951 | 1951 | * @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 |
1952 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1953 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1954 | - * @since 1.9.1 |
|
1955 | - * @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. |
|
1956 | - * @param array $form GF Form array |
|
1957 | - * @param int $view_id View ID |
|
1958 | - */ |
|
1959 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1960 | - |
|
1961 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1952 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1953 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1954 | + * @since 1.9.1 |
|
1955 | + * @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. |
|
1956 | + * @param array $form GF Form array |
|
1957 | + * @param int $view_id View ID |
|
1958 | + */ |
|
1959 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1960 | + |
|
1961 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1962 | 1962 | foreach( $fields as $k => $field ) { |
1963 | 1963 | if( $field->adminOnly ) { |
1964 | - unset( $fields[ $k ] ); |
|
1964 | + unset( $fields[ $k ] ); |
|
1965 | 1965 | } |
1966 | 1966 | } |
1967 | 1967 | return array_values( $fields ); |
1968 | 1968 | } |
1969 | 1969 | |
1970 | - foreach( $fields as &$field ) { |
|
1971 | - $field->adminOnly = false; |
|
1970 | + foreach( $fields as &$field ) { |
|
1971 | + $field->adminOnly = false; |
|
1972 | 1972 | } |
1973 | 1973 | |
1974 | 1974 | return $fields; |
@@ -1988,13 +1988,13 @@ discard block |
||
1988 | 1988 | */ |
1989 | 1989 | private function unselect_default_values( $form ) { |
1990 | 1990 | |
1991 | - foreach ( $form['fields'] as &$field ) { |
|
1991 | + foreach ( $form['fields'] as &$field ) { |
|
1992 | 1992 | |
1993 | 1993 | if ( empty( $field->choices ) ) { |
1994 | - continue; |
|
1994 | + continue; |
|
1995 | 1995 | } |
1996 | 1996 | |
1997 | - foreach ( $field->choices as &$choice ) { |
|
1997 | + foreach ( $field->choices as &$choice ) { |
|
1998 | 1998 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
1999 | 1999 | $choice['isSelected'] = false; |
2000 | 2000 | } |
@@ -2031,36 +2031,36 @@ discard block |
||
2031 | 2031 | |
2032 | 2032 | if( 'checkbox' === $field->type ) { |
2033 | 2033 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
2034 | - $input_id = $input['id']; |
|
2035 | - $choice = $field->choices[ $key ]; |
|
2036 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
2037 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
2038 | - if( $match ) { |
|
2039 | - $field->choices[ $key ]['isSelected'] = true; |
|
2040 | - } |
|
2034 | + $input_id = $input['id']; |
|
2035 | + $choice = $field->choices[ $key ]; |
|
2036 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
2037 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
2038 | + if( $match ) { |
|
2039 | + $field->choices[ $key ]['isSelected'] = true; |
|
2040 | + } |
|
2041 | 2041 | } |
2042 | 2042 | } else { |
2043 | 2043 | |
2044 | 2044 | // We need to run through each field to set the default values |
2045 | 2045 | foreach ( $this->entry as $field_id => $field_value ) { |
2046 | 2046 | |
2047 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2047 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2048 | 2048 | |
2049 | - if( 'list' === $field->type ) { |
|
2050 | - $list_rows = maybe_unserialize( $field_value ); |
|
2049 | + if( 'list' === $field->type ) { |
|
2050 | + $list_rows = maybe_unserialize( $field_value ); |
|
2051 | 2051 | |
2052 | - $list_field_value = array(); |
|
2053 | - foreach ( (array) $list_rows as $row ) { |
|
2054 | - foreach ( (array) $row as $column ) { |
|
2055 | - $list_field_value[] = $column; |
|
2056 | - } |
|
2057 | - } |
|
2052 | + $list_field_value = array(); |
|
2053 | + foreach ( (array) $list_rows as $row ) { |
|
2054 | + foreach ( (array) $row as $column ) { |
|
2055 | + $list_field_value[] = $column; |
|
2056 | + } |
|
2057 | + } |
|
2058 | 2058 | |
2059 | - $field->defaultValue = serialize( $list_field_value ); |
|
2060 | - } else { |
|
2061 | - $field->defaultValue = $field_value; |
|
2062 | - } |
|
2063 | - } |
|
2059 | + $field->defaultValue = serialize( $list_field_value ); |
|
2060 | + } else { |
|
2061 | + $field->defaultValue = $field_value; |
|
2062 | + } |
|
2063 | + } |
|
2064 | 2064 | } |
2065 | 2065 | } |
2066 | 2066 | } |
@@ -2121,7 +2121,7 @@ discard block |
||
2121 | 2121 | foreach ( $form['fields'] as &$field ) { |
2122 | 2122 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2123 | 2123 | |
2124 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2124 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2125 | 2125 | |
2126 | 2126 | if ( $field['id'] == $rule_field_id ) { |
2127 | 2127 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2172,7 +2172,7 @@ discard block |
||
2172 | 2172 | return $has_conditional_logic; |
2173 | 2173 | } |
2174 | 2174 | |
2175 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2175 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2176 | 2176 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
2177 | 2177 | } |
2178 | 2178 | |
@@ -2239,14 +2239,14 @@ discard block |
||
2239 | 2239 | |
2240 | 2240 | if( $echo && $error !== true ) { |
2241 | 2241 | |
2242 | - $error = esc_html( $error ); |
|
2242 | + $error = esc_html( $error ); |
|
2243 | 2243 | |
2244 | - /** |
|
2245 | - * @since 1.9 |
|
2246 | - */ |
|
2247 | - if ( ! empty( $this->entry ) ) { |
|
2248 | - $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;" ) ); |
|
2249 | - } |
|
2244 | + /** |
|
2245 | + * @since 1.9 |
|
2246 | + */ |
|
2247 | + if ( ! empty( $this->entry ) ) { |
|
2248 | + $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;" ) ); |
|
2249 | + } |
|
2250 | 2250 | |
2251 | 2251 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
2252 | 2252 | } |