@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | function __construct() { |
23 | 23 | |
24 | 24 | $this->widget_id = 'poll'; |
25 | - $this->widget_description = __('Displays the results of Poll Fields that exist in the form.', 'gravityview' ); |
|
26 | - $this->widget_subtitle = sprintf( _x('Note: this will display poll results for %sall form entries%s, not only the entries displayed in the View.', 'The string placeholders are for emphasis HTML', 'gravityview' ), '<em>', '</em>' ); |
|
25 | + $this->widget_description = __( 'Displays the results of Poll Fields that exist in the form.', 'gravityview' ); |
|
26 | + $this->widget_subtitle = sprintf( _x( 'Note: this will display poll results for %sall form entries%s, not only the entries displayed in the View.', 'The string placeholders are for emphasis HTML', 'gravityview' ), '<em>', '</em>' ); |
|
27 | 27 | |
28 | 28 | $default_values = array( |
29 | 29 | 'header' => 1, |
@@ -32,27 +32,27 @@ discard block |
||
32 | 32 | |
33 | 33 | $settings = array( |
34 | 34 | 'percentages' => array( |
35 | - 'label' => __('Display Percentages', 'gravityview'), |
|
35 | + 'label' => __( 'Display Percentages', 'gravityview' ), |
|
36 | 36 | 'type' => 'checkbox', |
37 | 37 | 'value' => true, |
38 | 38 | 'tooltip' => __( 'Display results percentages as part of results? Supported values are: true, false. Defaults to "true".', 'gravityview' ), |
39 | 39 | ), |
40 | 40 | 'counts' => array( |
41 | - 'label' => __('Display Counts', 'gravityview'), |
|
41 | + 'label' => __( 'Display Counts', 'gravityview' ), |
|
42 | 42 | 'type' => 'checkbox', |
43 | 43 | 'value' => true, |
44 | 44 | 'tooltip' => __( 'Display number of times each choice has been selected when displaying results? Supported values are: true, false. Defaults to "true".', 'gravityview' ), |
45 | 45 | ), |
46 | 46 | 'style' => array( |
47 | 47 | 'type' => 'select', |
48 | - 'label' => __('Style', 'gravityview'), |
|
48 | + 'label' => __( 'Style', 'gravityview' ), |
|
49 | 49 | 'tooltip' => __( 'The Polls Add-On currently supports 4 built in styles: red, green, orange, blue. Defaults to "green".', 'gravityview' ), |
50 | 50 | 'value' => 'green', |
51 | 51 | 'choices' => array( |
52 | - 'green' => __('Green', 'gravityview'), |
|
53 | - 'blue' => __('Blue', 'gravityview'), |
|
54 | - 'red' => __('Red', 'gravityview'), |
|
55 | - 'orange' => __('Orange', 'gravityview'), |
|
52 | + 'green' => __( 'Green', 'gravityview' ), |
|
53 | + 'blue' => __( 'Blue', 'gravityview' ), |
|
54 | + 'red' => __( 'Red', 'gravityview' ), |
|
55 | + 'orange' => __( 'Orange', 'gravityview' ), |
|
56 | 56 | ), |
57 | 57 | ), |
58 | 58 | ); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
63 | 63 | } |
64 | 64 | |
65 | - parent::__construct( __( 'Poll Results', 'gravityview' ) , null, $default_values, $settings ); |
|
65 | + parent::__construct( __( 'Poll Results', 'gravityview' ), null, $default_values, $settings ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | |
90 | 90 | $GFPolls = GFPolls::get_instance(); |
91 | 91 | |
92 | - wp_enqueue_script('gpoll_js', $GFPolls->get_base_url() . '/js/gpoll.js', array('jquery'), $GFPolls->_version); |
|
92 | + wp_enqueue_script( 'gpoll_js', $GFPolls->get_base_url() . '/js/gpoll.js', array( 'jquery' ), $GFPolls->_version ); |
|
93 | 93 | |
94 | 94 | $GFPolls->localize_scripts(); |
95 | 95 | |
96 | - wp_enqueue_style('gpoll_css', $GFPolls->get_base_url() . '/css/gpoll.css', null, $GFPolls->_version); |
|
96 | + wp_enqueue_style( 'gpoll_css', $GFPolls->get_base_url() . '/css/gpoll.css', null, $GFPolls->_version ); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function pre_render_frontend() { |
105 | 105 | |
106 | - if( ! class_exists('GFPolls') ) { |
|
106 | + if ( ! class_exists( 'GFPolls' ) ) { |
|
107 | 107 | |
108 | 108 | gravityview()->log->error( 'Poll Widget not displayed; the Poll Addon is not loaded' ); |
109 | 109 | |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | |
113 | 113 | $view = gravityview()->views->get(); |
114 | 114 | |
115 | - $poll_fields = array( $view->form->form['id'] => GFCommon::get_fields_by_type( $view->form, array( 'poll' ) ) ); |
|
115 | + $poll_fields = array( $view->form->form[ 'id' ] => GFCommon::get_fields_by_type( $view->form, array( 'poll' ) ) ); |
|
116 | 116 | |
117 | 117 | foreach ( $view->joins as $join ) { |
118 | - $poll_fields[ $join->join_on->form['id'] ] = GFCommon::get_fields_by_type( $join->join_on->form, array( 'poll' ) ); |
|
118 | + $poll_fields[ $join->join_on->form[ 'id' ] ] = GFCommon::get_fields_by_type( $join->join_on->form, array( 'poll' ) ); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $poll_fields = array_filter( $poll_fields ); |
@@ -167,12 +167,12 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function render_frontend( $widget_args, $content = '', $context = '' ) { |
169 | 169 | |
170 | - if( ! $this->pre_render_frontend() ) { |
|
170 | + if ( ! $this->pre_render_frontend() ) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
174 | 174 | // Make sure the class is loaded in DataTables |
175 | - if( !class_exists( 'GFFormDisplay' ) ) { |
|
175 | + if ( ! class_exists( 'GFFormDisplay' ) ) { |
|
176 | 176 | include_once( GFCommon::get_base_path() . '/form_display.php' ); |
177 | 177 | } |
178 | 178 | |
@@ -180,14 +180,14 @@ discard block |
||
180 | 180 | |
181 | 181 | $settings = $this->get_frontend_settings( $widget_args ); |
182 | 182 | |
183 | - $percentages = empty( $settings['percentages'] ) ? 'false' : 'true'; |
|
183 | + $percentages = empty( $settings[ 'percentages' ] ) ? 'false' : 'true'; |
|
184 | 184 | |
185 | - $counts = empty( $settings['counts'] ) ? 'false' : 'true'; |
|
185 | + $counts = empty( $settings[ 'counts' ] ) ? 'false' : 'true'; |
|
186 | 186 | |
187 | - if( !empty( $settings['field'] ) ) { |
|
188 | - $merge_tag = sprintf( '{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}', $settings['field'], $settings['style'], $percentages, $counts ); |
|
187 | + if ( ! empty( $settings[ 'field' ] ) ) { |
|
188 | + $merge_tag = sprintf( '{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}', $settings[ 'field' ], $settings[ 'style' ], $percentages, $counts ); |
|
189 | 189 | } else { |
190 | - $merge_tag = sprintf( '{all_poll_results: style="%s" percentages="%s" counts="%s"}', $settings['style'], $percentages, $counts ); |
|
190 | + $merge_tag = sprintf( '{all_poll_results: style="%s" percentages="%s" counts="%s"}', $settings[ 'style' ], $percentages, $counts ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | $gravityview_view = GravityView_View::getInstance(); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $gravityview_view->poll_settings = $settings; |
198 | 198 | $gravityview_view->poll_fields = $this->poll_fields; |
199 | 199 | |
200 | - $gravityview_view->render('widget', 'poll', false ); |
|
200 | + $gravityview_view->render( 'widget', 'poll', false ); |
|
201 | 201 | |
202 | 202 | unset( $gravityview_view->poll_merge_tag, $gravityview_view->poll_settings, $gravityview_view->poll_form, $gravityview_view->poll_fields ); |
203 | 203 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @return string |
27 | 27 | */ |
28 | 28 | public function the_field( \GV\Field $field, $extras = null ) { |
29 | - $form = \GV\GF_Form::by_id( $field->form_id ) ? : $this->view->form; |
|
29 | + $form = \GV\GF_Form::by_id( $field->form_id ) ?: $this->view->form; |
|
30 | 30 | $entry = $this->entry->from_field( $field ); |
31 | 31 | |
32 | 32 | if ( ! $entry ) { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | $renderer = new Field_Renderer(); |
37 | - $source = is_numeric( $field->ID ) ? ( GF_Form::by_id( $field->form_id ) ? : $this->view->form ) : new Internal_Source(); |
|
37 | + $source = is_numeric( $field->ID ) ? ( GF_Form::by_id( $field->form_id ) ?: $this->view->form ) : new Internal_Source(); |
|
38 | 38 | |
39 | 39 | $value = $renderer->render( $field, $this->view, $source, $entry, $this->request ); |
40 | 40 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | $hide_empty = apply_filters( 'gravityview/render/hide-empty-zone', Utils::get( $extras, 'hide_empty', $this->view->settings->get( 'hide_empty', false ) ), $context ); |
63 | 63 | |
64 | 64 | if ( is_numeric( $field->ID ) ) { |
65 | - $extras['field'] = $field->as_configuration(); |
|
65 | + $extras[ 'field' ] = $field->as_configuration(); |
|
66 | 66 | } |
67 | 67 | |
68 | - $extras['entry'] = $this->entry->as_entry(); |
|
69 | - $extras['hide_empty'] = $hide_empty; |
|
70 | - $extras['label'] = $label; |
|
71 | - $extras['value'] = $value; |
|
68 | + $extras[ 'entry' ] = $this->entry->as_entry(); |
|
69 | + $extras[ 'hide_empty' ] = $hide_empty; |
|
70 | + $extras[ 'label' ] = $label; |
|
71 | + $extras[ 'value' ] = $value; |
|
72 | 72 | |
73 | 73 | return \gravityview_field_output( $extras, $context ); |
74 | 74 | } |
@@ -573,7 +573,8 @@ discard block |
||
573 | 573 | |
574 | 574 | // Only allow quantity to be set if it's allowed to be edited |
575 | 575 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
576 | - } else { // otherwise set to what it previously was |
|
576 | + } else { |
|
577 | +// otherwise set to what it previously was |
|
577 | 578 | $_POST[ $input_name ] = $entry[ $input['id'] ]; |
578 | 579 | } |
579 | 580 | } else { |
@@ -958,7 +959,7 @@ discard block |
||
958 | 959 | |
959 | 960 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
960 | 961 | |
961 | - if( ! $this->is_valid ){ |
|
962 | + if( ! $this->is_valid ) { |
|
962 | 963 | |
963 | 964 | // Keeping this compatible with Gravity Forms. |
964 | 965 | $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
@@ -2070,9 +2071,7 @@ discard block |
||
2070 | 2071 | // Verify |
2071 | 2072 | else if( ! $this->is_edit_entry() ) { |
2072 | 2073 | $valid = false; |
2073 | - } |
|
2074 | - |
|
2075 | - else { |
|
2074 | + } else { |
|
2076 | 2075 | $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
2077 | 2076 | } |
2078 | 2077 |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | |
103 | 103 | /** |
104 | 104 | * ID of the current post. May also be ID of the current View. |
105 | - * |
|
106 | - * @since 2.0.13 |
|
107 | 105 | * |
108 | - * @var int |
|
106 | + * @since 2.0.13 |
|
107 | + * |
|
108 | + * @var int |
|
109 | 109 | */ |
110 | 110 | public $post_id; |
111 | 111 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function prevent_maybe_process_form() { |
191 | 191 | |
192 | - if( ! $this->is_edit_entry_submission() ) { |
|
192 | + if( ! $this->is_edit_entry_submission() ) { |
|
193 | 193 | return; |
194 | 194 | } |
195 | 195 | |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | * When Edit entry view is requested setup the vars |
229 | 229 | */ |
230 | 230 | private function setup_vars() { |
231 | - global $post; |
|
231 | + global $post; |
|
232 | 232 | |
233 | 233 | $gravityview_view = GravityView_View::getInstance(); |
234 | 234 | |
235 | 235 | |
236 | 236 | $entries = $gravityview_view->getEntries(); |
237 | - self::$original_entry = $entries[0]; |
|
238 | - $this->entry = $entries[0]; |
|
237 | + self::$original_entry = $entries[0]; |
|
238 | + $this->entry = $entries[0]; |
|
239 | 239 | |
240 | 240 | self::$original_form = GFAPI::get_form( $this->entry['form_id'] ); |
241 | 241 | $this->form = $gravityview_view->getForm(); |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | |
378 | 378 | GFFormsModel::save_lead( $form, $this->entry ); |
379 | 379 | |
380 | - // Delete the values for hidden inputs |
|
381 | - $this->unset_hidden_field_values(); |
|
380 | + // Delete the values for hidden inputs |
|
381 | + $this->unset_hidden_field_values(); |
|
382 | 382 | |
383 | 383 | $this->entry['date_created'] = $date_created; |
384 | 384 | |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | // Perform actions normally performed after updating a lead |
392 | 392 | $this->after_update(); |
393 | 393 | |
394 | - /** |
|
394 | + /** |
|
395 | 395 | * Must be AFTER after_update()! |
396 | 396 | * @see https://github.com/gravityview/GravityView/issues/764 |
397 | 397 | */ |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | |
400 | 400 | /** |
401 | 401 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
402 | - * @since 2.1 Added $gv_data parameter |
|
402 | + * @since 2.1 Added $gv_data parameter |
|
403 | 403 | * @param array $form Gravity Forms form array |
404 | 404 | * @param string $entry_id Numeric ID of the entry that was updated |
405 | 405 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | * @return void |
424 | 424 | */ |
425 | 425 | private function unset_hidden_field_values() { |
426 | - global $wpdb; |
|
426 | + global $wpdb; |
|
427 | 427 | |
428 | 428 | /** |
429 | 429 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
448 | 448 | } |
449 | 449 | |
450 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
450 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
451 | 451 | |
452 | 452 | if ( ! is_numeric( $input_id ) ) { |
453 | 453 | continue; |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | continue; |
458 | 458 | } |
459 | 459 | |
460 | - // Reset fields that are or would be hidden |
|
461 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
460 | + // Reset fields that are or would be hidden |
|
461 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
462 | 462 | |
463 | 463 | $empty_value = $field->get_value_save_entry( |
464 | 464 | is_array( $field->get_entry_inputs() ) ? array() : '', |
@@ -470,16 +470,16 @@ discard block |
||
470 | 470 | $empty_value = ''; |
471 | 471 | } |
472 | 472 | |
473 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
473 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
474 | 474 | |
475 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
475 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
476 | 476 | |
477 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
477 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
478 | 478 | // after submission |
479 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
480 | - $_POST[ $post_input_id ] = ''; |
|
481 | - } |
|
482 | - } |
|
479 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
480 | + $_POST[ $post_input_id ] = ''; |
|
481 | + } |
|
482 | + } |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | |
635 | 635 | $form = $this->filter_conditional_logic( $this->form ); |
636 | 636 | |
637 | - /** @type GF_Field $field */ |
|
637 | + /** @type GF_Field $field */ |
|
638 | 638 | foreach( $form['fields'] as $k => &$field ) { |
639 | 639 | |
640 | 640 | /** |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | |
650 | 650 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
651 | 651 | foreach( $field->inputs as $key => $input ) { |
652 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
652 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
653 | 653 | } |
654 | 654 | } |
655 | 655 | } |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | |
690 | 690 | $inputs = $field->get_entry_inputs(); |
691 | 691 | if ( is_array( $inputs ) ) { |
692 | - foreach ( $inputs as $input ) { |
|
692 | + foreach ( $inputs as $input ) { |
|
693 | 693 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
694 | 694 | |
695 | 695 | if ( 'product' === $field->type ) { |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | } |
709 | 709 | |
710 | 710 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
711 | - } |
|
711 | + } |
|
712 | 712 | } else { |
713 | 713 | // Set to what it previously was if it's not editable |
714 | 714 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
755 | 755 | |
756 | 756 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
757 | - $ary = stripslashes_deep( $ary ); |
|
757 | + $ary = stripslashes_deep( $ary ); |
|
758 | 758 | $img_url = \GV\Utils::get( $ary, 0 ); |
759 | 759 | |
760 | 760 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | private function maybe_update_post_fields( $form ) { |
828 | 828 | |
829 | 829 | if( empty( $this->entry['post_id'] ) ) { |
830 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
830 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
831 | 831 | return; |
832 | 832 | } |
833 | 833 | |
@@ -862,49 +862,49 @@ discard block |
||
862 | 862 | |
863 | 863 | switch( $field->type ) { |
864 | 864 | |
865 | - case 'post_title': |
|
866 | - $post_title = $value; |
|
867 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
868 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
869 | - } |
|
870 | - $updated_post->post_title = $post_title; |
|
871 | - $updated_post->post_name = $post_title; |
|
872 | - unset( $post_title ); |
|
873 | - break; |
|
874 | - |
|
875 | - case 'post_content': |
|
876 | - $post_content = $value; |
|
877 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
878 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
879 | - } |
|
880 | - $updated_post->post_content = $post_content; |
|
881 | - unset( $post_content ); |
|
882 | - break; |
|
883 | - case 'post_excerpt': |
|
884 | - $updated_post->post_excerpt = $value; |
|
885 | - break; |
|
886 | - case 'post_tags': |
|
887 | - wp_set_post_tags( $post_id, $value, false ); |
|
888 | - break; |
|
889 | - case 'post_category': |
|
890 | - break; |
|
891 | - case 'post_custom_field': |
|
865 | + case 'post_title': |
|
866 | + $post_title = $value; |
|
867 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
868 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
869 | + } |
|
870 | + $updated_post->post_title = $post_title; |
|
871 | + $updated_post->post_name = $post_title; |
|
872 | + unset( $post_title ); |
|
873 | + break; |
|
874 | + |
|
875 | + case 'post_content': |
|
876 | + $post_content = $value; |
|
877 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
878 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
879 | + } |
|
880 | + $updated_post->post_content = $post_content; |
|
881 | + unset( $post_content ); |
|
882 | + break; |
|
883 | + case 'post_excerpt': |
|
884 | + $updated_post->post_excerpt = $value; |
|
885 | + break; |
|
886 | + case 'post_tags': |
|
887 | + wp_set_post_tags( $post_id, $value, false ); |
|
888 | + break; |
|
889 | + case 'post_category': |
|
890 | + break; |
|
891 | + case 'post_custom_field': |
|
892 | 892 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
893 | 893 | $value = $value[ $field_id ]; |
894 | 894 | } |
895 | 895 | |
896 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
897 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
898 | - } |
|
896 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
897 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
898 | + } |
|
899 | 899 | |
900 | 900 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
901 | 901 | |
902 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
903 | - break; |
|
902 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
903 | + break; |
|
904 | 904 | |
905 | - case 'post_image': |
|
906 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
907 | - break; |
|
905 | + case 'post_image': |
|
906 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
907 | + break; |
|
908 | 908 | |
909 | 909 | } |
910 | 910 | |
@@ -1074,14 +1074,14 @@ discard block |
||
1074 | 1074 | ?><h2 class="gv-edit-entry-title"> |
1075 | 1075 | <span><?php |
1076 | 1076 | |
1077 | - /** |
|
1078 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
1079 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
1080 | - * @param GravityView_Edit_Entry_Render $this This object |
|
1081 | - */ |
|
1082 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1077 | + /** |
|
1078 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
1079 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
1080 | + * @param GravityView_Edit_Entry_Render $this This object |
|
1081 | + */ |
|
1082 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1083 | 1083 | |
1084 | - echo esc_attr( $edit_entry_title ); |
|
1084 | + echo esc_attr( $edit_entry_title ); |
|
1085 | 1085 | ?></span> |
1086 | 1086 | </h2> |
1087 | 1087 | |
@@ -1136,13 +1136,13 @@ discard block |
||
1136 | 1136 | ); |
1137 | 1137 | |
1138 | 1138 | /** |
1139 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1140 | - * @since 1.16.3 |
|
1141 | - * @param array $labels Default button labels associative array |
|
1142 | - * @param array $form The Gravity Forms form |
|
1143 | - * @param array $entry The Gravity Forms entry |
|
1144 | - * @param int $view_id The current View ID |
|
1145 | - */ |
|
1139 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1140 | + * @since 1.16.3 |
|
1141 | + * @param array $labels Default button labels associative array |
|
1142 | + * @param array $form The Gravity Forms form |
|
1143 | + * @param array $entry The Gravity Forms entry |
|
1144 | + * @param int $view_id The current View ID |
|
1145 | + */ |
|
1146 | 1146 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1147 | 1147 | |
1148 | 1148 | $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
@@ -1179,26 +1179,26 @@ discard block |
||
1179 | 1179 | |
1180 | 1180 | switch ( $edit_redirect ) { |
1181 | 1181 | |
1182 | - case '0': |
|
1183 | - $redirect_url = $back_link; |
|
1184 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1185 | - break; |
|
1186 | - |
|
1187 | - case '1': |
|
1188 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1189 | - $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>' ); |
|
1190 | - break; |
|
1191 | - |
|
1192 | - case '2': |
|
1193 | - $redirect_url = $edit_redirect_url; |
|
1194 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1195 | - $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>' ); |
|
1196 | - break; |
|
1197 | - |
|
1198 | - case '': |
|
1199 | - default: |
|
1200 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1201 | - break; |
|
1182 | + case '0': |
|
1183 | + $redirect_url = $back_link; |
|
1184 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1185 | + break; |
|
1186 | + |
|
1187 | + case '1': |
|
1188 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1189 | + $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>' ); |
|
1190 | + break; |
|
1191 | + |
|
1192 | + case '2': |
|
1193 | + $redirect_url = $edit_redirect_url; |
|
1194 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1195 | + $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>' ); |
|
1196 | + break; |
|
1197 | + |
|
1198 | + case '': |
|
1199 | + default: |
|
1200 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1201 | + break; |
|
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | if ( isset( $redirect_url ) ) { |
@@ -1264,13 +1264,13 @@ discard block |
||
1264 | 1264 | ); |
1265 | 1265 | |
1266 | 1266 | /** |
1267 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1268 | - * @since 1.16.3 |
|
1269 | - * @param array $labels Default button labels associative array |
|
1270 | - * @param array $form The Gravity Forms form |
|
1271 | - * @param array $entry The Gravity Forms entry |
|
1272 | - * @param int $view_id The current View ID |
|
1273 | - */ |
|
1267 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
1268 | + * @since 1.16.3 |
|
1269 | + * @param array $labels Default button labels associative array |
|
1270 | + * @param array $form The Gravity Forms form |
|
1271 | + * @param array $entry The Gravity Forms entry |
|
1272 | + * @param int $view_id The current View ID |
|
1273 | + */ |
|
1274 | 1274 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1275 | 1275 | |
1276 | 1276 | GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
@@ -1316,7 +1316,7 @@ discard block |
||
1316 | 1316 | |
1317 | 1317 | ob_get_clean(); |
1318 | 1318 | |
1319 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1319 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1320 | 1320 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1321 | 1321 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
1322 | 1322 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1376,7 +1376,7 @@ discard block |
||
1376 | 1376 | |
1377 | 1377 | // for now we don't support Save and Continue feature. |
1378 | 1378 | if( ! self::$supports_save_and_continue ) { |
1379 | - unset( $form['save'] ); |
|
1379 | + unset( $form['save'] ); |
|
1380 | 1380 | } |
1381 | 1381 | |
1382 | 1382 | $form = $this->unselect_default_values( $form ); |
@@ -1403,30 +1403,30 @@ discard block |
||
1403 | 1403 | return $field_content; |
1404 | 1404 | } |
1405 | 1405 | |
1406 | - $message = null; |
|
1406 | + $message = null; |
|
1407 | 1407 | |
1408 | - // First, make sure they have the capability to edit the post. |
|
1409 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1408 | + // First, make sure they have the capability to edit the post. |
|
1409 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1410 | 1410 | |
1411 | - /** |
|
1412 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1413 | - * @param string $message The existing "You don't have permission..." text |
|
1414 | - */ |
|
1415 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1411 | + /** |
|
1412 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1413 | + * @param string $message The existing "You don't have permission..." text |
|
1414 | + */ |
|
1415 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1416 | 1416 | |
1417 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1418 | - /** |
|
1419 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1420 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1421 | - */ |
|
1422 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1423 | - } |
|
1417 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1418 | + /** |
|
1419 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1420 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1421 | + */ |
|
1422 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1423 | + } |
|
1424 | 1424 | |
1425 | - if( $message ) { |
|
1426 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1427 | - } |
|
1425 | + if( $message ) { |
|
1426 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1427 | + } |
|
1428 | 1428 | |
1429 | - return $field_content; |
|
1429 | + return $field_content; |
|
1430 | 1430 | } |
1431 | 1431 | |
1432 | 1432 | /** |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | || ! empty( $field_content ) |
1455 | 1455 | || in_array( $field->type, array( 'honeypot' ) ) |
1456 | 1456 | ) { |
1457 | - return $field_content; |
|
1457 | + return $field_content; |
|
1458 | 1458 | } |
1459 | 1459 | |
1460 | 1460 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1462,24 +1462,24 @@ discard block |
||
1462 | 1462 | |
1463 | 1463 | $field_value = $this->get_field_value( $field ); |
1464 | 1464 | |
1465 | - // Prevent any PHP warnings, like undefined index |
|
1466 | - ob_start(); |
|
1465 | + // Prevent any PHP warnings, like undefined index |
|
1466 | + ob_start(); |
|
1467 | 1467 | |
1468 | - $return = null; |
|
1468 | + $return = null; |
|
1469 | 1469 | |
1470 | 1470 | /** @var GravityView_Field $gv_field */ |
1471 | 1471 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1472 | 1472 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1473 | 1473 | } else { |
1474 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1475 | - } |
|
1474 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1475 | + } |
|
1476 | 1476 | |
1477 | - // If there was output, it's an error |
|
1478 | - $warnings = ob_get_clean(); |
|
1477 | + // If there was output, it's an error |
|
1478 | + $warnings = ob_get_clean(); |
|
1479 | 1479 | |
1480 | - if( !empty( $warnings ) ) { |
|
1481 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1482 | - } |
|
1480 | + if( !empty( $warnings ) ) { |
|
1481 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1482 | + } |
|
1483 | 1483 | |
1484 | 1484 | return $return; |
1485 | 1485 | } |
@@ -1514,8 +1514,8 @@ discard block |
||
1514 | 1514 | $input_id = strval( $input['id'] ); |
1515 | 1515 | |
1516 | 1516 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1517 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1518 | - $allow_pre_populated = false; |
|
1517 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1518 | + $allow_pre_populated = false; |
|
1519 | 1519 | } |
1520 | 1520 | |
1521 | 1521 | } |
@@ -1539,7 +1539,7 @@ discard block |
||
1539 | 1539 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1540 | 1540 | $categories = array(); |
1541 | 1541 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1542 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1542 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1543 | 1543 | } |
1544 | 1544 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1545 | 1545 | } |
@@ -1549,25 +1549,25 @@ discard block |
||
1549 | 1549 | // if value is empty get the default value if defined |
1550 | 1550 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1551 | 1551 | |
1552 | - /** |
|
1553 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1554 | - * @since 1.11 |
|
1555 | - * @since 1.20 Added third param |
|
1556 | - * @param mixed $field_value field value used to populate the input |
|
1557 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1558 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1559 | - */ |
|
1560 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1561 | - |
|
1562 | - /** |
|
1563 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1564 | - * @since 1.17 |
|
1565 | - * @since 1.20 Added third param |
|
1566 | - * @param mixed $field_value field value used to populate the input |
|
1567 | - * @param GF_Field $field Gravity Forms field object |
|
1568 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1569 | - */ |
|
1570 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1552 | + /** |
|
1553 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1554 | + * @since 1.11 |
|
1555 | + * @since 1.20 Added third param |
|
1556 | + * @param mixed $field_value field value used to populate the input |
|
1557 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1558 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1559 | + */ |
|
1560 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1561 | + |
|
1562 | + /** |
|
1563 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1564 | + * @since 1.17 |
|
1565 | + * @since 1.20 Added third param |
|
1566 | + * @param mixed $field_value field value used to populate the input |
|
1567 | + * @param GF_Field $field Gravity Forms field object |
|
1568 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1569 | + */ |
|
1570 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1571 | 1571 | |
1572 | 1572 | return $field_value; |
1573 | 1573 | } |
@@ -1594,7 +1594,7 @@ discard block |
||
1594 | 1594 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1595 | 1595 | // expects certain field array items to be set. |
1596 | 1596 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1597 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1597 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1608,61 +1608,61 @@ discard block |
||
1608 | 1608 | */ |
1609 | 1609 | case 'fileupload': |
1610 | 1610 | |
1611 | - // Set the previous value |
|
1612 | - $entry = $this->get_entry(); |
|
1611 | + // Set the previous value |
|
1612 | + $entry = $this->get_entry(); |
|
1613 | 1613 | |
1614 | - $input_name = 'input_'.$field->id; |
|
1615 | - $form_id = $form['id']; |
|
1614 | + $input_name = 'input_'.$field->id; |
|
1615 | + $form_id = $form['id']; |
|
1616 | 1616 | |
1617 | - $value = NULL; |
|
1617 | + $value = NULL; |
|
1618 | 1618 | |
1619 | - // Use the previous entry value as the default. |
|
1620 | - if( isset( $entry[ $field->id ] ) ) { |
|
1621 | - $value = $entry[ $field->id ]; |
|
1622 | - } |
|
1619 | + // Use the previous entry value as the default. |
|
1620 | + if( isset( $entry[ $field->id ] ) ) { |
|
1621 | + $value = $entry[ $field->id ]; |
|
1622 | + } |
|
1623 | 1623 | |
1624 | - // If this is a single upload file |
|
1625 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1626 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1627 | - $value = $file_path['url']; |
|
1624 | + // If this is a single upload file |
|
1625 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1626 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1627 | + $value = $file_path['url']; |
|
1628 | 1628 | |
1629 | - } else { |
|
1629 | + } else { |
|
1630 | 1630 | |
1631 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1632 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1633 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1631 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1632 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1633 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1634 | 1634 | |
1635 | - } |
|
1635 | + } |
|
1636 | 1636 | |
1637 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1637 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1638 | 1638 | |
1639 | - // If there are fresh uploads, process and merge them. |
|
1640 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1641 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1642 | - $value = empty( $value ) ? '[]' : $value; |
|
1643 | - $value = stripslashes_deep( $value ); |
|
1644 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1645 | - } |
|
1639 | + // If there are fresh uploads, process and merge them. |
|
1640 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1641 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1642 | + $value = empty( $value ) ? '[]' : $value; |
|
1643 | + $value = stripslashes_deep( $value ); |
|
1644 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1645 | + } |
|
1646 | 1646 | |
1647 | - } else { |
|
1647 | + } else { |
|
1648 | 1648 | |
1649 | - // A file already exists when editing an entry |
|
1650 | - // We set this to solve issue when file upload fields are required. |
|
1651 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1649 | + // A file already exists when editing an entry |
|
1650 | + // We set this to solve issue when file upload fields are required. |
|
1651 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1652 | 1652 | |
1653 | - } |
|
1653 | + } |
|
1654 | 1654 | |
1655 | - $this->entry[ $input_name ] = $value; |
|
1656 | - $_POST[ $input_name ] = $value; |
|
1655 | + $this->entry[ $input_name ] = $value; |
|
1656 | + $_POST[ $input_name ] = $value; |
|
1657 | 1657 | |
1658 | - break; |
|
1658 | + break; |
|
1659 | 1659 | |
1660 | 1660 | case 'number': |
1661 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1662 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1663 | - $_POST['input_'.$field->id ] = NULL; |
|
1664 | - } |
|
1665 | - break; |
|
1661 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1662 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1663 | + $_POST['input_'.$field->id ] = NULL; |
|
1664 | + } |
|
1665 | + break; |
|
1666 | 1666 | } |
1667 | 1667 | |
1668 | 1668 | } |
@@ -1752,43 +1752,43 @@ discard block |
||
1752 | 1752 | case 'fileupload' : |
1753 | 1753 | case 'post_image': |
1754 | 1754 | |
1755 | - // in case nothing is uploaded but there are already files saved |
|
1756 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1757 | - $field->failed_validation = false; |
|
1758 | - unset( $field->validation_message ); |
|
1759 | - } |
|
1755 | + // in case nothing is uploaded but there are already files saved |
|
1756 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1757 | + $field->failed_validation = false; |
|
1758 | + unset( $field->validation_message ); |
|
1759 | + } |
|
1760 | 1760 | |
1761 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1762 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1761 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1762 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1763 | 1763 | |
1764 | - $input_name = 'input_' . $field->id; |
|
1765 | - //uploaded |
|
1766 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1764 | + $input_name = 'input_' . $field->id; |
|
1765 | + //uploaded |
|
1766 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1767 | 1767 | |
1768 | - //existent |
|
1769 | - $entry = $this->get_entry(); |
|
1770 | - $value = NULL; |
|
1771 | - if( isset( $entry[ $field->id ] ) ) { |
|
1772 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1773 | - } |
|
1768 | + //existent |
|
1769 | + $entry = $this->get_entry(); |
|
1770 | + $value = NULL; |
|
1771 | + if( isset( $entry[ $field->id ] ) ) { |
|
1772 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1773 | + } |
|
1774 | 1774 | |
1775 | - // count uploaded files and existent entry files |
|
1776 | - $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1777 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
1775 | + // count uploaded files and existent entry files |
|
1776 | + $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1777 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
1778 | 1778 | |
1779 | - if( $count_files > $field->maxFiles ) { |
|
1780 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1781 | - $field->failed_validation = 1; |
|
1782 | - $gv_valid = false; |
|
1779 | + if( $count_files > $field->maxFiles ) { |
|
1780 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1781 | + $field->failed_validation = 1; |
|
1782 | + $gv_valid = false; |
|
1783 | 1783 | |
1784 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1785 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1786 | - } |
|
1784 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1785 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1786 | + } |
|
1787 | 1787 | |
1788 | - } |
|
1788 | + } |
|
1789 | 1789 | |
1790 | 1790 | |
1791 | - break; |
|
1791 | + break; |
|
1792 | 1792 | |
1793 | 1793 | } |
1794 | 1794 | |
@@ -1799,47 +1799,47 @@ discard block |
||
1799 | 1799 | |
1800 | 1800 | switch ( $field_type ) { |
1801 | 1801 | |
1802 | - // Captchas don't need to be re-entered. |
|
1803 | - case 'captcha': |
|
1802 | + // Captchas don't need to be re-entered. |
|
1803 | + case 'captcha': |
|
1804 | 1804 | |
1805 | - // Post Image fields aren't editable, so we un-fail them. |
|
1806 | - case 'post_image': |
|
1807 | - $field->failed_validation = false; |
|
1808 | - unset( $field->validation_message ); |
|
1809 | - break; |
|
1805 | + // Post Image fields aren't editable, so we un-fail them. |
|
1806 | + case 'post_image': |
|
1807 | + $field->failed_validation = false; |
|
1808 | + unset( $field->validation_message ); |
|
1809 | + break; |
|
1810 | 1810 | |
1811 | 1811 | } |
1812 | 1812 | |
1813 | 1813 | // You can't continue inside a switch, so we do it after. |
1814 | 1814 | if( empty( $field->failed_validation ) ) { |
1815 | - continue; |
|
1815 | + continue; |
|
1816 | 1816 | } |
1817 | 1817 | |
1818 | 1818 | // checks if the No Duplicates option is not validating entry against itself, since |
1819 | 1819 | // we're editing a stored entry, it would also assume it's a duplicate. |
1820 | 1820 | if( !empty( $field->noDuplicates ) ) { |
1821 | 1821 | |
1822 | - $entry = $this->get_entry(); |
|
1822 | + $entry = $this->get_entry(); |
|
1823 | 1823 | |
1824 | - // If the value of the entry is the same as the stored value |
|
1825 | - // Then we can assume it's not a duplicate, it's the same. |
|
1826 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1827 | - //if value submitted was not changed, then don't validate |
|
1828 | - $field->failed_validation = false; |
|
1824 | + // If the value of the entry is the same as the stored value |
|
1825 | + // Then we can assume it's not a duplicate, it's the same. |
|
1826 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1827 | + //if value submitted was not changed, then don't validate |
|
1828 | + $field->failed_validation = false; |
|
1829 | 1829 | |
1830 | - unset( $field->validation_message ); |
|
1830 | + unset( $field->validation_message ); |
|
1831 | 1831 | |
1832 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1832 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1833 | 1833 | |
1834 | - continue; |
|
1835 | - } |
|
1834 | + continue; |
|
1835 | + } |
|
1836 | 1836 | } |
1837 | 1837 | |
1838 | 1838 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1839 | 1839 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1840 | - unset( $field->validation_message ); |
|
1840 | + unset( $field->validation_message ); |
|
1841 | 1841 | $field->failed_validation = false; |
1842 | - continue; |
|
1842 | + continue; |
|
1843 | 1843 | } |
1844 | 1844 | |
1845 | 1845 | $gv_valid = false; |
@@ -1903,8 +1903,8 @@ discard block |
||
1903 | 1903 | // Hide fields depending on admin settings |
1904 | 1904 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1905 | 1905 | |
1906 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1907 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1906 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1907 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1908 | 1908 | |
1909 | 1909 | /** |
1910 | 1910 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1995,11 +1995,11 @@ discard block |
||
1995 | 1995 | // The edit tab has been configured, so we loop through to configured settings |
1996 | 1996 | foreach ( $configured_fields as $configured_field ) { |
1997 | 1997 | |
1998 | - /** @var GF_Field $field */ |
|
1999 | - foreach ( $fields as $field ) { |
|
1998 | + /** @var GF_Field $field */ |
|
1999 | + foreach ( $fields as $field ) { |
|
2000 | 2000 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
2001 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
2002 | - break; |
|
2001 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
2002 | + break; |
|
2003 | 2003 | } |
2004 | 2004 | |
2005 | 2005 | } |
@@ -2055,28 +2055,28 @@ discard block |
||
2055 | 2055 | */ |
2056 | 2056 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
2057 | 2057 | |
2058 | - /** |
|
2058 | + /** |
|
2059 | 2059 | * @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 |
2060 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
2061 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
2062 | - * @since 1.9.1 |
|
2063 | - * @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. |
|
2064 | - * @param array $form GF Form array |
|
2065 | - * @param int $view_id View ID |
|
2066 | - */ |
|
2067 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
2068 | - |
|
2069 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2060 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
2061 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
2062 | + * @since 1.9.1 |
|
2063 | + * @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. |
|
2064 | + * @param array $form GF Form array |
|
2065 | + * @param int $view_id View ID |
|
2066 | + */ |
|
2067 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
2068 | + |
|
2069 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2070 | 2070 | foreach( $fields as $k => $field ) { |
2071 | 2071 | if( $field->adminOnly ) { |
2072 | - unset( $fields[ $k ] ); |
|
2072 | + unset( $fields[ $k ] ); |
|
2073 | 2073 | } |
2074 | 2074 | } |
2075 | 2075 | return array_values( $fields ); |
2076 | 2076 | } |
2077 | 2077 | |
2078 | - foreach( $fields as &$field ) { |
|
2079 | - $field->adminOnly = false; |
|
2078 | + foreach( $fields as &$field ) { |
|
2079 | + $field->adminOnly = false; |
|
2080 | 2080 | } |
2081 | 2081 | |
2082 | 2082 | return $fields; |
@@ -2096,13 +2096,13 @@ discard block |
||
2096 | 2096 | */ |
2097 | 2097 | private function unselect_default_values( $form ) { |
2098 | 2098 | |
2099 | - foreach ( $form['fields'] as &$field ) { |
|
2099 | + foreach ( $form['fields'] as &$field ) { |
|
2100 | 2100 | |
2101 | 2101 | if ( empty( $field->choices ) ) { |
2102 | - continue; |
|
2102 | + continue; |
|
2103 | 2103 | } |
2104 | 2104 | |
2105 | - foreach ( $field->choices as &$choice ) { |
|
2105 | + foreach ( $field->choices as &$choice ) { |
|
2106 | 2106 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
2107 | 2107 | $choice['isSelected'] = false; |
2108 | 2108 | } |
@@ -2139,36 +2139,36 @@ discard block |
||
2139 | 2139 | |
2140 | 2140 | if( 'checkbox' === $field->type ) { |
2141 | 2141 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
2142 | - $input_id = $input['id']; |
|
2143 | - $choice = $field->choices[ $key ]; |
|
2144 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
2145 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
2146 | - if( $match ) { |
|
2147 | - $field->choices[ $key ]['isSelected'] = true; |
|
2148 | - } |
|
2142 | + $input_id = $input['id']; |
|
2143 | + $choice = $field->choices[ $key ]; |
|
2144 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
2145 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
2146 | + if( $match ) { |
|
2147 | + $field->choices[ $key ]['isSelected'] = true; |
|
2148 | + } |
|
2149 | 2149 | } |
2150 | 2150 | } else { |
2151 | 2151 | |
2152 | 2152 | // We need to run through each field to set the default values |
2153 | 2153 | foreach ( $this->entry as $field_id => $field_value ) { |
2154 | 2154 | |
2155 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2155 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2156 | 2156 | |
2157 | - if( 'list' === $field->type ) { |
|
2158 | - $list_rows = maybe_unserialize( $field_value ); |
|
2157 | + if( 'list' === $field->type ) { |
|
2158 | + $list_rows = maybe_unserialize( $field_value ); |
|
2159 | 2159 | |
2160 | - $list_field_value = array(); |
|
2161 | - foreach ( (array) $list_rows as $row ) { |
|
2162 | - foreach ( (array) $row as $column ) { |
|
2163 | - $list_field_value[] = $column; |
|
2164 | - } |
|
2165 | - } |
|
2160 | + $list_field_value = array(); |
|
2161 | + foreach ( (array) $list_rows as $row ) { |
|
2162 | + foreach ( (array) $row as $column ) { |
|
2163 | + $list_field_value[] = $column; |
|
2164 | + } |
|
2165 | + } |
|
2166 | 2166 | |
2167 | - $field->defaultValue = serialize( $list_field_value ); |
|
2168 | - } else { |
|
2169 | - $field->defaultValue = $field_value; |
|
2170 | - } |
|
2171 | - } |
|
2167 | + $field->defaultValue = serialize( $list_field_value ); |
|
2168 | + } else { |
|
2169 | + $field->defaultValue = $field_value; |
|
2170 | + } |
|
2171 | + } |
|
2172 | 2172 | } |
2173 | 2173 | } |
2174 | 2174 | } |
@@ -2229,7 +2229,7 @@ discard block |
||
2229 | 2229 | foreach ( $form['fields'] as &$field ) { |
2230 | 2230 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2231 | 2231 | |
2232 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2232 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2233 | 2233 | |
2234 | 2234 | if ( $field['id'] == $rule_field_id ) { |
2235 | 2235 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2280,7 +2280,7 @@ discard block |
||
2280 | 2280 | return $has_conditional_logic; |
2281 | 2281 | } |
2282 | 2282 | |
2283 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2283 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2284 | 2284 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
2285 | 2285 | } |
2286 | 2286 | |
@@ -2347,14 +2347,14 @@ discard block |
||
2347 | 2347 | |
2348 | 2348 | if( $echo && $error !== true ) { |
2349 | 2349 | |
2350 | - $error = esc_html( $error ); |
|
2350 | + $error = esc_html( $error ); |
|
2351 | 2351 | |
2352 | - /** |
|
2353 | - * @since 1.9 |
|
2354 | - */ |
|
2355 | - if ( ! empty( $this->entry ) ) { |
|
2356 | - $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;" ) ); |
|
2357 | - } |
|
2352 | + /** |
|
2353 | + * @since 1.9 |
|
2354 | + */ |
|
2355 | + if ( ! empty( $this->entry ) ) { |
|
2356 | + $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;" ) ); |
|
2357 | + } |
|
2358 | 2358 | |
2359 | 2359 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
2360 | 2360 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | function load() { |
136 | 136 | |
137 | 137 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
138 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
138 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
139 | 139 | |
140 | 140 | // Don't display an embedded form when editing an entry |
141 | 141 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | add_action( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
146 | 146 | add_action( 'admin_init', array( $this, 'prevent_maybe_process_form' ), 8 ); |
147 | 147 | |
148 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
148 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
149 | 149 | |
150 | 150 | add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 ); |
151 | 151 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
157 | 157 | |
158 | 158 | // Add fields expected by GFFormDisplay::validate() |
159 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
159 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
160 | 160 | |
161 | 161 | // Fix multiselect value for GF 2.2 |
162 | 162 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | */ |
175 | 175 | public function prevent_render_form() { |
176 | - if( $this->is_edit_entry() ) { |
|
177 | - if( 'wp_head' === current_filter() ) { |
|
176 | + if ( $this->is_edit_entry() ) { |
|
177 | + if ( 'wp_head' === current_filter() ) { |
|
178 | 178 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
179 | 179 | } else { |
180 | 180 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -189,17 +189,17 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function prevent_maybe_process_form() { |
191 | 191 | |
192 | - if( ! $this->is_edit_entry_submission() ) { |
|
192 | + if ( ! $this->is_edit_entry_submission() ) { |
|
193 | 193 | return; |
194 | 194 | } |
195 | 195 | |
196 | 196 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' ); |
197 | 197 | |
198 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
199 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
198 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
199 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
200 | 200 | |
201 | - remove_action( 'admin_init', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
202 | - remove_action( 'admin_init', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
201 | + remove_action( 'admin_init', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
202 | + remove_action( 'admin_init', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | $is_edit_entry = |
212 | 212 | ( GravityView_frontend::is_single_entry() || gravityview()->request->is_entry() ) |
213 | - && ( ! empty( $_GET['edit'] ) ); |
|
213 | + && ( ! empty( $_GET[ 'edit' ] ) ); |
|
214 | 214 | |
215 | 215 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
216 | 216 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @return boolean |
222 | 222 | */ |
223 | 223 | public function is_edit_entry_submission() { |
224 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
224 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -234,16 +234,16 @@ discard block |
||
234 | 234 | |
235 | 235 | |
236 | 236 | $entries = $gravityview_view->getEntries(); |
237 | - self::$original_entry = $entries[0]; |
|
238 | - $this->entry = $entries[0]; |
|
237 | + self::$original_entry = $entries[ 0 ]; |
|
238 | + $this->entry = $entries[ 0 ]; |
|
239 | 239 | |
240 | - self::$original_form = GFAPI::get_form( $this->entry['form_id'] ); |
|
240 | + self::$original_form = GFAPI::get_form( $this->entry[ 'form_id' ] ); |
|
241 | 241 | $this->form = $gravityview_view->getForm(); |
242 | - $this->form_id = $this->entry['form_id']; |
|
242 | + $this->form_id = $this->entry[ 'form_id' ]; |
|
243 | 243 | $this->view_id = $gravityview_view->getViewId(); |
244 | 244 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
245 | 245 | |
246 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
246 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | |
271 | 271 | if ( $entry instanceof \GV\Entry ) { |
272 | 272 | $this->entry = $entry->as_entry(); |
273 | - $this->form_id = (int) $entry->as_entry()['form_id']; |
|
273 | + $this->form_id = (int)$entry->as_entry()[ 'form_id' ]; |
|
274 | 274 | $this->form = GFAPI::get_form( $this->form_id ); |
275 | 275 | } |
276 | 276 | |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | private function print_scripts() { |
309 | 309 | $gravityview_view = GravityView_View::getInstance(); |
310 | 310 | |
311 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
311 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
312 | 312 | |
313 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
313 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
314 | 314 | |
315 | 315 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
316 | 316 | |
@@ -326,19 +326,19 @@ discard block |
||
326 | 326 | */ |
327 | 327 | private function process_save( $gv_data ) { |
328 | 328 | |
329 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
329 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
330 | 330 | return; |
331 | 331 | } |
332 | 332 | |
333 | 333 | // Make sure the entry, view, and form IDs are all correct |
334 | 334 | $valid = $this->verify_nonce(); |
335 | 335 | |
336 | - if ( !$valid ) { |
|
336 | + if ( ! $valid ) { |
|
337 | 337 | gravityview()->log->error( 'Nonce validation failed.' ); |
338 | 338 | return; |
339 | 339 | } |
340 | 340 | |
341 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
341 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
342 | 342 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
343 | 343 | return; |
344 | 344 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | |
350 | 350 | $this->validate(); |
351 | 351 | |
352 | - if( $this->is_valid ) { |
|
352 | + if ( $this->is_valid ) { |
|
353 | 353 | |
354 | 354 | gravityview()->log->debug( 'Submission is valid.' ); |
355 | 355 | |
@@ -361,15 +361,15 @@ discard block |
||
361 | 361 | /** |
362 | 362 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
363 | 363 | */ |
364 | - unset( $_GET['page'] ); |
|
364 | + unset( $_GET[ 'page' ] ); |
|
365 | 365 | |
366 | - $date_created = $this->entry['date_created']; |
|
366 | + $date_created = $this->entry[ 'date_created' ]; |
|
367 | 367 | |
368 | 368 | /** |
369 | 369 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
370 | 370 | * @since 1.17.2 |
371 | 371 | */ |
372 | - unset( $this->entry['date_created'] ); |
|
372 | + unset( $this->entry[ 'date_created' ] ); |
|
373 | 373 | |
374 | 374 | /** |
375 | 375 | * @action `gravityview/edit_entry/before_update` Perform an action before the entry has been updated using Edit Entry |
@@ -379,14 +379,14 @@ discard block |
||
379 | 379 | * @param GravityView_Edit_Entry_Render $this This object |
380 | 380 | * @param GravityView_View_Data $gv_data The View data |
381 | 381 | */ |
382 | - do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data ); |
|
382 | + do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data ); |
|
383 | 383 | |
384 | 384 | GFFormsModel::save_lead( $form, $this->entry ); |
385 | 385 | |
386 | 386 | // Delete the values for hidden inputs |
387 | 387 | $this->unset_hidden_field_values(); |
388 | 388 | |
389 | - $this->entry['date_created'] = $date_created; |
|
389 | + $this->entry[ 'date_created' ] = $date_created; |
|
390 | 390 | |
391 | 391 | // Process calculation fields |
392 | 392 | $this->update_calculation_fields(); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * @param GravityView_Edit_Entry_Render $this This object |
412 | 412 | * @param GravityView_View_Data $gv_data The View data |
413 | 413 | */ |
414 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
414 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
415 | 415 | |
416 | 416 | } else { |
417 | 417 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -447,10 +447,10 @@ discard block |
||
447 | 447 | |
448 | 448 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
449 | 449 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
450 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
450 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
451 | 451 | } else { |
452 | 452 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
453 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
453 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -468,11 +468,11 @@ discard block |
||
468 | 468 | |
469 | 469 | $empty_value = $field->get_value_save_entry( |
470 | 470 | is_array( $field->get_entry_inputs() ) ? array() : '', |
471 | - $this->form, '', $this->entry['id'], $this->entry |
|
471 | + $this->form, '', $this->entry[ 'id' ], $this->entry |
|
472 | 472 | ); |
473 | 473 | |
474 | 474 | if ( $field->has_calculation() ) { |
475 | - $this->unset_hidden_calculations[] = $field->id; // Unset |
|
475 | + $this->unset_hidden_calculations[ ] = $field->id; // Unset |
|
476 | 476 | $empty_value = ''; |
477 | 477 | } |
478 | 478 | |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | private function preset_approval_fields() { |
502 | 502 | $has_approved_field = false; |
503 | 503 | |
504 | - foreach ( self::$original_form['fields'] as $field ) { |
|
504 | + foreach ( self::$original_form[ 'fields' ] as $field ) { |
|
505 | 505 | if ( $field->gravityview_approved ) { |
506 | 506 | $has_approved_field = true; |
507 | 507 | break; |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | |
515 | 515 | $is_field_hidden = true; |
516 | 516 | |
517 | - foreach ( $this->form['fields'] as $field ) { |
|
517 | + foreach ( $this->form[ 'fields' ] as $field ) { |
|
518 | 518 | if ( $field->gravityview_approved ) { |
519 | 519 | $is_field_hidden = false; |
520 | 520 | break; |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | |
540 | 540 | remove_filter( 'gravityview/approve_entries/update_unapproved_meta', array( $this, 'prevent_update_unapproved_meta' ), 9 ); |
541 | 541 | |
542 | - if ( ! $value = gform_get_meta( $entry['id'], 'is_approved' ) ) { |
|
542 | + if ( ! $value = gform_get_meta( $entry[ 'id' ], 'is_approved' ) ) { |
|
543 | 543 | |
544 | 544 | $value = GravityView_Entry_Approval_Status::UNAPPROVED; |
545 | 545 | |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | } |
605 | 605 | |
606 | 606 | /** No file is being uploaded. */ |
607 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
607 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
608 | 608 | /** So return the original upload, with $value as backup (it can be empty during edit form rendering) */ |
609 | 609 | return rgar( $entry, $input_id, $value ); |
610 | 610 | } |
@@ -622,11 +622,11 @@ discard block |
||
622 | 622 | * @return mixed |
623 | 623 | */ |
624 | 624 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
625 | - if( ! $this->is_edit_entry() ) { |
|
625 | + if ( ! $this->is_edit_entry() ) { |
|
626 | 626 | return $plupload_init; |
627 | 627 | } |
628 | 628 | |
629 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
629 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
630 | 630 | |
631 | 631 | return $plupload_init; |
632 | 632 | } |
@@ -641,26 +641,26 @@ discard block |
||
641 | 641 | $form = $this->filter_conditional_logic( $this->form ); |
642 | 642 | |
643 | 643 | /** @type GF_Field $field */ |
644 | - foreach( $form['fields'] as $k => &$field ) { |
|
644 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
645 | 645 | |
646 | 646 | /** |
647 | 647 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
648 | 648 | * @since 1.16.3 |
649 | 649 | */ |
650 | - if( $field->has_calculation() ) { |
|
651 | - unset( $form['fields'][ $k ] ); |
|
650 | + if ( $field->has_calculation() ) { |
|
651 | + unset( $form[ 'fields' ][ $k ] ); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | $field->adminOnly = false; |
655 | 655 | |
656 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
657 | - foreach( $field->inputs as $key => $input ) { |
|
658 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
656 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
657 | + foreach ( $field->inputs as $key => $input ) { |
|
658 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | } |
662 | 662 | |
663 | - $form['fields'] = array_values( $form['fields'] ); |
|
663 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
664 | 664 | |
665 | 665 | return $form; |
666 | 666 | } |
@@ -672,14 +672,14 @@ discard block |
||
672 | 672 | $update = false; |
673 | 673 | |
674 | 674 | // get the most up to date entry values |
675 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
675 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
676 | 676 | |
677 | 677 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
678 | 678 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
679 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
679 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
680 | 680 | } else { |
681 | 681 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
682 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
682 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | |
@@ -696,24 +696,24 @@ discard block |
||
696 | 696 | $inputs = $field->get_entry_inputs(); |
697 | 697 | if ( is_array( $inputs ) ) { |
698 | 698 | foreach ( $inputs as $input ) { |
699 | - list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
|
699 | + list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 ); |
|
700 | 700 | |
701 | 701 | if ( 'product' === $field->type ) { |
702 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
702 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
703 | 703 | |
704 | 704 | // Only allow quantity to be set if it's allowed to be edited |
705 | 705 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
706 | 706 | } else { // otherwise set to what it previously was |
707 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
707 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
708 | 708 | } |
709 | 709 | } else { |
710 | 710 | // Set to what it previously was if it's not editable |
711 | 711 | if ( ! in_array( $field_id, $allowed_fields ) ) { |
712 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
712 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
713 | 713 | } |
714 | 714 | } |
715 | 715 | |
716 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
716 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
717 | 717 | } |
718 | 718 | } else { |
719 | 719 | // Set to what it previously was if it's not editable |
@@ -753,19 +753,19 @@ discard block |
||
753 | 753 | |
754 | 754 | $input_name = 'input_' . $field_id; |
755 | 755 | |
756 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
756 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
757 | 757 | |
758 | 758 | // We have a new image |
759 | 759 | |
760 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
760 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
761 | 761 | |
762 | 762 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
763 | 763 | $ary = stripslashes_deep( $ary ); |
764 | 764 | $img_url = \GV\Utils::get( $ary, 0 ); |
765 | 765 | |
766 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
767 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
768 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
766 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
767 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
768 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
769 | 769 | |
770 | 770 | $image_meta = array( |
771 | 771 | 'post_excerpt' => $img_caption, |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | |
775 | 775 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
776 | 776 | if ( ! empty( $img_title ) ) { |
777 | - $image_meta['post_title'] = $img_title; |
|
777 | + $image_meta[ 'post_title' ] = $img_title; |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | /** |
@@ -832,15 +832,15 @@ discard block |
||
832 | 832 | */ |
833 | 833 | private function maybe_update_post_fields( $form ) { |
834 | 834 | |
835 | - if( empty( $this->entry['post_id'] ) ) { |
|
835 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
836 | 836 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
837 | 837 | return; |
838 | 838 | } |
839 | 839 | |
840 | - $post_id = $this->entry['post_id']; |
|
840 | + $post_id = $this->entry[ 'post_id' ]; |
|
841 | 841 | |
842 | 842 | // Security check |
843 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
843 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
844 | 844 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
845 | 845 | return; |
846 | 846 | } |
@@ -853,25 +853,25 @@ discard block |
||
853 | 853 | |
854 | 854 | $field = RGFormsModel::get_field( $form, $field_id ); |
855 | 855 | |
856 | - if( ! $field ) { |
|
856 | + if ( ! $field ) { |
|
857 | 857 | continue; |
858 | 858 | } |
859 | 859 | |
860 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
860 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
861 | 861 | |
862 | 862 | // Get the value of the field, including $_POSTed value |
863 | 863 | $value = RGFormsModel::get_field_value( $field ); |
864 | 864 | |
865 | 865 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
866 | 866 | $entry_tmp = $this->entry; |
867 | - $entry_tmp["{$field_id}"] = $value; |
|
867 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
868 | 868 | |
869 | - switch( $field->type ) { |
|
869 | + switch ( $field->type ) { |
|
870 | 870 | |
871 | 871 | case 'post_title': |
872 | 872 | $post_title = $value; |
873 | 873 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
874 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
874 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
875 | 875 | } |
876 | 876 | $updated_post->post_title = $post_title; |
877 | 877 | $updated_post->post_name = $post_title; |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | case 'post_content': |
882 | 882 | $post_content = $value; |
883 | 883 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
884 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
884 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
885 | 885 | } |
886 | 886 | $updated_post->post_content = $post_content; |
887 | 887 | unset( $post_content ); |
@@ -899,11 +899,11 @@ discard block |
||
899 | 899 | $value = $value[ $field_id ]; |
900 | 900 | } |
901 | 901 | |
902 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
902 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
903 | 903 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
904 | 904 | } |
905 | 905 | |
906 | - $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
|
906 | + $value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry ); |
|
907 | 907 | |
908 | 908 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
909 | 909 | break; |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | } |
916 | 916 | |
917 | 917 | // update entry after |
918 | - $this->entry["{$field_id}"] = $value; |
|
918 | + $this->entry[ "{$field_id}" ] = $value; |
|
919 | 919 | |
920 | 920 | $update_entry = true; |
921 | 921 | |
@@ -924,11 +924,11 @@ discard block |
||
924 | 924 | |
925 | 925 | } |
926 | 926 | |
927 | - if( $update_entry ) { |
|
927 | + if ( $update_entry ) { |
|
928 | 928 | |
929 | 929 | $return_entry = GFAPI::update_entry( $this->entry ); |
930 | 930 | |
931 | - if( is_wp_error( $return_entry ) ) { |
|
931 | + if ( is_wp_error( $return_entry ) ) { |
|
932 | 932 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
933 | 933 | } else { |
934 | 934 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | |
939 | 939 | $return_post = wp_update_post( $updated_post, true ); |
940 | 940 | |
941 | - if( is_wp_error( $return_post ) ) { |
|
941 | + if ( is_wp_error( $return_post ) ) { |
|
942 | 942 | $return_post->add_data( $updated_post, '$updated_post' ); |
943 | 943 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
944 | 944 | } else { |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
973 | 973 | |
974 | 974 | // replace conditional shortcodes |
975 | - if( $do_shortcode ) { |
|
975 | + if ( $do_shortcode ) { |
|
976 | 976 | $output = do_shortcode( $output ); |
977 | 977 | } |
978 | 978 | |
@@ -991,19 +991,19 @@ discard block |
||
991 | 991 | */ |
992 | 992 | private function after_update() { |
993 | 993 | |
994 | - do_action( 'gform_after_update_entry', self::$original_form, $this->entry['id'], self::$original_entry ); |
|
995 | - do_action( "gform_after_update_entry_{$this->form['id']}", self::$original_form, $this->entry['id'], self::$original_entry ); |
|
994 | + do_action( 'gform_after_update_entry', self::$original_form, $this->entry[ 'id' ], self::$original_entry ); |
|
995 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", self::$original_form, $this->entry[ 'id' ], self::$original_entry ); |
|
996 | 996 | |
997 | 997 | // Re-define the entry now that we've updated it. |
998 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
998 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
999 | 999 | |
1000 | 1000 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
1001 | 1001 | |
1002 | 1002 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
1003 | 1003 | // We need to clear the cache because Gravity Forms caches the field values, which |
1004 | 1004 | // we have just updated. |
1005 | - foreach ($this->form['fields'] as $key => $field) { |
|
1006 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
1005 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
1006 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
1007 | 1007 | } |
1008 | 1008 | } |
1009 | 1009 | |
@@ -1013,11 +1013,11 @@ discard block |
||
1013 | 1013 | * @since develop |
1014 | 1014 | */ |
1015 | 1015 | if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) { |
1016 | - $feeds = GFAPI::get_feeds( null, $entry['form_id'] ); |
|
1016 | + $feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] ); |
|
1017 | 1017 | if ( ! is_wp_error( $feeds ) ) { |
1018 | 1018 | $registered_feeds = array(); |
1019 | 1019 | foreach ( GFAddOn::get_registered_addons() as $registered_feed ) { |
1020 | - if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
1020 | + if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
1021 | 1021 | if ( method_exists( $registered_feed, 'get_instance' ) ) { |
1022 | 1022 | $registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) ); |
1023 | 1023 | $registered_feeds[ $registered_feed->get_slug() ] = $registered_feed; |
@@ -1025,8 +1025,8 @@ discard block |
||
1025 | 1025 | } |
1026 | 1026 | } |
1027 | 1027 | foreach ( $feeds as $feed ) { |
1028 | - if ( in_array( $feed['id'], $allowed_feeds ) ) { |
|
1029 | - if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) { |
|
1028 | + if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) { |
|
1029 | + if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) { |
|
1030 | 1030 | $returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form ); |
1031 | 1031 | if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) { |
1032 | 1032 | $entry = $returned_entry; |
@@ -1054,9 +1054,9 @@ discard block |
||
1054 | 1054 | |
1055 | 1055 | $view = \GV\View::by_id( $this->view_id ); |
1056 | 1056 | |
1057 | - if( $view->settings->get( 'edit_locking' ) ) { |
|
1057 | + if ( $view->settings->get( 'edit_locking' ) ) { |
|
1058 | 1058 | $locking = new GravityView_Edit_Entry_Locking(); |
1059 | - $locking->maybe_lock_object( $this->entry['id'] ); |
|
1059 | + $locking->maybe_lock_object( $this->entry[ 'id' ] ); |
|
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | ?> |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | |
1070 | 1070 | <div class="gv-edit-entry-wrapper"><?php |
1071 | 1071 | |
1072 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
1072 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
1073 | 1073 | |
1074 | 1074 | /** |
1075 | 1075 | * Fixes weird wpautop() issue |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | * @param string $edit_entry_title Modify the "Edit Entry" title |
1086 | 1086 | * @param GravityView_Edit_Entry_Render $this This object |
1087 | 1087 | */ |
1088 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1088 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
1089 | 1089 | |
1090 | 1090 | echo esc_attr( $edit_entry_title ); |
1091 | 1091 | ?></span> |
@@ -1151,18 +1151,18 @@ discard block |
||
1151 | 1151 | */ |
1152 | 1152 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1153 | 1153 | |
1154 | - $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
|
1154 | + $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels[ 'submit' ]; |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
1158 | 1158 | |
1159 | - if( ! $this->is_valid ){ |
|
1159 | + if ( ! $this->is_valid ) { |
|
1160 | 1160 | |
1161 | 1161 | // Keeping this compatible with Gravity Forms. |
1162 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
1163 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
1162 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
1163 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
1164 | 1164 | |
1165 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
1165 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
1166 | 1166 | |
1167 | 1167 | } elseif ( false === $this->is_paged_submitted ) { |
1168 | 1168 | // Paged form that hasn't been submitted on the last page yet |
@@ -1175,7 +1175,7 @@ discard block |
||
1175 | 1175 | * @param int $view_id View ID |
1176 | 1176 | * @param array $entry Gravity Forms entry array |
1177 | 1177 | */ |
1178 | - $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message , $this->view_id, $this->entry ); |
|
1178 | + $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message, $this->view_id, $this->entry ); |
|
1179 | 1179 | |
1180 | 1180 | echo GVCommon::generate_notice( $message ); |
1181 | 1181 | } else { |
@@ -1187,23 +1187,23 @@ discard block |
||
1187 | 1187 | |
1188 | 1188 | case '0': |
1189 | 1189 | $redirect_url = $back_link; |
1190 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1190 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
1191 | 1191 | break; |
1192 | 1192 | |
1193 | 1193 | case '1': |
1194 | 1194 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
1195 | - $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>' ); |
|
1195 | + $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>' ); |
|
1196 | 1196 | break; |
1197 | 1197 | |
1198 | 1198 | case '2': |
1199 | 1199 | $redirect_url = $edit_redirect_url; |
1200 | 1200 | $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
1201 | - $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>' ); |
|
1201 | + $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>' ); |
|
1202 | 1202 | break; |
1203 | 1203 | |
1204 | 1204 | case '': |
1205 | 1205 | default: |
1206 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1206 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
1207 | 1207 | break; |
1208 | 1208 | } |
1209 | 1209 | |
@@ -1219,7 +1219,7 @@ discard block |
||
1219 | 1219 | * @param array $entry Gravity Forms entry array |
1220 | 1220 | * @param string $back_link URL to return to the original entry. @since 1.6 |
1221 | 1221 | */ |
1222 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
1222 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
1223 | 1223 | |
1224 | 1224 | echo GVCommon::generate_notice( $message ); |
1225 | 1225 | } |
@@ -1243,8 +1243,8 @@ discard block |
||
1243 | 1243 | */ |
1244 | 1244 | do_action( 'gravityview/edit-entry/render/before', $this ); |
1245 | 1245 | |
1246 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1247 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
1246 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
1247 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1248 | 1248 | add_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
1249 | 1249 | add_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
1250 | 1250 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
@@ -1253,14 +1253,14 @@ discard block |
||
1253 | 1253 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
1254 | 1254 | |
1255 | 1255 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
1256 | - unset( $_GET['page'] ); |
|
1256 | + unset( $_GET[ 'page' ] ); |
|
1257 | 1257 | |
1258 | 1258 | $this->show_next_button = false; |
1259 | 1259 | $this->show_previous_button = false; |
1260 | 1260 | |
1261 | 1261 | // TODO: Verify multiple-page forms |
1262 | 1262 | if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) { |
1263 | - if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form['id'], 0 ) ) ) { |
|
1263 | + if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form[ 'id' ], 0 ) ) ) { |
|
1264 | 1264 | |
1265 | 1265 | $labels = array( |
1266 | 1266 | 'cancel' => __( 'Cancel', 'gravityview' ), |
@@ -1279,20 +1279,20 @@ discard block |
||
1279 | 1279 | */ |
1280 | 1280 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1281 | 1281 | |
1282 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
|
1283 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'is_valid' ] = true; |
|
1282 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'form' ] = $this->form; |
|
1283 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'is_valid' ] = true; |
|
1284 | 1284 | |
1285 | - if ( \GV\Utils::_POST( 'save' ) === $labels['next'] ) { |
|
1285 | + if ( \GV\Utils::_POST( 'save' ) === $labels[ 'next' ] ) { |
|
1286 | 1286 | $last_page = \GFFormDisplay::get_max_page_number( $this->form ); |
1287 | 1287 | |
1288 | 1288 | while ( ++$page_number < $last_page && RGFormsModel::is_page_hidden( $this->form, $page_number, \GV\Utils::_POST( 'gform_field_values' ) ) ) { |
1289 | 1289 | } // Advance to next visible page |
1290 | - } elseif ( \GV\Utils::_POST( 'save' ) === $labels['previous'] ) { |
|
1290 | + } elseif ( \GV\Utils::_POST( 'save' ) === $labels[ 'previous' ] ) { |
|
1291 | 1291 | while ( --$page_number > 1 && RGFormsModel::is_page_hidden( $this->form, $page_number, \GV\Utils::_POST( 'gform_field_values' ) ) ) { |
1292 | 1292 | } // Advance to next visible page |
1293 | 1293 | } |
1294 | 1294 | |
1295 | - GFFormDisplay::$submission[ $this->form['id'] ]['page_number'] = $page_number; |
|
1295 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'page_number' ] = $page_number; |
|
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | if ( ( $page_number = intval( $page_number ) ) < 2 ) { |
@@ -1318,7 +1318,7 @@ discard block |
||
1318 | 1318 | |
1319 | 1319 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1320 | 1320 | |
1321 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1321 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1322 | 1322 | |
1323 | 1323 | ob_get_clean(); |
1324 | 1324 | |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | * @return string |
1347 | 1347 | */ |
1348 | 1348 | public function render_form_buttons() { |
1349 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1349 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1350 | 1350 | } |
1351 | 1351 | |
1352 | 1352 | |
@@ -1365,15 +1365,15 @@ discard block |
||
1365 | 1365 | */ |
1366 | 1366 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1367 | 1367 | |
1368 | - if( $form['id'] != $this->form_id ) { |
|
1368 | + if ( $form[ 'id' ] != $this->form_id ) { |
|
1369 | 1369 | return $form; |
1370 | 1370 | } |
1371 | 1371 | |
1372 | 1372 | // In case we have validated the form, use it to inject the validation results into the form render |
1373 | - if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) { |
|
1373 | + if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) { |
|
1374 | 1374 | $form = $this->form_after_validation; |
1375 | 1375 | } else { |
1376 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1376 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | $form = $this->filter_conditional_logic( $form ); |
@@ -1381,8 +1381,8 @@ discard block |
||
1381 | 1381 | $form = $this->prefill_conditional_logic( $form ); |
1382 | 1382 | |
1383 | 1383 | // for now we don't support Save and Continue feature. |
1384 | - if( ! self::$supports_save_and_continue ) { |
|
1385 | - unset( $form['save'] ); |
|
1384 | + if ( ! self::$supports_save_and_continue ) { |
|
1385 | + unset( $form[ 'save' ] ); |
|
1386 | 1386 | } |
1387 | 1387 | |
1388 | 1388 | $form = $this->unselect_default_values( $form ); |
@@ -1405,31 +1405,31 @@ discard block |
||
1405 | 1405 | */ |
1406 | 1406 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1407 | 1407 | |
1408 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
1408 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
1409 | 1409 | return $field_content; |
1410 | 1410 | } |
1411 | 1411 | |
1412 | 1412 | $message = null; |
1413 | 1413 | |
1414 | 1414 | // First, make sure they have the capability to edit the post. |
1415 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1415 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1416 | 1416 | |
1417 | 1417 | /** |
1418 | 1418 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1419 | 1419 | * @param string $message The existing "You don't have permission..." text |
1420 | 1420 | */ |
1421 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1421 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1422 | 1422 | |
1423 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1423 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1424 | 1424 | /** |
1425 | 1425 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1426 | 1426 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1427 | 1427 | */ |
1428 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1428 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1429 | 1429 | } |
1430 | 1430 | |
1431 | - if( $message ) { |
|
1432 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1431 | + if ( $message ) { |
|
1432 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1433 | 1433 | } |
1434 | 1434 | |
1435 | 1435 | return $field_content; |
@@ -1453,8 +1453,8 @@ discard block |
||
1453 | 1453 | |
1454 | 1454 | // If the form has been submitted, then we don't need to pre-fill the values, |
1455 | 1455 | // Except for fileupload type and when a field input is overridden- run always!! |
1456 | - if( |
|
1457 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1456 | + if ( |
|
1457 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1458 | 1458 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1459 | 1459 | && ! GFCommon::is_product_field( $field->type ) |
1460 | 1460 | || ! empty( $field_content ) |
@@ -1474,7 +1474,7 @@ discard block |
||
1474 | 1474 | $return = null; |
1475 | 1475 | |
1476 | 1476 | /** @var GravityView_Field $gv_field */ |
1477 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1477 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1478 | 1478 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1479 | 1479 | } else { |
1480 | 1480 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1483,7 +1483,7 @@ discard block |
||
1483 | 1483 | // If there was output, it's an error |
1484 | 1484 | $warnings = ob_get_clean(); |
1485 | 1485 | |
1486 | - if( !empty( $warnings ) ) { |
|
1486 | + if ( ! empty( $warnings ) ) { |
|
1487 | 1487 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1488 | 1488 | } |
1489 | 1489 | |
@@ -1508,7 +1508,7 @@ discard block |
||
1508 | 1508 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1509 | 1509 | |
1510 | 1510 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1511 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1511 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1512 | 1512 | |
1513 | 1513 | $field_value = array(); |
1514 | 1514 | |
@@ -1517,10 +1517,10 @@ discard block |
||
1517 | 1517 | |
1518 | 1518 | foreach ( (array)$field->inputs as $input ) { |
1519 | 1519 | |
1520 | - $input_id = strval( $input['id'] ); |
|
1520 | + $input_id = strval( $input[ 'id' ] ); |
|
1521 | 1521 | |
1522 | 1522 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1523 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1523 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1524 | 1524 | $allow_pre_populated = false; |
1525 | 1525 | } |
1526 | 1526 | |
@@ -1528,7 +1528,7 @@ discard block |
||
1528 | 1528 | |
1529 | 1529 | $pre_value = $field->get_value_submission( array(), false ); |
1530 | 1530 | |
1531 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1531 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1532 | 1532 | |
1533 | 1533 | } else { |
1534 | 1534 | |
@@ -1539,13 +1539,13 @@ discard block |
||
1539 | 1539 | |
1540 | 1540 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1541 | 1541 | // or pre-populated value if not empty and set to override saved value |
1542 | - $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; |
|
1542 | + $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; |
|
1543 | 1543 | |
1544 | 1544 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1545 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1545 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1546 | 1546 | $categories = array(); |
1547 | 1547 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1548 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1548 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1549 | 1549 | } |
1550 | 1550 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1551 | 1551 | } |
@@ -1573,7 +1573,7 @@ discard block |
||
1573 | 1573 | * @param GF_Field $field Gravity Forms field object |
1574 | 1574 | * @param GravityView_Edit_Entry_Render $this Current object |
1575 | 1575 | */ |
1576 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1576 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1577 | 1577 | |
1578 | 1578 | return $field_value; |
1579 | 1579 | } |
@@ -1590,12 +1590,12 @@ discard block |
||
1590 | 1590 | */ |
1591 | 1591 | public function gform_pre_validation( $form ) { |
1592 | 1592 | |
1593 | - if( ! $this->verify_nonce() ) { |
|
1593 | + if ( ! $this->verify_nonce() ) { |
|
1594 | 1594 | return $form; |
1595 | 1595 | } |
1596 | 1596 | |
1597 | 1597 | // Fix PHP warning regarding undefined index. |
1598 | - foreach ( $form['fields'] as &$field) { |
|
1598 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1599 | 1599 | |
1600 | 1600 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1601 | 1601 | // expects certain field array items to be set. |
@@ -1603,7 +1603,7 @@ discard block |
||
1603 | 1603 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1604 | 1604 | } |
1605 | 1605 | |
1606 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1606 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1607 | 1607 | |
1608 | 1608 | /** |
1609 | 1609 | * 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. |
@@ -1617,26 +1617,26 @@ discard block |
||
1617 | 1617 | // Set the previous value |
1618 | 1618 | $entry = $this->get_entry(); |
1619 | 1619 | |
1620 | - $input_name = 'input_'.$field->id; |
|
1621 | - $form_id = $form['id']; |
|
1620 | + $input_name = 'input_' . $field->id; |
|
1621 | + $form_id = $form[ 'id' ]; |
|
1622 | 1622 | |
1623 | 1623 | $value = NULL; |
1624 | 1624 | |
1625 | 1625 | // Use the previous entry value as the default. |
1626 | - if( isset( $entry[ $field->id ] ) ) { |
|
1626 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1627 | 1627 | $value = $entry[ $field->id ]; |
1628 | 1628 | } |
1629 | 1629 | |
1630 | 1630 | // If this is a single upload file |
1631 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1632 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1633 | - $value = $file_path['url']; |
|
1631 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1632 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1633 | + $value = $file_path[ 'url' ]; |
|
1634 | 1634 | |
1635 | 1635 | } else { |
1636 | 1636 | |
1637 | 1637 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1638 | 1638 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1639 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1639 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1640 | 1640 | |
1641 | 1641 | } |
1642 | 1642 | |
@@ -1644,10 +1644,10 @@ discard block |
||
1644 | 1644 | |
1645 | 1645 | // If there are fresh uploads, process and merge them. |
1646 | 1646 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1647 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1647 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1648 | 1648 | $value = empty( $value ) ? '[]' : $value; |
1649 | 1649 | $value = stripslashes_deep( $value ); |
1650 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1650 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1651 | 1651 | } |
1652 | 1652 | |
1653 | 1653 | } else { |
@@ -1665,8 +1665,8 @@ discard block |
||
1665 | 1665 | |
1666 | 1666 | case 'number': |
1667 | 1667 | // Fix "undefined index" issue at line 1286 in form_display.php |
1668 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1669 | - $_POST['input_'.$field->id ] = NULL; |
|
1668 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1669 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1670 | 1670 | } |
1671 | 1671 | break; |
1672 | 1672 | } |
@@ -1703,7 +1703,7 @@ discard block |
||
1703 | 1703 | * You can enter whatever you want! |
1704 | 1704 | * We try validating, and customize the results using `self::custom_validation()` |
1705 | 1705 | */ |
1706 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1706 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1707 | 1707 | |
1708 | 1708 | // Needed by the validate funtion |
1709 | 1709 | $failed_validation_page = NULL; |
@@ -1711,14 +1711,14 @@ discard block |
||
1711 | 1711 | |
1712 | 1712 | // Prevent entry limit from running when editing an entry, also |
1713 | 1713 | // prevent form scheduling from preventing editing |
1714 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1714 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1715 | 1715 | |
1716 | 1716 | // Hide fields depending on Edit Entry settings |
1717 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1717 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1718 | 1718 | |
1719 | 1719 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1720 | 1720 | |
1721 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1721 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1722 | 1722 | } |
1723 | 1723 | |
1724 | 1724 | |
@@ -1746,7 +1746,7 @@ discard block |
||
1746 | 1746 | |
1747 | 1747 | $gv_valid = true; |
1748 | 1748 | |
1749 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1749 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1750 | 1750 | |
1751 | 1751 | $value = RGFormsModel::get_field_value( $field ); |
1752 | 1752 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1759,22 +1759,22 @@ discard block |
||
1759 | 1759 | case 'post_image': |
1760 | 1760 | |
1761 | 1761 | // in case nothing is uploaded but there are already files saved |
1762 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1762 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1763 | 1763 | $field->failed_validation = false; |
1764 | 1764 | unset( $field->validation_message ); |
1765 | 1765 | } |
1766 | 1766 | |
1767 | 1767 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1768 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1768 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1769 | 1769 | |
1770 | 1770 | $input_name = 'input_' . $field->id; |
1771 | 1771 | //uploaded |
1772 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1772 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1773 | 1773 | |
1774 | 1774 | //existent |
1775 | 1775 | $entry = $this->get_entry(); |
1776 | 1776 | $value = NULL; |
1777 | - if( isset( $entry[ $field->id ] ) ) { |
|
1777 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1778 | 1778 | $value = json_decode( $entry[ $field->id ], true ); |
1779 | 1779 | } |
1780 | 1780 | |
@@ -1782,13 +1782,13 @@ discard block |
||
1782 | 1782 | $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
1783 | 1783 | ( is_array( $value ) ? count( $value ) : 0 ); |
1784 | 1784 | |
1785 | - if( $count_files > $field->maxFiles ) { |
|
1785 | + if ( $count_files > $field->maxFiles ) { |
|
1786 | 1786 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1787 | 1787 | $field->failed_validation = 1; |
1788 | 1788 | $gv_valid = false; |
1789 | 1789 | |
1790 | 1790 | // in case of error make sure the newest upload files are removed from the upload input |
1791 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1791 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1792 | 1792 | } |
1793 | 1793 | |
1794 | 1794 | } |
@@ -1799,7 +1799,7 @@ discard block |
||
1799 | 1799 | } |
1800 | 1800 | |
1801 | 1801 | // This field has failed validation. |
1802 | - if( !empty( $field->failed_validation ) ) { |
|
1802 | + if ( ! empty( $field->failed_validation ) ) { |
|
1803 | 1803 | |
1804 | 1804 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1805 | 1805 | |
@@ -1817,19 +1817,19 @@ discard block |
||
1817 | 1817 | } |
1818 | 1818 | |
1819 | 1819 | // You can't continue inside a switch, so we do it after. |
1820 | - if( empty( $field->failed_validation ) ) { |
|
1820 | + if ( empty( $field->failed_validation ) ) { |
|
1821 | 1821 | continue; |
1822 | 1822 | } |
1823 | 1823 | |
1824 | 1824 | // checks if the No Duplicates option is not validating entry against itself, since |
1825 | 1825 | // we're editing a stored entry, it would also assume it's a duplicate. |
1826 | - if( !empty( $field->noDuplicates ) ) { |
|
1826 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1827 | 1827 | |
1828 | 1828 | $entry = $this->get_entry(); |
1829 | 1829 | |
1830 | 1830 | // If the value of the entry is the same as the stored value |
1831 | 1831 | // Then we can assume it's not a duplicate, it's the same. |
1832 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1832 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1833 | 1833 | //if value submitted was not changed, then don't validate |
1834 | 1834 | $field->failed_validation = false; |
1835 | 1835 | |
@@ -1842,7 +1842,7 @@ discard block |
||
1842 | 1842 | } |
1843 | 1843 | |
1844 | 1844 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1845 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1845 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1846 | 1846 | unset( $field->validation_message ); |
1847 | 1847 | $field->failed_validation = false; |
1848 | 1848 | continue; |
@@ -1854,12 +1854,12 @@ discard block |
||
1854 | 1854 | |
1855 | 1855 | } |
1856 | 1856 | |
1857 | - $validation_results['is_valid'] = $gv_valid; |
|
1857 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1858 | 1858 | |
1859 | 1859 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1860 | 1860 | |
1861 | 1861 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1862 | - $this->form_after_validation = $validation_results['form']; |
|
1862 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1863 | 1863 | |
1864 | 1864 | return $validation_results; |
1865 | 1865 | } |
@@ -1872,7 +1872,7 @@ discard block |
||
1872 | 1872 | */ |
1873 | 1873 | public function get_entry() { |
1874 | 1874 | |
1875 | - if( empty( $this->entry ) ) { |
|
1875 | + if ( empty( $this->entry ) ) { |
|
1876 | 1876 | // Get the database value of the entry that's being edited |
1877 | 1877 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1878 | 1878 | } |
@@ -1904,10 +1904,10 @@ discard block |
||
1904 | 1904 | } |
1905 | 1905 | |
1906 | 1906 | // If edit tab not yet configured, show all fields |
1907 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1907 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1908 | 1908 | |
1909 | 1909 | // Hide fields depending on admin settings |
1910 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1910 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1911 | 1911 | |
1912 | 1912 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1913 | 1913 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1940,7 +1940,7 @@ discard block |
||
1940 | 1940 | */ |
1941 | 1941 | private function filter_fields( $fields, $configured_fields ) { |
1942 | 1942 | |
1943 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1943 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1944 | 1944 | return $fields; |
1945 | 1945 | } |
1946 | 1946 | |
@@ -1957,12 +1957,12 @@ discard block |
||
1957 | 1957 | |
1958 | 1958 | // Remove the fields that have calculation properties and keep them to be used later |
1959 | 1959 | // @since 1.16.2 |
1960 | - if( $field->has_calculation() ) { |
|
1961 | - $this->fields_with_calculation[] = $field; |
|
1960 | + if ( $field->has_calculation() ) { |
|
1961 | + $this->fields_with_calculation[ ] = $field; |
|
1962 | 1962 | // don't remove the calculation fields on form render. |
1963 | 1963 | } |
1964 | 1964 | |
1965 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1965 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1966 | 1966 | unset( $fields[ $key ] ); |
1967 | 1967 | } |
1968 | 1968 | } |
@@ -1992,7 +1992,7 @@ discard block |
||
1992 | 1992 | continue; // Never include when no fields are configured |
1993 | 1993 | } |
1994 | 1994 | |
1995 | - $out_fields[] = $field; |
|
1995 | + $out_fields[ ] = $field; |
|
1996 | 1996 | } |
1997 | 1997 | |
1998 | 1998 | return array_values( $out_fields ); |
@@ -2003,8 +2003,8 @@ discard block |
||
2003 | 2003 | |
2004 | 2004 | /** @var GF_Field $field */ |
2005 | 2005 | foreach ( $fields as $field ) { |
2006 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
2007 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
2006 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
2007 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
2008 | 2008 | break; |
2009 | 2009 | } |
2010 | 2010 | |
@@ -2027,14 +2027,14 @@ discard block |
||
2027 | 2027 | |
2028 | 2028 | $return_field = $field; |
2029 | 2029 | |
2030 | - if( empty( $field_setting['show_label'] ) ) { |
|
2030 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
2031 | 2031 | $return_field->label = ''; |
2032 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
2033 | - $return_field->label = $field_setting['custom_label']; |
|
2032 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
2033 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
2034 | 2034 | } |
2035 | 2035 | |
2036 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
2037 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
2036 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
2037 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
2038 | 2038 | } |
2039 | 2039 | |
2040 | 2040 | /** |
@@ -2072,16 +2072,16 @@ discard block |
||
2072 | 2072 | */ |
2073 | 2073 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
2074 | 2074 | |
2075 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2076 | - foreach( $fields as $k => $field ) { |
|
2077 | - if( $field->adminOnly ) { |
|
2075 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
2076 | + foreach ( $fields as $k => $field ) { |
|
2077 | + if ( $field->adminOnly ) { |
|
2078 | 2078 | unset( $fields[ $k ] ); |
2079 | 2079 | } |
2080 | 2080 | } |
2081 | 2081 | return array_values( $fields ); |
2082 | 2082 | } |
2083 | 2083 | |
2084 | - foreach( $fields as &$field ) { |
|
2084 | + foreach ( $fields as &$field ) { |
|
2085 | 2085 | $field->adminOnly = false; |
2086 | 2086 | } |
2087 | 2087 | |
@@ -2102,7 +2102,7 @@ discard block |
||
2102 | 2102 | */ |
2103 | 2103 | private function unselect_default_values( $form ) { |
2104 | 2104 | |
2105 | - foreach ( $form['fields'] as &$field ) { |
|
2105 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2106 | 2106 | |
2107 | 2107 | if ( empty( $field->choices ) ) { |
2108 | 2108 | continue; |
@@ -2110,7 +2110,7 @@ discard block |
||
2110 | 2110 | |
2111 | 2111 | foreach ( $field->choices as &$choice ) { |
2112 | 2112 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
2113 | - $choice['isSelected'] = false; |
|
2113 | + $choice[ 'isSelected' ] = false; |
|
2114 | 2114 | } |
2115 | 2115 | } |
2116 | 2116 | } |
@@ -2135,22 +2135,22 @@ discard block |
||
2135 | 2135 | */ |
2136 | 2136 | function prefill_conditional_logic( $form ) { |
2137 | 2137 | |
2138 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
2138 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
2139 | 2139 | return $form; |
2140 | 2140 | } |
2141 | 2141 | |
2142 | 2142 | // Have Conditional Logic pre-fill fields as if the data were default values |
2143 | 2143 | /** @var GF_Field $field */ |
2144 | - foreach ( $form['fields'] as &$field ) { |
|
2144 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2145 | 2145 | |
2146 | - if( 'checkbox' === $field->type ) { |
|
2146 | + if ( 'checkbox' === $field->type ) { |
|
2147 | 2147 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
2148 | - $input_id = $input['id']; |
|
2148 | + $input_id = $input[ 'id' ]; |
|
2149 | 2149 | $choice = $field->choices[ $key ]; |
2150 | 2150 | $value = \GV\Utils::get( $this->entry, $input_id ); |
2151 | 2151 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
2152 | - if( $match ) { |
|
2153 | - $field->choices[ $key ]['isSelected'] = true; |
|
2152 | + if ( $match ) { |
|
2153 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
2154 | 2154 | } |
2155 | 2155 | } |
2156 | 2156 | } else { |
@@ -2158,15 +2158,15 @@ discard block |
||
2158 | 2158 | // We need to run through each field to set the default values |
2159 | 2159 | foreach ( $this->entry as $field_id => $field_value ) { |
2160 | 2160 | |
2161 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2161 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2162 | 2162 | |
2163 | - if( 'list' === $field->type ) { |
|
2163 | + if ( 'list' === $field->type ) { |
|
2164 | 2164 | $list_rows = maybe_unserialize( $field_value ); |
2165 | 2165 | |
2166 | 2166 | $list_field_value = array(); |
2167 | - foreach ( (array) $list_rows as $row ) { |
|
2168 | - foreach ( (array) $row as $column ) { |
|
2169 | - $list_field_value[] = $column; |
|
2167 | + foreach ( (array)$list_rows as $row ) { |
|
2168 | + foreach ( (array)$row as $column ) { |
|
2169 | + $list_field_value[ ] = $column; |
|
2170 | 2170 | } |
2171 | 2171 | } |
2172 | 2172 | |
@@ -2199,32 +2199,32 @@ discard block |
||
2199 | 2199 | * @see https://github.com/gravityview/GravityView/issues/840 |
2200 | 2200 | * @since develop |
2201 | 2201 | */ |
2202 | - $the_form = GFAPI::get_form( $form['id'] ); |
|
2202 | + $the_form = GFAPI::get_form( $form[ 'id' ] ); |
|
2203 | 2203 | $editable_ids = array(); |
2204 | - foreach ( $form['fields'] as $field ) { |
|
2205 | - $editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context |
|
2204 | + foreach ( $form[ 'fields' ] as $field ) { |
|
2205 | + $editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context |
|
2206 | 2206 | } |
2207 | 2207 | $remove_conditions_rule = array(); |
2208 | - foreach ( $the_form['fields'] as $field ) { |
|
2209 | - if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) { |
|
2210 | - foreach ( $field->conditionalLogic['rules'] as $i => $rule ) { |
|
2211 | - if ( ! in_array( $rule['fieldId'], $editable_ids ) ) { |
|
2208 | + foreach ( $the_form[ 'fields' ] as $field ) { |
|
2209 | + if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) { |
|
2210 | + foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) { |
|
2211 | + if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) { |
|
2212 | 2212 | /** |
2213 | 2213 | * This conditional field is not editable in this View. |
2214 | 2214 | * We need to remove the rule, but only if it matches. |
2215 | 2215 | */ |
2216 | - if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) { |
|
2216 | + if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) { |
|
2217 | 2217 | $value = $_field->get_value_export( $this->entry ); |
2218 | - } elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) { |
|
2219 | - $value = $this->entry[ $rule['fieldId'] ]; |
|
2218 | + } elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) { |
|
2219 | + $value = $this->entry[ $rule[ 'fieldId' ] ]; |
|
2220 | 2220 | } else { |
2221 | - $value = gform_get_meta( $this->entry['id'], $rule['fieldId'] ); |
|
2221 | + $value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] ); |
|
2222 | 2222 | } |
2223 | 2223 | |
2224 | - $match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] ); |
|
2224 | + $match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] ); |
|
2225 | 2225 | |
2226 | 2226 | if ( $match ) { |
2227 | - $remove_conditions_rule[] = array( $field['id'], $i ); |
|
2227 | + $remove_conditions_rule[ ] = array( $field[ 'id' ], $i ); |
|
2228 | 2228 | } |
2229 | 2229 | } |
2230 | 2230 | } |
@@ -2232,21 +2232,21 @@ discard block |
||
2232 | 2232 | } |
2233 | 2233 | |
2234 | 2234 | if ( $remove_conditions_rule ) { |
2235 | - foreach ( $form['fields'] as &$field ) { |
|
2235 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2236 | 2236 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2237 | 2237 | |
2238 | 2238 | list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
2239 | 2239 | |
2240 | - if ( $field['id'] == $rule_field_id ) { |
|
2241 | - unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
|
2242 | - gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) ); |
|
2240 | + if ( $field[ 'id' ] == $rule_field_id ) { |
|
2241 | + unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] ); |
|
2242 | + gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) ); |
|
2243 | 2243 | } |
2244 | 2244 | } |
2245 | 2245 | } |
2246 | 2246 | } |
2247 | 2247 | |
2248 | 2248 | /** Normalize the indices... */ |
2249 | - $form['fields'] = array_values( $form['fields'] ); |
|
2249 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
2250 | 2250 | |
2251 | 2251 | /** |
2252 | 2252 | * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields? |
@@ -2256,16 +2256,16 @@ discard block |
||
2256 | 2256 | */ |
2257 | 2257 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
2258 | 2258 | |
2259 | - if( $use_conditional_logic ) { |
|
2259 | + if ( $use_conditional_logic ) { |
|
2260 | 2260 | return $form; |
2261 | 2261 | } |
2262 | 2262 | |
2263 | - foreach( $form['fields'] as &$field ) { |
|
2263 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2264 | 2264 | /* @var GF_Field $field */ |
2265 | 2265 | $field->conditionalLogic = null; |
2266 | 2266 | } |
2267 | 2267 | |
2268 | - unset( $form['button']['conditionalLogic'] ); |
|
2268 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
2269 | 2269 | |
2270 | 2270 | return $form; |
2271 | 2271 | |
@@ -2282,7 +2282,7 @@ discard block |
||
2282 | 2282 | */ |
2283 | 2283 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
2284 | 2284 | |
2285 | - if( ! $this->is_edit_entry() ) { |
|
2285 | + if ( ! $this->is_edit_entry() ) { |
|
2286 | 2286 | return $has_conditional_logic; |
2287 | 2287 | } |
2288 | 2288 | |
@@ -2314,44 +2314,44 @@ discard block |
||
2314 | 2314 | * 2. There are two entries embedded using oEmbed |
2315 | 2315 | * 3. One of the entries has just been saved |
2316 | 2316 | */ |
2317 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
2317 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
2318 | 2318 | |
2319 | 2319 | $error = true; |
2320 | 2320 | |
2321 | 2321 | } |
2322 | 2322 | |
2323 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
2323 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
2324 | 2324 | |
2325 | 2325 | $error = true; |
2326 | 2326 | |
2327 | - } elseif( ! $this->verify_nonce() ) { |
|
2327 | + } elseif ( ! $this->verify_nonce() ) { |
|
2328 | 2328 | |
2329 | 2329 | /** |
2330 | 2330 | * If the Entry is embedded, there may be two entries on the same page. |
2331 | 2331 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
2332 | 2332 | */ |
2333 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
2333 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
2334 | 2334 | $error = true; |
2335 | 2335 | } else { |
2336 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
2336 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
2337 | 2337 | } |
2338 | 2338 | |
2339 | 2339 | } |
2340 | 2340 | |
2341 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
2342 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
2341 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
2342 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
2343 | 2343 | } |
2344 | 2344 | |
2345 | - if( $this->entry['status'] === 'trash' ) { |
|
2346 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
2345 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
2346 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
2347 | 2347 | } |
2348 | 2348 | |
2349 | 2349 | // No errors; everything's fine here! |
2350 | - if( empty( $error ) ) { |
|
2350 | + if ( empty( $error ) ) { |
|
2351 | 2351 | return true; |
2352 | 2352 | } |
2353 | 2353 | |
2354 | - if( $echo && $error !== true ) { |
|
2354 | + if ( $echo && $error !== true ) { |
|
2355 | 2355 | |
2356 | 2356 | $error = esc_html( $error ); |
2357 | 2357 | |
@@ -2359,10 +2359,10 @@ discard block |
||
2359 | 2359 | * @since 1.9 |
2360 | 2360 | */ |
2361 | 2361 | if ( ! empty( $this->entry ) ) { |
2362 | - $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;" ) ); |
|
2362 | + $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;" ) ); |
|
2363 | 2363 | } |
2364 | 2364 | |
2365 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
2365 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
2366 | 2366 | } |
2367 | 2367 | |
2368 | 2368 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2382,17 +2382,17 @@ discard block |
||
2382 | 2382 | |
2383 | 2383 | $error = NULL; |
2384 | 2384 | |
2385 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2386 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
2385 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2386 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
2387 | 2387 | } |
2388 | 2388 | |
2389 | 2389 | // No errors; everything's fine here! |
2390 | - if( empty( $error ) ) { |
|
2390 | + if ( empty( $error ) ) { |
|
2391 | 2391 | return true; |
2392 | 2392 | } |
2393 | 2393 | |
2394 | - if( $echo ) { |
|
2395 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
2394 | + if ( $echo ) { |
|
2395 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
2396 | 2396 | } |
2397 | 2397 | |
2398 | 2398 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2413,14 +2413,14 @@ discard block |
||
2413 | 2413 | private function check_user_cap_edit_field( $field ) { |
2414 | 2414 | |
2415 | 2415 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
2416 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2416 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2417 | 2417 | return true; |
2418 | 2418 | } |
2419 | 2419 | |
2420 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
2420 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
2421 | 2421 | |
2422 | - if( $field_cap ) { |
|
2423 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
2422 | + if ( $field_cap ) { |
|
2423 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
2424 | 2424 | } |
2425 | 2425 | |
2426 | 2426 | return false; |
@@ -2435,17 +2435,17 @@ discard block |
||
2435 | 2435 | return true; |
2436 | 2436 | |
2437 | 2437 | // Verify form submitted for editing single |
2438 | - if( $this->is_edit_entry_submission() ) { |
|
2438 | + if ( $this->is_edit_entry_submission() ) { |
|
2439 | 2439 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2440 | 2440 | } |
2441 | 2441 | |
2442 | 2442 | // Verify |
2443 | - else if( ! $this->is_edit_entry() ) { |
|
2443 | + else if ( ! $this->is_edit_entry() ) { |
|
2444 | 2444 | $valid = false; |
2445 | 2445 | } |
2446 | 2446 | |
2447 | 2447 | else { |
2448 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2448 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2449 | 2449 | } |
2450 | 2450 | |
2451 | 2451 | /** |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @var string The hash key used to generate secure message history |
16 | - * @since 2.2.5 |
|
16 | + * @since 2.2.5 |
|
17 | 17 | */ |
18 | 18 | const beacon_key = 'lCXlwbQR707kipR+J0MCqcxrhGOHjGF0ldD6yNbGM0w='; |
19 | 19 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'payment_id' => '', |
111 | 111 | 'customer_name' => '', |
112 | 112 | 'customer_email' => '', |
113 | - 'price_id' => '0', |
|
113 | + 'price_id' => '0', |
|
114 | 114 | ) ); |
115 | 115 | |
116 | 116 | // This is just HTML we don't need. |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | case 3: |
128 | 128 | $package = 'All Access'; |
129 | 129 | break; |
130 | - case 4: |
|
131 | - $package = 'Lifetime'; |
|
132 | - break; |
|
130 | + case 4: |
|
131 | + $package = 'Lifetime'; |
|
132 | + break; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $current_user = wp_get_current_user(); |
@@ -159,27 +159,27 @@ discard block |
||
159 | 159 | // Help Scout length limit is 200 characters |
160 | 160 | foreach( $data as $key => $value ) { |
161 | 161 | if ( ! is_string( $value ) ) { |
162 | - continue; |
|
162 | + continue; |
|
163 | 163 | } |
164 | - $data[ $key ] = mb_substr( $value, 0, 200 ); |
|
165 | - } |
|
164 | + $data[ $key ] = mb_substr( $value, 0, 200 ); |
|
165 | + } |
|
166 | 166 | |
167 | 167 | $localization_data = array( |
168 | 168 | 'contactEnabled' => (int)GVCommon::has_cap( 'gravityview_contact_support' ), |
169 | 169 | 'data' => $data, |
170 | 170 | 'translation' => $translation, |
171 | - 'suggest' => array(), |
|
171 | + 'suggest' => array(), |
|
172 | 172 | ); |
173 | 173 | |
174 | 174 | /** |
175 | - * @filter `gravityview/support_port/localization_data` Filter data passed to the Support Port, before localize_script is run |
|
175 | + * @filter `gravityview/support_port/localization_data` Filter data passed to the Support Port, before localize_script is run |
|
176 | 176 | * @since 2.0 |
177 | - * @param array $localization_data { |
|
178 | - * @type int $contactEnabled Can the user contact support? |
|
179 | - * @type array $data Support/license info |
|
180 | - * @type array $translation i18n strings |
|
181 | - * @type array $suggest Article IDs to recommend to the user (per page in the admin |
|
182 | - * } |
|
177 | + * @param array $localization_data { |
|
178 | + * @type int $contactEnabled Can the user contact support? |
|
179 | + * @type array $data Support/license info |
|
180 | + * @type array $translation i18n strings |
|
181 | + * @type array $suggest Article IDs to recommend to the user (per page in the admin |
|
182 | + * } |
|
183 | 183 | */ |
184 | 184 | $localization_data = apply_filters( 'gravityview/support_port/localization_data', $localization_data ); |
185 | 185 | |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | * |
194 | 194 | * If the user doesn't have the `gravityview_support_port` capability, returns false; then |
195 | 195 | * If global setting is "hide", returns false; then |
196 | - * If user preference is not set, return global setting; then |
|
197 | - * If user preference is set, return that setting. |
|
196 | + * If user preference is not set, return global setting; then |
|
197 | + * If user preference is set, return that setting. |
|
198 | 198 | * |
199 | 199 | * @since 1.15 |
200 | - * @since 1.17.5 Changed behavior to respect global setting |
|
200 | + * @since 1.17.5 Changed behavior to respect global setting |
|
201 | 201 | * |
202 | 202 | * @param int $user Optional. ID of the user to check, defaults to 0 for current user. |
203 | 203 | * |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $global_setting = gravityview()->plugin->settings->get( 'support_port' ); |
213 | 213 | |
214 | 214 | if ( empty( $global_setting ) ) { |
215 | - return false; |
|
215 | + return false; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | // Get the per-user Support Port setting |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * Modifies the output of profile.php to add GravityView Support preference |
249 | 249 | * |
250 | 250 | * @since 1.15 |
251 | - * @since 1.17.5 Only show if global setting is active |
|
251 | + * @since 1.17.5 Only show if global setting is active |
|
252 | 252 | * |
253 | 253 | * @param WP_User $user Current user info |
254 | 254 | * |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $global_setting = gravityview()->plugin->settings->get( 'support_port' ); |
260 | 260 | |
261 | 261 | if ( empty( $global_setting ) ) { |
262 | - return; |
|
262 | + return; |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -47,7 +47,6 @@ |
||
47 | 47 | * @param string $atts |
48 | 48 | * @param string $css_class |
49 | 49 | * @param string $anchor_text |
50 | - * @param string $link_text |
|
51 | 50 | * |
52 | 51 | * @return string If no article information exists, original tooltip. Otherwise, modified! |
53 | 52 | */ |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function maybe_add_article_to_tooltip( $tooltip = '', $article = array(), $url = '', $atts = '', $css_class = '', $anchor_text = '' ) { |
55 | 55 | |
56 | - if ( empty( $article['id'] ) ) { |
|
56 | + if ( empty( $article[ 'id' ] ) ) { |
|
57 | 57 | return $tooltip; |
58 | 58 | } |
59 | 59 | |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | |
70 | 70 | $css_class .= ' gv_tooltip'; |
71 | 71 | |
72 | - if ( ! empty( $article['type'] ) ) { |
|
73 | - $atts = sprintf( 'data-beacon-article-%s="%s"', $article['type'], $article['id'] ); |
|
72 | + if ( ! empty( $article[ 'type' ] ) ) { |
|
73 | + $atts = sprintf( 'data-beacon-article-%s="%s"', $article[ 'type' ], $article[ 'id' ] ); |
|
74 | 74 | } else { |
75 | - $atts = sprintf( 'data-beacon-article="%s"', $article['id'] ); |
|
75 | + $atts = sprintf( 'data-beacon-article="%s"', $article[ 'id' ] ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $url = \GV\Utils::get( $article, 'url', '#' ); |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | ) ); |
173 | 173 | |
174 | 174 | // This is just HTML we don't need. |
175 | - unset( $response['message'] ); |
|
175 | + unset( $response[ 'message' ] ); |
|
176 | 176 | |
177 | - switch ( intval( $response['price_id'] ) ) { |
|
177 | + switch ( intval( $response[ 'price_id' ] ) ) { |
|
178 | 178 | default: |
179 | 179 | case 1: |
180 | 180 | $package = 'Core'; |
@@ -202,12 +202,12 @@ discard block |
||
202 | 202 | 'signature' => hash_hmac( 'sha256', $current_user->user_email, self::beacon_key ), |
203 | 203 | 'affiliate_id' => gravityview()->plugin->settings->get( 'affiliate_id' ), |
204 | 204 | 'is_super_admin' => is_super_admin(), |
205 | - 'License Key' => $response['license_key'] . ' (' . ucwords( $response['license'] ) . ')', |
|
205 | + 'License Key' => $response[ 'license_key' ] . ' (' . ucwords( $response[ 'license' ] ) . ')', |
|
206 | 206 | 'License Level' => $package, |
207 | 207 | 'Alt Emails' => sprintf( "Admin: %s, GV Support: %s", get_bloginfo( 'admin_email' ), gravityview()->plugin->settings->get( 'support-email' ) ), |
208 | - 'Payment Details' => $response['customer_name'] . ' ' . $response['customer_email'], |
|
208 | + 'Payment Details' => $response[ 'customer_name' ] . ' ' . $response[ 'customer_email' ], |
|
209 | 209 | 'WordPress Version' => get_bloginfo( 'version', 'display' ), |
210 | - 'PHP Version' => phpversion() . ' on ' . esc_html( $_SERVER['SERVER_SOFTWARE'] ), |
|
210 | + 'PHP Version' => phpversion() . ' on ' . esc_html( $_SERVER[ 'SERVER_SOFTWARE' ] ), |
|
211 | 211 | 'No-Conflict Mode' => empty( $no_conflict_mode ) ? 'Disabled' : 'Enabled', |
212 | 212 | 'GravityView Version' => \GV\Plugin::$version, |
213 | 213 | 'Gravity Forms Version' => GFForms::$version, |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | ob_get_clean(); |
218 | 218 | |
219 | 219 | // Help Scout length limit is 200 characters |
220 | - foreach( $data as $key => $value ) { |
|
220 | + foreach ( $data as $key => $value ) { |
|
221 | 221 | if ( ! is_string( $value ) ) { |
222 | 222 | continue; |
223 | 223 | } |
@@ -28,18 +28,18 @@ |
||
28 | 28 | |
29 | 29 | $sort_fields_input = '<select name="template_settings[sort_field][]" class="gravityview_sort_field" id="gravityview_sort_field_%d">%s</select>'; |
30 | 30 | |
31 | - if ( is_array( $current_settings['sort_field'] ) ) { |
|
32 | - $primary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'][0] ); |
|
33 | - $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'][1] ); |
|
31 | + if ( is_array( $current_settings[ 'sort_field' ] ) ) { |
|
32 | + $primary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings[ 'sort_field' ][ 0 ] ); |
|
33 | + $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings[ 'sort_field' ][ 1 ] ); |
|
34 | 34 | } else { |
35 | - $primary_sort_fields = $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'] ); |
|
35 | + $primary_sort_fields = $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings[ 'sort_field' ] ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Splice the sort direction |
39 | 39 | $_directions = array(); |
40 | 40 | foreach ( (array)\GV\Utils::get( $current_settings, 'sort_direction', array() ) as $i => $direction ) { |
41 | 41 | if ( ! $i ) { |
42 | - $_directions['sort_direction'] = $direction; |
|
42 | + $_directions[ 'sort_direction' ] = $direction; |
|
43 | 43 | } else { |
44 | 44 | $_directions[ sprintf( 'sort_direction_%d', $i + 1 ) ] = $direction; |
45 | 45 | } |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @see add_columns_sort_links |
143 | 143 | * @param string $url Single-sort URL |
144 | - * @param array $sort_args Single sorting for rules, in [ field_id, dir ] format |
|
145 | - * @param string|int $field_id ID of the current field being displayed |
|
144 | + * @param string[] $sort_args Single sorting for rules, in [ field_id, dir ] format |
|
145 | + * @param string $field_id ID of the current field being displayed |
|
146 | 146 | * |
147 | 147 | * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url |
148 | 148 | */ |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * Output a field cell. |
347 | 347 | * |
348 | 348 | * @param \GV\Field $field The field to be ouput. |
349 | - * @param \GV\Field $entry The entry this field is for. |
|
349 | + * @param Entry $entry The entry this field is for. |
|
350 | 350 | * |
351 | 351 | * @return void |
352 | 352 | */ |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | |
21 | 21 | /** |
22 | - * Constructor. Add filters to modify output. |
|
23 | - * |
|
22 | + * Constructor. Add filters to modify output. |
|
23 | + * |
|
24 | 24 | * @since 2.0.4 |
25 | 25 | * |
26 | 26 | * @param View $view |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __construct( View $view, Entry_Collection $entries, Request $request ) { |
31 | 31 | |
32 | - add_filter( 'gravityview/template/field/label', array( __CLASS__, 'add_columns_sort_links' ), 100, 2 ); |
|
32 | + add_filter( 'gravityview/template/field/label', array( __CLASS__, 'add_columns_sort_links' ), 100, 2 ); |
|
33 | 33 | |
34 | 34 | parent::__construct( $view, $entries, $request ); |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * Add sorting links to HTML columns that support sorting |
|
39 | - * |
|
40 | - * @since 2.0.4 |
|
41 | - * @since 2.0.5 Made static |
|
42 | - * |
|
43 | - * @static |
|
44 | - * |
|
38 | + * Add sorting links to HTML columns that support sorting |
|
39 | + * |
|
40 | + * @since 2.0.4 |
|
41 | + * @since 2.0.5 Made static |
|
42 | + * |
|
43 | + * @static |
|
44 | + * |
|
45 | 45 | * @param string $column_label Label for the table column |
46 | 46 | * @param \GV\Template_Context $context |
47 | 47 | * |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $sort_columns = $context->view->settings->get( 'sort_columns' ); |
53 | 53 | |
54 | 54 | if ( empty( $sort_columns ) ) { |
55 | - return $column_label; |
|
55 | + return $column_label; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if ( ! \GravityView_frontend::getInstance()->is_field_sortable( $context->field->ID, $context->view->form->form ) ) { |
@@ -102,22 +102,22 @@ discard block |
||
102 | 102 | // If we are already sorting by the current field... |
103 | 103 | if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
104 | 104 | |
105 | - switch( $sorting['direction'] ) { |
|
106 | - // No sort |
|
107 | - case '': |
|
108 | - $sort_args[1] = 'asc'; |
|
109 | - $class .= ' gv-icon-caret-up-down'; |
|
110 | - break; |
|
111 | - case 'desc': |
|
112 | - $sort_args[1] = ''; |
|
113 | - $class .= ' gv-icon-sort-asc'; |
|
114 | - break; |
|
115 | - case 'asc': |
|
116 | - default: |
|
117 | - $sort_args[1] = 'desc'; |
|
118 | - $class .= ' gv-icon-sort-desc'; |
|
119 | - break; |
|
120 | - } |
|
105 | + switch( $sorting['direction'] ) { |
|
106 | + // No sort |
|
107 | + case '': |
|
108 | + $sort_args[1] = 'asc'; |
|
109 | + $class .= ' gv-icon-caret-up-down'; |
|
110 | + break; |
|
111 | + case 'desc': |
|
112 | + $sort_args[1] = ''; |
|
113 | + $class .= ' gv-icon-sort-asc'; |
|
114 | + break; |
|
115 | + case 'asc': |
|
116 | + default: |
|
117 | + $sort_args[1] = 'desc'; |
|
118 | + $class .= ' gv-icon-sort-desc'; |
|
119 | + break; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | } else { |
123 | 123 | $class .= ' gv-icon-caret-up-down'; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $url = remove_query_arg( 'sort', $url ); |
128 | 128 | $multisort_url = self::_get_multisort_url( $url, $sort_args, $context->field->ID ); |
129 | 129 | |
130 | - $url = add_query_arg( $sort_args[0], $sort_args[1], $url ); |
|
130 | + $url = add_query_arg( $sort_args[0], $sort_args[1], $url ); |
|
131 | 131 | |
132 | 132 | $return = '<a href="'. esc_url_raw( $url ) .'"'; |
133 | 133 | |
@@ -141,50 +141,50 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
144 | - * Get the multi-sort URL used in the sorting links |
|
145 | - * |
|
146 | - * @todo Consider moving to Utils? |
|
147 | - * |
|
148 | - * @since 2.3 |
|
149 | - * |
|
150 | - * @see add_columns_sort_links |
|
144 | + * Get the multi-sort URL used in the sorting links |
|
145 | + * |
|
146 | + * @todo Consider moving to Utils? |
|
147 | + * |
|
148 | + * @since 2.3 |
|
149 | + * |
|
150 | + * @see add_columns_sort_links |
|
151 | 151 | * @param string $url Single-sort URL |
152 | 152 | * @param array $sort_args Single sorting for rules, in [ field_id, dir ] format |
153 | - * @param string|int $field_id ID of the current field being displayed |
|
154 | - * |
|
155 | - * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url |
|
153 | + * @param string|int $field_id ID of the current field being displayed |
|
154 | + * |
|
155 | + * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url |
|
156 | 156 | */ |
157 | 157 | static public function _get_multisort_url( $url, $sort_args, $field_id ) { |
158 | 158 | |
159 | 159 | $sorts = Utils::_GET( 'sort' ); |
160 | 160 | |
161 | 161 | if ( ! is_array( $sorts ) ) { |
162 | - return $url; |
|
162 | + return $url; |
|
163 | 163 | } |
164 | 164 | |
165 | - $multisort_url = $url; |
|
165 | + $multisort_url = $url; |
|
166 | 166 | |
167 | 167 | // If the field has already been sorted by, add the field to the URL |
168 | - if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) { |
|
169 | - if ( count( $keys ) ) { |
|
170 | - $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url ); |
|
171 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
172 | - } else { |
|
173 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
174 | - } |
|
175 | - } |
|
176 | - // Otherwise, we are just updating the sort order |
|
177 | - else { |
|
178 | - |
|
179 | - // Pass empty value to unset |
|
180 | - if( '' === $sort_args[1] ) { |
|
181 | - unset( $sorts[ $field_id ] ); |
|
182 | - } else { |
|
183 | - $sorts[ $field_id ] = $sort_args[1]; |
|
184 | - } |
|
185 | - |
|
186 | - $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url ); |
|
187 | - } |
|
168 | + if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) { |
|
169 | + if ( count( $keys ) ) { |
|
170 | + $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url ); |
|
171 | + $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
172 | + } else { |
|
173 | + $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
174 | + } |
|
175 | + } |
|
176 | + // Otherwise, we are just updating the sort order |
|
177 | + else { |
|
178 | + |
|
179 | + // Pass empty value to unset |
|
180 | + if( '' === $sort_args[1] ) { |
|
181 | + unset( $sorts[ $field_id ] ); |
|
182 | + } else { |
|
183 | + $sorts[ $field_id ] = $sort_args[1]; |
|
184 | + } |
|
185 | + |
|
186 | + $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url ); |
|
187 | + } |
|
188 | 188 | |
189 | 189 | return $multisort_url; |
190 | 190 | } |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
217 | - * Returns the label for a column, with support for all deprecated filters |
|
218 | - * |
|
219 | - * @since 2.1 |
|
220 | - * |
|
217 | + * Returns the label for a column, with support for all deprecated filters |
|
218 | + * |
|
219 | + * @since 2.1 |
|
220 | + * |
|
221 | 221 | * @param \GV\Field $field |
222 | 222 | * @param \GV\Template_Context $context |
223 | 223 | */ |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $column_label = apply_filters( 'gravityview/template/field/label', $column_label, $context ); |
241 | 241 | |
242 | 242 | return $column_label; |
243 | - } |
|
243 | + } |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Output the entry row. |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | */ |
310 | 310 | do_action( 'gravityview/template/table/cells/before', $context ); |
311 | 311 | |
312 | - /** |
|
313 | - * @action `gravityview_table_cells_before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
314 | - * @since 1.0.7 |
|
312 | + /** |
|
313 | + * @action `gravityview_table_cells_before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
314 | + * @since 1.0.7 |
|
315 | 315 | * @param \GravityView_View $this Current GravityView_View object |
316 | 316 | * @deprecated Use `gravityview/template/table/cells/before` |
317 | - */ |
|
318 | - do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() ); |
|
317 | + */ |
|
318 | + do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() ); |
|
319 | 319 | |
320 | - foreach ( $fields->all() as $field ) { |
|
320 | + foreach ( $fields->all() as $field ) { |
|
321 | 321 | if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) { |
322 | 322 | if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) { |
323 | 323 | $field = $this->view->unions[ $entry['form_id'] ][ $field->ID ]; |
@@ -337,13 +337,13 @@ discard block |
||
337 | 337 | */ |
338 | 338 | do_action( 'gravityview/template/table/cells/after', $context ); |
339 | 339 | |
340 | - /** |
|
341 | - * @action `gravityview_table_cells_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
342 | - * @since 1.0.7 |
|
340 | + /** |
|
341 | + * @action `gravityview_table_cells_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
342 | + * @since 1.0.7 |
|
343 | 343 | * @param \GravityView_View $this Current GravityView_View object |
344 | 344 | * @deprecated Use `gravityview/template/table/cells/after` |
345 | - */ |
|
346 | - do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() ); |
|
345 | + */ |
|
346 | + do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() ); |
|
347 | 347 | |
348 | 348 | ?> |
349 | 349 | </tr> |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | 'value' => $value, |
385 | 385 | 'hide_empty' => false, |
386 | 386 | 'zone_id' => 'directory_table-columns', |
387 | - 'label' => self::get_field_column_label( $field, $context ), |
|
387 | + 'label' => self::get_field_column_label( $field, $context ), |
|
388 | 388 | 'markup' => '<td id="{{ field_id }}" class="{{ class }}" data-label="{{label_value:data-label}}">{{ value }}</td>', |
389 | - 'form' => $form, |
|
389 | + 'form' => $form, |
|
390 | 390 | ); |
391 | 391 | |
392 | 392 | /** Output. */ |
@@ -411,11 +411,11 @@ discard block |
||
411 | 411 | do_action( 'gravityview/template/table/body/before', $context ); |
412 | 412 | |
413 | 413 | /** |
414 | - * @action `gravityview_table_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows. |
|
415 | - * @deprecated Use `gravityview/template/table/body/before` |
|
416 | - * @since 1.0.7 |
|
417 | - * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
418 | - */ |
|
414 | + * @action `gravityview_table_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows. |
|
415 | + * @deprecated Use `gravityview/template/table/body/before` |
|
416 | + * @since 1.0.7 |
|
417 | + * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
418 | + */ |
|
419 | 419 | do_action( 'gravityview_table_body_before', \GravityView_View::getInstance() /** ugh! */ ); |
420 | 420 | } |
421 | 421 | |
@@ -437,11 +437,11 @@ discard block |
||
437 | 437 | do_action( 'gravityview/template/table/body/after', $context ); |
438 | 438 | |
439 | 439 | /** |
440 | - * @action `gravityview_table_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows. |
|
441 | - * @deprecated Use `gravityview/template/table/body/after` |
|
442 | - * @since 1.0.7 |
|
443 | - * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
444 | - */ |
|
440 | + * @action `gravityview_table_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows. |
|
441 | + * @deprecated Use `gravityview/template/table/body/after` |
|
442 | + * @since 1.0.7 |
|
443 | + * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
444 | + */ |
|
445 | 445 | do_action( 'gravityview_table_body_after', \GravityView_View::getInstance() /** ugh! */ ); |
446 | 446 | } |
447 | 447 |
@@ -69,22 +69,22 @@ discard block |
||
69 | 69 | if ( is_array( $sorts ) ) { |
70 | 70 | foreach ( (array)$sorts as $key => $direction ) { |
71 | 71 | if ( $key == $context->field->ID ) { |
72 | - $sorting['key'] = $context->field->ID; |
|
73 | - $sorting['direction'] = strtolower( $direction ); |
|
72 | + $sorting[ 'key' ] = $context->field->ID; |
|
73 | + $sorting[ 'direction' ] = strtolower( $direction ); |
|
74 | 74 | break; |
75 | 75 | } |
76 | 76 | } |
77 | 77 | } else { |
78 | 78 | if ( $sorts == $context->field->ID ) { |
79 | - $sorting['key'] = $context->field->ID; |
|
80 | - $sorting['direction'] = strtolower( Utils::_GET( 'dir', '' ) ); |
|
79 | + $sorting[ 'key' ] = $context->field->ID; |
|
80 | + $sorting[ 'direction' ] = strtolower( Utils::_GET( 'dir', '' ) ); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | } else { |
84 | 84 | foreach ( (array)$context->view->settings->get( 'sort_field', array() ) as $i => $sort_field ) { |
85 | 85 | if ( $sort_field == $context->field->ID ) { |
86 | - $sorting['key'] = $sort_field; |
|
87 | - $sorting['direction'] = strtolower( Utils::get( $directions, $i, '' ) ); |
|
86 | + $sorting[ 'key' ] = $sort_field; |
|
87 | + $sorting[ 'direction' ] = strtolower( Utils::get( $directions, $i, '' ) ); |
|
88 | 88 | break; // Only get the first sort |
89 | 89 | } |
90 | 90 | } |
@@ -100,21 +100,21 @@ discard block |
||
100 | 100 | ); |
101 | 101 | |
102 | 102 | // If we are already sorting by the current field... |
103 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
103 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
104 | 104 | |
105 | - switch( $sorting['direction'] ) { |
|
105 | + switch ( $sorting[ 'direction' ] ) { |
|
106 | 106 | // No sort |
107 | 107 | case '': |
108 | - $sort_args[1] = 'asc'; |
|
108 | + $sort_args[ 1 ] = 'asc'; |
|
109 | 109 | $class .= ' gv-icon-caret-up-down'; |
110 | 110 | break; |
111 | 111 | case 'desc': |
112 | - $sort_args[1] = ''; |
|
112 | + $sort_args[ 1 ] = ''; |
|
113 | 113 | $class .= ' gv-icon-sort-asc'; |
114 | 114 | break; |
115 | 115 | case 'asc': |
116 | 116 | default: |
117 | - $sort_args[1] = 'desc'; |
|
117 | + $sort_args[ 1 ] = 'desc'; |
|
118 | 118 | $class .= ' gv-icon-sort-desc'; |
119 | 119 | break; |
120 | 120 | } |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | $url = remove_query_arg( 'sort', $url ); |
128 | 128 | $multisort_url = self::_get_multisort_url( $url, $sort_args, $context->field->ID ); |
129 | 129 | |
130 | - $url = add_query_arg( $sort_args[0], $sort_args[1], $url ); |
|
130 | + $url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $url ); |
|
131 | 131 | |
132 | - $return = '<a href="'. esc_url_raw( $url ) .'"'; |
|
132 | + $return = '<a href="' . esc_url_raw( $url ) . '"'; |
|
133 | 133 | |
134 | 134 | if ( ! empty( $multisort_url ) ) { |
135 | - $return .= ' data-multisort-href="'. esc_url_raw( $multisort_url ) . '"'; |
|
135 | + $return .= ' data-multisort-href="' . esc_url_raw( $multisort_url ) . '"'; |
|
136 | 136 | } |
137 | 137 | |
138 | - $return .= ' class="'. $class .'" ></a> '. $column_label; |
|
138 | + $return .= ' class="' . $class . '" ></a> ' . $column_label; |
|
139 | 139 | |
140 | 140 | return $return; |
141 | 141 | } |
@@ -168,19 +168,19 @@ discard block |
||
168 | 168 | if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) { |
169 | 169 | if ( count( $keys ) ) { |
170 | 170 | $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url ); |
171 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
171 | + $multisort_url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $multisort_url ); |
|
172 | 172 | } else { |
173 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
173 | + $multisort_url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $multisort_url ); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | // Otherwise, we are just updating the sort order |
177 | 177 | else { |
178 | 178 | |
179 | 179 | // Pass empty value to unset |
180 | - if( '' === $sort_args[1] ) { |
|
180 | + if ( '' === $sort_args[ 1 ] ) { |
|
181 | 181 | unset( $sorts[ $field_id ] ); |
182 | 182 | } else { |
183 | - $sorts[ $field_id ] = $sort_args[1]; |
|
183 | + $sorts[ $field_id ] = $sort_args[ 1 ]; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url ); |
@@ -318,9 +318,9 @@ discard block |
||
318 | 318 | do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() ); |
319 | 319 | |
320 | 320 | foreach ( $fields->all() as $field ) { |
321 | - if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) { |
|
322 | - if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) { |
|
323 | - $field = $this->view->unions[ $entry['form_id'] ][ $field->ID ]; |
|
321 | + if ( isset( $this->view->unions[ $entry[ 'form_id' ] ] ) ) { |
|
322 | + if ( isset( $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ] ) ) { |
|
323 | + $field = $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ]; |
|
324 | 324 | } else { |
325 | 325 | if ( ! $field instanceof Internal_Field ) { |
326 | 326 | $field = Internal_Field::from_configuration( array( 'id' => 'custom' ) ); |
@@ -170,10 +170,10 @@ |
||
170 | 170 | */ |
171 | 171 | public function is_edit_entry( $form_id = 0 ) { |
172 | 172 | /** |
173 | - * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n |
|
174 | - * The Edit Entry functionality overrides this value. |
|
175 | - * @param boolean $is_edit_entry |
|
176 | - */ |
|
173 | + * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n |
|
174 | + * The Edit Entry functionality overrides this value. |
|
175 | + * @param boolean $is_edit_entry |
|
176 | + */ |
|
177 | 177 | if ( ( $entry = $this->is_entry( $form_id ) ) && apply_filters( 'gravityview_is_edit_entry', false ) ) { |
178 | 178 | if ( $entry->is_multi() ) { |
179 | 179 | return array_pop( $entry->entries ); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public static function is_add_oembed_preview() { |
71 | 71 | /** The preview request is a parse-embed AJAX call without a type set. */ |
72 | - return ( self::is_ajax() && ! empty( $_POST['action'] ) && $_POST['action'] == 'parse-embed' && ! isset( $_POST['type'] ) ); |
|
72 | + return ( self::is_ajax() && ! empty( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'parse-embed' && ! isset( $_POST[ 'type' ] ) ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return boolean |
88 | 88 | */ |
89 | 89 | public static function is_rest() { |
90 | - return ! empty( $GLOBALS['wp']->query_vars['rest_route'] ); |
|
90 | + return ! empty( $GLOBALS[ 'wp' ]->query_vars[ 'rest_route' ] ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! in_array( $e['form_id'], $valid_forms ) ) { |
|
160 | + if ( ! in_array( $e[ 'form_id' ], $valid_forms ) ) { |
|
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | $entry = Multi_Entry::from_entries( array_filter( $multientry ) ); |
176 | - } else { |
|
176 | + } else { |
|
177 | 177 | /** |
178 | 178 | * A regular one. |
179 | 179 | */ |
@@ -231,15 +231,15 @@ discard block |
||
231 | 231 | $get = $_GET; |
232 | 232 | } |
233 | 233 | |
234 | - unset( $get['mode'] ); |
|
234 | + unset( $get[ 'mode' ] ); |
|
235 | 235 | |
236 | 236 | $get = array_filter( $get, 'gravityview_is_not_empty_string' ); |
237 | 237 | |
238 | - if( $has_field_key = $this->_has_field_key( $get ) ) { |
|
238 | + if ( $has_field_key = $this->_has_field_key( $get ) ) { |
|
239 | 239 | return true; |
240 | 240 | } |
241 | 241 | |
242 | - return isset( $get['gv_search'] ) || isset( $get['gv_start'] ) || isset( $get['gv_end'] ) || isset( $get['gv_by'] ) || isset( $get['gv_id'] ); |
|
242 | + return isset( $get[ 'gv_search' ] ) || isset( $get[ 'gv_start' ] ) || isset( $get[ 'gv_end' ] ) || isset( $get[ 'gv_by' ] ) || isset( $get[ 'gv_id' ] ); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | |
263 | 263 | $meta = array(); |
264 | 264 | foreach ( $fields as $field ) { |
265 | - if( empty( $field->_gf_field_class_name ) ) { |
|
266 | - $meta[] = preg_quote( $field->name ); |
|
265 | + if ( empty( $field->_gf_field_class_name ) ) { |
|
266 | + $meta[ ] = preg_quote( $field->name ); |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | 270 | foreach ( $get as $key => $value ) { |
271 | - if ( preg_match('/^filter_(([0-9_]+)|'. implode( '|', $meta ) .')$/sm', $key ) ) { |
|
271 | + if ( preg_match( '/^filter_(([0-9_]+)|' . implode( '|', $meta ) . ')$/sm', $key ) ) { |
|
272 | 272 | $has_field_key = true; |
273 | 273 | break; |
274 | 274 | } |
@@ -173,7 +173,7 @@ |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | $entry = Multi_Entry::from_entries( array_filter( $multientry ) ); |
176 | - } else { |
|
176 | + } else { |
|
177 | 177 | /** |
178 | 178 | * A regular one. |
179 | 179 | */ |
@@ -361,14 +361,14 @@ discard block |
||
361 | 361 | /** |
362 | 362 | * update_approved function. |
363 | 363 | * |
364 | - * @since 1.18 Moved to GravityView_Entry_Approval::update_approved |
|
364 | + * @since 1.18 Moved to GravityView_Entry_Approval::update_approved |
|
365 | 365 | * @see GravityView_Entry_Approval::update_approved |
366 | - * |
|
366 | + * |
|
367 | 367 | * @param int $entry_id (default: 0) |
368 | 368 | * @param int $approved (default: 0) |
369 | 369 | * @param int $form_id (default: 0) |
370 | 370 | * @param int $approvedcolumn (default: 0) |
371 | - * |
|
371 | + * |
|
372 | 372 | * @return boolean True: It worked; False: it failed |
373 | 373 | */ |
374 | 374 | public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
@@ -378,9 +378,9 @@ discard block |
||
378 | 378 | /** |
379 | 379 | * Calculate the approve field.input id |
380 | 380 | * |
381 | - * @since 1.18 Moved to GravityView_Entry_Approval::get_approved_column |
|
382 | - * @see GravityView_Entry_Approval::get_approved_column |
|
383 | - * |
|
381 | + * @since 1.18 Moved to GravityView_Entry_Approval::get_approved_column |
|
382 | + * @see GravityView_Entry_Approval::get_approved_column |
|
383 | + * |
|
384 | 384 | * @param mixed $form GF Form or Form ID |
385 | 385 | * @return false|null|string Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set. |
386 | 386 | */ |
@@ -505,37 +505,37 @@ discard block |
||
505 | 505 | 'bulk_actions' => $this->get_bulk_actions( $form_id ), |
506 | 506 | 'bulk_message' => $this->bulk_update_message, |
507 | 507 | 'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('unapproved'), |
508 | - 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'), |
|
508 | + 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'), |
|
509 | 509 | 'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('approved'), |
510 | 510 | 'column_title' => __( 'Show entry in directory view?', 'gravityview'), |
511 | 511 | 'column_link' => esc_url( $this->get_sort_link() ), |
512 | - 'status_popover_template' => GravityView_Entry_Approval::get_popover_template(), |
|
512 | + 'status_popover_template' => GravityView_Entry_Approval::get_popover_template(), |
|
513 | 513 | 'status_popover_placement' => GravityView_Entry_Approval::get_popover_placement(), |
514 | 514 | ) ); |
515 | 515 | |
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
519 | - * Generate a link to sort by approval status |
|
520 | - * |
|
521 | - * Note: Sorting by approval will never be great because it's not possible currently to declare the sorting as |
|
522 | - * numeric, but it does group the approved entries together. |
|
523 | - * |
|
524 | - * @since 2.0.14 Remove need for approval field for sorting by approval status |
|
525 | - * |
|
519 | + * Generate a link to sort by approval status |
|
520 | + * |
|
521 | + * Note: Sorting by approval will never be great because it's not possible currently to declare the sorting as |
|
522 | + * numeric, but it does group the approved entries together. |
|
523 | + * |
|
524 | + * @since 2.0.14 Remove need for approval field for sorting by approval status |
|
525 | + * |
|
526 | 526 | * @param int $form_id [NO LONGER USED] |
527 | 527 | * |
528 | 528 | * @return string Sorting link |
529 | 529 | */ |
530 | 530 | private function get_sort_link( $form_id = 0 ) { |
531 | 531 | |
532 | - $args = array( |
|
533 | - 'orderby' => 'is_approved', |
|
534 | - 'order' => ( 'desc' === \GV\Utils::_GET( 'order' ) ) ? 'asc' : 'desc', |
|
535 | - ); |
|
532 | + $args = array( |
|
533 | + 'orderby' => 'is_approved', |
|
534 | + 'order' => ( 'desc' === \GV\Utils::_GET( 'order' ) ) ? 'asc' : 'desc', |
|
535 | + ); |
|
536 | 536 | |
537 | 537 | return add_query_arg( $args ); |
538 | - } |
|
538 | + } |
|
539 | 539 | |
540 | 540 | /** |
541 | 541 | * Get an array of options to be added to the Gravity Forms "Bulk action" dropdown in a "GravityView" option group |
@@ -577,9 +577,9 @@ discard block |
||
577 | 577 | // Sanitize the values, just to be sure. |
578 | 578 | foreach ( $bulk_actions as $key => $group ) { |
579 | 579 | |
580 | - if( empty( $group ) ) { |
|
581 | - continue; |
|
582 | - } |
|
580 | + if( empty( $group ) ) { |
|
581 | + continue; |
|
582 | + } |
|
583 | 583 | |
584 | 584 | foreach ( $group as $i => $action ) { |
585 | 585 | $bulk_actions[ $key ][ $i ]['label'] = esc_html( $bulk_actions[ $key ][ $i ]['label'] ); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** gf_entries page - entries table screen */ |
45 | 45 | |
46 | 46 | // capture bulk actions |
47 | - add_action( 'gform_loaded', array( $this, 'process_bulk_action') ); |
|
47 | + add_action( 'gform_loaded', array( $this, 'process_bulk_action' ) ); |
|
48 | 48 | |
49 | 49 | // add hidden field with approve status |
50 | 50 | add_action( 'gform_entries_first_column_actions', array( $this, 'add_entry_approved_hidden_input' ), 1, 5 ); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips' ) ); |
53 | 53 | |
54 | 54 | // adding styles and scripts |
55 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') ); |
|
55 | + add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ) ); |
|
56 | 56 | // bypass Gravity Forms no-conflict mode |
57 | 57 | add_filter( 'gform_noconflict_scripts', array( $this, 'register_gform_noconflict_script' ) ); |
58 | 58 | add_filter( 'gform_noconflict_styles', array( $this, 'register_gform_noconflict_style' ) ); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param bool $show_filter_links True: show the "approved"/"disapproved" filter links. False: hide them. |
82 | 82 | * @param array $form GF Form object of current form |
83 | 83 | */ |
84 | - if( false === apply_filters( 'gravityview/approve_entries/show_filter_links_entry_list', true, $form ) ) { |
|
84 | + if ( false === apply_filters( 'gravityview/approve_entries/show_filter_links_entry_list', true, $form ) ) { |
|
85 | 85 | return $filter_links; |
86 | 86 | } |
87 | 87 | |
@@ -109,27 +109,27 @@ discard block |
||
109 | 109 | $approved_count = $disapproved_count = $unapproved_count = 0; |
110 | 110 | |
111 | 111 | // Only count if necessary |
112 | - if( $include_counts ) { |
|
113 | - $approved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_approved ) ) ); |
|
114 | - $disapproved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_disapproved ) ) ); |
|
115 | - $unapproved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_unapproved ) ) ); |
|
112 | + if ( $include_counts ) { |
|
113 | + $approved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_approved ) ) ); |
|
114 | + $disapproved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_disapproved ) ) ); |
|
115 | + $unapproved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_unapproved ) ) ); |
|
116 | 116 | } |
117 | 117 | |
118 | - $filter_links[] = array( |
|
118 | + $filter_links[ ] = array( |
|
119 | 119 | 'id' => 'gv_approved', |
120 | 120 | 'field_filters' => $field_filters_approved, |
121 | 121 | 'count' => $approved_count, |
122 | 122 | 'label' => GravityView_Entry_Approval_Status::get_label( GravityView_Entry_Approval_Status::APPROVED ), |
123 | 123 | ); |
124 | 124 | |
125 | - $filter_links[] = array( |
|
125 | + $filter_links[ ] = array( |
|
126 | 126 | 'id' => 'gv_disapproved', |
127 | 127 | 'field_filters' => $field_filters_disapproved, |
128 | 128 | 'count' => $disapproved_count, |
129 | 129 | 'label' => GravityView_Entry_Approval_Status::get_label( GravityView_Entry_Approval_Status::DISAPPROVED ), |
130 | 130 | ); |
131 | 131 | |
132 | - $filter_links[] = array( |
|
132 | + $filter_links[ ] = array( |
|
133 | 133 | 'id' => 'gv_unapproved', |
134 | 134 | 'field_filters' => $field_filters_unapproved, |
135 | 135 | 'count' => $unapproved_count, |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | */ |
149 | 149 | function tooltips( $tooltips ) { |
150 | 150 | |
151 | - $tooltips['form_gravityview_fields'] = array( |
|
152 | - 'title' => __('GravityView Fields', 'gravityview'), |
|
153 | - 'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview'), |
|
151 | + $tooltips[ 'form_gravityview_fields' ] = array( |
|
152 | + 'title' => __( 'GravityView Fields', 'gravityview' ), |
|
153 | + 'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview' ), |
|
154 | 154 | ); |
155 | 155 | |
156 | 156 | return $tooltips; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | $gv_bulk_action = false; |
263 | 263 | |
264 | - if( version_compare( GFForms::$version, '2.0', '>=' ) ) { |
|
264 | + if ( version_compare( GFForms::$version, '2.0', '>=' ) ) { |
|
265 | 265 | $bulk_action = ( '-1' !== \GV\Utils::_POST( 'action' ) ) ? \GV\Utils::_POST( 'action' ) : \GV\Utils::_POST( 'action2' ); |
266 | 266 | } else { |
267 | 267 | // GF 1.9.x - Bulk action 2 is the bottom bulk action select form. |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | } |
270 | 270 | |
271 | 271 | // Check the $bulk_action value against GV actions, see if they're the same. I hate strpos(). |
272 | - if( ! empty( $bulk_action ) && preg_match( '/^('. implode( '|', $this->bulk_action_prefixes ) .')/ism', $bulk_action ) ) { |
|
272 | + if ( ! empty( $bulk_action ) && preg_match( '/^(' . implode( '|', $this->bulk_action_prefixes ) . ')/ism', $bulk_action ) ) { |
|
273 | 273 | $gv_bulk_action = $bulk_action; |
274 | 274 | } |
275 | 275 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | |
295 | 295 | // gforms_entry_list is the nonce that confirms we're on the right page |
296 | 296 | // gforms_update_note is sent when bulk editing entry notes. We don't want to process then. |
297 | - if ( $bulk_action && \GV\Utils::_POST( 'gforms_entry_list' ) && empty( $_POST['gforms_update_note'] ) ) { |
|
297 | + if ( $bulk_action && \GV\Utils::_POST( 'gforms_entry_list' ) && empty( $_POST[ 'gforms_update_note' ] ) ) { |
|
298 | 298 | |
299 | 299 | check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' ); |
300 | 300 | |
@@ -312,13 +312,13 @@ discard block |
||
312 | 312 | } |
313 | 313 | |
314 | 314 | // All entries are set to be updated, not just the visible ones |
315 | - if ( ! empty( $_POST['all_entries'] ) ) { |
|
315 | + if ( ! empty( $_POST[ 'all_entries' ] ) ) { |
|
316 | 316 | |
317 | 317 | // Convert the current entry search into GF-formatted search criteria |
318 | 318 | $search = array( |
319 | - 'search_field' => isset( $_POST['f'] ) ? $_POST['f'][0] : 0, |
|
320 | - 'search_value' => isset( $_POST['v'][0] ) ? $_POST['v'][0] : '', |
|
321 | - 'search_operator' => isset( $_POST['o'][0] ) ? $_POST['o'][0] : 'contains', |
|
319 | + 'search_field' => isset( $_POST[ 'f' ] ) ? $_POST[ 'f' ][ 0 ] : 0, |
|
320 | + 'search_value' => isset( $_POST[ 'v' ][ 0 ] ) ? $_POST[ 'v' ][ 0 ] : '', |
|
321 | + 'search_operator' => isset( $_POST[ 'o' ][ 0 ] ) ? $_POST[ 'o' ][ 0 ] : 'contains', |
|
322 | 322 | ); |
323 | 323 | |
324 | 324 | $search_criteria = GravityView_frontend::get_search_criteria( $search, $form_id ); |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | } else { |
330 | 330 | |
331 | 331 | // Changed from 'lead' to 'entry' in 2.0 |
332 | - $entries = isset( $_POST['lead'] ) ? $_POST['lead'] : $_POST['entry']; |
|
332 | + $entries = isset( $_POST[ 'lead' ] ) ? $_POST[ 'lead' ] : $_POST[ 'entry' ]; |
|
333 | 333 | |
334 | 334 | } |
335 | 335 | |
@@ -341,15 +341,15 @@ discard block |
||
341 | 341 | $entry_count = count( $entries ) > 1 ? sprintf( __( '%d entries', 'gravityview' ), count( $entries ) ) : __( '1 entry', 'gravityview' ); |
342 | 342 | |
343 | 343 | switch ( $approved_status ) { |
344 | - case $this->bulk_action_prefixes['approve']: |
|
344 | + case $this->bulk_action_prefixes[ 'approve' ]: |
|
345 | 345 | GravityView_Entry_Approval::update_bulk( $entries, GravityView_Entry_Approval_Status::APPROVED, $form_id ); |
346 | 346 | $this->bulk_update_message = sprintf( __( '%s approved.', 'gravityview' ), $entry_count ); |
347 | 347 | break; |
348 | - case $this->bulk_action_prefixes['unapprove']: |
|
348 | + case $this->bulk_action_prefixes[ 'unapprove' ]: |
|
349 | 349 | GravityView_Entry_Approval::update_bulk( $entries, GravityView_Entry_Approval_Status::UNAPPROVED, $form_id ); |
350 | 350 | $this->bulk_update_message = sprintf( __( '%s unapproved.', 'gravityview' ), $entry_count ); |
351 | 351 | break; |
352 | - case $this->bulk_action_prefixes['disapprove']: |
|
352 | + case $this->bulk_action_prefixes[ 'disapprove' ]: |
|
353 | 353 | GravityView_Entry_Approval::update_bulk( $entries, GravityView_Entry_Approval_Status::DISAPPROVED, $form_id ); |
354 | 354 | $this->bulk_update_message = sprintf( __( '%s disapproved.', 'gravityview' ), $entry_count ); |
355 | 355 | break; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return boolean True: It worked; False: it failed |
373 | 373 | */ |
374 | - public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
|
374 | + public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0 ) { |
|
375 | 375 | return GravityView_Entry_Approval::update_approved( $entry_id, $approved, $form_id, $approvedcolumn ); |
376 | 376 | } |
377 | 377 | |
@@ -401,20 +401,20 @@ discard block |
||
401 | 401 | * |
402 | 402 | * @return void |
403 | 403 | */ |
404 | - static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) { |
|
404 | + static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) { |
|
405 | 405 | |
406 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry['id'] ) ) { |
|
406 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry[ 'id' ] ) ) { |
|
407 | 407 | return; |
408 | 408 | } |
409 | 409 | |
410 | - if( empty( $entry['id'] ) ) { |
|
410 | + if ( empty( $entry[ 'id' ] ) ) { |
|
411 | 411 | return; |
412 | 412 | } |
413 | 413 | |
414 | 414 | $status_value = GravityView_Entry_Approval::get_entry_status( $entry, 'value' ); |
415 | 415 | |
416 | - if( $status_value ) { |
|
417 | - echo '<input type="hidden" class="entry_approval" id="entry_approved_'. $entry['id'] .'" value="' . esc_attr( $status_value ) . '" />'; |
|
416 | + if ( $status_value ) { |
|
417 | + echo '<input type="hidden" class="entry_approval" id="entry_approved_' . $entry[ 'id' ] . '" value="' . esc_attr( $status_value ) . '" />'; |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 | |
@@ -427,10 +427,10 @@ discard block |
||
427 | 427 | */ |
428 | 428 | private function get_form_id() { |
429 | 429 | |
430 | - $form_id = GFForms::get('id'); |
|
430 | + $form_id = GFForms::get( 'id' ); |
|
431 | 431 | |
432 | 432 | // If there are no forms identified, use the first form. That's how GF does it. |
433 | - if( empty( $form_id ) && class_exists('RGFormsModel') ) { |
|
433 | + if ( empty( $form_id ) && class_exists( 'RGFormsModel' ) ) { |
|
434 | 434 | $form_id = $this->get_first_form_id(); |
435 | 435 | } |
436 | 436 | |
@@ -450,14 +450,14 @@ discard block |
||
450 | 450 | |
451 | 451 | $forms = RGFormsModel::get_forms( null, 'title' ); |
452 | 452 | |
453 | - if( ! isset( $forms[0] ) ) { |
|
453 | + if ( ! isset( $forms[ 0 ] ) ) { |
|
454 | 454 | gravityview()->log->error( 'No forms were found' ); |
455 | 455 | return 0; |
456 | 456 | } |
457 | 457 | |
458 | - $first_form = $forms[0]; |
|
458 | + $first_form = $forms[ 0 ]; |
|
459 | 459 | |
460 | - $form_id = is_object( $forms[0] ) ? $first_form->id : $first_form['id']; |
|
460 | + $form_id = is_object( $forms[ 0 ] ) ? $first_form->id : $first_form[ 'id' ]; |
|
461 | 461 | |
462 | 462 | return intval( $form_id ); |
463 | 463 | } |
@@ -465,37 +465,37 @@ discard block |
||
465 | 465 | |
466 | 466 | function add_scripts_and_styles( $hook ) { |
467 | 467 | |
468 | - if( ! class_exists( 'GFForms' ) ) { |
|
468 | + if ( ! class_exists( 'GFForms' ) ) { |
|
469 | 469 | gravityview()->log->error( 'GFForms does not exist.' ); |
470 | 470 | return; |
471 | 471 | } |
472 | 472 | |
473 | 473 | // enqueue styles & scripts gf_entries |
474 | 474 | // But only if we're on the main Entries page, not on reports pages |
475 | - if( GFForms::get_page() !== 'entry_list' ) { |
|
475 | + if ( GFForms::get_page() !== 'entry_list' ) { |
|
476 | 476 | return; |
477 | 477 | } |
478 | 478 | |
479 | 479 | $form_id = $this->get_form_id(); |
480 | 480 | |
481 | 481 | // Things are broken; no forms were found |
482 | - if( empty( $form_id ) ) { |
|
482 | + if ( empty( $form_id ) ) { |
|
483 | 483 | return; |
484 | 484 | } |
485 | 485 | |
486 | - wp_enqueue_style( 'gravityview_entries_list', plugins_url('assets/css/admin-entries-list.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
486 | + wp_enqueue_style( 'gravityview_entries_list', plugins_url( 'assets/css/admin-entries-list.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
|
487 | 487 | |
488 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
488 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
489 | 489 | |
490 | - wp_enqueue_script( 'gravityview_gf_entries_scripts', plugins_url('assets/js/admin-entries-list'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version ); |
|
490 | + wp_enqueue_script( 'gravityview_gf_entries_scripts', plugins_url( 'assets/js/admin-entries-list' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version ); |
|
491 | 491 | |
492 | 492 | wp_enqueue_script( 'gravityview_entries_list-popper', plugins_url( 'assets/lib/tippy/popper.min.js', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
493 | 493 | wp_enqueue_script( 'gravityview_entries_list-tippy', plugins_url( 'assets/lib/tippy/tippy.min.js', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
494 | 494 | wp_enqueue_style( 'gravityview_entries_list-tippy', plugins_url( 'assets/lib/tippy/tippy.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
495 | 495 | |
496 | 496 | wp_localize_script( 'gravityview_gf_entries_scripts', 'gvGlobals', array( |
497 | - 'nonce' => wp_create_nonce( 'gravityview_entry_approval'), |
|
498 | - 'admin_nonce' => wp_create_nonce( 'gravityview_admin_entry_approval'), |
|
497 | + 'nonce' => wp_create_nonce( 'gravityview_entry_approval' ), |
|
498 | + 'admin_nonce' => wp_create_nonce( 'gravityview_admin_entry_approval' ), |
|
499 | 499 | 'form_id' => $form_id, |
500 | 500 | 'show_column' => (int)$this->show_approve_entry_column( $form_id ), |
501 | 501 | 'add_bulk_action' => (int)GVCommon::has_cap( 'gravityview_moderate_entries' ), |
@@ -504,10 +504,10 @@ discard block |
||
504 | 504 | 'status_unapproved' => GravityView_Entry_Approval_Status::UNAPPROVED, |
505 | 505 | 'bulk_actions' => $this->get_bulk_actions( $form_id ), |
506 | 506 | 'bulk_message' => $this->bulk_update_message, |
507 | - 'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('unapproved'), |
|
508 | - 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'), |
|
509 | - 'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('approved'), |
|
510 | - 'column_title' => __( 'Show entry in directory view?', 'gravityview'), |
|
507 | + 'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr( 'unapproved' ), |
|
508 | + 'approve_title' => GravityView_Entry_Approval_Status::get_title_attr( 'disapproved' ), |
|
509 | + 'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr( 'approved' ), |
|
510 | + 'column_title' => __( 'Show entry in directory view?', 'gravityview' ), |
|
511 | 511 | 'column_link' => esc_url( $this->get_sort_link() ), |
512 | 512 | 'status_popover_template' => GravityView_Entry_Approval::get_popover_template(), |
513 | 513 | 'status_popover_placement' => GravityView_Entry_Approval::get_popover_placement(), |
@@ -551,16 +551,16 @@ discard block |
||
551 | 551 | $bulk_actions = array( |
552 | 552 | 'GravityView' => array( |
553 | 553 | array( |
554 | - 'label' => GravityView_Entry_Approval_Status::get_string('approved', 'action'), |
|
555 | - 'value' => sprintf( '%s-%d', $this->bulk_action_prefixes['approve'], $form_id ), |
|
554 | + 'label' => GravityView_Entry_Approval_Status::get_string( 'approved', 'action' ), |
|
555 | + 'value' => sprintf( '%s-%d', $this->bulk_action_prefixes[ 'approve' ], $form_id ), |
|
556 | 556 | ), |
557 | 557 | array( |
558 | - 'label' => GravityView_Entry_Approval_Status::get_string('disapproved', 'action'), |
|
559 | - 'value' => sprintf( '%s-%d', $this->bulk_action_prefixes['disapprove'], $form_id ), |
|
558 | + 'label' => GravityView_Entry_Approval_Status::get_string( 'disapproved', 'action' ), |
|
559 | + 'value' => sprintf( '%s-%d', $this->bulk_action_prefixes[ 'disapprove' ], $form_id ), |
|
560 | 560 | ), |
561 | 561 | array( |
562 | - 'label' => GravityView_Entry_Approval_Status::get_string('unapproved', 'action'), |
|
563 | - 'value' => sprintf( '%s-%d', $this->bulk_action_prefixes['unapprove'], $form_id ), |
|
562 | + 'label' => GravityView_Entry_Approval_Status::get_string( 'unapproved', 'action' ), |
|
563 | + 'value' => sprintf( '%s-%d', $this->bulk_action_prefixes[ 'unapprove' ], $form_id ), |
|
564 | 564 | ), |
565 | 565 | ), |
566 | 566 | ); |
@@ -577,13 +577,13 @@ discard block |
||
577 | 577 | // Sanitize the values, just to be sure. |
578 | 578 | foreach ( $bulk_actions as $key => $group ) { |
579 | 579 | |
580 | - if( empty( $group ) ) { |
|
580 | + if ( empty( $group ) ) { |
|
581 | 581 | continue; |
582 | 582 | } |
583 | 583 | |
584 | 584 | foreach ( $group as $i => $action ) { |
585 | - $bulk_actions[ $key ][ $i ]['label'] = esc_html( $bulk_actions[ $key ][ $i ]['label'] ); |
|
586 | - $bulk_actions[ $key ][ $i ]['value'] = esc_attr( $bulk_actions[ $key ][ $i ]['value'] ); |
|
585 | + $bulk_actions[ $key ][ $i ][ 'label' ] = esc_html( $bulk_actions[ $key ][ $i ][ 'label' ] ); |
|
586 | + $bulk_actions[ $key ][ $i ][ 'value' ] = esc_attr( $bulk_actions[ $key ][ $i ][ 'value' ] ); |
|
587 | 587 | } |
588 | 588 | } |
589 | 589 | |
@@ -608,13 +608,13 @@ discard block |
||
608 | 608 | * @since 1.7.2 |
609 | 609 | * @param boolean $hide_if_no_connections |
610 | 610 | */ |
611 | - $hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false ); |
|
611 | + $hide_if_no_connections = apply_filters( 'gravityview/approve_entries/hide-if-no-connections', false ); |
|
612 | 612 | |
613 | - if( $hide_if_no_connections ) { |
|
613 | + if ( $hide_if_no_connections ) { |
|
614 | 614 | |
615 | 615 | $connected_views = gravityview_get_connected_views( $form_id ); |
616 | 616 | |
617 | - if( empty( $connected_views ) ) { |
|
617 | + if ( empty( $connected_views ) ) { |
|
618 | 618 | $show_approve_column = false; |
619 | 619 | } |
620 | 620 | } |
@@ -624,21 +624,21 @@ discard block |
||
624 | 624 | * @param boolean $show_approve_column Whether the column will be shown |
625 | 625 | * @param int $form_id The ID of the Gravity Forms form for which entries are being shown |
626 | 626 | */ |
627 | - $show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id ); |
|
627 | + $show_approve_column = apply_filters( 'gravityview/approve_entries/show-column', $show_approve_column, $form_id ); |
|
628 | 628 | |
629 | 629 | return $show_approve_column; |
630 | 630 | } |
631 | 631 | |
632 | 632 | function register_gform_noconflict_script( $scripts ) { |
633 | - $scripts[] = 'gravityview_gf_entries_scripts'; |
|
634 | - $scripts[] = 'gravityview_entries_list-popper'; |
|
635 | - $scripts[] = 'gravityview_entries_list-tippy'; |
|
633 | + $scripts[ ] = 'gravityview_gf_entries_scripts'; |
|
634 | + $scripts[ ] = 'gravityview_entries_list-popper'; |
|
635 | + $scripts[ ] = 'gravityview_entries_list-tippy'; |
|
636 | 636 | return $scripts; |
637 | 637 | } |
638 | 638 | |
639 | 639 | function register_gform_noconflict_style( $styles ) { |
640 | - $styles[] = 'gravityview_entries_list'; |
|
641 | - $styles[] = 'gravityview_entries_list-tippy'; |
|
640 | + $styles[ ] = 'gravityview_entries_list'; |
|
641 | + $styles[ ] = 'gravityview_entries_list-tippy'; |
|
642 | 642 | return $styles; |
643 | 643 | } |
644 | 644 |
@@ -278,7 +278,7 @@ |
||
278 | 278 | * Capture bulk actions - gf_entries table |
279 | 279 | * |
280 | 280 | * @uses GravityView_frontend::get_search_criteria() Convert the $_POST search request into a properly formatted request. |
281 | - * @return void|boolean |
|
281 | + * @return false|null |
|
282 | 282 | */ |
283 | 283 | public function process_bulk_action() { |
284 | 284 |
@@ -76,7 +76,7 @@ |
||
76 | 76 | * @param \GV\View $view The view we're looking at. |
77 | 77 | * @param string $path The path of the offending template. |
78 | 78 | * |
79 | - * @return \Callable A closure used in the filter. |
|
79 | + * @return \Closure A closure used in the filter. |
|
80 | 80 | */ |
81 | 81 | public function legacy_template_warning( $view, $path ) { |
82 | 82 | return function() use ( $view, $path ) { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $current_user = wp_get_current_user(); |
82 | 82 | $user_meta_key = '_gv_dismissed_entry_approval_notice' . $gravityview->view->ID; |
83 | 83 | |
84 | - if ( isset( $_GET['gv-dismiss'] ) && wp_verify_nonce( $_GET['gv-dismiss'], 'dismiss' ) ) { |
|
84 | + if ( isset( $_GET[ 'gv-dismiss' ] ) && wp_verify_nonce( $_GET[ 'gv-dismiss' ], 'dismiss' ) ) { |
|
85 | 85 | add_user_meta( $current_user->ID, $user_meta_key, 1 ); // Prevent user from seeing this again for this View |
86 | 86 | return; |
87 | 87 | } |
@@ -150,8 +150,7 @@ discard block |
||
150 | 150 | $tab = __( 'Edit Entry', 'gravityview' ); |
151 | 151 | $context = 'edit'; |
152 | 152 | break; |
153 | - case ( $gravityview->request->is_entry( $gravityview->view->form ? $gravityview->view->form->ID : 0 ) ): |
|
154 | - $tab = __( 'Single Entry', 'gravityview' ); |
|
153 | + case ( $gravityview->request->is_entry( $gravityview->view->form ? $gravityview->view->form->ID : 0 ) ) : $tab = __( 'Single Entry', 'gravityview' ); |
|
155 | 154 | $context = 'single'; |
156 | 155 | break; |
157 | 156 | default: |
@@ -173,7 +172,7 @@ discard block |
||
173 | 172 | $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
174 | 173 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
175 | 174 | |
176 | - $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
175 | + $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
177 | 176 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
178 | 177 | |
179 | 178 | echo \GVCommon::generate_notice( $output . $image, 'gv-warning warning', 'edit_gravityview', $gravityview->view->ID ); |
@@ -199,11 +198,11 @@ discard block |
||
199 | 198 | |
200 | 199 | $post_types = get_post_types(); |
201 | 200 | |
202 | - foreach( $post_types as $post_type ) { |
|
201 | + foreach ( $post_types as $post_type ) { |
|
203 | 202 | $post_type_rewrite = get_post_type_object( $post_type )->rewrite; |
204 | 203 | |
205 | 204 | if ( $slug = \GV\Utils::get( $post_type_rewrite, 'slug' ) ) { |
206 | - $reserved_slugs[] = $slug; |
|
205 | + $reserved_slugs[ ] = $slug; |
|
207 | 206 | } |
208 | 207 | } |
209 | 208 |