@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | |
95 | 95 | /** |
96 | 96 | * ID of the current post. May also be ID of the current View. |
97 | - * |
|
98 | - * @since 2.0.13 |
|
99 | - * |
|
100 | - * @var int |
|
97 | + * |
|
98 | + * @since 2.0.13 |
|
99 | + * |
|
100 | + * @var int |
|
101 | 101 | */ |
102 | 102 | public $post_id; |
103 | 103 | |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | public function prevent_maybe_process_form() { |
170 | 170 | |
171 | 171 | if( ! empty( $_POST ) ) { |
172 | - gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
172 | + gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | if( $this->is_edit_entry_submission() ) { |
176 | 176 | remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -202,14 +202,14 @@ discard block |
||
202 | 202 | * When Edit entry view is requested setup the vars |
203 | 203 | */ |
204 | 204 | private function setup_vars() { |
205 | - global $post; |
|
205 | + global $post; |
|
206 | 206 | |
207 | 207 | $gravityview_view = GravityView_View::getInstance(); |
208 | 208 | |
209 | 209 | |
210 | 210 | $entries = $gravityview_view->getEntries(); |
211 | - self::$original_entry = $entries[0]; |
|
212 | - $this->entry = $entries[0]; |
|
211 | + self::$original_entry = $entries[0]; |
|
212 | + $this->entry = $entries[0]; |
|
213 | 213 | |
214 | 214 | self::$original_form = $gravityview_view->getForm(); |
215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | |
334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
335 | 335 | |
336 | - // Delete the values for hidden inputs |
|
337 | - $this->unset_hidden_field_values(); |
|
336 | + // Delete the values for hidden inputs |
|
337 | + $this->unset_hidden_field_values(); |
|
338 | 338 | |
339 | 339 | $this->entry['date_created'] = $date_created; |
340 | 340 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | // Perform actions normally performed after updating a lead |
345 | 345 | $this->after_update(); |
346 | 346 | |
347 | - /** |
|
347 | + /** |
|
348 | 348 | * Must be AFTER after_update()! |
349 | 349 | * @see https://github.com/gravityview/GravityView/issues/764 |
350 | 350 | */ |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | /** |
354 | 354 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
355 | - * @since 2.1 Added $gv_data parameter |
|
355 | + * @since 2.1 Added $gv_data parameter |
|
356 | 356 | * @param array $form Gravity Forms form array |
357 | 357 | * @param string $entry_id Numeric ID of the entry that was updated |
358 | 358 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | * @return void |
377 | 377 | */ |
378 | 378 | private function unset_hidden_field_values() { |
379 | - global $wpdb; |
|
379 | + global $wpdb; |
|
380 | 380 | |
381 | 381 | /** |
382 | 382 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -398,29 +398,29 @@ discard block |
||
398 | 398 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
399 | 399 | } |
400 | 400 | |
401 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
401 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
402 | 402 | |
403 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
403 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
404 | 404 | |
405 | - // Reset fields that are hidden |
|
406 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
407 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
405 | + // Reset fields that are hidden |
|
406 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
407 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
408 | 408 | |
409 | 409 | $empty_value = $field->get_value_save_entry( |
410 | 410 | is_array( $field->get_entry_inputs() ) ? array() : '', |
411 | 411 | $this->form, '', $this->entry['id'], $this->entry |
412 | 412 | ); |
413 | 413 | |
414 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
414 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
415 | 415 | |
416 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
416 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
417 | 417 | |
418 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
418 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
419 | 419 | // after submission |
420 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
421 | - $_POST[ $post_input_id ] = ''; |
|
422 | - } |
|
423 | - } |
|
420 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
421 | + $_POST[ $post_input_id ] = ''; |
|
422 | + } |
|
423 | + } |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | |
515 | 515 | $form = $this->form; |
516 | 516 | |
517 | - /** @var GF_Field $field */ |
|
517 | + /** @var GF_Field $field */ |
|
518 | 518 | foreach( $form['fields'] as $k => &$field ) { |
519 | 519 | |
520 | 520 | /** |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | |
531 | 531 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
532 | 532 | foreach( $field->inputs as $key => $input ) { |
533 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
533 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
534 | 534 | } |
535 | 535 | } |
536 | 536 | } |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | foreach ( $this->fields_with_calculation as $field ) { |
564 | 564 | $inputs = $field->get_entry_inputs(); |
565 | 565 | if ( is_array( $inputs ) ) { |
566 | - foreach ( $inputs as $input ) { |
|
566 | + foreach ( $inputs as $input ) { |
|
567 | 567 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
568 | - } |
|
568 | + } |
|
569 | 569 | } else { |
570 | 570 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $field->id ); |
571 | 571 | } |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
608 | 608 | |
609 | 609 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
610 | - $ary = stripslashes_deep( $ary ); |
|
610 | + $ary = stripslashes_deep( $ary ); |
|
611 | 611 | $img_url = \GV\Utils::get( $ary, 0 ); |
612 | 612 | |
613 | 613 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | private function maybe_update_post_fields( $form ) { |
681 | 681 | |
682 | 682 | if( empty( $this->entry['post_id'] ) ) { |
683 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
683 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
684 | 684 | return; |
685 | 685 | } |
686 | 686 | |
@@ -715,49 +715,49 @@ discard block |
||
715 | 715 | |
716 | 716 | switch( $field->type ) { |
717 | 717 | |
718 | - case 'post_title': |
|
719 | - $post_title = $value; |
|
720 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
721 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
722 | - } |
|
723 | - $updated_post->post_title = $post_title; |
|
724 | - $updated_post->post_name = $post_title; |
|
725 | - unset( $post_title ); |
|
726 | - break; |
|
727 | - |
|
728 | - case 'post_content': |
|
729 | - $post_content = $value; |
|
730 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
731 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
732 | - } |
|
733 | - $updated_post->post_content = $post_content; |
|
734 | - unset( $post_content ); |
|
735 | - break; |
|
736 | - case 'post_excerpt': |
|
737 | - $updated_post->post_excerpt = $value; |
|
738 | - break; |
|
739 | - case 'post_tags': |
|
740 | - wp_set_post_tags( $post_id, $value, false ); |
|
741 | - break; |
|
742 | - case 'post_category': |
|
743 | - break; |
|
744 | - case 'post_custom_field': |
|
718 | + case 'post_title': |
|
719 | + $post_title = $value; |
|
720 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
721 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
722 | + } |
|
723 | + $updated_post->post_title = $post_title; |
|
724 | + $updated_post->post_name = $post_title; |
|
725 | + unset( $post_title ); |
|
726 | + break; |
|
727 | + |
|
728 | + case 'post_content': |
|
729 | + $post_content = $value; |
|
730 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
731 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
732 | + } |
|
733 | + $updated_post->post_content = $post_content; |
|
734 | + unset( $post_content ); |
|
735 | + break; |
|
736 | + case 'post_excerpt': |
|
737 | + $updated_post->post_excerpt = $value; |
|
738 | + break; |
|
739 | + case 'post_tags': |
|
740 | + wp_set_post_tags( $post_id, $value, false ); |
|
741 | + break; |
|
742 | + case 'post_category': |
|
743 | + break; |
|
744 | + case 'post_custom_field': |
|
745 | 745 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
746 | 746 | $value = $value[ $field_id ]; |
747 | 747 | } |
748 | 748 | |
749 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
750 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
751 | - } |
|
749 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
750 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
751 | + } |
|
752 | 752 | |
753 | 753 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
754 | 754 | |
755 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
756 | - break; |
|
755 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
756 | + break; |
|
757 | 757 | |
758 | - case 'post_image': |
|
759 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
760 | - break; |
|
758 | + case 'post_image': |
|
759 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
760 | + break; |
|
761 | 761 | |
762 | 762 | } |
763 | 763 | |
@@ -880,14 +880,14 @@ discard block |
||
880 | 880 | ?><h2 class="gv-edit-entry-title"> |
881 | 881 | <span><?php |
882 | 882 | |
883 | - /** |
|
884 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
885 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
886 | - * @param GravityView_Edit_Entry_Render $this This object |
|
887 | - */ |
|
888 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
883 | + /** |
|
884 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
885 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
886 | + * @param GravityView_Edit_Entry_Render $this This object |
|
887 | + */ |
|
888 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
889 | 889 | |
890 | - echo esc_attr( $edit_entry_title ); |
|
890 | + echo esc_attr( $edit_entry_title ); |
|
891 | 891 | ?></span> |
892 | 892 | </h2> |
893 | 893 | |
@@ -950,26 +950,26 @@ discard block |
||
950 | 950 | |
951 | 951 | switch ( $edit_redirect ) { |
952 | 952 | |
953 | - case '0': |
|
954 | - $redirect_url = $back_link; |
|
955 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
956 | - break; |
|
957 | - |
|
958 | - case '1': |
|
959 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
960 | - $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>' ); |
|
961 | - break; |
|
962 | - |
|
963 | - case '2': |
|
964 | - $redirect_url = $edit_redirect_url; |
|
965 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
966 | - $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>' ); |
|
967 | - break; |
|
968 | - |
|
969 | - case '': |
|
970 | - default: |
|
971 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
972 | - break; |
|
953 | + case '0': |
|
954 | + $redirect_url = $back_link; |
|
955 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
956 | + break; |
|
957 | + |
|
958 | + case '1': |
|
959 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
960 | + $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>' ); |
|
961 | + break; |
|
962 | + |
|
963 | + case '2': |
|
964 | + $redirect_url = $edit_redirect_url; |
|
965 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
966 | + $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>' ); |
|
967 | + break; |
|
968 | + |
|
969 | + case '': |
|
970 | + default: |
|
971 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
972 | + break; |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | if ( isset( $redirect_url ) ) { |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | |
1027 | 1027 | ob_get_clean(); |
1028 | 1028 | |
1029 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1029 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1030 | 1030 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1031 | 1031 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
1032 | 1032 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | |
1081 | 1081 | // for now we don't support Save and Continue feature. |
1082 | 1082 | if( ! self::$supports_save_and_continue ) { |
1083 | - unset( $form['save'] ); |
|
1083 | + unset( $form['save'] ); |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | $form = $this->unselect_default_values( $form ); |
@@ -1107,30 +1107,30 @@ discard block |
||
1107 | 1107 | return $field_content; |
1108 | 1108 | } |
1109 | 1109 | |
1110 | - $message = null; |
|
1110 | + $message = null; |
|
1111 | 1111 | |
1112 | - // First, make sure they have the capability to edit the post. |
|
1113 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1112 | + // First, make sure they have the capability to edit the post. |
|
1113 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1114 | 1114 | |
1115 | - /** |
|
1116 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1117 | - * @param string $message The existing "You don't have permission..." text |
|
1118 | - */ |
|
1119 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1115 | + /** |
|
1116 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1117 | + * @param string $message The existing "You don't have permission..." text |
|
1118 | + */ |
|
1119 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1120 | 1120 | |
1121 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1122 | - /** |
|
1123 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1124 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1125 | - */ |
|
1126 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1127 | - } |
|
1121 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1122 | + /** |
|
1123 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1124 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1125 | + */ |
|
1126 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1127 | + } |
|
1128 | 1128 | |
1129 | - if( $message ) { |
|
1130 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1131 | - } |
|
1129 | + if( $message ) { |
|
1130 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1131 | + } |
|
1132 | 1132 | |
1133 | - return $field_content; |
|
1133 | + return $field_content; |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | /** |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | || ! empty( $field_content ) |
1159 | 1159 | || in_array( $field->type, array( 'honeypot' ) ) |
1160 | 1160 | ) { |
1161 | - return $field_content; |
|
1161 | + return $field_content; |
|
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1166,24 +1166,24 @@ discard block |
||
1166 | 1166 | |
1167 | 1167 | $field_value = $this->get_field_value( $field ); |
1168 | 1168 | |
1169 | - // Prevent any PHP warnings, like undefined index |
|
1170 | - ob_start(); |
|
1169 | + // Prevent any PHP warnings, like undefined index |
|
1170 | + ob_start(); |
|
1171 | 1171 | |
1172 | - $return = null; |
|
1172 | + $return = null; |
|
1173 | 1173 | |
1174 | 1174 | /** @var GravityView_Field $gv_field */ |
1175 | 1175 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1176 | 1176 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1177 | 1177 | } else { |
1178 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1179 | - } |
|
1178 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1179 | + } |
|
1180 | 1180 | |
1181 | - // If there was output, it's an error |
|
1182 | - $warnings = ob_get_clean(); |
|
1181 | + // If there was output, it's an error |
|
1182 | + $warnings = ob_get_clean(); |
|
1183 | 1183 | |
1184 | - if( !empty( $warnings ) ) { |
|
1185 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1186 | - } |
|
1184 | + if( !empty( $warnings ) ) { |
|
1185 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1186 | + } |
|
1187 | 1187 | |
1188 | 1188 | return $return; |
1189 | 1189 | } |
@@ -1218,8 +1218,8 @@ discard block |
||
1218 | 1218 | $input_id = strval( $input['id'] ); |
1219 | 1219 | |
1220 | 1220 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1221 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1222 | - $allow_pre_populated = false; |
|
1221 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1222 | + $allow_pre_populated = false; |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | } |
@@ -1243,7 +1243,7 @@ discard block |
||
1243 | 1243 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1244 | 1244 | $categories = array(); |
1245 | 1245 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1246 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1246 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1247 | 1247 | } |
1248 | 1248 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1249 | 1249 | } |
@@ -1253,25 +1253,25 @@ discard block |
||
1253 | 1253 | // if value is empty get the default value if defined |
1254 | 1254 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1255 | 1255 | |
1256 | - /** |
|
1257 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1258 | - * @since 1.11 |
|
1259 | - * @since 1.20 Added third param |
|
1260 | - * @param mixed $field_value field value used to populate the input |
|
1261 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1262 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1263 | - */ |
|
1264 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1265 | - |
|
1266 | - /** |
|
1267 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1268 | - * @since 1.17 |
|
1269 | - * @since 1.20 Added third param |
|
1270 | - * @param mixed $field_value field value used to populate the input |
|
1271 | - * @param GF_Field $field Gravity Forms field object |
|
1272 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1273 | - */ |
|
1274 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1256 | + /** |
|
1257 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1258 | + * @since 1.11 |
|
1259 | + * @since 1.20 Added third param |
|
1260 | + * @param mixed $field_value field value used to populate the input |
|
1261 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1262 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1263 | + */ |
|
1264 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1265 | + |
|
1266 | + /** |
|
1267 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1268 | + * @since 1.17 |
|
1269 | + * @since 1.20 Added third param |
|
1270 | + * @param mixed $field_value field value used to populate the input |
|
1271 | + * @param GF_Field $field Gravity Forms field object |
|
1272 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1273 | + */ |
|
1274 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1275 | 1275 | |
1276 | 1276 | return $field_value; |
1277 | 1277 | } |
@@ -1298,7 +1298,7 @@ discard block |
||
1298 | 1298 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1299 | 1299 | // expects certain field array items to be set. |
1300 | 1300 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1301 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1301 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1312,61 +1312,61 @@ discard block |
||
1312 | 1312 | */ |
1313 | 1313 | case 'fileupload': |
1314 | 1314 | |
1315 | - // Set the previous value |
|
1316 | - $entry = $this->get_entry(); |
|
1315 | + // Set the previous value |
|
1316 | + $entry = $this->get_entry(); |
|
1317 | 1317 | |
1318 | - $input_name = 'input_'.$field->id; |
|
1319 | - $form_id = $form['id']; |
|
1318 | + $input_name = 'input_'.$field->id; |
|
1319 | + $form_id = $form['id']; |
|
1320 | 1320 | |
1321 | - $value = NULL; |
|
1321 | + $value = NULL; |
|
1322 | 1322 | |
1323 | - // Use the previous entry value as the default. |
|
1324 | - if( isset( $entry[ $field->id ] ) ) { |
|
1325 | - $value = $entry[ $field->id ]; |
|
1326 | - } |
|
1323 | + // Use the previous entry value as the default. |
|
1324 | + if( isset( $entry[ $field->id ] ) ) { |
|
1325 | + $value = $entry[ $field->id ]; |
|
1326 | + } |
|
1327 | 1327 | |
1328 | - // If this is a single upload file |
|
1329 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1330 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1331 | - $value = $file_path['url']; |
|
1328 | + // If this is a single upload file |
|
1329 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1330 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1331 | + $value = $file_path['url']; |
|
1332 | 1332 | |
1333 | - } else { |
|
1333 | + } else { |
|
1334 | 1334 | |
1335 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1336 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1337 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1335 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1336 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1337 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1338 | 1338 | |
1339 | - } |
|
1339 | + } |
|
1340 | 1340 | |
1341 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1341 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1342 | 1342 | |
1343 | - // If there are fresh uploads, process and merge them. |
|
1344 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1345 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1346 | - $value = empty( $value ) ? '[]' : $value; |
|
1347 | - $value = stripslashes_deep( $value ); |
|
1348 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1349 | - } |
|
1343 | + // If there are fresh uploads, process and merge them. |
|
1344 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1345 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1346 | + $value = empty( $value ) ? '[]' : $value; |
|
1347 | + $value = stripslashes_deep( $value ); |
|
1348 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1349 | + } |
|
1350 | 1350 | |
1351 | - } else { |
|
1351 | + } else { |
|
1352 | 1352 | |
1353 | - // A file already exists when editing an entry |
|
1354 | - // We set this to solve issue when file upload fields are required. |
|
1355 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1353 | + // A file already exists when editing an entry |
|
1354 | + // We set this to solve issue when file upload fields are required. |
|
1355 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1356 | 1356 | |
1357 | - } |
|
1357 | + } |
|
1358 | 1358 | |
1359 | - $this->entry[ $input_name ] = $value; |
|
1360 | - $_POST[ $input_name ] = $value; |
|
1359 | + $this->entry[ $input_name ] = $value; |
|
1360 | + $_POST[ $input_name ] = $value; |
|
1361 | 1361 | |
1362 | - break; |
|
1362 | + break; |
|
1363 | 1363 | |
1364 | 1364 | case 'number': |
1365 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1366 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1367 | - $_POST['input_'.$field->id ] = NULL; |
|
1368 | - } |
|
1369 | - break; |
|
1365 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1366 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1367 | + $_POST['input_'.$field->id ] = NULL; |
|
1368 | + } |
|
1369 | + break; |
|
1370 | 1370 | } |
1371 | 1371 | |
1372 | 1372 | } |
@@ -1451,42 +1451,42 @@ discard block |
||
1451 | 1451 | case 'fileupload' : |
1452 | 1452 | case 'post_image': |
1453 | 1453 | |
1454 | - // in case nothing is uploaded but there are already files saved |
|
1455 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1456 | - $field->failed_validation = false; |
|
1457 | - unset( $field->validation_message ); |
|
1458 | - } |
|
1454 | + // in case nothing is uploaded but there are already files saved |
|
1455 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1456 | + $field->failed_validation = false; |
|
1457 | + unset( $field->validation_message ); |
|
1458 | + } |
|
1459 | 1459 | |
1460 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1461 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1460 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1461 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1462 | 1462 | |
1463 | - $input_name = 'input_' . $field->id; |
|
1464 | - //uploaded |
|
1465 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1463 | + $input_name = 'input_' . $field->id; |
|
1464 | + //uploaded |
|
1465 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1466 | 1466 | |
1467 | - //existent |
|
1468 | - $entry = $this->get_entry(); |
|
1469 | - $value = NULL; |
|
1470 | - if( isset( $entry[ $field->id ] ) ) { |
|
1471 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1472 | - } |
|
1467 | + //existent |
|
1468 | + $entry = $this->get_entry(); |
|
1469 | + $value = NULL; |
|
1470 | + if( isset( $entry[ $field->id ] ) ) { |
|
1471 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1472 | + } |
|
1473 | 1473 | |
1474 | - // count uploaded files and existent entry files |
|
1475 | - $count_files = count( $file_names ) + count( $value ); |
|
1474 | + // count uploaded files and existent entry files |
|
1475 | + $count_files = count( $file_names ) + count( $value ); |
|
1476 | 1476 | |
1477 | - if( $count_files > $field->maxFiles ) { |
|
1478 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1479 | - $field->failed_validation = 1; |
|
1480 | - $gv_valid = false; |
|
1477 | + if( $count_files > $field->maxFiles ) { |
|
1478 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1479 | + $field->failed_validation = 1; |
|
1480 | + $gv_valid = false; |
|
1481 | 1481 | |
1482 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1483 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1484 | - } |
|
1482 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1483 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1484 | + } |
|
1485 | 1485 | |
1486 | - } |
|
1486 | + } |
|
1487 | 1487 | |
1488 | 1488 | |
1489 | - break; |
|
1489 | + break; |
|
1490 | 1490 | |
1491 | 1491 | } |
1492 | 1492 | |
@@ -1497,47 +1497,47 @@ discard block |
||
1497 | 1497 | |
1498 | 1498 | switch ( $field_type ) { |
1499 | 1499 | |
1500 | - // Captchas don't need to be re-entered. |
|
1501 | - case 'captcha': |
|
1500 | + // Captchas don't need to be re-entered. |
|
1501 | + case 'captcha': |
|
1502 | 1502 | |
1503 | - // Post Image fields aren't editable, so we un-fail them. |
|
1504 | - case 'post_image': |
|
1505 | - $field->failed_validation = false; |
|
1506 | - unset( $field->validation_message ); |
|
1507 | - break; |
|
1503 | + // Post Image fields aren't editable, so we un-fail them. |
|
1504 | + case 'post_image': |
|
1505 | + $field->failed_validation = false; |
|
1506 | + unset( $field->validation_message ); |
|
1507 | + break; |
|
1508 | 1508 | |
1509 | 1509 | } |
1510 | 1510 | |
1511 | 1511 | // You can't continue inside a switch, so we do it after. |
1512 | 1512 | if( empty( $field->failed_validation ) ) { |
1513 | - continue; |
|
1513 | + continue; |
|
1514 | 1514 | } |
1515 | 1515 | |
1516 | 1516 | // checks if the No Duplicates option is not validating entry against itself, since |
1517 | 1517 | // we're editing a stored entry, it would also assume it's a duplicate. |
1518 | 1518 | if( !empty( $field->noDuplicates ) ) { |
1519 | 1519 | |
1520 | - $entry = $this->get_entry(); |
|
1520 | + $entry = $this->get_entry(); |
|
1521 | 1521 | |
1522 | - // If the value of the entry is the same as the stored value |
|
1523 | - // Then we can assume it's not a duplicate, it's the same. |
|
1524 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1525 | - //if value submitted was not changed, then don't validate |
|
1526 | - $field->failed_validation = false; |
|
1522 | + // If the value of the entry is the same as the stored value |
|
1523 | + // Then we can assume it's not a duplicate, it's the same. |
|
1524 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1525 | + //if value submitted was not changed, then don't validate |
|
1526 | + $field->failed_validation = false; |
|
1527 | 1527 | |
1528 | - unset( $field->validation_message ); |
|
1528 | + unset( $field->validation_message ); |
|
1529 | 1529 | |
1530 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1530 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1531 | 1531 | |
1532 | - continue; |
|
1533 | - } |
|
1532 | + continue; |
|
1533 | + } |
|
1534 | 1534 | } |
1535 | 1535 | |
1536 | 1536 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1537 | 1537 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1538 | - unset( $field->validation_message ); |
|
1539 | - $field->validation_message = false; |
|
1540 | - continue; |
|
1538 | + unset( $field->validation_message ); |
|
1539 | + $field->validation_message = false; |
|
1540 | + continue; |
|
1541 | 1541 | } |
1542 | 1542 | |
1543 | 1543 | $gv_valid = false; |
@@ -1601,8 +1601,8 @@ discard block |
||
1601 | 1601 | // Hide fields depending on admin settings |
1602 | 1602 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1603 | 1603 | |
1604 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1605 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1604 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1605 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1606 | 1606 | |
1607 | 1607 | /** |
1608 | 1608 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1662,11 +1662,11 @@ discard block |
||
1662 | 1662 | // The edit tab has been configured, so we loop through to configured settings |
1663 | 1663 | foreach ( $configured_fields as $configured_field ) { |
1664 | 1664 | |
1665 | - /** @var GF_Field $field */ |
|
1666 | - foreach ( $fields as $field ) { |
|
1665 | + /** @var GF_Field $field */ |
|
1666 | + foreach ( $fields as $field ) { |
|
1667 | 1667 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
1668 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1669 | - break; |
|
1668 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1669 | + break; |
|
1670 | 1670 | } |
1671 | 1671 | |
1672 | 1672 | } |
@@ -1722,28 +1722,28 @@ discard block |
||
1722 | 1722 | */ |
1723 | 1723 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
1724 | 1724 | |
1725 | - /** |
|
1725 | + /** |
|
1726 | 1726 | * @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 |
1727 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1728 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1729 | - * @since 1.9.1 |
|
1730 | - * @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. |
|
1731 | - * @param array $form GF Form array |
|
1732 | - * @param int $view_id View ID |
|
1733 | - */ |
|
1734 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1735 | - |
|
1736 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1727 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1728 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1729 | + * @since 1.9.1 |
|
1730 | + * @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. |
|
1731 | + * @param array $form GF Form array |
|
1732 | + * @param int $view_id View ID |
|
1733 | + */ |
|
1734 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1735 | + |
|
1736 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1737 | 1737 | foreach( $fields as $k => $field ) { |
1738 | 1738 | if( $field->adminOnly ) { |
1739 | - unset( $fields[ $k ] ); |
|
1739 | + unset( $fields[ $k ] ); |
|
1740 | 1740 | } |
1741 | 1741 | } |
1742 | 1742 | return array_values( $fields ); |
1743 | 1743 | } |
1744 | 1744 | |
1745 | - foreach( $fields as &$field ) { |
|
1746 | - $field->adminOnly = false; |
|
1745 | + foreach( $fields as &$field ) { |
|
1746 | + $field->adminOnly = false; |
|
1747 | 1747 | } |
1748 | 1748 | |
1749 | 1749 | return $fields; |
@@ -1763,13 +1763,13 @@ discard block |
||
1763 | 1763 | */ |
1764 | 1764 | private function unselect_default_values( $form ) { |
1765 | 1765 | |
1766 | - foreach ( $form['fields'] as &$field ) { |
|
1766 | + foreach ( $form['fields'] as &$field ) { |
|
1767 | 1767 | |
1768 | 1768 | if ( empty( $field->choices ) ) { |
1769 | - continue; |
|
1769 | + continue; |
|
1770 | 1770 | } |
1771 | 1771 | |
1772 | - foreach ( $field->choices as &$choice ) { |
|
1772 | + foreach ( $field->choices as &$choice ) { |
|
1773 | 1773 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
1774 | 1774 | $choice['isSelected'] = false; |
1775 | 1775 | } |
@@ -1806,36 +1806,36 @@ discard block |
||
1806 | 1806 | |
1807 | 1807 | if( 'checkbox' === $field->type ) { |
1808 | 1808 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1809 | - $input_id = $input['id']; |
|
1810 | - $choice = $field->choices[ $key ]; |
|
1811 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1812 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1813 | - if( $match ) { |
|
1814 | - $field->choices[ $key ]['isSelected'] = true; |
|
1815 | - } |
|
1809 | + $input_id = $input['id']; |
|
1810 | + $choice = $field->choices[ $key ]; |
|
1811 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1812 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1813 | + if( $match ) { |
|
1814 | + $field->choices[ $key ]['isSelected'] = true; |
|
1815 | + } |
|
1816 | 1816 | } |
1817 | 1817 | } else { |
1818 | 1818 | |
1819 | 1819 | // We need to run through each field to set the default values |
1820 | 1820 | foreach ( $this->entry as $field_id => $field_value ) { |
1821 | 1821 | |
1822 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1822 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1823 | 1823 | |
1824 | - if( 'list' === $field->type ) { |
|
1825 | - $list_rows = maybe_unserialize( $field_value ); |
|
1824 | + if( 'list' === $field->type ) { |
|
1825 | + $list_rows = maybe_unserialize( $field_value ); |
|
1826 | 1826 | |
1827 | - $list_field_value = array(); |
|
1828 | - foreach ( (array) $list_rows as $row ) { |
|
1829 | - foreach ( (array) $row as $column ) { |
|
1830 | - $list_field_value[] = $column; |
|
1831 | - } |
|
1832 | - } |
|
1827 | + $list_field_value = array(); |
|
1828 | + foreach ( (array) $list_rows as $row ) { |
|
1829 | + foreach ( (array) $row as $column ) { |
|
1830 | + $list_field_value[] = $column; |
|
1831 | + } |
|
1832 | + } |
|
1833 | 1833 | |
1834 | - $field->defaultValue = serialize( $list_field_value ); |
|
1835 | - } else { |
|
1836 | - $field->defaultValue = $field_value; |
|
1837 | - } |
|
1838 | - } |
|
1834 | + $field->defaultValue = serialize( $list_field_value ); |
|
1835 | + } else { |
|
1836 | + $field->defaultValue = $field_value; |
|
1837 | + } |
|
1838 | + } |
|
1839 | 1839 | } |
1840 | 1840 | } |
1841 | 1841 | } |
@@ -1892,7 +1892,7 @@ discard block |
||
1892 | 1892 | return $has_conditional_logic; |
1893 | 1893 | } |
1894 | 1894 | |
1895 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
1895 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
1896 | 1896 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
1897 | 1897 | } |
1898 | 1898 | |
@@ -1959,14 +1959,14 @@ discard block |
||
1959 | 1959 | |
1960 | 1960 | if( $echo && $error !== true ) { |
1961 | 1961 | |
1962 | - $error = esc_html( $error ); |
|
1962 | + $error = esc_html( $error ); |
|
1963 | 1963 | |
1964 | - /** |
|
1965 | - * @since 1.9 |
|
1966 | - */ |
|
1967 | - if ( ! empty( $this->entry ) ) { |
|
1968 | - $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;" ) ); |
|
1969 | - } |
|
1964 | + /** |
|
1965 | + * @since 1.9 |
|
1966 | + */ |
|
1967 | + if ( ! empty( $this->entry ) ) { |
|
1968 | + $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;" ) ); |
|
1969 | + } |
|
1970 | 1970 | |
1971 | 1971 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
1972 | 1972 | } |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | function load() { |
116 | 116 | |
117 | 117 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
118 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
118 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
119 | 119 | |
120 | 120 | // Don't display an embedded form when editing an entry |
121 | 121 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
122 | 122 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
123 | 123 | |
124 | 124 | // Stop Gravity Forms processing what is ours! |
125 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
125 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
126 | 126 | |
127 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
127 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
128 | 128 | |
129 | 129 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
130 | 130 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
136 | 136 | |
137 | 137 | // Add fields expected by GFFormDisplay::validate() |
138 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
138 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
139 | 139 | |
140 | 140 | // Fix multiselect value for GF 2.2 |
141 | 141 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @return void |
153 | 153 | */ |
154 | 154 | public function prevent_render_form() { |
155 | - if( $this->is_edit_entry() ) { |
|
156 | - if( 'wp_head' === current_filter() ) { |
|
155 | + if ( $this->is_edit_entry() ) { |
|
156 | + if ( 'wp_head' === current_filter() ) { |
|
157 | 157 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
158 | 158 | } else { |
159 | 159 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function prevent_maybe_process_form() { |
170 | 170 | |
171 | - if( ! empty( $_POST ) ) { |
|
171 | + if ( ! empty( $_POST ) ) { |
|
172 | 172 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
173 | 173 | } |
174 | 174 | |
175 | - if( $this->is_edit_entry_submission() ) { |
|
176 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
175 | + if ( $this->is_edit_entry_submission() ) { |
|
176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function is_edit_entry() { |
186 | 186 | |
187 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
187 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
188 | 188 | |
189 | 189 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
190 | 190 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return boolean |
196 | 196 | */ |
197 | 197 | public function is_edit_entry_submission() { |
198 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
198 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | |
209 | 209 | |
210 | 210 | $entries = $gravityview_view->getEntries(); |
211 | - self::$original_entry = $entries[0]; |
|
212 | - $this->entry = $entries[0]; |
|
211 | + self::$original_entry = $entries[ 0 ]; |
|
212 | + $this->entry = $entries[ 0 ]; |
|
213 | 213 | |
214 | 214 | self::$original_form = $gravityview_view->getForm(); |
215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $this->view_id = $gravityview_view->getViewId(); |
218 | 218 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
219 | 219 | |
220 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
220 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | private function print_scripts() { |
269 | 269 | $gravityview_view = GravityView_View::getInstance(); |
270 | 270 | |
271 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
271 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
272 | 272 | |
273 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
273 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
274 | 274 | |
275 | 275 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
276 | 276 | |
@@ -286,19 +286,19 @@ discard block |
||
286 | 286 | */ |
287 | 287 | private function process_save( $gv_data ) { |
288 | 288 | |
289 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
289 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
290 | 290 | return; |
291 | 291 | } |
292 | 292 | |
293 | 293 | // Make sure the entry, view, and form IDs are all correct |
294 | 294 | $valid = $this->verify_nonce(); |
295 | 295 | |
296 | - if ( !$valid ) { |
|
296 | + if ( ! $valid ) { |
|
297 | 297 | gravityview()->log->error( 'Nonce validation failed.' ); |
298 | 298 | return; |
299 | 299 | } |
300 | 300 | |
301 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
301 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
302 | 302 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
303 | 303 | return; |
304 | 304 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | $this->validate(); |
311 | 311 | |
312 | - if( $this->is_valid ) { |
|
312 | + if ( $this->is_valid ) { |
|
313 | 313 | |
314 | 314 | gravityview()->log->debug( 'Submission is valid.' ); |
315 | 315 | |
@@ -321,22 +321,22 @@ discard block |
||
321 | 321 | /** |
322 | 322 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
323 | 323 | */ |
324 | - unset( $_GET['page'] ); |
|
324 | + unset( $_GET[ 'page' ] ); |
|
325 | 325 | |
326 | - $date_created = $this->entry['date_created']; |
|
326 | + $date_created = $this->entry[ 'date_created' ]; |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
330 | 330 | * @since 1.17.2 |
331 | 331 | */ |
332 | - unset( $this->entry['date_created'] ); |
|
332 | + unset( $this->entry[ 'date_created' ] ); |
|
333 | 333 | |
334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
335 | 335 | |
336 | 336 | // Delete the values for hidden inputs |
337 | 337 | $this->unset_hidden_field_values(); |
338 | 338 | |
339 | - $this->entry['date_created'] = $date_created; |
|
339 | + $this->entry[ 'date_created' ] = $date_created; |
|
340 | 340 | |
341 | 341 | // Process calculation fields |
342 | 342 | $this->update_calculation_fields(); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param GravityView_Edit_Entry_Render $this This object |
359 | 359 | * @param GravityView_View_Data $gv_data The View data |
360 | 360 | */ |
361 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
361 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
362 | 362 | |
363 | 363 | } else { |
364 | 364 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -386,16 +386,16 @@ discard block |
||
386 | 386 | */ |
387 | 387 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
388 | 388 | |
389 | - if( ! $unset_hidden_field_values ) { |
|
389 | + if ( ! $unset_hidden_field_values ) { |
|
390 | 390 | return; |
391 | 391 | } |
392 | 392 | |
393 | 393 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
394 | 394 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
395 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
395 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
396 | 396 | } else { |
397 | 397 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
398 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
398 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | |
409 | 409 | $empty_value = $field->get_value_save_entry( |
410 | 410 | is_array( $field->get_entry_inputs() ) ? array() : '', |
411 | - $this->form, '', $this->entry['id'], $this->entry |
|
411 | + $this->form, '', $this->entry[ 'id' ], $this->entry |
|
412 | 412 | ); |
413 | 413 | |
414 | 414 | $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | } |
479 | 479 | |
480 | 480 | /** No file is being uploaded. */ |
481 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
481 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
482 | 482 | /** So return the original upload */ |
483 | 483 | return $entry[ $input_id ]; |
484 | 484 | } |
@@ -496,11 +496,11 @@ discard block |
||
496 | 496 | * @return mixed |
497 | 497 | */ |
498 | 498 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
499 | - if( ! $this->is_edit_entry() ) { |
|
499 | + if ( ! $this->is_edit_entry() ) { |
|
500 | 500 | return $plupload_init; |
501 | 501 | } |
502 | 502 | |
503 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
503 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
504 | 504 | |
505 | 505 | return $plupload_init; |
506 | 506 | } |
@@ -515,27 +515,27 @@ discard block |
||
515 | 515 | $form = $this->form; |
516 | 516 | |
517 | 517 | /** @var GF_Field $field */ |
518 | - foreach( $form['fields'] as $k => &$field ) { |
|
518 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
519 | 519 | |
520 | 520 | /** |
521 | 521 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
522 | 522 | * @since 1.16.3 |
523 | 523 | * @var GF_Field $field |
524 | 524 | */ |
525 | - if( $field->has_calculation() ) { |
|
526 | - unset( $form['fields'][ $k ] ); |
|
525 | + if ( $field->has_calculation() ) { |
|
526 | + unset( $form[ 'fields' ][ $k ] ); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | $field->adminOnly = false; |
530 | 530 | |
531 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
532 | - foreach( $field->inputs as $key => $input ) { |
|
533 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
531 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
532 | + foreach ( $field->inputs as $key => $input ) { |
|
533 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
534 | 534 | } |
535 | 535 | } |
536 | 536 | } |
537 | 537 | |
538 | - $form['fields'] = array_values( $form['fields'] ); |
|
538 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
539 | 539 | |
540 | 540 | return $form; |
541 | 541 | } |
@@ -547,14 +547,14 @@ discard block |
||
547 | 547 | $update = false; |
548 | 548 | |
549 | 549 | // get the most up to date entry values |
550 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
550 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
551 | 551 | |
552 | 552 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
553 | 553 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
554 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
554 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
555 | 555 | } else { |
556 | 556 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
557 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
557 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | $inputs = $field->get_entry_inputs(); |
565 | 565 | if ( is_array( $inputs ) ) { |
566 | 566 | foreach ( $inputs as $input ) { |
567 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
567 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
568 | 568 | } |
569 | 569 | } else { |
570 | 570 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $field->id ); |
@@ -600,19 +600,19 @@ discard block |
||
600 | 600 | |
601 | 601 | $input_name = 'input_' . $field_id; |
602 | 602 | |
603 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
603 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
604 | 604 | |
605 | 605 | // We have a new image |
606 | 606 | |
607 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
607 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
608 | 608 | |
609 | 609 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
610 | 610 | $ary = stripslashes_deep( $ary ); |
611 | 611 | $img_url = \GV\Utils::get( $ary, 0 ); |
612 | 612 | |
613 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
614 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
615 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
613 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
614 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
615 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
616 | 616 | |
617 | 617 | $image_meta = array( |
618 | 618 | 'post_excerpt' => $img_caption, |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | |
622 | 622 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
623 | 623 | if ( ! empty( $img_title ) ) { |
624 | - $image_meta['post_title'] = $img_title; |
|
624 | + $image_meta[ 'post_title' ] = $img_title; |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | /** |
@@ -679,15 +679,15 @@ discard block |
||
679 | 679 | */ |
680 | 680 | private function maybe_update_post_fields( $form ) { |
681 | 681 | |
682 | - if( empty( $this->entry['post_id'] ) ) { |
|
682 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
683 | 683 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
684 | 684 | return; |
685 | 685 | } |
686 | 686 | |
687 | - $post_id = $this->entry['post_id']; |
|
687 | + $post_id = $this->entry[ 'post_id' ]; |
|
688 | 688 | |
689 | 689 | // Security check |
690 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
690 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
691 | 691 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
692 | 692 | return; |
693 | 693 | } |
@@ -700,25 +700,25 @@ discard block |
||
700 | 700 | |
701 | 701 | $field = RGFormsModel::get_field( $form, $field_id ); |
702 | 702 | |
703 | - if( ! $field ) { |
|
703 | + if ( ! $field ) { |
|
704 | 704 | continue; |
705 | 705 | } |
706 | 706 | |
707 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
707 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
708 | 708 | |
709 | 709 | // Get the value of the field, including $_POSTed value |
710 | 710 | $value = RGFormsModel::get_field_value( $field ); |
711 | 711 | |
712 | 712 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
713 | 713 | $entry_tmp = $this->entry; |
714 | - $entry_tmp["{$field_id}"] = $value; |
|
714 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
715 | 715 | |
716 | - switch( $field->type ) { |
|
716 | + switch ( $field->type ) { |
|
717 | 717 | |
718 | 718 | case 'post_title': |
719 | 719 | $post_title = $value; |
720 | 720 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
721 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
721 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
722 | 722 | } |
723 | 723 | $updated_post->post_title = $post_title; |
724 | 724 | $updated_post->post_name = $post_title; |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | case 'post_content': |
729 | 729 | $post_content = $value; |
730 | 730 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
731 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
731 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
732 | 732 | } |
733 | 733 | $updated_post->post_content = $post_content; |
734 | 734 | unset( $post_content ); |
@@ -746,11 +746,11 @@ discard block |
||
746 | 746 | $value = $value[ $field_id ]; |
747 | 747 | } |
748 | 748 | |
749 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
749 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
750 | 750 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
751 | 751 | } |
752 | 752 | |
753 | - $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
|
753 | + $value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry ); |
|
754 | 754 | |
755 | 755 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
756 | 756 | break; |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | } |
763 | 763 | |
764 | 764 | // update entry after |
765 | - $this->entry["{$field_id}"] = $value; |
|
765 | + $this->entry[ "{$field_id}" ] = $value; |
|
766 | 766 | |
767 | 767 | $update_entry = true; |
768 | 768 | |
@@ -771,11 +771,11 @@ discard block |
||
771 | 771 | |
772 | 772 | } |
773 | 773 | |
774 | - if( $update_entry ) { |
|
774 | + if ( $update_entry ) { |
|
775 | 775 | |
776 | 776 | $return_entry = GFAPI::update_entry( $this->entry ); |
777 | 777 | |
778 | - if( is_wp_error( $return_entry ) ) { |
|
778 | + if ( is_wp_error( $return_entry ) ) { |
|
779 | 779 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
780 | 780 | } else { |
781 | 781 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | |
786 | 786 | $return_post = wp_update_post( $updated_post, true ); |
787 | 787 | |
788 | - if( is_wp_error( $return_post ) ) { |
|
788 | + if ( is_wp_error( $return_post ) ) { |
|
789 | 789 | $return_post->add_data( $updated_post, '$updated_post' ); |
790 | 790 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
791 | 791 | } else { |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
820 | 820 | |
821 | 821 | // replace conditional shortcodes |
822 | - if( $do_shortcode ) { |
|
822 | + if ( $do_shortcode ) { |
|
823 | 823 | $output = do_shortcode( $output ); |
824 | 824 | } |
825 | 825 | |
@@ -838,19 +838,19 @@ discard block |
||
838 | 838 | */ |
839 | 839 | private function after_update() { |
840 | 840 | |
841 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
842 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
841 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
842 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
843 | 843 | |
844 | 844 | // Re-define the entry now that we've updated it. |
845 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
845 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
846 | 846 | |
847 | 847 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
848 | 848 | |
849 | 849 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
850 | 850 | // We need to clear the cache because Gravity Forms caches the field values, which |
851 | 851 | // we have just updated. |
852 | - foreach ($this->form['fields'] as $key => $field) { |
|
853 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
852 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
853 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
854 | 854 | } |
855 | 855 | } |
856 | 856 | |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | |
870 | 870 | <div class="gv-edit-entry-wrapper"><?php |
871 | 871 | |
872 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
872 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
873 | 873 | |
874 | 874 | /** |
875 | 875 | * Fixes weird wpautop() issue |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | * @param string $edit_entry_title Modify the "Edit Entry" title |
886 | 886 | * @param GravityView_Edit_Entry_Render $this This object |
887 | 887 | */ |
888 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
888 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
889 | 889 | |
890 | 890 | echo esc_attr( $edit_entry_title ); |
891 | 891 | ?></span> |
@@ -935,13 +935,13 @@ discard block |
||
935 | 935 | |
936 | 936 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
937 | 937 | |
938 | - if( ! $this->is_valid ){ |
|
938 | + if ( ! $this->is_valid ) { |
|
939 | 939 | |
940 | 940 | // Keeping this compatible with Gravity Forms. |
941 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
942 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
941 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
942 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
943 | 943 | |
944 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
944 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
945 | 945 | |
946 | 946 | } else { |
947 | 947 | $view = \GV\View::by_id( $this->view_id ); |
@@ -952,23 +952,23 @@ discard block |
||
952 | 952 | |
953 | 953 | case '0': |
954 | 954 | $redirect_url = $back_link; |
955 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
955 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
956 | 956 | break; |
957 | 957 | |
958 | 958 | case '1': |
959 | 959 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
960 | - $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>' ); |
|
960 | + $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>' ); |
|
961 | 961 | break; |
962 | 962 | |
963 | 963 | case '2': |
964 | 964 | $redirect_url = $edit_redirect_url; |
965 | 965 | $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
966 | - $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>' ); |
|
966 | + $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>' ); |
|
967 | 967 | break; |
968 | 968 | |
969 | 969 | case '': |
970 | 970 | default: |
971 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
971 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
972 | 972 | break; |
973 | 973 | } |
974 | 974 | |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | * @param array $entry Gravity Forms entry array |
985 | 985 | * @param string $back_link URL to return to the original entry. @since 1.6 |
986 | 986 | */ |
987 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
987 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
988 | 988 | |
989 | 989 | echo GVCommon::generate_notice( $message ); |
990 | 990 | } |
@@ -1008,21 +1008,21 @@ discard block |
||
1008 | 1008 | */ |
1009 | 1009 | do_action( 'gravityview/edit-entry/render/before', $this ); |
1010 | 1010 | |
1011 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1012 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
1011 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
1012 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1013 | 1013 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
1014 | 1014 | |
1015 | 1015 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
1016 | 1016 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
1017 | 1017 | |
1018 | 1018 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
1019 | - unset( $_GET['page'] ); |
|
1019 | + unset( $_GET[ 'page' ] ); |
|
1020 | 1020 | |
1021 | 1021 | // TODO: Verify multiple-page forms |
1022 | 1022 | |
1023 | 1023 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1024 | 1024 | |
1025 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1025 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1026 | 1026 | |
1027 | 1027 | ob_get_clean(); |
1028 | 1028 | |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | * @return string |
1049 | 1049 | */ |
1050 | 1050 | public function render_form_buttons() { |
1051 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1051 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | |
@@ -1068,10 +1068,10 @@ discard block |
||
1068 | 1068 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1069 | 1069 | |
1070 | 1070 | // In case we have validated the form, use it to inject the validation results into the form render |
1071 | - if( isset( $this->form_after_validation ) ) { |
|
1071 | + if ( isset( $this->form_after_validation ) ) { |
|
1072 | 1072 | $form = $this->form_after_validation; |
1073 | 1073 | } else { |
1074 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1074 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | $form = $this->filter_conditional_logic( $form ); |
@@ -1079,8 +1079,8 @@ discard block |
||
1079 | 1079 | $form = $this->prefill_conditional_logic( $form ); |
1080 | 1080 | |
1081 | 1081 | // for now we don't support Save and Continue feature. |
1082 | - if( ! self::$supports_save_and_continue ) { |
|
1083 | - unset( $form['save'] ); |
|
1082 | + if ( ! self::$supports_save_and_continue ) { |
|
1083 | + unset( $form[ 'save' ] ); |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | $form = $this->unselect_default_values( $form ); |
@@ -1103,31 +1103,31 @@ discard block |
||
1103 | 1103 | */ |
1104 | 1104 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1105 | 1105 | |
1106 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
1106 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
1107 | 1107 | return $field_content; |
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | $message = null; |
1111 | 1111 | |
1112 | 1112 | // First, make sure they have the capability to edit the post. |
1113 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1113 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1114 | 1114 | |
1115 | 1115 | /** |
1116 | 1116 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1117 | 1117 | * @param string $message The existing "You don't have permission..." text |
1118 | 1118 | */ |
1119 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1119 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1120 | 1120 | |
1121 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1121 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1122 | 1122 | /** |
1123 | 1123 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1124 | 1124 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1125 | 1125 | */ |
1126 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1126 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1127 | 1127 | } |
1128 | 1128 | |
1129 | - if( $message ) { |
|
1130 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1129 | + if ( $message ) { |
|
1130 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | return $field_content; |
@@ -1151,8 +1151,8 @@ discard block |
||
1151 | 1151 | |
1152 | 1152 | // If the form has been submitted, then we don't need to pre-fill the values, |
1153 | 1153 | // Except for fileupload type and when a field input is overridden- run always!! |
1154 | - if( |
|
1155 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1154 | + if ( |
|
1155 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1156 | 1156 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1157 | 1157 | && ! GFCommon::is_product_field( $field->type ) |
1158 | 1158 | || ! empty( $field_content ) |
@@ -1172,7 +1172,7 @@ discard block |
||
1172 | 1172 | $return = null; |
1173 | 1173 | |
1174 | 1174 | /** @var GravityView_Field $gv_field */ |
1175 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1175 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1176 | 1176 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1177 | 1177 | } else { |
1178 | 1178 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1181,7 +1181,7 @@ discard block |
||
1181 | 1181 | // If there was output, it's an error |
1182 | 1182 | $warnings = ob_get_clean(); |
1183 | 1183 | |
1184 | - if( !empty( $warnings ) ) { |
|
1184 | + if ( ! empty( $warnings ) ) { |
|
1185 | 1185 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1186 | 1186 | } |
1187 | 1187 | |
@@ -1206,7 +1206,7 @@ discard block |
||
1206 | 1206 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1207 | 1207 | |
1208 | 1208 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1209 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1209 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1210 | 1210 | |
1211 | 1211 | $field_value = array(); |
1212 | 1212 | |
@@ -1215,10 +1215,10 @@ discard block |
||
1215 | 1215 | |
1216 | 1216 | foreach ( (array)$field->inputs as $input ) { |
1217 | 1217 | |
1218 | - $input_id = strval( $input['id'] ); |
|
1218 | + $input_id = strval( $input[ 'id' ] ); |
|
1219 | 1219 | |
1220 | 1220 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1221 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1221 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1222 | 1222 | $allow_pre_populated = false; |
1223 | 1223 | } |
1224 | 1224 | |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | |
1227 | 1227 | $pre_value = $field->get_value_submission( array(), false ); |
1228 | 1228 | |
1229 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1229 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1230 | 1230 | |
1231 | 1231 | } else { |
1232 | 1232 | |
@@ -1237,13 +1237,13 @@ discard block |
||
1237 | 1237 | |
1238 | 1238 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1239 | 1239 | // or pre-populated value if not empty and set to override saved value |
1240 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1240 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1241 | 1241 | |
1242 | 1242 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1243 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1243 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1244 | 1244 | $categories = array(); |
1245 | 1245 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1246 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1246 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1247 | 1247 | } |
1248 | 1248 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1249 | 1249 | } |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | * @param GF_Field $field Gravity Forms field object |
1272 | 1272 | * @param GravityView_Edit_Entry_Render $this Current object |
1273 | 1273 | */ |
1274 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1274 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1275 | 1275 | |
1276 | 1276 | return $field_value; |
1277 | 1277 | } |
@@ -1288,12 +1288,12 @@ discard block |
||
1288 | 1288 | */ |
1289 | 1289 | public function gform_pre_validation( $form ) { |
1290 | 1290 | |
1291 | - if( ! $this->verify_nonce() ) { |
|
1291 | + if ( ! $this->verify_nonce() ) { |
|
1292 | 1292 | return $form; |
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | // Fix PHP warning regarding undefined index. |
1296 | - foreach ( $form['fields'] as &$field) { |
|
1296 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1297 | 1297 | |
1298 | 1298 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1299 | 1299 | // expects certain field array items to be set. |
@@ -1301,7 +1301,7 @@ discard block |
||
1301 | 1301 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1302 | 1302 | } |
1303 | 1303 | |
1304 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1304 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1305 | 1305 | |
1306 | 1306 | /** |
1307 | 1307 | * 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. |
@@ -1315,26 +1315,26 @@ discard block |
||
1315 | 1315 | // Set the previous value |
1316 | 1316 | $entry = $this->get_entry(); |
1317 | 1317 | |
1318 | - $input_name = 'input_'.$field->id; |
|
1319 | - $form_id = $form['id']; |
|
1318 | + $input_name = 'input_' . $field->id; |
|
1319 | + $form_id = $form[ 'id' ]; |
|
1320 | 1320 | |
1321 | 1321 | $value = NULL; |
1322 | 1322 | |
1323 | 1323 | // Use the previous entry value as the default. |
1324 | - if( isset( $entry[ $field->id ] ) ) { |
|
1324 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1325 | 1325 | $value = $entry[ $field->id ]; |
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | // If this is a single upload file |
1329 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1330 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1331 | - $value = $file_path['url']; |
|
1329 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1330 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1331 | + $value = $file_path[ 'url' ]; |
|
1332 | 1332 | |
1333 | 1333 | } else { |
1334 | 1334 | |
1335 | 1335 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1336 | 1336 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1337 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1337 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1338 | 1338 | |
1339 | 1339 | } |
1340 | 1340 | |
@@ -1342,10 +1342,10 @@ discard block |
||
1342 | 1342 | |
1343 | 1343 | // If there are fresh uploads, process and merge them. |
1344 | 1344 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1345 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1345 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1346 | 1346 | $value = empty( $value ) ? '[]' : $value; |
1347 | 1347 | $value = stripslashes_deep( $value ); |
1348 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1348 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | } else { |
@@ -1363,8 +1363,8 @@ discard block |
||
1363 | 1363 | |
1364 | 1364 | case 'number': |
1365 | 1365 | // Fix "undefined index" issue at line 1286 in form_display.php |
1366 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1367 | - $_POST['input_'.$field->id ] = NULL; |
|
1366 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1367 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1368 | 1368 | } |
1369 | 1369 | break; |
1370 | 1370 | } |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | * You can enter whatever you want! |
1402 | 1402 | * We try validating, and customize the results using `self::custom_validation()` |
1403 | 1403 | */ |
1404 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1404 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1405 | 1405 | |
1406 | 1406 | // Needed by the validate funtion |
1407 | 1407 | $failed_validation_page = NULL; |
@@ -1409,14 +1409,14 @@ discard block |
||
1409 | 1409 | |
1410 | 1410 | // Prevent entry limit from running when editing an entry, also |
1411 | 1411 | // prevent form scheduling from preventing editing |
1412 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1412 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1413 | 1413 | |
1414 | 1414 | // Hide fields depending on Edit Entry settings |
1415 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1415 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1416 | 1416 | |
1417 | 1417 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1418 | 1418 | |
1419 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1419 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1420 | 1420 | } |
1421 | 1421 | |
1422 | 1422 | |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | |
1440 | 1440 | $gv_valid = true; |
1441 | 1441 | |
1442 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1442 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1443 | 1443 | |
1444 | 1444 | $value = RGFormsModel::get_field_value( $field ); |
1445 | 1445 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1452,35 +1452,35 @@ discard block |
||
1452 | 1452 | case 'post_image': |
1453 | 1453 | |
1454 | 1454 | // in case nothing is uploaded but there are already files saved |
1455 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1455 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1456 | 1456 | $field->failed_validation = false; |
1457 | 1457 | unset( $field->validation_message ); |
1458 | 1458 | } |
1459 | 1459 | |
1460 | 1460 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1461 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1461 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1462 | 1462 | |
1463 | 1463 | $input_name = 'input_' . $field->id; |
1464 | 1464 | //uploaded |
1465 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1465 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1466 | 1466 | |
1467 | 1467 | //existent |
1468 | 1468 | $entry = $this->get_entry(); |
1469 | 1469 | $value = NULL; |
1470 | - if( isset( $entry[ $field->id ] ) ) { |
|
1470 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1471 | 1471 | $value = json_decode( $entry[ $field->id ], true ); |
1472 | 1472 | } |
1473 | 1473 | |
1474 | 1474 | // count uploaded files and existent entry files |
1475 | 1475 | $count_files = count( $file_names ) + count( $value ); |
1476 | 1476 | |
1477 | - if( $count_files > $field->maxFiles ) { |
|
1477 | + if ( $count_files > $field->maxFiles ) { |
|
1478 | 1478 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1479 | 1479 | $field->failed_validation = 1; |
1480 | 1480 | $gv_valid = false; |
1481 | 1481 | |
1482 | 1482 | // in case of error make sure the newest upload files are removed from the upload input |
1483 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1483 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | } |
@@ -1491,7 +1491,7 @@ discard block |
||
1491 | 1491 | } |
1492 | 1492 | |
1493 | 1493 | // This field has failed validation. |
1494 | - if( !empty( $field->failed_validation ) ) { |
|
1494 | + if ( ! empty( $field->failed_validation ) ) { |
|
1495 | 1495 | |
1496 | 1496 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1497 | 1497 | |
@@ -1509,19 +1509,19 @@ discard block |
||
1509 | 1509 | } |
1510 | 1510 | |
1511 | 1511 | // You can't continue inside a switch, so we do it after. |
1512 | - if( empty( $field->failed_validation ) ) { |
|
1512 | + if ( empty( $field->failed_validation ) ) { |
|
1513 | 1513 | continue; |
1514 | 1514 | } |
1515 | 1515 | |
1516 | 1516 | // checks if the No Duplicates option is not validating entry against itself, since |
1517 | 1517 | // we're editing a stored entry, it would also assume it's a duplicate. |
1518 | - if( !empty( $field->noDuplicates ) ) { |
|
1518 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1519 | 1519 | |
1520 | 1520 | $entry = $this->get_entry(); |
1521 | 1521 | |
1522 | 1522 | // If the value of the entry is the same as the stored value |
1523 | 1523 | // Then we can assume it's not a duplicate, it's the same. |
1524 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1524 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1525 | 1525 | //if value submitted was not changed, then don't validate |
1526 | 1526 | $field->failed_validation = false; |
1527 | 1527 | |
@@ -1534,7 +1534,7 @@ discard block |
||
1534 | 1534 | } |
1535 | 1535 | |
1536 | 1536 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1537 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1537 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1538 | 1538 | unset( $field->validation_message ); |
1539 | 1539 | $field->validation_message = false; |
1540 | 1540 | continue; |
@@ -1546,12 +1546,12 @@ discard block |
||
1546 | 1546 | |
1547 | 1547 | } |
1548 | 1548 | |
1549 | - $validation_results['is_valid'] = $gv_valid; |
|
1549 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1550 | 1550 | |
1551 | 1551 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1552 | 1552 | |
1553 | 1553 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1554 | - $this->form_after_validation = $validation_results['form']; |
|
1554 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1555 | 1555 | |
1556 | 1556 | return $validation_results; |
1557 | 1557 | } |
@@ -1564,7 +1564,7 @@ discard block |
||
1564 | 1564 | */ |
1565 | 1565 | public function get_entry() { |
1566 | 1566 | |
1567 | - if( empty( $this->entry ) ) { |
|
1567 | + if ( empty( $this->entry ) ) { |
|
1568 | 1568 | // Get the database value of the entry that's being edited |
1569 | 1569 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1570 | 1570 | } |
@@ -1596,10 +1596,10 @@ discard block |
||
1596 | 1596 | } |
1597 | 1597 | |
1598 | 1598 | // If edit tab not yet configured, show all fields |
1599 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1599 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1600 | 1600 | |
1601 | 1601 | // Hide fields depending on admin settings |
1602 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1602 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1603 | 1603 | |
1604 | 1604 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1605 | 1605 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1631,7 +1631,7 @@ discard block |
||
1631 | 1631 | */ |
1632 | 1632 | private function filter_fields( $fields, $configured_fields ) { |
1633 | 1633 | |
1634 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1634 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1635 | 1635 | return $fields; |
1636 | 1636 | } |
1637 | 1637 | |
@@ -1644,18 +1644,18 @@ discard block |
||
1644 | 1644 | |
1645 | 1645 | // Remove the fields that have calculation properties and keep them to be used later |
1646 | 1646 | // @since 1.16.2 |
1647 | - if( $field->has_calculation() ) { |
|
1648 | - $this->fields_with_calculation[] = $field; |
|
1647 | + if ( $field->has_calculation() ) { |
|
1648 | + $this->fields_with_calculation[ ] = $field; |
|
1649 | 1649 | // don't remove the calculation fields on form render. |
1650 | 1650 | } |
1651 | 1651 | |
1652 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1652 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1653 | 1653 | unset( $fields[ $key ] ); |
1654 | 1654 | } |
1655 | 1655 | } |
1656 | 1656 | |
1657 | 1657 | // The Edit tab has not been configured, so we return all fields by default. |
1658 | - if( empty( $configured_fields ) ) { |
|
1658 | + if ( empty( $configured_fields ) ) { |
|
1659 | 1659 | return array_values( $fields ); |
1660 | 1660 | } |
1661 | 1661 | |
@@ -1664,8 +1664,8 @@ discard block |
||
1664 | 1664 | |
1665 | 1665 | /** @var GF_Field $field */ |
1666 | 1666 | foreach ( $fields as $field ) { |
1667 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1668 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1667 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1668 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1669 | 1669 | break; |
1670 | 1670 | } |
1671 | 1671 | |
@@ -1688,14 +1688,14 @@ discard block |
||
1688 | 1688 | |
1689 | 1689 | $return_field = $field; |
1690 | 1690 | |
1691 | - if( empty( $field_setting['show_label'] ) ) { |
|
1691 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1692 | 1692 | $return_field->label = ''; |
1693 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1694 | - $return_field->label = $field_setting['custom_label']; |
|
1693 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1694 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1695 | 1695 | } |
1696 | 1696 | |
1697 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1698 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1697 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1698 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1699 | 1699 | } |
1700 | 1700 | |
1701 | 1701 | /** |
@@ -1733,16 +1733,16 @@ discard block |
||
1733 | 1733 | */ |
1734 | 1734 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1735 | 1735 | |
1736 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1737 | - foreach( $fields as $k => $field ) { |
|
1738 | - if( $field->adminOnly ) { |
|
1736 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1737 | + foreach ( $fields as $k => $field ) { |
|
1738 | + if ( $field->adminOnly ) { |
|
1739 | 1739 | unset( $fields[ $k ] ); |
1740 | 1740 | } |
1741 | 1741 | } |
1742 | 1742 | return array_values( $fields ); |
1743 | 1743 | } |
1744 | 1744 | |
1745 | - foreach( $fields as &$field ) { |
|
1745 | + foreach ( $fields as &$field ) { |
|
1746 | 1746 | $field->adminOnly = false; |
1747 | 1747 | } |
1748 | 1748 | |
@@ -1763,7 +1763,7 @@ discard block |
||
1763 | 1763 | */ |
1764 | 1764 | private function unselect_default_values( $form ) { |
1765 | 1765 | |
1766 | - foreach ( $form['fields'] as &$field ) { |
|
1766 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1767 | 1767 | |
1768 | 1768 | if ( empty( $field->choices ) ) { |
1769 | 1769 | continue; |
@@ -1771,7 +1771,7 @@ discard block |
||
1771 | 1771 | |
1772 | 1772 | foreach ( $field->choices as &$choice ) { |
1773 | 1773 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
1774 | - $choice['isSelected'] = false; |
|
1774 | + $choice[ 'isSelected' ] = false; |
|
1775 | 1775 | } |
1776 | 1776 | } |
1777 | 1777 | } |
@@ -1796,22 +1796,22 @@ discard block |
||
1796 | 1796 | */ |
1797 | 1797 | function prefill_conditional_logic( $form ) { |
1798 | 1798 | |
1799 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1799 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1800 | 1800 | return $form; |
1801 | 1801 | } |
1802 | 1802 | |
1803 | 1803 | // Have Conditional Logic pre-fill fields as if the data were default values |
1804 | 1804 | /** @var GF_Field $field */ |
1805 | - foreach ( $form['fields'] as &$field ) { |
|
1805 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1806 | 1806 | |
1807 | - if( 'checkbox' === $field->type ) { |
|
1807 | + if ( 'checkbox' === $field->type ) { |
|
1808 | 1808 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1809 | - $input_id = $input['id']; |
|
1809 | + $input_id = $input[ 'id' ]; |
|
1810 | 1810 | $choice = $field->choices[ $key ]; |
1811 | 1811 | $value = \GV\Utils::get( $this->entry, $input_id ); |
1812 | 1812 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
1813 | - if( $match ) { |
|
1814 | - $field->choices[ $key ]['isSelected'] = true; |
|
1813 | + if ( $match ) { |
|
1814 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
1815 | 1815 | } |
1816 | 1816 | } |
1817 | 1817 | } else { |
@@ -1819,15 +1819,15 @@ discard block |
||
1819 | 1819 | // We need to run through each field to set the default values |
1820 | 1820 | foreach ( $this->entry as $field_id => $field_value ) { |
1821 | 1821 | |
1822 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1822 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1823 | 1823 | |
1824 | - if( 'list' === $field->type ) { |
|
1824 | + if ( 'list' === $field->type ) { |
|
1825 | 1825 | $list_rows = maybe_unserialize( $field_value ); |
1826 | 1826 | |
1827 | 1827 | $list_field_value = array(); |
1828 | - foreach ( (array) $list_rows as $row ) { |
|
1829 | - foreach ( (array) $row as $column ) { |
|
1830 | - $list_field_value[] = $column; |
|
1828 | + foreach ( (array)$list_rows as $row ) { |
|
1829 | + foreach ( (array)$row as $column ) { |
|
1830 | + $list_field_value[ ] = $column; |
|
1831 | 1831 | } |
1832 | 1832 | } |
1833 | 1833 | |
@@ -1862,16 +1862,16 @@ discard block |
||
1862 | 1862 | */ |
1863 | 1863 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
1864 | 1864 | |
1865 | - if( $use_conditional_logic ) { |
|
1865 | + if ( $use_conditional_logic ) { |
|
1866 | 1866 | return $form; |
1867 | 1867 | } |
1868 | 1868 | |
1869 | - foreach( $form['fields'] as &$field ) { |
|
1869 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1870 | 1870 | /* @var GF_Field $field */ |
1871 | 1871 | $field->conditionalLogic = null; |
1872 | 1872 | } |
1873 | 1873 | |
1874 | - unset( $form['button']['conditionalLogic'] ); |
|
1874 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1875 | 1875 | |
1876 | 1876 | return $form; |
1877 | 1877 | |
@@ -1888,7 +1888,7 @@ discard block |
||
1888 | 1888 | */ |
1889 | 1889 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
1890 | 1890 | |
1891 | - if( ! $this->is_edit_entry() ) { |
|
1891 | + if ( ! $this->is_edit_entry() ) { |
|
1892 | 1892 | return $has_conditional_logic; |
1893 | 1893 | } |
1894 | 1894 | |
@@ -1920,44 +1920,44 @@ discard block |
||
1920 | 1920 | * 2. There are two entries embedded using oEmbed |
1921 | 1921 | * 3. One of the entries has just been saved |
1922 | 1922 | */ |
1923 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1923 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1924 | 1924 | |
1925 | 1925 | $error = true; |
1926 | 1926 | |
1927 | 1927 | } |
1928 | 1928 | |
1929 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1929 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1930 | 1930 | |
1931 | 1931 | $error = true; |
1932 | 1932 | |
1933 | - } elseif( ! $this->verify_nonce() ) { |
|
1933 | + } elseif ( ! $this->verify_nonce() ) { |
|
1934 | 1934 | |
1935 | 1935 | /** |
1936 | 1936 | * If the Entry is embedded, there may be two entries on the same page. |
1937 | 1937 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1938 | 1938 | */ |
1939 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1939 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1940 | 1940 | $error = true; |
1941 | 1941 | } else { |
1942 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1942 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
1943 | 1943 | } |
1944 | 1944 | |
1945 | 1945 | } |
1946 | 1946 | |
1947 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1948 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1947 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1948 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
1949 | 1949 | } |
1950 | 1950 | |
1951 | - if( $this->entry['status'] === 'trash' ) { |
|
1952 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1951 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
1952 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1953 | 1953 | } |
1954 | 1954 | |
1955 | 1955 | // No errors; everything's fine here! |
1956 | - if( empty( $error ) ) { |
|
1956 | + if ( empty( $error ) ) { |
|
1957 | 1957 | return true; |
1958 | 1958 | } |
1959 | 1959 | |
1960 | - if( $echo && $error !== true ) { |
|
1960 | + if ( $echo && $error !== true ) { |
|
1961 | 1961 | |
1962 | 1962 | $error = esc_html( $error ); |
1963 | 1963 | |
@@ -1965,10 +1965,10 @@ discard block |
||
1965 | 1965 | * @since 1.9 |
1966 | 1966 | */ |
1967 | 1967 | if ( ! empty( $this->entry ) ) { |
1968 | - $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;" ) ); |
|
1968 | + $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;" ) ); |
|
1969 | 1969 | } |
1970 | 1970 | |
1971 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1971 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
1972 | 1972 | } |
1973 | 1973 | |
1974 | 1974 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1988,17 +1988,17 @@ discard block |
||
1988 | 1988 | |
1989 | 1989 | $error = NULL; |
1990 | 1990 | |
1991 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1992 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
1991 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1992 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
1993 | 1993 | } |
1994 | 1994 | |
1995 | 1995 | // No errors; everything's fine here! |
1996 | - if( empty( $error ) ) { |
|
1996 | + if ( empty( $error ) ) { |
|
1997 | 1997 | return true; |
1998 | 1998 | } |
1999 | 1999 | |
2000 | - if( $echo ) { |
|
2001 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
2000 | + if ( $echo ) { |
|
2001 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
2002 | 2002 | } |
2003 | 2003 | |
2004 | 2004 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2019,14 +2019,14 @@ discard block |
||
2019 | 2019 | private function check_user_cap_edit_field( $field ) { |
2020 | 2020 | |
2021 | 2021 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
2022 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2022 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2023 | 2023 | return true; |
2024 | 2024 | } |
2025 | 2025 | |
2026 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
2026 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
2027 | 2027 | |
2028 | - if( $field_cap ) { |
|
2029 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
2028 | + if ( $field_cap ) { |
|
2029 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
2030 | 2030 | } |
2031 | 2031 | |
2032 | 2032 | return false; |
@@ -2040,17 +2040,17 @@ discard block |
||
2040 | 2040 | public function verify_nonce() { |
2041 | 2041 | |
2042 | 2042 | // Verify form submitted for editing single |
2043 | - if( $this->is_edit_entry_submission() ) { |
|
2043 | + if ( $this->is_edit_entry_submission() ) { |
|
2044 | 2044 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2045 | 2045 | } |
2046 | 2046 | |
2047 | 2047 | // Verify |
2048 | - else if( ! $this->is_edit_entry() ) { |
|
2048 | + else if ( ! $this->is_edit_entry() ) { |
|
2049 | 2049 | $valid = false; |
2050 | 2050 | } |
2051 | 2051 | |
2052 | 2052 | else { |
2053 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2053 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2054 | 2054 | } |
2055 | 2055 | |
2056 | 2056 | /** |
@@ -24,6 +24,6 @@ |
||
24 | 24 | $plugin_theme_hooks_files = glob( $include_path . 'class-gravityview-{plugin,theme}-hooks-*.php', $glob_flags ); |
25 | 25 | |
26 | 26 | // Load all plugin and theme files automatically |
27 | -foreach ( (array) $plugin_theme_hooks_files as $gv_hooks_filename ) { |
|
27 | +foreach ( (array)$plugin_theme_hooks_files as $gv_hooks_filename ) { |
|
28 | 28 | include $gv_hooks_filename; |
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'type' => 'radio', |
65 | 65 | 'full_width' => true, |
66 | 66 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
67 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
67 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
68 | 68 | 'value' => 'any', |
69 | 69 | 'class' => 'hide-if-js', |
70 | 70 | 'options' => array( |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
88 | 88 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
89 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
89 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
90 | 90 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
91 | 91 | |
92 | 92 | // ajax - get the searchable fields |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
230 | 230 | $script_source = empty( $script_min ) ? '/source' : ''; |
231 | 231 | |
232 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
232 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
233 | 233 | |
234 | 234 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
235 | 235 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
252 | 252 | */ |
253 | 253 | public function register_no_conflict( $allowed ) { |
254 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
254 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
255 | 255 | return $allowed; |
256 | 256 | } |
257 | 257 | |
@@ -264,24 +264,24 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public static function get_searchable_fields() { |
266 | 266 | |
267 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
267 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
268 | 268 | exit( '0' ); |
269 | 269 | } |
270 | 270 | |
271 | 271 | $form = ''; |
272 | 272 | |
273 | 273 | // Fetch the form for the current View |
274 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
274 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
275 | 275 | |
276 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
276 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
277 | 277 | |
278 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
278 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
279 | 279 | |
280 | - $form = (int) $_POST['formid']; |
|
280 | + $form = (int)$_POST[ 'formid' ]; |
|
281 | 281 | |
282 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
282 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
283 | 283 | |
284 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
284 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
285 | 285 | |
286 | 286 | } |
287 | 287 | |
@@ -331,14 +331,14 @@ discard block |
||
331 | 331 | ); |
332 | 332 | |
333 | 333 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
334 | - $custom_fields['is_approved'] = array( |
|
334 | + $custom_fields[ 'is_approved' ] = array( |
|
335 | 335 | 'text' => esc_html__( 'Approval Status', 'gravityview' ), |
336 | 336 | 'type' => 'multi', |
337 | 337 | ); |
338 | 338 | } |
339 | 339 | |
340 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
341 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
340 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
341 | + $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] ); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | // Get fields with sub-inputs and no parent |
@@ -360,13 +360,13 @@ discard block |
||
360 | 360 | |
361 | 361 | foreach ( $fields as $id => $field ) { |
362 | 362 | |
363 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
363 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
364 | 364 | continue; |
365 | 365 | } |
366 | 366 | |
367 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
367 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
368 | 368 | |
369 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
369 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
390 | 390 | |
391 | 391 | // @todo - This needs to be improved - many fields have . including products and addresses |
392 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
392 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
393 | 393 | $input_type = 'boolean'; // on/off checkbox |
394 | 394 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
395 | 395 | $input_type = 'multi'; //multiselect |
@@ -433,19 +433,19 @@ discard block |
||
433 | 433 | $post_id = 0; |
434 | 434 | |
435 | 435 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
436 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
437 | - $post_id = absint( $widget_args['post_id'] ); |
|
436 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
437 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
438 | 438 | } |
439 | 439 | // We're in the WordPress Widget context, and the base View ID should be used |
440 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
441 | - $post_id = absint( $widget_args['view_id'] ); |
|
440 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
441 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | $args = gravityview_get_permalink_query_args( $post_id ); |
445 | 445 | |
446 | 446 | // Add hidden fields to the search form |
447 | 447 | foreach ( $args as $key => $value ) { |
448 | - $search_fields[] = array( |
|
448 | + $search_fields[ ] = array( |
|
449 | 449 | 'name' => $key, |
450 | 450 | 'input' => 'hidden', |
451 | 451 | 'value' => $value, |
@@ -484,22 +484,22 @@ discard block |
||
484 | 484 | /** |
485 | 485 | * Include the sidebar Widgets. |
486 | 486 | */ |
487 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
487 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
488 | 488 | |
489 | 489 | foreach ( $widgets as $widget ) { |
490 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
491 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
490 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
491 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
492 | 492 | foreach ( $_fields as $field ) { |
493 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
493 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | } |
497 | 497 | } |
498 | 498 | |
499 | 499 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
500 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
500 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
501 | 501 | foreach ( $_fields as $field ) { |
502 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
502 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | } |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
530 | 530 | } |
531 | 531 | |
532 | - if( 'post' === $this->search_method ) { |
|
532 | + if ( 'post' === $this->search_method ) { |
|
533 | 533 | $get = $_POST; |
534 | 534 | } else { |
535 | 535 | $get = $_GET; |
@@ -548,14 +548,14 @@ discard block |
||
548 | 548 | $get = gv_map_deep( $get, 'rawurldecode' ); |
549 | 549 | |
550 | 550 | // Make sure array key is set up |
551 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
551 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
552 | 552 | |
553 | 553 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
554 | 554 | |
555 | 555 | // add free search |
556 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
556 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
557 | 557 | |
558 | - $search_all_value = trim( $get['gv_search'] ); |
|
558 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
559 | 559 | |
560 | 560 | /** |
561 | 561 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | } |
581 | 581 | |
582 | 582 | foreach ( $words as $word ) { |
583 | - $search_criteria['field_filters'][] = array( |
|
583 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
584 | 584 | 'key' => null, // The field ID to search |
585 | 585 | 'value' => $word, // The value to search |
586 | 586 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -593,14 +593,14 @@ discard block |
||
593 | 593 | /** |
594 | 594 | * Get and normalize the dates according to the input format. |
595 | 595 | */ |
596 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
597 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
596 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
597 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
598 | 598 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
602 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
603 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
602 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
603 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
604 | 604 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
605 | 605 | } |
606 | 606 | } |
@@ -635,22 +635,22 @@ discard block |
||
635 | 635 | */ |
636 | 636 | if ( ! empty( $curr_start ) ) { |
637 | 637 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
638 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
638 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | if ( ! empty( $curr_end ) ) { |
642 | 642 | // Fast-forward 24 hour on the end time |
643 | 643 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
644 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
645 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
646 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
644 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
645 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
646 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | } |
650 | 650 | |
651 | 651 | // search for a specific entry ID |
652 | 652 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
653 | - $search_criteria['field_filters'][] = array( |
|
653 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
654 | 654 | 'key' => 'id', |
655 | 655 | 'value' => absint( $get[ 'gv_id' ] ), |
656 | 656 | 'operator' => '=', |
@@ -659,41 +659,41 @@ discard block |
||
659 | 659 | |
660 | 660 | // search for a specific Created_by ID |
661 | 661 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
662 | - $search_criteria['field_filters'][] = array( |
|
662 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
663 | 663 | 'key' => 'created_by', |
664 | - 'value' => $get['gv_by'], |
|
664 | + 'value' => $get[ 'gv_by' ], |
|
665 | 665 | 'operator' => '=', |
666 | 666 | ); |
667 | 667 | } |
668 | 668 | |
669 | 669 | // Get search mode passed in URL |
670 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
670 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
671 | 671 | |
672 | 672 | // get the other search filters |
673 | 673 | foreach ( $get as $key => $value ) { |
674 | 674 | |
675 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
675 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
676 | 676 | continue; |
677 | 677 | } |
678 | 678 | |
679 | 679 | $filter_key = $this->convert_request_key_to_filter_key( $key ); |
680 | 680 | |
681 | 681 | // could return simple filter or multiple filters |
682 | - if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) { |
|
682 | + if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) { |
|
683 | 683 | continue; |
684 | 684 | } |
685 | 685 | |
686 | 686 | $filter = $this->prepare_field_filter( $filter_key, $value, $view ); |
687 | 687 | |
688 | - if ( isset( $filter[0]['value'] ) ) { |
|
689 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
688 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
689 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
690 | 690 | |
691 | 691 | // if date range type, set search mode to ALL |
692 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
692 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
693 | 693 | $mode = 'all'; |
694 | 694 | } |
695 | - } elseif( !empty( $filter ) ) { |
|
696 | - $search_criteria['field_filters'][] = $filter; |
|
695 | + } elseif ( ! empty( $filter ) ) { |
|
696 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
697 | 697 | } |
698 | 698 | } |
699 | 699 | |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | * @since 1.5.1 |
703 | 703 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
704 | 704 | */ |
705 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
705 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
706 | 706 | |
707 | 707 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
708 | 708 | |
@@ -727,19 +727,19 @@ discard block |
||
727 | 727 | */ |
728 | 728 | $search_criteria = $this->filter_entries( array(), null, array( 'id' => $view->ID ), true /** force search_criteria */ ); |
729 | 729 | |
730 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
730 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
731 | 731 | return; |
732 | 732 | } |
733 | 733 | |
734 | 734 | $widgets = $view->widgets->by_id( $this->widget_id ); |
735 | 735 | if ( $widgets->count() ) { |
736 | 736 | $widgets = $widgets->all(); |
737 | - $widget = $widgets[0]; |
|
737 | + $widget = $widgets[ 0 ]; |
|
738 | 738 | |
739 | 739 | $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ); |
740 | 740 | |
741 | - foreach ( (array) $search_fields as $search_field ) { |
|
742 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
741 | + foreach ( (array)$search_fields as $search_field ) { |
|
742 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
743 | 743 | $created_by_text_mode = true; |
744 | 744 | } |
745 | 745 | } |
@@ -747,19 +747,19 @@ discard block |
||
747 | 747 | |
748 | 748 | $extra_conditions = array(); |
749 | 749 | |
750 | - foreach ( $search_criteria['field_filters'] as &$filter ) { |
|
750 | + foreach ( $search_criteria[ 'field_filters' ] as &$filter ) { |
|
751 | 751 | if ( ! is_array( $filter ) ) { |
752 | 752 | continue; |
753 | 753 | } |
754 | 754 | |
755 | 755 | // Construct a manual query for unapproved statuses |
756 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) { |
|
757 | - $_tmp_query = new GF_Query( $view->form->ID, array( |
|
756 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) { |
|
757 | + $_tmp_query = new GF_Query( $view->form->ID, array( |
|
758 | 758 | 'field_filters' => array( |
759 | 759 | array( |
760 | 760 | 'operator' => 'in', |
761 | 761 | 'key' => 'is_approved', |
762 | - 'value' => (array) $filter['value'], |
|
762 | + 'value' => (array)$filter[ 'value' ], |
|
763 | 763 | ), |
764 | 764 | array( |
765 | 765 | 'operator' => 'is', |
@@ -771,25 +771,25 @@ discard block |
||
771 | 771 | ) ); |
772 | 772 | $_tmp_query_parts = $_tmp_query->_introspect(); |
773 | 773 | |
774 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
774 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
775 | 775 | |
776 | 776 | $filter = false; |
777 | 777 | continue; |
778 | 778 | } |
779 | 779 | |
780 | 780 | // Construct manual query for text mode creator search |
781 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
782 | - $extra_conditions[] = new GravityView_Widget_Search_GF_Query_Condition( $filter, $view ); |
|
781 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
782 | + $extra_conditions[ ] = new GravityView_Widget_Search_GF_Query_Condition( $filter, $view ); |
|
783 | 783 | $filter = false; |
784 | 784 | continue; |
785 | 785 | } |
786 | 786 | |
787 | 787 | // By default, we want searches to be wildcard for each field. |
788 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
788 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
789 | 789 | |
790 | 790 | // For multichoice, let's have an in (OR) search. |
791 | - if ( is_array( $filter['value'] ) ) { |
|
792 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
791 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
792 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | /** |
@@ -797,10 +797,10 @@ discard block |
||
797 | 797 | * @param string $operator Existing search operator |
798 | 798 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
799 | 799 | */ |
800 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
800 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
801 | 801 | } |
802 | 802 | |
803 | - $search_criteria['field_filters'] = array_filter( $search_criteria['field_filters'] ); |
|
803 | + $search_criteria[ 'field_filters' ] = array_filter( $search_criteria[ 'field_filters' ] ); |
|
804 | 804 | |
805 | 805 | /** |
806 | 806 | * Parse the filter criteria to generate the needed |
@@ -813,12 +813,12 @@ discard block |
||
813 | 813 | /** |
814 | 814 | * Grab the current clauses. We'll be combining them shortly. |
815 | 815 | */ |
816 | - $query_parts = $query->_introspect(); |
|
816 | + $query_parts = $query->_introspect(); |
|
817 | 817 | |
818 | 818 | /** |
819 | 819 | * Combine the parts as a new WHERE clause. |
820 | 820 | */ |
821 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'], $_tmp_query_parts['where'] ), $extra_conditions ) ); |
|
821 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ], $_tmp_query_parts[ 'where' ] ), $extra_conditions ) ); |
|
822 | 822 | $query->where( $where ); |
823 | 823 | } |
824 | 824 | |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | $field_id = str_replace( 'filter_', '', $key ); |
842 | 842 | |
843 | 843 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
844 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
844 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
845 | 845 | $field_id = str_replace( '_', '.', $field_id ); |
846 | 846 | } |
847 | 847 | |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | |
877 | 877 | case 'select': |
878 | 878 | case 'radio': |
879 | - $filter['operator'] = 'is'; |
|
879 | + $filter[ 'operator' ] = 'is'; |
|
880 | 880 | break; |
881 | 881 | |
882 | 882 | case 'post_category': |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | |
891 | 891 | foreach ( $value as $val ) { |
892 | 892 | $cat = get_term( $val, 'category' ); |
893 | - $filter[] = array( |
|
893 | + $filter[ ] = array( |
|
894 | 894 | 'key' => $filter_key, |
895 | 895 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
896 | 896 | 'operator' => 'is', |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | $filter = array(); |
910 | 910 | |
911 | 911 | foreach ( $value as $val ) { |
912 | - $filter[] = array( 'key' => $filter_key, 'value' => $val ); |
|
912 | + $filter[ ] = array( 'key' => $filter_key, 'value' => $val ); |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | break; |
@@ -918,9 +918,9 @@ discard block |
||
918 | 918 | // convert checkbox on/off into the correct search filter |
919 | 919 | if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
920 | 920 | foreach ( $form_field->inputs as $k => $input ) { |
921 | - if ( $input['id'] == $filter_key ) { |
|
922 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
923 | - $filter['operator'] = 'is'; |
|
921 | + if ( $input[ 'id' ] == $filter_key ) { |
|
922 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
923 | + $filter[ 'operator' ] = 'is'; |
|
924 | 924 | break; |
925 | 925 | } |
926 | 926 | } |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | $filter = array(); |
931 | 931 | |
932 | 932 | foreach ( $value as $val ) { |
933 | - $filter[] = array( |
|
933 | + $filter[ ] = array( |
|
934 | 934 | 'key' => $filter_key, |
935 | 935 | 'value' => $val, |
936 | 936 | 'operator' => 'is', |
@@ -951,9 +951,9 @@ discard block |
||
951 | 951 | foreach ( $words as $word ) { |
952 | 952 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
953 | 953 | // Keep the same key for each filter |
954 | - $filter['value'] = $word; |
|
954 | + $filter[ 'value' ] = $word; |
|
955 | 955 | // Add a search for the value |
956 | - $filters[] = $filter; |
|
956 | + $filters[ ] = $filter; |
|
957 | 957 | } |
958 | 958 | } |
959 | 959 | |
@@ -967,19 +967,19 @@ discard block |
||
967 | 967 | |
968 | 968 | foreach ( $searchable_fields as $searchable_field ) { |
969 | 969 | |
970 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
970 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
971 | 971 | continue; |
972 | 972 | } |
973 | 973 | |
974 | 974 | // Only exact-match dropdowns, not text search |
975 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
975 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
976 | 976 | continue; |
977 | 977 | } |
978 | 978 | |
979 | 979 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
980 | 980 | |
981 | 981 | if ( 4 === $input_id ) { |
982 | - $filter['operator'] = 'is'; |
|
982 | + $filter[ 'operator' ] = 'is'; |
|
983 | 983 | }; |
984 | 984 | } |
985 | 985 | } |
@@ -1006,12 +1006,12 @@ discard block |
||
1006 | 1006 | * @since 1.16.3 |
1007 | 1007 | * Safeguard until GF implements '<=' operator |
1008 | 1008 | */ |
1009 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1009 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1010 | 1010 | $operator = '<'; |
1011 | 1011 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
1012 | 1012 | } |
1013 | 1013 | |
1014 | - $filter[] = array( |
|
1014 | + $filter[ ] = array( |
|
1015 | 1015 | 'key' => $filter_key, |
1016 | 1016 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
1017 | 1017 | 'operator' => $operator, |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | } |
1020 | 1020 | } else { |
1021 | 1021 | $date = $value; |
1022 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1022 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | break; |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | 'ymd_dot' => 'Y.m.d', |
1051 | 1051 | ); |
1052 | 1052 | |
1053 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
1053 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
1054 | 1054 | $format = $datepicker[ $field->dateFormat ]; |
1055 | 1055 | } |
1056 | 1056 | |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | public function add_template_path( $file_paths ) { |
1088 | 1088 | |
1089 | 1089 | // Index 100 is the default GravityView template path. |
1090 | - $file_paths[102] = self::$file . 'templates/'; |
|
1090 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
1091 | 1091 | |
1092 | 1092 | return $file_paths; |
1093 | 1093 | } |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | $has_date = false; |
1107 | 1107 | |
1108 | 1108 | foreach ( $search_fields as $k => $field ) { |
1109 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1109 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1110 | 1110 | $has_date = true; |
1111 | 1111 | break; |
1112 | 1112 | } |
@@ -1133,7 +1133,7 @@ discard block |
||
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | // get configured search fields |
1136 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
1136 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
1137 | 1137 | |
1138 | 1138 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
1139 | 1139 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1148,40 +1148,40 @@ discard block |
||
1148 | 1148 | |
1149 | 1149 | $updated_field = $this->get_search_filter_details( $updated_field ); |
1150 | 1150 | |
1151 | - switch ( $field['field'] ) { |
|
1151 | + switch ( $field[ 'field' ] ) { |
|
1152 | 1152 | |
1153 | 1153 | case 'search_all': |
1154 | - $updated_field['key'] = 'search_all'; |
|
1155 | - $updated_field['input'] = 'search_all'; |
|
1156 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1154 | + $updated_field[ 'key' ] = 'search_all'; |
|
1155 | + $updated_field[ 'input' ] = 'search_all'; |
|
1156 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1157 | 1157 | break; |
1158 | 1158 | |
1159 | 1159 | case 'entry_date': |
1160 | - $updated_field['key'] = 'entry_date'; |
|
1161 | - $updated_field['input'] = 'entry_date'; |
|
1162 | - $updated_field['value'] = array( |
|
1160 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1161 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1162 | + $updated_field[ 'value' ] = array( |
|
1163 | 1163 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1164 | 1164 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1165 | 1165 | ); |
1166 | 1166 | break; |
1167 | 1167 | |
1168 | 1168 | case 'entry_id': |
1169 | - $updated_field['key'] = 'entry_id'; |
|
1170 | - $updated_field['input'] = 'entry_id'; |
|
1171 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1169 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1170 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1171 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1172 | 1172 | break; |
1173 | 1173 | |
1174 | 1174 | case 'created_by': |
1175 | - $updated_field['key'] = 'created_by'; |
|
1176 | - $updated_field['name'] = 'gv_by'; |
|
1177 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1178 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
1175 | + $updated_field[ 'key' ] = 'created_by'; |
|
1176 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1177 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1178 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
1179 | 1179 | break; |
1180 | 1180 | |
1181 | 1181 | case 'is_approved': |
1182 | - $updated_field['key'] = 'is_approved'; |
|
1183 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1184 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
1182 | + $updated_field[ 'key' ] = 'is_approved'; |
|
1183 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1184 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
1185 | 1185 | break; |
1186 | 1186 | } |
1187 | 1187 | |
@@ -1200,16 +1200,16 @@ discard block |
||
1200 | 1200 | */ |
1201 | 1201 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
1202 | 1202 | |
1203 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1203 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1204 | 1204 | |
1205 | 1205 | /** @since 1.14 */ |
1206 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1206 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1207 | 1207 | |
1208 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1208 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1209 | 1209 | |
1210 | 1210 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1211 | 1211 | |
1212 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1212 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1213 | 1213 | |
1214 | 1214 | if ( $this->has_date_field( $search_fields ) ) { |
1215 | 1215 | // enqueue datepicker stuff only if needed! |
@@ -1231,10 +1231,10 @@ discard block |
||
1231 | 1231 | public static function get_search_class( $custom_class = '' ) { |
1232 | 1232 | $gravityview_view = GravityView_View::getInstance(); |
1233 | 1233 | |
1234 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1234 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1235 | 1235 | |
1236 | - if ( ! empty( $custom_class ) ) { |
|
1237 | - $search_class .= ' '.$custom_class; |
|
1236 | + if ( ! empty( $custom_class ) ) { |
|
1237 | + $search_class .= ' ' . $custom_class; |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | /** |
@@ -1278,9 +1278,9 @@ discard block |
||
1278 | 1278 | |
1279 | 1279 | if ( ! $label ) { |
1280 | 1280 | |
1281 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1281 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1282 | 1282 | |
1283 | - switch( $field['field'] ) { |
|
1283 | + switch ( $field[ 'field' ] ) { |
|
1284 | 1284 | case 'search_all': |
1285 | 1285 | $label = __( 'Search Entries:', 'gravityview' ); |
1286 | 1286 | break; |
@@ -1292,10 +1292,10 @@ discard block |
||
1292 | 1292 | break; |
1293 | 1293 | default: |
1294 | 1294 | // If this is a field input, not a field |
1295 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1295 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1296 | 1296 | |
1297 | 1297 | // Get the label for the field in question, which returns an array |
1298 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1298 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1299 | 1299 | |
1300 | 1300 | // Get the item with the `label` key |
1301 | 1301 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1334,32 +1334,32 @@ discard block |
||
1334 | 1334 | $form = $gravityview_view->getForm(); |
1335 | 1335 | |
1336 | 1336 | // for advanced field ids (eg, first name / last name ) |
1337 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1337 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1338 | 1338 | |
1339 | 1339 | // get searched value from $_GET/$_POST (string or array) |
1340 | 1340 | $value = $this->rgget_or_rgpost( $name ); |
1341 | 1341 | |
1342 | 1342 | // get form field details |
1343 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1343 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1344 | 1344 | |
1345 | 1345 | $filter = array( |
1346 | - 'key' => $field['field'], |
|
1346 | + 'key' => $field[ 'field' ], |
|
1347 | 1347 | 'name' => $name, |
1348 | 1348 | 'label' => self::get_field_label( $field, $form_field ), |
1349 | - 'input' => $field['input'], |
|
1349 | + 'input' => $field[ 'input' ], |
|
1350 | 1350 | 'value' => $value, |
1351 | - 'type' => $form_field['type'], |
|
1351 | + 'type' => $form_field[ 'type' ], |
|
1352 | 1352 | ); |
1353 | 1353 | |
1354 | 1354 | // collect choices |
1355 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1356 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1357 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1358 | - $filter['choices'] = $form_field['choices']; |
|
1355 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1356 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1357 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1358 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1362 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1361 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1362 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1363 | 1363 | } |
1364 | 1364 | |
1365 | 1365 | return $filter; |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | |
1384 | 1384 | $choices = array(); |
1385 | 1385 | foreach ( $users as $user ) { |
1386 | - $choices[] = array( |
|
1386 | + $choices[ ] = array( |
|
1387 | 1387 | 'value' => $user->ID, |
1388 | 1388 | 'text' => $user->display_name, |
1389 | 1389 | ); |
@@ -1403,9 +1403,9 @@ discard block |
||
1403 | 1403 | |
1404 | 1404 | $choices = array(); |
1405 | 1405 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
1406 | - $choices[] = array( |
|
1407 | - 'value' => $status['value'], |
|
1408 | - 'text' => $status['label'], |
|
1406 | + $choices[ ] = array( |
|
1407 | + 'value' => $status[ 'value' ], |
|
1408 | + 'text' => $status[ 'label' ], |
|
1409 | 1409 | ); |
1410 | 1410 | } |
1411 | 1411 | |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | */ |
1458 | 1458 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1459 | 1459 | |
1460 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1460 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1461 | 1461 | |
1462 | 1462 | return $js_dependencies; |
1463 | 1463 | } |
@@ -1501,7 +1501,7 @@ discard block |
||
1501 | 1501 | 'isRTL' => is_rtl(), |
1502 | 1502 | ), $view_data ); |
1503 | 1503 | |
1504 | - $localizations['datepicker'] = $datepicker_settings; |
|
1504 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1505 | 1505 | |
1506 | 1506 | return $localizations; |
1507 | 1507 | |
@@ -1528,7 +1528,7 @@ discard block |
||
1528 | 1528 | * @return void |
1529 | 1529 | */ |
1530 | 1530 | private function maybe_enqueue_flexibility() { |
1531 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1531 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1532 | 1532 | wp_enqueue_script( 'gv-flexibility' ); |
1533 | 1533 | } |
1534 | 1534 | } |
@@ -1550,7 +1550,7 @@ discard block |
||
1550 | 1550 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1551 | 1551 | |
1552 | 1552 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1553 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1553 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1554 | 1554 | |
1555 | 1555 | /** |
1556 | 1556 | * @filter `gravityview_search_datepicker_class` |
@@ -1629,7 +1629,7 @@ discard block |
||
1629 | 1629 | public function add_preview_inputs() { |
1630 | 1630 | global $wp; |
1631 | 1631 | |
1632 | - if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) { |
|
1632 | + if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) { |
|
1633 | 1633 | return; |
1634 | 1634 | } |
1635 | 1635 | |
@@ -1654,7 +1654,7 @@ discard block |
||
1654 | 1654 | */ |
1655 | 1655 | class GravityView_Widget_Search_GF_Query_Condition extends \GF_Query_Condition { |
1656 | 1656 | public function __construct( $filter, $view ) { |
1657 | - $this->value = $filter['value']; |
|
1657 | + $this->value = $filter[ 'value' ]; |
|
1658 | 1658 | $this->view = $view; |
1659 | 1659 | } |
1660 | 1660 | |
@@ -1686,11 +1686,11 @@ discard block |
||
1686 | 1686 | $conditions = array(); |
1687 | 1687 | |
1688 | 1688 | foreach ( $user_fields as $user_field ) { |
1689 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1689 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1690 | 1690 | } |
1691 | 1691 | |
1692 | 1692 | foreach ( $user_meta_fields as $meta_field ) { |
1693 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1693 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1694 | 1694 | } |
1695 | 1695 | |
1696 | 1696 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | |
126 | 126 | $form = false; |
127 | 127 | |
128 | - if( $entry ) { |
|
129 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
128 | + if ( $entry ) { |
|
129 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | return $form; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | - return (bool) $has_transaction_data; |
|
205 | + return (bool)$has_transaction_data; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
242 | 242 | |
243 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
243 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
244 | 244 | |
245 | 245 | return $result; |
246 | 246 | } |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
259 | 259 | */ |
260 | - public static function get_forms( $active = true, $trash = false ) { |
|
260 | + public static function get_forms( $active = true, $trash = false ) { |
|
261 | 261 | $forms = array(); |
262 | 262 | if ( class_exists( 'GFAPI' ) ) { |
263 | - if( 'any' === $active ) { |
|
263 | + if ( 'any' === $active ) { |
|
264 | 264 | $active_forms = GFAPI::get_forms( true, $trash ); |
265 | 265 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
266 | 266 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | $has_post_fields = false; |
292 | 292 | |
293 | 293 | if ( $form ) { |
294 | - foreach ( $form['fields'] as $field ) { |
|
295 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
296 | - $fields["{$field['id']}"] = array( |
|
294 | + foreach ( $form[ 'fields' ] as $field ) { |
|
295 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
296 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
297 | 297 | 'label' => \GV\Utils::get( $field, 'label' ), |
298 | 298 | 'parent' => null, |
299 | 299 | 'type' => \GV\Utils::get( $field, 'type' ), |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | ); |
303 | 303 | } |
304 | 304 | |
305 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
306 | - foreach ( $field['inputs'] as $input ) { |
|
305 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
306 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
307 | 307 | |
308 | - if( ! empty( $input['isHidden'] ) ) { |
|
308 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
309 | 309 | continue; |
310 | 310 | } |
311 | 311 | |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | * @hack |
314 | 314 | * In case of email/email confirmation, the input for email has the same id as the parent field |
315 | 315 | */ |
316 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
316 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
317 | 317 | continue; |
318 | 318 | } |
319 | - $fields["{$input['id']}"] = array( |
|
319 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
320 | 320 | 'label' => \GV\Utils::get( $input, 'label' ), |
321 | 321 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
322 | 322 | 'parent' => $field, |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } |
329 | 329 | |
330 | 330 | |
331 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
331 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
332 | 332 | $has_product_fields = true; |
333 | 333 | } |
334 | 334 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @since 1.7 |
343 | 343 | */ |
344 | 344 | if ( $has_post_fields ) { |
345 | - $fields['post_id'] = array( |
|
345 | + $fields[ 'post_id' ] = array( |
|
346 | 346 | 'label' => __( 'Post ID', 'gravityview' ), |
347 | 347 | 'type' => 'post_id', |
348 | 348 | ); |
@@ -355,11 +355,11 @@ discard block |
||
355 | 355 | foreach ( $payment_fields as $payment_field ) { |
356 | 356 | |
357 | 357 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
358 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
358 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
359 | 359 | continue; |
360 | 360 | } |
361 | 361 | |
362 | - $fields["{$payment_field->name}"] = array( |
|
362 | + $fields[ "{$payment_field->name}" ] = array( |
|
363 | 363 | 'label' => $payment_field->label, |
364 | 364 | 'desc' => $payment_field->description, |
365 | 365 | 'type' => $payment_field->name, |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | |
392 | 392 | $fields = array(); |
393 | 393 | |
394 | - foreach ( $extra_fields as $key => $field ){ |
|
395 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
396 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
394 | + foreach ( $extra_fields as $key => $field ) { |
|
395 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
396 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
@@ -433,33 +433,33 @@ discard block |
||
433 | 433 | 'search_criteria' => null, |
434 | 434 | 'sorting' => null, |
435 | 435 | 'paging' => null, |
436 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
436 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
437 | 437 | 'context_view_id' => null, |
438 | 438 | ); |
439 | 439 | |
440 | 440 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
441 | 441 | |
442 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
443 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
442 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
443 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
444 | 444 | |
445 | 445 | if ( ! is_array( $filter ) ) { |
446 | 446 | continue; |
447 | 447 | } |
448 | 448 | |
449 | 449 | // By default, we want searches to be wildcard for each field. |
450 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
450 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
451 | 451 | |
452 | 452 | /** |
453 | 453 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
454 | 454 | * @param string $operator Existing search operator |
455 | 455 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
456 | 456 | */ |
457 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
457 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | // don't send just the [mode] without any field filter. |
461 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
462 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
461 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
462 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | } |
@@ -470,33 +470,33 @@ discard block |
||
470 | 470 | * Prepare date formats to be in Gravity Forms DB format; |
471 | 471 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
472 | 472 | */ |
473 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
473 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
474 | 474 | |
475 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
475 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
476 | 476 | |
477 | 477 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
478 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
478 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
479 | 479 | |
480 | 480 | if ( $date ) { |
481 | 481 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
482 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
482 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
483 | 483 | } else { |
484 | - gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria['search_criteria'][ $key ] ) ); |
|
484 | + gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria[ 'search_criteria' ][ $key ] ) ); |
|
485 | 485 | |
486 | 486 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
487 | - unset( $criteria['search_criteria'][ $key ] ); |
|
487 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | - if ( empty( $criteria['context_view_id'] ) ) { |
|
492 | + if ( empty( $criteria[ 'context_view_id' ] ) ) { |
|
493 | 493 | // Calculate the context view id and send it to the advanced filter |
494 | 494 | if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
495 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
495 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
496 | 496 | } else if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
497 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
497 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
498 | 498 | } else if ( 'delete' === GFForms::get( 'action' ) ) { |
499 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
499 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * @param array $form_ids Forms to search |
507 | 507 | * @param int $view_id ID of the view being used to search |
508 | 508 | */ |
509 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
509 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
510 | 510 | |
511 | 511 | return (array)$criteria; |
512 | 512 | } |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | /** Reduce # of database calls */ |
542 | 542 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
543 | 543 | |
544 | - if ( ! empty( $criteria['cache'] ) ) { |
|
544 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
545 | 545 | |
546 | 546 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
547 | 547 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | |
550 | 550 | // Still update the total count when using cached results |
551 | 551 | if ( ! is_null( $total ) ) { |
552 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
552 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | $return = $entries; |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | $entries = apply_filters_ref_array( 'gravityview_before_get_entries', array( null, $criteria, $passed_criteria, &$total ) ); |
572 | 572 | |
573 | 573 | // No entries returned from gravityview_before_get_entries |
574 | - if( is_null( $entries ) ) { |
|
574 | + if ( is_null( $entries ) ) { |
|
575 | 575 | |
576 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
576 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
577 | 577 | |
578 | 578 | if ( is_wp_error( $entries ) ) { |
579 | 579 | gravityview()->log->error( '{error}', array( 'error' => $entries->get_error_message(), 'data' => $entries ) ); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
587 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
588 | 588 | |
589 | 589 | // Cache results |
590 | 590 | $Cache->set( $entries, 'entries' ); |
@@ -693,12 +693,12 @@ discard block |
||
693 | 693 | */ |
694 | 694 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
695 | 695 | |
696 | - if( $check_entry_display ) { |
|
696 | + if ( $check_entry_display ) { |
|
697 | 697 | // Is the entry allowed |
698 | 698 | $entry = self::check_entry_display( $entry ); |
699 | 699 | } |
700 | 700 | |
701 | - if( is_wp_error( $entry ) ) { |
|
701 | + if ( is_wp_error( $entry ) ) { |
|
702 | 702 | gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) ); |
703 | 703 | return false; |
704 | 704 | } |
@@ -732,12 +732,12 @@ discard block |
||
732 | 732 | |
733 | 733 | $value = false; |
734 | 734 | |
735 | - if( 'context' === $val1 ) { |
|
735 | + if ( 'context' === $val1 ) { |
|
736 | 736 | |
737 | 737 | $matching_contexts = array( $val2 ); |
738 | 738 | |
739 | 739 | // We allow for non-standard contexts. |
740 | - switch( $val2 ) { |
|
740 | + switch ( $val2 ) { |
|
741 | 741 | // Check for either single or edit |
742 | 742 | case 'singular': |
743 | 743 | $matching_contexts = array( 'single', 'edit' ); |
@@ -780,18 +780,18 @@ discard block |
||
780 | 780 | $json_val_1 = json_decode( $val1, true ); |
781 | 781 | $json_val_2 = json_decode( $val2, true ); |
782 | 782 | |
783 | - if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
783 | + if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
784 | 784 | |
785 | 785 | $json_in = false; |
786 | - $json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 ); |
|
787 | - $json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 ); |
|
786 | + $json_val_1 = $json_val_1 ? (array)$json_val_1 : array( $val1 ); |
|
787 | + $json_val_2 = $json_val_2 ? (array)$json_val_2 : array( $val2 ); |
|
788 | 788 | |
789 | 789 | // For JSON, we want to compare as "in" or "not in" rather than "contains" |
790 | 790 | foreach ( $json_val_1 as $item_1 ) { |
791 | 791 | foreach ( $json_val_2 as $item_2 ) { |
792 | 792 | $json_in = self::matches_operation( $item_1, $item_2, 'is' ); |
793 | 793 | |
794 | - if( $json_in ) { |
|
794 | + if ( $json_in ) { |
|
795 | 795 | break 2; |
796 | 796 | } |
797 | 797 | } |
@@ -843,10 +843,10 @@ discard block |
||
843 | 843 | public static function check_entry_display( $entry, $view = null ) { |
844 | 844 | |
845 | 845 | if ( ! $entry || is_wp_error( $entry ) ) { |
846 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
846 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
847 | 847 | } |
848 | 848 | |
849 | - if ( empty( $entry['form_id'] ) ) { |
|
849 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
850 | 850 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
851 | 851 | } |
852 | 852 | |
@@ -856,19 +856,19 @@ discard block |
||
856 | 856 | * Check whether the entry is in the entries subset by running a modified query. |
857 | 857 | */ |
858 | 858 | add_action( 'gravityview/view/query', $entry_subset_callback = function( &$query, $view, $request ) use ( $entry ) { |
859 | - $_tmp_query = new \GF_Query( $view->form->ID, array( 'field_filters' => array( 'mode' => 'all', array( 'key' => 'id', 'operation' => 'is', 'value' => $entry['id'] ) ) ) ); |
|
859 | + $_tmp_query = new \GF_Query( $view->form->ID, array( 'field_filters' => array( 'mode' => 'all', array( 'key' => 'id', 'operation' => 'is', 'value' => $entry[ 'id' ] ) ) ) ); |
|
860 | 860 | $_tmp_query_parts = $_tmp_query->_introspect(); |
861 | 861 | |
862 | 862 | $query_parts = $query->_introspect(); |
863 | 863 | |
864 | - $query->where( \GF_Query_Condition::_and( $_tmp_query_parts['where'], $query_parts['where'] ) ); |
|
864 | + $query->where( \GF_Query_Condition::_and( $_tmp_query_parts[ 'where' ], $query_parts[ 'where' ] ) ); |
|
865 | 865 | |
866 | 866 | }, 10, 3 ); |
867 | 867 | |
868 | 868 | // Prevent page offset from being applied to the single entry query; it's used to return to the referring page number |
869 | 869 | add_filter( 'gravityview_search_criteria', $remove_pagenum = function( $criteria ) { |
870 | 870 | |
871 | - $criteria['paging'] = array( |
|
871 | + $criteria[ 'paging' ] = array( |
|
872 | 872 | 'offset' => 0, |
873 | 873 | 'page_size' => 25 |
874 | 874 | ); |
@@ -887,20 +887,20 @@ discard block |
||
887 | 887 | } |
888 | 888 | |
889 | 889 | // This entry is on a View with joins |
890 | - if( $entries[0] instanceof \GV\Multi_Entry ) { |
|
890 | + if ( $entries[ 0 ] instanceof \GV\Multi_Entry ) { |
|
891 | 891 | |
892 | 892 | $multi_entry_ids = array(); |
893 | 893 | |
894 | - foreach ( $entries[0]->entries as $multi_entry ) { |
|
895 | - $multi_entry_ids[] = (int) $multi_entry->ID; |
|
894 | + foreach ( $entries[ 0 ]->entries as $multi_entry ) { |
|
895 | + $multi_entry_ids[ ] = (int)$multi_entry->ID; |
|
896 | 896 | } |
897 | 897 | |
898 | - if( ! in_array( (int) $entry['id'], $multi_entry_ids, true ) ) { |
|
898 | + if ( ! in_array( (int)$entry[ 'id' ], $multi_entry_ids, true ) ) { |
|
899 | 899 | remove_action( 'gravityview/view/query', $entry_subset_callback ); |
900 | 900 | return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' ); |
901 | 901 | } |
902 | 902 | |
903 | - } elseif ( (int) $entries[0]->ID !== (int) $entry['id'] ) { |
|
903 | + } elseif ( (int)$entries[ 0 ]->ID !== (int)$entry[ 'id' ] ) { |
|
904 | 904 | remove_action( 'gravityview/view/query', $entry_subset_callback ); |
905 | 905 | return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' ); |
906 | 906 | } |
@@ -913,59 +913,59 @@ discard block |
||
913 | 913 | 'context_view_id' => $view ? $view->ID : null, |
914 | 914 | ) ); |
915 | 915 | |
916 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
916 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
917 | 917 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No search criteria found:', array( 'data' => $criteria ) ); |
918 | 918 | return $entry; |
919 | 919 | } |
920 | 920 | |
921 | 921 | // Make sure the current View is connected to the same form as the Entry |
922 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
923 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
922 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
923 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
924 | 924 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
925 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
926 | - return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
925 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
926 | + return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
927 | 927 | } |
928 | 928 | } |
929 | 929 | |
930 | - $search_criteria = $criteria['search_criteria']; |
|
930 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
931 | 931 | |
932 | 932 | // check entry status |
933 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
934 | - return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
933 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
934 | + return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | // check entry date |
938 | 938 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
939 | 939 | |
940 | 940 | // field_filters |
941 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
941 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
942 | 942 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No field filters criteria found:', array( 'data' => $search_criteria ) ); |
943 | 943 | return $entry; |
944 | 944 | } |
945 | 945 | |
946 | - $filters = $search_criteria['field_filters']; |
|
946 | + $filters = $search_criteria[ 'field_filters' ]; |
|
947 | 947 | |
948 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
948 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
949 | 949 | |
950 | - $mode = $mode ? : 'all'; // If mode is an empty string, assume it's 'all' |
|
950 | + $mode = $mode ?: 'all'; // If mode is an empty string, assume it's 'all' |
|
951 | 951 | |
952 | 952 | // Prevent the mode from being processed below |
953 | - unset( $filters['mode'] ); |
|
953 | + unset( $filters[ 'mode' ] ); |
|
954 | 954 | |
955 | - $form = self::get_form( $entry['form_id'] ); |
|
955 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
956 | 956 | |
957 | 957 | foreach ( $filters as $filter ) { |
958 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
958 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
959 | 959 | |
960 | - if ( ! isset( $filter['key'] ) ) { |
|
960 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
961 | 961 | gravityview()->log->debug( '[apply_filters_to_entry] Filter key not set, any field mode', array( 'filter' => $filter ) ); |
962 | 962 | /** |
963 | 963 | * This is a cross-field search. Let's start digging'. |
964 | 964 | */ |
965 | 965 | foreach ( \GV\Utils::get( $form, 'fields', array() ) as $field ) { |
966 | 966 | $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
967 | - if ( $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ) ) { |
|
968 | - if ( 'any' === $mode) { |
|
967 | + if ( $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ) ) { |
|
968 | + if ( 'any' === $mode ) { |
|
969 | 969 | return $entry; // All good here |
970 | 970 | } // mode === 'all' |
971 | 971 | continue 2; // Next filter |
@@ -974,13 +974,13 @@ discard block |
||
974 | 974 | } |
975 | 975 | |
976 | 976 | if ( 'all' === $mode ) { |
977 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a subcriterium for any field in ALL mode', $filter ); |
|
977 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a subcriterium for any field in ALL mode', $filter ); |
|
978 | 978 | } |
979 | 979 | |
980 | 980 | continue; |
981 | 981 | } |
982 | 982 | |
983 | - $k = $filter['key']; |
|
983 | + $k = $filter[ 'key' ]; |
|
984 | 984 | |
985 | 985 | $field = self::get_field( $form, $k ); |
986 | 986 | |
@@ -988,12 +988,12 @@ discard block |
||
988 | 988 | $field_value = isset( $entry[ $k ] ) ? $entry[ $k ] : null; |
989 | 989 | $field = $k; |
990 | 990 | } else { |
991 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
991 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
992 | 992 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
993 | 993 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? \GV\Utils::get( $field_value, $k ) : $field_value; |
994 | 994 | } |
995 | 995 | |
996 | - $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
996 | + $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
997 | 997 | |
998 | 998 | // Any match is all we need to know |
999 | 999 | if ( $is_value_match && 'any' === $mode ) { |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | |
1003 | 1003 | // Any failed match is a total fail |
1004 | 1004 | if ( ! $is_value_match && 'all' === $mode ) { |
1005 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
1005 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
1006 | 1006 | } |
1007 | 1007 | } |
1008 | 1008 | |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved: all conditions were met' ); |
1013 | 1013 | return $entry; |
1014 | 1014 | } else { |
1015 | - return new WP_Error('failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
1015 | + return new WP_Error( 'failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | } |
@@ -1053,18 +1053,18 @@ discard block |
||
1053 | 1053 | * Gravity Forms code to adjust date to locally-configured Time Zone |
1054 | 1054 | * @see GFCommon::format_date() for original code |
1055 | 1055 | */ |
1056 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
1056 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
1057 | 1057 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
1058 | 1058 | |
1059 | - $format = \GV\Utils::get( $atts, 'format' ); |
|
1060 | - $is_human = ! empty( $atts['human'] ); |
|
1061 | - $is_diff = ! empty( $atts['diff'] ); |
|
1062 | - $is_raw = ! empty( $atts['raw'] ); |
|
1063 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
1064 | - $include_time = ! empty( $atts['time'] ); |
|
1059 | + $format = \GV\Utils::get( $atts, 'format' ); |
|
1060 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
1061 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
1062 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
1063 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
1064 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
1065 | 1065 | |
1066 | 1066 | // If we're using time diff, we want to have a different default format |
1067 | - if( empty( $format ) ) { |
|
1067 | + if ( empty( $format ) ) { |
|
1068 | 1068 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
1069 | 1069 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
1070 | 1070 | } |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | // If raw was specified, don't modify the stored value |
1073 | 1073 | if ( $is_raw ) { |
1074 | 1074 | $formatted_date = $date_string; |
1075 | - } elseif( $is_timestamp ) { |
|
1075 | + } elseif ( $is_timestamp ) { |
|
1076 | 1076 | $formatted_date = $date_local_timestamp; |
1077 | 1077 | } elseif ( $is_diff ) { |
1078 | 1078 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | |
1107 | 1107 | $label = \GV\Utils::get( $field, 'label' ); |
1108 | 1108 | |
1109 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
1109 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
1110 | 1110 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
1111 | 1111 | } |
1112 | 1112 | |
@@ -1134,7 +1134,7 @@ discard block |
||
1134 | 1134 | $form = GFAPI::get_form( $form ); |
1135 | 1135 | } |
1136 | 1136 | |
1137 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
1137 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
1138 | 1138 | return GFFormsModel::get_field( $form, $field_id ); |
1139 | 1139 | } else { |
1140 | 1140 | return null; |
@@ -1181,19 +1181,19 @@ discard block |
||
1181 | 1181 | $shortcodes = array(); |
1182 | 1182 | |
1183 | 1183 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
1184 | - if ( empty( $matches ) ){ |
|
1184 | + if ( empty( $matches ) ) { |
|
1185 | 1185 | return false; |
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | foreach ( $matches as $shortcode ) { |
1189 | - if ( $tag === $shortcode[2] ) { |
|
1189 | + if ( $tag === $shortcode[ 2 ] ) { |
|
1190 | 1190 | |
1191 | 1191 | // Changed this to $shortcode instead of true so we get the parsed atts. |
1192 | - $shortcodes[] = $shortcode; |
|
1192 | + $shortcodes[ ] = $shortcode; |
|
1193 | 1193 | |
1194 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
1195 | - foreach( $results as $result ) { |
|
1196 | - $shortcodes[] = $result; |
|
1194 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
1195 | + foreach ( $results as $result ) { |
|
1196 | + $shortcodes[ ] = $result; |
|
1197 | 1197 | } |
1198 | 1198 | } |
1199 | 1199 | } |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | 'post_type' => 'gravityview', |
1226 | 1226 | 'posts_per_page' => 100, |
1227 | 1227 | 'meta_key' => '_gravityview_form_id', |
1228 | - 'meta_value' => (int) $form_id, |
|
1228 | + 'meta_value' => (int)$form_id, |
|
1229 | 1229 | ); |
1230 | 1230 | $args = wp_parse_args( $args, $defaults ); |
1231 | 1231 | $views = get_posts( $args ); |
@@ -1237,21 +1237,21 @@ discard block |
||
1237 | 1237 | |
1238 | 1238 | $data = unserialize( $view->meta_value ); |
1239 | 1239 | |
1240 | - if( ! $data || ! is_array( $data ) ) { |
|
1240 | + if ( ! $data || ! is_array( $data ) ) { |
|
1241 | 1241 | continue; |
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | foreach ( $data as $datum ) { |
1245 | - if ( ! empty( $datum[2] ) && (int) $datum[2] === (int) $form_id ) { |
|
1246 | - $joined_forms[] = $view->post_id; |
|
1245 | + if ( ! empty( $datum[ 2 ] ) && (int)$datum[ 2 ] === (int)$form_id ) { |
|
1246 | + $joined_forms[ ] = $view->post_id; |
|
1247 | 1247 | } |
1248 | 1248 | } |
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | if ( $joined_forms ) { |
1252 | - $joined_args = array( |
|
1252 | + $joined_args = array( |
|
1253 | 1253 | 'post_type' => 'gravityview', |
1254 | - 'posts_per_page' => $args['posts_per_page'], |
|
1254 | + 'posts_per_page' => $args[ 'posts_per_page' ], |
|
1255 | 1255 | 'post__in' => $joined_forms, |
1256 | 1256 | ); |
1257 | 1257 | $views = array_merge( $views, get_posts( $joined_args ) ); |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | |
1408 | 1408 | $directory_widgets = wp_parse_args( $view_widgets, $defaults ); |
1409 | 1409 | |
1410 | - if( $json_decode ) { |
|
1410 | + if ( $json_decode ) { |
|
1411 | 1411 | $directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' ); |
1412 | 1412 | } |
1413 | 1413 | |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | * @return string html |
1424 | 1424 | */ |
1425 | 1425 | public static function get_sortable_fields( $formid, $current = '' ) { |
1426 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1426 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
1427 | 1427 | |
1428 | 1428 | if ( empty( $formid ) ) { |
1429 | 1429 | return $output; |
@@ -1436,11 +1436,11 @@ discard block |
||
1436 | 1436 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1437 | 1437 | |
1438 | 1438 | foreach ( $fields as $id => $field ) { |
1439 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1439 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1440 | 1440 | continue; |
1441 | 1441 | } |
1442 | 1442 | |
1443 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1443 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1444 | 1444 | } |
1445 | 1445 | } |
1446 | 1446 | |
@@ -1475,9 +1475,9 @@ discard block |
||
1475 | 1475 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1476 | 1476 | |
1477 | 1477 | // TODO: Convert to using array_filter |
1478 | - foreach( $fields as $id => $field ) { |
|
1478 | + foreach ( $fields as $id => $field ) { |
|
1479 | 1479 | |
1480 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1480 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1481 | 1481 | unset( $fields[ $id ] ); |
1482 | 1482 | } |
1483 | 1483 | } |
@@ -1518,14 +1518,14 @@ discard block |
||
1518 | 1518 | * @param int|array $field field key or field array |
1519 | 1519 | * @return boolean |
1520 | 1520 | */ |
1521 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1521 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1522 | 1522 | |
1523 | 1523 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1524 | 1524 | $form = self::get_form( $form ); |
1525 | 1525 | } |
1526 | 1526 | |
1527 | 1527 | // If entry meta, it's a string. Otherwise, numeric |
1528 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1528 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1529 | 1529 | $type = $field; |
1530 | 1530 | } else { |
1531 | 1531 | $type = self::get_field_type( $form, $field ); |
@@ -1539,9 +1539,9 @@ discard block |
||
1539 | 1539 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1540 | 1540 | |
1541 | 1541 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1542 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1543 | - if( true === $gv_field->is_numeric ) { |
|
1544 | - $numeric_types[] = $gv_field->is_numeric; |
|
1542 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1543 | + if ( true === $gv_field->is_numeric ) { |
|
1544 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1545 | 1545 | } |
1546 | 1546 | } |
1547 | 1547 | |
@@ -1691,18 +1691,18 @@ discard block |
||
1691 | 1691 | $final_atts = array_filter( $final_atts ); |
1692 | 1692 | |
1693 | 1693 | // If the href wasn't passed as an attribute, use the value passed to the function |
1694 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1695 | - $final_atts['href'] = $href; |
|
1694 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1695 | + $final_atts[ 'href' ] = $href; |
|
1696 | 1696 | } |
1697 | 1697 | |
1698 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1698 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1699 | 1699 | |
1700 | 1700 | /** |
1701 | 1701 | * Fix potential security issue with target=_blank |
1702 | 1702 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
1703 | 1703 | */ |
1704 | - if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
1705 | - $final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1704 | + if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
1705 | + $final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1706 | 1706 | } |
1707 | 1707 | |
1708 | 1708 | // Sort the attributes alphabetically, to help testing |
@@ -1714,7 +1714,7 @@ discard block |
||
1714 | 1714 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1715 | 1715 | } |
1716 | 1716 | |
1717 | - if( '' !== $output ) { |
|
1717 | + if ( '' !== $output ) { |
|
1718 | 1718 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1719 | 1719 | } |
1720 | 1720 | |
@@ -1741,7 +1741,7 @@ discard block |
||
1741 | 1741 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1742 | 1742 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1743 | 1743 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
1744 | - $merged[] = $value; |
|
1744 | + $merged[ ] = $value; |
|
1745 | 1745 | } else { |
1746 | 1746 | $merged[ $key ] = $value; |
1747 | 1747 | } |
@@ -1774,7 +1774,7 @@ discard block |
||
1774 | 1774 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1775 | 1775 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1776 | 1776 | */ |
1777 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1777 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1778 | 1778 | |
1779 | 1779 | return get_users( $get_users_settings ); |
1780 | 1780 | } |
@@ -1794,11 +1794,11 @@ discard block |
||
1794 | 1794 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
1795 | 1795 | |
1796 | 1796 | // If $cap is defined, only show notice if user has capability |
1797 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1797 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1798 | 1798 | return ''; |
1799 | 1799 | } |
1800 | 1800 | |
1801 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1801 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1802 | 1802 | } |
1803 | 1803 | |
1804 | 1804 | /** |