@@ -36,7 +36,6 @@ |
||
36 | 36 | * @since 1.16.4 |
37 | 37 | * @since 1.17 Moved to GravityView_Plugin_Hooks_Gravity_Forms_Survey class |
38 | 38 | * |
39 | - * @param array $form |
|
40 | 39 | * |
41 | 40 | * @return array Form, with all fields set to `allowsPrepopulate => true` |
42 | 41 | */ |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $return = $input_type; |
47 | 47 | |
48 | - if( 'survey' === $field_type ) { |
|
48 | + if ( 'survey' === $field_type ) { |
|
49 | 49 | $return = 'select'; |
50 | 50 | } |
51 | 51 | |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | public function fix_survey_fields( $fields ) { |
66 | 66 | |
67 | 67 | /** @var GF_Field $field */ |
68 | - foreach( $fields as &$field ) { |
|
69 | - if( 'survey' === $field->type ) { |
|
68 | + foreach ( $fields as &$field ) { |
|
69 | + if ( 'survey' === $field->type ) { |
|
70 | 70 | $field->allowsPrepopulate = true; |
71 | 71 | } |
72 | 72 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | function add_render_hooks() { |
85 | - add_filter( 'gform_field_value', array( $this, 'fix_survey_field_value'), 10, 3 ); |
|
85 | + add_filter( 'gform_field_value', array( $this, 'fix_survey_field_value' ), 10, 3 ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | function remove_render_hooks() { |
98 | - remove_filter( 'gform_field_value', array( $this, 'fix_survey_field_value'), 10 ); |
|
98 | + remove_filter( 'gform_field_value', array( $this, 'fix_survey_field_value' ), 10 ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function fix_survey_field_value( $value, $field, $name ) { |
115 | 115 | |
116 | - if( 'survey' === $field->type ) { |
|
116 | + if ( 'survey' === $field->type ) { |
|
117 | 117 | |
118 | - $entry = GravityView_Edit_Entry::getInstance()->instances['render']->get_entry(); |
|
118 | + $entry = GravityView_Edit_Entry::getInstance()->instances[ 'render' ]->get_entry(); |
|
119 | 119 | |
120 | 120 | // We need to run through each survey row until we find a match for expected values |
121 | 121 | foreach ( $entry as $field_id => $field_value ) { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | list( $row_val, $col_val ) = explode( ':', $field_value, 2 ); |
129 | 129 | |
130 | 130 | // If the $name matches the $row_val, we are processing the correct row |
131 | - if( $row_val === $name ) { |
|
131 | + if ( $row_val === $name ) { |
|
132 | 132 | $value = $field_value; |
133 | 133 | break; |
134 | 134 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return void |
31 | 31 | */ |
32 | 32 | private function add_hooks() { |
33 | - add_filter( 'gravityview/edit_entry/field_value_post_custom_field', array( $this, 'edit_entry_field_value'), 10, 2 ); |
|
33 | + add_filter( 'gravityview/edit_entry/field_value_post_custom_field', array( $this, 'edit_entry_field_value' ), 10, 2 ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function edit_entry_field_value( $field_value, $field ) { |
47 | 47 | |
48 | - if( 'list' === $field->inputType ) { |
|
48 | + if ( 'list' === $field->inputType ) { |
|
49 | 49 | $field_value = is_string( $field_value ) ? json_decode( $field_value, true ) : $field_value; |
50 | 50 | |
51 | 51 | if ( ! is_array( $field_value ) ) { |
@@ -12,10 +12,10 @@ |
||
12 | 12 | |
13 | 13 | $field_info_items = array(); |
14 | 14 | |
15 | - if( !empty( $this->item['description'] ) ) { |
|
15 | + if ( ! empty( $this->item[ 'description' ] ) ) { |
|
16 | 16 | |
17 | - $field_info_items[] = array( |
|
18 | - 'value' => $this->item['description'] |
|
17 | + $field_info_items[ ] = array( |
|
18 | + 'value' => $this->item[ 'description' ] |
|
19 | 19 | ); |
20 | 20 | |
21 | 21 | } |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | function modify_entry_value_workflow_step( $output, $entry, $field_settings, $field ) { |
48 | 48 | |
49 | 49 | // If not set, the entry hasn't started a workflow |
50 | - $has_workflow_step = isset( $entry['workflow_step'] ); |
|
50 | + $has_workflow_step = isset( $entry[ 'workflow_step' ] ); |
|
51 | 51 | |
52 | - if( $has_workflow_step ) { |
|
52 | + if ( $has_workflow_step ) { |
|
53 | 53 | |
54 | - $GFlow = new Gravity_Flow_API( $entry['form_id'] ); |
|
54 | + $GFlow = new Gravity_Flow_API( $entry[ 'form_id' ] ); |
|
55 | 55 | |
56 | 56 | if ( $current_step = $GFlow->get_current_step( $entry ) ) { |
57 | 57 | $output = esc_html( $current_step->get_name() ); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | preg_match( '/workflow_step_status_(\d+)/', $key, $matches ); |
80 | 80 | |
81 | 81 | if ( ! empty( $matches ) ) { |
82 | - $workflow_step_id = intval( $matches[1] ); |
|
82 | + $workflow_step_id = intval( $matches[ 1 ] ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | return $workflow_step_id; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | $return = $label; |
100 | 100 | |
101 | - if ( '' === $label && $workflow_step_id = $this->get_step_id_from_key( $field['field'] ) ) { |
|
101 | + if ( '' === $label && $workflow_step_id = $this->get_step_id_from_key( $field[ 'field' ] ) ) { |
|
102 | 102 | |
103 | 103 | $step = $this->get_workflow_step( $workflow_step_id ); |
104 | 104 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | $workflow_step = $GFlow->get_step( $workflow_step_id ); |
130 | 130 | |
131 | - if( ! $GFlow || ! $workflow_step ) { |
|
131 | + if ( ! $GFlow || ! $workflow_step ) { |
|
132 | 132 | return false; |
133 | 133 | } |
134 | 134 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | foreach ( $search_fields as & $search_field ) { |
152 | 152 | |
153 | - if ( $this->name === $search_field['key'] ) { |
|
153 | + if ( $this->name === $search_field[ 'key' ] ) { |
|
154 | 154 | |
155 | 155 | $form_id = GravityView_View::getInstance()->getFormId(); |
156 | 156 | |
@@ -159,21 +159,21 @@ discard block |
||
159 | 159 | $choices = array(); |
160 | 160 | |
161 | 161 | foreach ( $workflow_steps as $step ) { |
162 | - $choices[] = array( |
|
162 | + $choices[ ] = array( |
|
163 | 163 | 'text' => $step->get_name(), |
164 | 164 | 'value' => $step->get_id(), |
165 | 165 | ); |
166 | 166 | } |
167 | 167 | |
168 | - $search_field['choices'] = $choices; |
|
168 | + $search_field[ 'choices' ] = $choices; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | // Workflow Step Statuses |
172 | - else if ( $workflow_step_id = $this->get_step_id_from_key( $search_field['key'] ) ) { |
|
172 | + else if ( $workflow_step_id = $this->get_step_id_from_key( $search_field[ 'key' ] ) ) { |
|
173 | 173 | |
174 | 174 | $status_key = sprintf( 'workflow_step_status_%d', $workflow_step_id ); |
175 | 175 | |
176 | - $search_field['choices'] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options( null, $status_key ); |
|
176 | + $search_field[ 'choices' ] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options( null, $status_key ); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 |
@@ -59,7 +59,6 @@ |
||
59 | 59 | * |
60 | 60 | * @param string $output HTML value output |
61 | 61 | * @param array $entry The GF entry array |
62 | - * @param array $field_settings Settings for the particular GV field |
|
63 | 62 | * @param array $field Field array, as fetched from GravityView_View::getCurrentField() |
64 | 63 | * |
65 | 64 | * @return string The field setting label for the current status. Uses defaults, if not configured. |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | function add_default_field( $entry_default_fields, $form, $zone ) { |
97 | 97 | |
98 | - if( 'edit' !== $zone ) { |
|
98 | + if ( 'edit' !== $zone ) { |
|
99 | 99 | $entry_default_fields[ $this->name ] = array( |
100 | 100 | 'label' => $this->label, |
101 | 101 | 'desc' => $this->description, |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | $merge_tags = array( |
122 | 122 | array( |
123 | - 'label' => __('Approval Status', 'gravityview'), |
|
123 | + 'label' => __( 'Approval Status', 'gravityview' ), |
|
124 | 124 | 'tag' => '{approval_status}' |
125 | 125 | ), |
126 | 126 | ); |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | gravityview()->log->error( 'No entry data available. Returning empty string.' ); |
161 | 161 | $replacement = ''; |
162 | 162 | } else { |
163 | - $replacement = GravityView_Entry_Approval::get_entry_status( $entry, $match[1] ); |
|
163 | + $replacement = GravityView_Entry_Approval::get_entry_status( $entry, $match[ 1 ] ); |
|
164 | 164 | } |
165 | 165 | |
166 | - $return = str_replace( $match[0], $replacement, $return ); |
|
166 | + $return = str_replace( $match[ 0 ], $replacement, $return ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | return $return; |
@@ -171,25 +171,25 @@ discard block |
||
171 | 171 | |
172 | 172 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
173 | 173 | |
174 | - $field_options['approved_label'] = array( |
|
174 | + $field_options[ 'approved_label' ] = array( |
|
175 | 175 | 'type' => 'text', |
176 | 176 | 'label' => __( 'Approved Label', 'gravityview' ), |
177 | 177 | 'desc' => __( 'If the entry is approved, display this value', 'gravityview' ), |
178 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('approved'), |
|
178 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label( 'approved' ), |
|
179 | 179 | ); |
180 | 180 | |
181 | - $field_options['disapproved_label'] = array( |
|
181 | + $field_options[ 'disapproved_label' ] = array( |
|
182 | 182 | 'type' => 'text', |
183 | 183 | 'label' => __( 'Disapproved Label', 'gravityview' ), |
184 | 184 | 'desc' => __( 'If the entry is not approved, display this value', 'gravityview' ), |
185 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('disapproved'), |
|
185 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label( 'disapproved' ), |
|
186 | 186 | ); |
187 | 187 | |
188 | - $field_options['unapproved_label'] = array( |
|
188 | + $field_options[ 'unapproved_label' ] = array( |
|
189 | 189 | 'type' => 'text', |
190 | 190 | 'label' => __( 'Unapproved Label', 'gravityview' ), |
191 | 191 | 'desc' => __( 'If the entry has not yet been approved or disapproved, display this value', 'gravityview' ), |
192 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('unapproved'), |
|
192 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label( 'unapproved' ), |
|
193 | 193 | ); |
194 | 194 | |
195 | 195 | return $field_options; |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | var $is_numeric = true; |
16 | 16 | |
17 | - var $search_operators = array( 'is', 'isnot', 'starts_with', 'ends_with' ); |
|
17 | + var $search_operators = array( 'is', 'isnot', 'starts_with', 'ends_with' ); |
|
18 | 18 | |
19 | 19 | var $group = 'pricing'; |
20 | 20 |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function clear_product_info_cache( $form = array(), $entry_id = 0, $Edit_Entry_Render = null ) { |
51 | 51 | |
52 | - if( $this->should_hide_product_fields( $Edit_Entry_Render->entry ) ) { |
|
52 | + if ( $this->should_hide_product_fields( $Edit_Entry_Render->entry ) ) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @see GVCommon::entry_has_transaction_data() |
102 | 102 | * @param boolean $hide_product_fields Whether to hide product fields in the editor. Uses $entry data to determine. |
103 | 103 | */ |
104 | - $hide_product_fields = (bool) apply_filters( 'gravityview/edit_entry/hide-product-fields', $has_transaction_data ); |
|
104 | + $hide_product_fields = (bool)apply_filters( 'gravityview/edit_entry/hide-product-fields', $has_transaction_data ); |
|
105 | 105 | |
106 | 106 | return $hide_product_fields; |
107 | 107 | } |
@@ -95,7 +95,7 @@ |
||
95 | 95 | * @param string $icon_class_name Icon class used in vertical tabs. Supports non-dashicon. If dashicons, no need for `dashicons ` prefix |
96 | 96 | * @param string $callback Function to render the metabox, if $file is not defined. |
97 | 97 | * @param array $callback_args Arguments passed to the callback |
98 | - * @return void |
|
98 | + * @return GravityView_Metabox_Tab |
|
99 | 99 | */ |
100 | 100 | function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array() ) { |
101 | 101 |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * @param array $callback_args Arguments passed to the callback |
98 | 98 | * @return void |
99 | 99 | */ |
100 | - function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array() ) { |
|
100 | + function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array() ) { |
|
101 | 101 | |
102 | - $this->id = $this->prefix.$id; |
|
102 | + $this->id = $this->prefix . $id; |
|
103 | 103 | $this->title = $title; |
104 | 104 | $this->render_template_file = $file; |
105 | 105 | $this->callback = $callback; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | function parse_icon_class_name( $icon_class_name = '' ) { |
120 | 120 | |
121 | - if( preg_match( '/dashicon/i', $icon_class_name ) ) { |
|
121 | + if ( preg_match( '/dashicon/i', $icon_class_name ) ) { |
|
122 | 122 | $icon_class_name = 'dashicons ' . $icon_class_name; |
123 | 123 | } |
124 | 124 | |
@@ -142,29 +142,29 @@ discard block |
||
142 | 142 | */ |
143 | 143 | function render( $post ) { |
144 | 144 | |
145 | - if( !empty( $this->render_template_file ) ) { |
|
145 | + if ( ! empty( $this->render_template_file ) ) { |
|
146 | 146 | |
147 | 147 | $file = $this->render_template_file; |
148 | 148 | |
149 | 149 | // If the full path exists, use it |
150 | - if( file_exists( $file ) ) { |
|
150 | + if ( file_exists( $file ) ) { |
|
151 | 151 | $path = $file; |
152 | 152 | } else { |
153 | - $path = GRAVITYVIEW_DIR .'includes/admin/metaboxes/views/'.$file; |
|
153 | + $path = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/views/' . $file; |
|
154 | 154 | } |
155 | 155 | |
156 | - if( file_exists( $path ) ) { |
|
156 | + if ( file_exists( $path ) ) { |
|
157 | 157 | include $path; |
158 | 158 | } else { |
159 | 159 | gravityview()->log->error( 'Metabox template file not found', array( 'data' => $this ) ); |
160 | 160 | } |
161 | 161 | |
162 | - } else if( !empty( $this->callback ) ) { |
|
162 | + } else if ( ! empty( $this->callback ) ) { |
|
163 | 163 | |
164 | - if( is_callable( $this->callback ) ) { |
|
164 | + if ( is_callable( $this->callback ) ) { |
|
165 | 165 | |
166 | 166 | /** @see do_accordion_sections() */ |
167 | - call_user_func( $this->callback, $post, (array) $this ); |
|
167 | + call_user_func( $this->callback, $post, (array)$this ); |
|
168 | 168 | |
169 | 169 | } else { |
170 | 170 | gravityview()->log->error( 'Metabox callback was not callable', array( 'data' => $this ) ); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @param int $entry_id ID of the Gravity Forms entry |
372 | 372 | * @param string $status String whether entry is approved or not. `0` for not approved, `Approved` for approved. |
373 | 373 | * @param int $form_id ID of the form of the entry being updated. Improves query performance. |
374 | - * @param string $approvedcolumn Gravity Forms Field ID |
|
374 | + * @param integer $approvedcolumn Gravity Forms Field ID |
|
375 | 375 | * |
376 | 376 | * @return true|WP_Error |
377 | 377 | */ |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * |
425 | 425 | * @since 1.19 |
426 | 426 | * |
427 | - * @param array|int $form Form ID or form array |
|
427 | + * @param integer $form Form ID or form array |
|
428 | 428 | * @param string $approved_column Approved column field ID |
429 | 429 | * |
430 | 430 | * @return string|null |
@@ -326,6 +326,6 @@ |
||
326 | 326 | <a href="#" data-approved="{$choices['approved']['value']}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-approved popover" title="{$choices['approved']['action']}"><span class="screen-reader-text">{$choices['approved']['action']}</span></a> |
327 | 327 | <a href="#" data-approved="{$choices['disapproved']['value']}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-disapproved popover" title="{$choices['disapproved']['action']}"><span class="screen-reader-text">{$choices['disapproved']['action']}</span></a> |
328 | 328 | <a href="#" data-approved="{$choices['unapproved']['value']}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-unapproved popover" title="{$choices['unapproved']['action']}"><span class="screen-reader-text">{$choices['unapproved']['action']}</span></a> |
329 | -TEMPLATE; |
|
329 | +template; |
|
330 | 330 | } |
331 | 331 | } |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | private function add_hooks() { |
40 | 40 | |
41 | 41 | // in case entry is edited (on admin or frontend) |
42 | - add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2); |
|
42 | + add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2 ); |
|
43 | 43 | |
44 | 44 | // when using the User opt-in field, check on entry submission |
45 | 45 | add_action( 'gform_after_submission', array( $this, 'after_submission' ), 10, 2 ); |
46 | 46 | |
47 | 47 | // process ajax approve entry requests |
48 | - add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved')); |
|
48 | + add_action( 'wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved' ) ); |
|
49 | 49 | |
50 | 50 | // autounapprove |
51 | 51 | add_action( 'gravityview/edit_entry/after_update', array( __CLASS__, 'autounapprove' ), 10, 4 ); |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | return; |
95 | 95 | } |
96 | 96 | |
97 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
97 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
98 | 98 | |
99 | 99 | if ( ! $form ) { |
100 | - gravityview()->log->error( 'Form not found at ID #{form_id} for entry #{entry_id}', array( 'form_id' => $entry['form_id'], 'entry_id' => $entry_id ) ); |
|
100 | + gravityview()->log->error( 'Form not found at ID #{form_id} for entry #{entry_id}', array( 'form_id' => $entry[ 'form_id' ], 'entry_id' => $entry_id ) ); |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public static function add_approval_notification_events( $notification_events = array(), $form = array() ) { |
116 | 116 | |
117 | - $notification_events['gravityview/approve_entries/approved'] = 'GravityView - ' . esc_html_x( 'Entry is approved', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
118 | - $notification_events['gravityview/approve_entries/disapproved'] = 'GravityView - ' . esc_html_x( 'Entry is disapproved', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
119 | - $notification_events['gravityview/approve_entries/unapproved'] = 'GravityView - ' . esc_html_x( 'Entry approval is reset', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
120 | - $notification_events['gravityview/approve_entries/updated'] = 'GravityView - ' . esc_html_x( 'Entry approval is changed', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
117 | + $notification_events[ 'gravityview/approve_entries/approved' ] = 'GravityView - ' . esc_html_x( 'Entry is approved', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
118 | + $notification_events[ 'gravityview/approve_entries/disapproved' ] = 'GravityView - ' . esc_html_x( 'Entry is disapproved', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
119 | + $notification_events[ 'gravityview/approve_entries/unapproved' ] = 'GravityView - ' . esc_html_x( 'Entry approval is reset', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
120 | + $notification_events[ 'gravityview/approve_entries/updated' ] = 'GravityView - ' . esc_html_x( 'Entry approval is changed', 'The title for an event in a notifications drop down list.', 'gravityview' ); |
|
121 | 121 | |
122 | 122 | return $notification_events; |
123 | 123 | } |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public static function get_entry_status( $entry, $value_or_label = 'label' ) { |
137 | 137 | |
138 | - $entry_id = is_array( $entry ) ? $entry['id'] : GVCommon::get_entry_id( $entry, true ); |
|
138 | + $entry_id = is_array( $entry ) ? $entry[ 'id' ] : GVCommon::get_entry_id( $entry, true ); |
|
139 | 139 | |
140 | 140 | $status = gform_get_meta( $entry_id, self::meta_key ); |
141 | 141 | |
142 | 142 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
143 | 143 | |
144 | - if( 'value' === $value_or_label ) { |
|
144 | + if ( 'value' === $value_or_label ) { |
|
145 | 145 | return $status; |
146 | 146 | } |
147 | 147 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $nonce = \GV\Utils::_POST( 'nonce' ); |
180 | 180 | |
181 | 181 | // Valid status |
182 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
182 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
183 | 183 | |
184 | 184 | gravityview()->log->error( 'Invalid approval status', array( 'data' => $_POST ) ); |
185 | 185 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
212 | 212 | |
213 | - $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') ); |
|
213 | + $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview' ) ); |
|
214 | 214 | |
215 | 215 | } |
216 | 216 | |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | // Set default |
275 | - self::update_approved_meta( $entry['id'], $default_status, $entry['form_id'] ); |
|
275 | + self::update_approved_meta( $entry[ 'id' ], $default_status, $entry[ 'form_id' ] ); |
|
276 | 276 | |
277 | 277 | // Then check for if there is an approval column, and use that value instead |
278 | - $this->after_update_entry_update_approved_meta( $form , $entry['id'] ); |
|
278 | + $this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] ); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -289,12 +289,12 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
291 | 291 | |
292 | - $approved_column = self::get_approved_column( $form['id'] ); |
|
292 | + $approved_column = self::get_approved_column( $form[ 'id' ] ); |
|
293 | 293 | |
294 | 294 | /** |
295 | 295 | * If the form doesn't contain the approve field, don't assume anything. |
296 | 296 | */ |
297 | - if( empty( $approved_column ) ) { |
|
297 | + if ( empty( $approved_column ) ) { |
|
298 | 298 | return; |
299 | 299 | } |
300 | 300 | |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | */ |
317 | 317 | $value = apply_filters( 'gravityview/approve_entries/update_unapproved_meta', $value, $form, $entry ); |
318 | 318 | |
319 | - self::update_approved_meta( $entry_id, $value, $form['id'] ); |
|
319 | + self::update_approved_meta( $entry_id, $value, $form[ 'id' ] ); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -334,12 +334,12 @@ discard block |
||
334 | 334 | */ |
335 | 335 | public static function update_bulk( $entries = array(), $approved, $form_id ) { |
336 | 336 | |
337 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
337 | + if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) { |
|
338 | 338 | gravityview()->log->error( 'Entries were empty or malformed.', array( 'data' => $entries ) ); |
339 | 339 | return NULL; |
340 | 340 | } |
341 | 341 | |
342 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
342 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
343 | 343 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
344 | 344 | return NULL; |
345 | 345 | } |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | $approved_column_id = self::get_approved_column( $form_id ); |
355 | 355 | |
356 | 356 | $success = true; |
357 | - foreach( $entries as $entry_id ) { |
|
357 | + foreach ( $entries as $entry_id ) { |
|
358 | 358 | $update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
359 | 359 | |
360 | - if( ! $update_success ) { |
|
360 | + if ( ! $update_success ) { |
|
361 | 361 | $success = false; |
362 | 362 | } |
363 | 363 | } |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | */ |
382 | 382 | public static function update_approved( $entry_id = 0, $approved = 2, $form_id = 0, $approvedcolumn = 0 ) { |
383 | 383 | |
384 | - if( !class_exists( 'GFAPI' ) ) { |
|
384 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
385 | 385 | gravityview()->log->error( 'GFAPI does not exist' ); |
386 | 386 | return false; |
387 | 387 | } |
388 | 388 | |
389 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
389 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
390 | 390 | gravityview()->log->error( 'Not a valid approval value.' ); |
391 | 391 | return false; |
392 | 392 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | // If the form has an Approve/Reject field, update that value |
404 | 404 | $result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn ); |
405 | 405 | |
406 | - if( is_wp_error( $result ) ) { |
|
406 | + if ( is_wp_error( $result ) ) { |
|
407 | 407 | gravityview()->log->error( 'Entry approval not updated: {error}', array( 'error' => $result->get_error_message() ) ); |
408 | 408 | return false; |
409 | 409 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | |
416 | 416 | // add note to entry if approval field updating worked or there was no approved field |
417 | 417 | // There's no validation for the meta |
418 | - if( true === $result ) { |
|
418 | + if ( true === $result ) { |
|
419 | 419 | |
420 | 420 | // Add an entry note |
421 | 421 | self::add_approval_status_updated_note( $entry_id, $approved ); |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | |
469 | 469 | $note_id = false; |
470 | 470 | |
471 | - if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
471 | + if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
472 | 472 | |
473 | 473 | $current_user = wp_get_current_user(); |
474 | 474 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | */ |
491 | 491 | private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) { |
492 | 492 | |
493 | - if( empty( $approvedcolumn ) ) { |
|
493 | + if ( empty( $approvedcolumn ) ) { |
|
494 | 494 | $approvedcolumn = self::get_approved_column( $form_id ); |
495 | 495 | } |
496 | 496 | |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
514 | 514 | |
515 | 515 | $new_value = ''; |
516 | - if( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
516 | + if ( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
517 | 517 | $new_value = self::get_approved_column_input_label( $form_id, $approvedcolumn ); |
518 | 518 | } |
519 | 519 | |
520 | 520 | //update entry |
521 | - $entry["{$approvedcolumn}"] = $new_value; |
|
521 | + $entry[ "{$approvedcolumn}" ] = $new_value; |
|
522 | 522 | |
523 | 523 | /** |
524 | 524 | * Note: GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves |
@@ -549,12 +549,12 @@ discard block |
||
549 | 549 | // If the user has enabled a different value than the label (for some reason), use it. |
550 | 550 | // This is highly unlikely |
551 | 551 | if ( is_array( $field->choices ) && ! empty( $field->choices ) ) { |
552 | - return isset( $field->choices[0]['value'] ) ? $field->choices[0]['value'] : $field->choices[0]['text']; |
|
552 | + return isset( $field->choices[ 0 ][ 'value' ] ) ? $field->choices[ 0 ][ 'value' ] : $field->choices[ 0 ][ 'text' ]; |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | // Otherwise, fall back on the inputs array |
556 | 556 | if ( is_array( $field->inputs ) && ! empty( $field->inputs ) ) { |
557 | - return $field->inputs[0]['label']; |
|
557 | + return $field->inputs[ 0 ][ 'label' ]; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | return null; |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | * @since 1.18 Added "unapproved" |
607 | 607 | * @param int $entry_id ID of the Gravity Forms entry |
608 | 608 | */ |
609 | - do_action( 'gravityview/approve_entries/' . $action , $entry_id ); |
|
609 | + do_action( 'gravityview/approve_entries/' . $action, $entry_id ); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
@@ -619,11 +619,11 @@ discard block |
||
619 | 619 | */ |
620 | 620 | static public function get_approved_column( $form ) { |
621 | 621 | |
622 | - if( empty( $form ) ) { |
|
622 | + if ( empty( $form ) ) { |
|
623 | 623 | return null; |
624 | 624 | } |
625 | 625 | |
626 | - if( !is_array( $form ) ) { |
|
626 | + if ( ! is_array( $form ) ) { |
|
627 | 627 | $form = GVCommon::get_form( $form ); |
628 | 628 | } |
629 | 629 | |
@@ -633,22 +633,22 @@ discard block |
||
633 | 633 | * @var string $key |
634 | 634 | * @var GF_Field $field |
635 | 635 | */ |
636 | - foreach( $form['fields'] as $key => $field ) { |
|
636 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
637 | 637 | |
638 | 638 | $inputs = $field->get_entry_inputs(); |
639 | 639 | |
640 | - if( !empty( $field->gravityview_approved ) ) { |
|
641 | - if ( ! empty( $inputs ) && !empty( $inputs[0]['id'] ) ) { |
|
642 | - $approved_column_id = $inputs[0]['id']; |
|
640 | + if ( ! empty( $field->gravityview_approved ) ) { |
|
641 | + if ( ! empty( $inputs ) && ! empty( $inputs[ 0 ][ 'id' ] ) ) { |
|
642 | + $approved_column_id = $inputs[ 0 ][ 'id' ]; |
|
643 | 643 | break; |
644 | 644 | } |
645 | 645 | } |
646 | 646 | |
647 | 647 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
648 | - if( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
648 | + if ( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
649 | 649 | foreach ( $inputs as $input ) { |
650 | - if ( 'approved' === strtolower( $input['label'] ) ) { |
|
651 | - $approved_column_id = $input['id']; |
|
650 | + if ( 'approved' === strtolower( $input[ 'label' ] ) ) { |
|
651 | + $approved_column_id = $input[ 'id' ]; |
|
652 | 652 | break; |
653 | 653 | } |
654 | 654 | } |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | |
675 | 675 | $view_keys = array_keys( $gv_data->get_views() ); |
676 | 676 | |
677 | - $view = \GV\View::by_id( $view_keys[0] ); |
|
677 | + $view = \GV\View::by_id( $view_keys[ 0 ] ); |
|
678 | 678 | |
679 | 679 | if ( ! $view->settings->get( 'unapprove_edit' ) ) { |
680 | 680 | return; |
@@ -699,11 +699,11 @@ discard block |
||
699 | 699 | return; |
700 | 700 | } |
701 | 701 | |
702 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
702 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
703 | 703 | $approval_status = GravityView_Entry_Approval_Status::UNAPPROVED; |
704 | 704 | } |
705 | 705 | |
706 | - self::update_approved_meta( $entry_id, $approval_status, $form['id'] ); |
|
706 | + self::update_approved_meta( $entry_id, $approval_status, $form[ 'id' ] ); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | /** |
@@ -741,9 +741,9 @@ discard block |
||
741 | 741 | $choices = GravityView_Entry_Approval_Status::get_all(); |
742 | 742 | |
743 | 743 | return <<<TEMPLATE |
744 | -<a href="#" data-approved="{$choices['approved']['value']}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-approved popover" title="{$choices['approved']['action']}"><span class="screen-reader-text">{$choices['approved']['action']}</span></a> |
|
745 | -<a href="#" data-approved="{$choices['disapproved']['value']}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-disapproved popover" title="{$choices['disapproved']['action']}"><span class="screen-reader-text">{$choices['disapproved']['action']}</span></a> |
|
746 | -<a href="#" data-approved="{$choices['unapproved']['value']}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-unapproved popover" title="{$choices['unapproved']['action']}"><span class="screen-reader-text">{$choices['unapproved']['action']}</span></a> |
|
744 | +<a href="#" data-approved="{$choices[ 'approved' ][ 'value' ]}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-approved popover" title="{$choices[ 'approved' ][ 'action' ]}"><span class="screen-reader-text">{$choices[ 'approved' ][ 'action' ]}</span></a> |
|
745 | +<a href="#" data-approved="{$choices[ 'disapproved' ][ 'value' ]}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-disapproved popover" title="{$choices[ 'disapproved' ][ 'action' ]}"><span class="screen-reader-text">{$choices[ 'disapproved' ][ 'action' ]}</span></a> |
|
746 | +<a href="#" data-approved="{$choices[ 'unapproved' ][ 'value' ]}" aria-role="button" aria-live="polite" class="gv-approval-toggle gv-approval-unapproved popover" title="{$choices[ 'unapproved' ][ 'action' ]}"><span class="screen-reader-text">{$choices[ 'unapproved' ][ 'action' ]}</span></a> |
|
747 | 747 | TEMPLATE; |
748 | 748 | } |
749 | 749 | } |