@@ -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. |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | function add_default_field( $entry_default_fields, $form, $zone ) { |
94 | 94 | |
95 | - if( 'edit' !== $zone ) { |
|
95 | + if ( 'edit' !== $zone ) { |
|
96 | 96 | $entry_default_fields[ $this->name ] = array( |
97 | 97 | 'label' => $this->label, |
98 | 98 | 'desc' => $this->description, |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | $merge_tags = array( |
119 | 119 | array( |
120 | - 'label' => __('Approval Status', 'gravityview'), |
|
120 | + 'label' => __( 'Approval Status', 'gravityview' ), |
|
121 | 121 | 'tag' => '{approval_status}' |
122 | 122 | ), |
123 | 123 | ); |
@@ -157,10 +157,10 @@ discard block |
||
157 | 157 | gravityview()->log->error( 'No entry data available. Returning empty string.' ); |
158 | 158 | $replacement = ''; |
159 | 159 | } else { |
160 | - $replacement = GravityView_Entry_Approval::get_entry_status( $entry, $match[1] ); |
|
160 | + $replacement = GravityView_Entry_Approval::get_entry_status( $entry, $match[ 1 ] ); |
|
161 | 161 | } |
162 | 162 | |
163 | - $return = str_replace( $match[0], $replacement, $return ); |
|
163 | + $return = str_replace( $match[ 0 ], $replacement, $return ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | return $return; |
@@ -168,25 +168,25 @@ discard block |
||
168 | 168 | |
169 | 169 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
170 | 170 | |
171 | - $field_options['approved_label'] = array( |
|
171 | + $field_options[ 'approved_label' ] = array( |
|
172 | 172 | 'type' => 'text', |
173 | 173 | 'label' => __( 'Approved Label', 'gravityview' ), |
174 | 174 | 'desc' => __( 'If the entry is approved, display this value', 'gravityview' ), |
175 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('approved'), |
|
175 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label( 'approved' ), |
|
176 | 176 | ); |
177 | 177 | |
178 | - $field_options['disapproved_label'] = array( |
|
178 | + $field_options[ 'disapproved_label' ] = array( |
|
179 | 179 | 'type' => 'text', |
180 | 180 | 'label' => __( 'Disapproved Label', 'gravityview' ), |
181 | 181 | 'desc' => __( 'If the entry is not approved, display this value', 'gravityview' ), |
182 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('disapproved'), |
|
182 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label( 'disapproved' ), |
|
183 | 183 | ); |
184 | 184 | |
185 | - $field_options['unapproved_label'] = array( |
|
185 | + $field_options[ 'unapproved_label' ] = array( |
|
186 | 186 | 'type' => 'text', |
187 | 187 | 'label' => __( 'Unapproved Label', 'gravityview' ), |
188 | 188 | 'desc' => __( 'If the entry has not yet been approved or disapproved, display this value', 'gravityview' ), |
189 | - 'placeholder' => GravityView_Entry_Approval_Status::get_label('unapproved'), |
|
189 | + 'placeholder' => GravityView_Entry_Approval_Status::get_label( 'unapproved' ), |
|
190 | 190 | ); |
191 | 191 | |
192 | 192 | 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 |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type ); |
46 | 46 | |
47 | 47 | // It's not the parent field; it's an input |
48 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
48 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
49 | 49 | |
50 | - if( $this->is_choice_value_enabled() ) { |
|
50 | + if ( $this->is_choice_value_enabled() ) { |
|
51 | 51 | |
52 | 52 | $desc = esc_html__( 'This input has a label and a value. What should be displayed?', 'gravityview' ); |
53 | 53 | $default = 'value'; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | ); |
66 | 66 | } |
67 | 67 | |
68 | - $field_options['choice_display'] = array( |
|
68 | + $field_options[ 'choice_display' ] = array( |
|
69 | 69 | 'type' => 'radio', |
70 | 70 | 'class' => 'vertical', |
71 | 71 | 'label' => __( 'What should be displayed:', 'gravityview' ), |
@@ -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 |
@@ -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 | |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | // Set default |
264 | - self::update_approved_meta( $entry['id'], $default_status, $entry['form_id'] ); |
|
264 | + self::update_approved_meta( $entry[ 'id' ], $default_status, $entry[ 'form_id' ] ); |
|
265 | 265 | |
266 | 266 | // Then check for if there is an approval column, and use that value instead |
267 | - $this->after_update_entry_update_approved_meta( $form , $entry['id'] ); |
|
267 | + $this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] ); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -278,12 +278,12 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
280 | 280 | |
281 | - $approved_column = self::get_approved_column( $form['id'] ); |
|
281 | + $approved_column = self::get_approved_column( $form[ 'id' ] ); |
|
282 | 282 | |
283 | 283 | /** |
284 | 284 | * If the form doesn't contain the approve field, don't assume anything. |
285 | 285 | */ |
286 | - if( empty( $approved_column ) ) { |
|
286 | + if ( empty( $approved_column ) ) { |
|
287 | 287 | return; |
288 | 288 | } |
289 | 289 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $value = GravityView_Entry_Approval_Status::APPROVED; |
298 | 298 | } |
299 | 299 | |
300 | - self::update_approved_meta( $entry_id, $value, $form['id'] ); |
|
300 | + self::update_approved_meta( $entry_id, $value, $form[ 'id' ] ); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -315,12 +315,12 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public static function update_bulk( $entries = array(), $approved, $form_id ) { |
317 | 317 | |
318 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
318 | + if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) { |
|
319 | 319 | gravityview()->log->error( 'Entries were empty or malformed.', array( 'data' => $entries ) ); |
320 | 320 | return NULL; |
321 | 321 | } |
322 | 322 | |
323 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
323 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
324 | 324 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
325 | 325 | return NULL; |
326 | 326 | } |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | $approved_column_id = self::get_approved_column( $form_id ); |
336 | 336 | |
337 | 337 | $success = true; |
338 | - foreach( $entries as $entry_id ) { |
|
338 | + foreach ( $entries as $entry_id ) { |
|
339 | 339 | $update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
340 | 340 | |
341 | - if( ! $update_success ) { |
|
341 | + if ( ! $update_success ) { |
|
342 | 342 | $success = false; |
343 | 343 | } |
344 | 344 | } |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public static function update_approved( $entry_id = 0, $approved = 2, $form_id = 0, $approvedcolumn = 0 ) { |
364 | 364 | |
365 | - if( !class_exists( 'GFAPI' ) ) { |
|
365 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
366 | 366 | gravityview()->log->error( 'GFAPI does not exist' ); |
367 | 367 | return false; |
368 | 368 | } |
369 | 369 | |
370 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
370 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
371 | 371 | gravityview()->log->error( 'Not a valid approval value.' ); |
372 | 372 | return false; |
373 | 373 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | // If the form has an Approve/Reject field, update that value |
385 | 385 | $result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn ); |
386 | 386 | |
387 | - if( is_wp_error( $result ) ) { |
|
387 | + if ( is_wp_error( $result ) ) { |
|
388 | 388 | gravityview()->log->error( 'Entry approval not updated: {error}', array( 'error' => $result->get_error_message() ) ); |
389 | 389 | return false; |
390 | 390 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | |
397 | 397 | // add note to entry if approval field updating worked or there was no approved field |
398 | 398 | // There's no validation for the meta |
399 | - if( true === $result ) { |
|
399 | + if ( true === $result ) { |
|
400 | 400 | |
401 | 401 | // Add an entry note |
402 | 402 | self::add_approval_status_updated_note( $entry_id, $approved ); |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | |
450 | 450 | $note_id = false; |
451 | 451 | |
452 | - if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
452 | + if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
453 | 453 | |
454 | 454 | $current_user = wp_get_current_user(); |
455 | 455 | |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) { |
473 | 473 | |
474 | - if( empty( $approvedcolumn ) ) { |
|
474 | + if ( empty( $approvedcolumn ) ) { |
|
475 | 475 | $approvedcolumn = self::get_approved_column( $form_id ); |
476 | 476 | } |
477 | 477 | |
@@ -494,12 +494,12 @@ discard block |
||
494 | 494 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
495 | 495 | |
496 | 496 | $new_value = ''; |
497 | - if( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
497 | + if ( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
498 | 498 | $new_value = self::get_approved_column_input_label( $form_id, $approvedcolumn ); |
499 | 499 | } |
500 | 500 | |
501 | 501 | //update entry |
502 | - $entry["{$approvedcolumn}"] = $new_value; |
|
502 | + $entry[ "{$approvedcolumn}" ] = $new_value; |
|
503 | 503 | |
504 | 504 | /** |
505 | 505 | * Note: GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves |
@@ -530,12 +530,12 @@ discard block |
||
530 | 530 | // If the user has enabled a different value than the label (for some reason), use it. |
531 | 531 | // This is highly unlikely |
532 | 532 | if ( is_array( $field->choices ) && ! empty( $field->choices ) ) { |
533 | - return isset( $field->choices[0]['value'] ) ? $field->choices[0]['value'] : $field->choices[0]['text']; |
|
533 | + return isset( $field->choices[ 0 ][ 'value' ] ) ? $field->choices[ 0 ][ 'value' ] : $field->choices[ 0 ][ 'text' ]; |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | // Otherwise, fall back on the inputs array |
537 | 537 | if ( is_array( $field->inputs ) && ! empty( $field->inputs ) ) { |
538 | - return $field->inputs[0]['label']; |
|
538 | + return $field->inputs[ 0 ][ 'label' ]; |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | return null; |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | * @since 1.18 Added "unapproved" |
588 | 588 | * @param int $entry_id ID of the Gravity Forms entry |
589 | 589 | */ |
590 | - do_action( 'gravityview/approve_entries/' . $action , $entry_id ); |
|
590 | + do_action( 'gravityview/approve_entries/' . $action, $entry_id ); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | /** |
@@ -600,11 +600,11 @@ discard block |
||
600 | 600 | */ |
601 | 601 | static public function get_approved_column( $form ) { |
602 | 602 | |
603 | - if( empty( $form ) ) { |
|
603 | + if ( empty( $form ) ) { |
|
604 | 604 | return null; |
605 | 605 | } |
606 | 606 | |
607 | - if( !is_array( $form ) ) { |
|
607 | + if ( ! is_array( $form ) ) { |
|
608 | 608 | $form = GVCommon::get_form( $form ); |
609 | 609 | } |
610 | 610 | |
@@ -614,22 +614,22 @@ discard block |
||
614 | 614 | * @var string $key |
615 | 615 | * @var GF_Field $field |
616 | 616 | */ |
617 | - foreach( $form['fields'] as $key => $field ) { |
|
617 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
618 | 618 | |
619 | 619 | $inputs = $field->get_entry_inputs(); |
620 | 620 | |
621 | - if( !empty( $field->gravityview_approved ) ) { |
|
622 | - if ( ! empty( $inputs ) && !empty( $inputs[0]['id'] ) ) { |
|
623 | - $approved_column_id = $inputs[0]['id']; |
|
621 | + if ( ! empty( $field->gravityview_approved ) ) { |
|
622 | + if ( ! empty( $inputs ) && ! empty( $inputs[ 0 ][ 'id' ] ) ) { |
|
623 | + $approved_column_id = $inputs[ 0 ][ 'id' ]; |
|
624 | 624 | break; |
625 | 625 | } |
626 | 626 | } |
627 | 627 | |
628 | 628 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
629 | - if( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
629 | + if ( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
630 | 630 | foreach ( $inputs as $input ) { |
631 | - if ( 'approved' === strtolower( $input['label'] ) ) { |
|
632 | - $approved_column_id = $input['id']; |
|
631 | + if ( 'approved' === strtolower( $input[ 'label' ] ) ) { |
|
632 | + $approved_column_id = $input[ 'id' ]; |
|
633 | 633 | break; |
634 | 634 | } |
635 | 635 | } |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | |
656 | 656 | $view_keys = array_keys( $gv_data->get_views() ); |
657 | 657 | |
658 | - $view = \GV\View::by_id( $view_keys[0] ); |
|
658 | + $view = \GV\View::by_id( $view_keys[ 0 ] ); |
|
659 | 659 | |
660 | 660 | if ( ! $view->settings->get( 'unapprove_edit' ) ) { |
661 | 661 | return; |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | return; |
666 | 666 | } |
667 | 667 | |
668 | - self::update_approved_meta( $entry_id, GravityView_Entry_Approval_Status::UNAPPROVED, $form['id'] ); |
|
668 | + self::update_approved_meta( $entry_id, GravityView_Entry_Approval_Status::UNAPPROVED, $form[ 'id' ] ); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | } |
@@ -245,7 +245,7 @@ |
||
245 | 245 | * @param bool $url_encode Whether to URL-encode output |
246 | 246 | * @param bool $esc_html Whether to apply `esc_html()` to output |
247 | 247 | * |
248 | - * @return mixed |
|
248 | + * @return string |
|
249 | 249 | */ |
250 | 250 | public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
251 | 251 |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | |
135 | 135 | add_filter( 'gravityview/sortable/field_blacklist', array( $this, '_filter_sortable_fields' ), 1 ); |
136 | 136 | |
137 | - if( $this->entry_meta_key ) { |
|
137 | + if ( $this->entry_meta_key ) { |
|
138 | 138 | add_filter( 'gform_entry_meta', array( $this, 'add_entry_meta' ) ); |
139 | 139 | add_filter( 'gravityview/common/sortable_fields', array( $this, 'add_sortable_field' ), 10, 2 ); |
140 | 140 | } |
141 | 141 | |
142 | - if( $this->_custom_merge_tag ) { |
|
142 | + if ( $this->_custom_merge_tag ) { |
|
143 | 143 | add_filter( 'gform_custom_merge_tags', array( $this, '_filter_gform_custom_merge_tags' ), 10, 4 ); |
144 | 144 | add_filter( 'gform_replace_merge_tags', array( $this, '_filter_gform_replace_merge_tags' ), 10, 7 ); |
145 | 145 | } |
146 | 146 | |
147 | - if( 'meta' === $this->group || '' !== $this->default_search_label ) { |
|
147 | + if ( 'meta' === $this->group || '' !== $this->default_search_label ) { |
|
148 | 148 | add_filter( 'gravityview_search_field_label', array( $this, 'set_default_search_label' ), 10, 3 ); |
149 | 149 | } |
150 | 150 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * Auto-assign label from Gravity Forms label, if exists |
153 | 153 | * @since 1.20 |
154 | 154 | */ |
155 | - if( empty( $this->label ) && ! empty( $this->_gf_field_class_name ) && class_exists( $this->_gf_field_class_name ) ) { |
|
155 | + if ( empty( $this->label ) && ! empty( $this->_gf_field_class_name ) && class_exists( $this->_gf_field_class_name ) ) { |
|
156 | 156 | $this->label = ucfirst( GF_Fields::get( $this->name )->get_form_editor_field_title() ); |
157 | 157 | } |
158 | 158 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | 'type' => $this->name |
176 | 176 | ); |
177 | 177 | |
178 | - $fields["{$this->entry_meta_key}"] = $added_field; |
|
178 | + $fields[ "{$this->entry_meta_key}" ] = $added_field; |
|
179 | 179 | |
180 | 180 | return $fields; |
181 | 181 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | function set_default_search_label( $label = '', $gf_field = null, $field = array() ) { |
197 | 197 | |
198 | - if( $this->name === $field['field'] && '' === $label ) { |
|
198 | + if ( $this->name === $field[ 'field' ] && '' === $label ) { |
|
199 | 199 | $label = esc_html( $this->default_search_label ); |
200 | 200 | } |
201 | 201 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return string Original text if {_custom_merge_tag} isn't found. Otherwise, replaced text. |
218 | 218 | */ |
219 | - public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
219 | + public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
220 | 220 | |
221 | 221 | // Is there is field merge tag? Strip whitespace off the ned, too. |
222 | 222 | preg_match_all( '/{' . preg_quote( $this->_custom_merge_tag ) . ':?(.*?)(?:\s)?}/ism', $text, $matches, PREG_SET_ORDER ); |
@@ -249,19 +249,19 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
251 | 251 | |
252 | - foreach( $matches as $match ) { |
|
252 | + foreach ( $matches as $match ) { |
|
253 | 253 | |
254 | - $full_tag = $match[0]; |
|
254 | + $full_tag = $match[ 0 ]; |
|
255 | 255 | |
256 | 256 | // Strip the Merge Tags |
257 | - $tag = str_replace( array( '{', '}'), '', $full_tag ); |
|
257 | + $tag = str_replace( array( '{', '}' ), '', $full_tag ); |
|
258 | 258 | |
259 | 259 | // Replace the value from the entry, if exists |
260 | - if( isset( $entry[ $tag ] ) ) { |
|
260 | + if ( isset( $entry[ $tag ] ) ) { |
|
261 | 261 | |
262 | 262 | $value = $entry[ $tag ]; |
263 | 263 | |
264 | - if( is_callable( array( $this, 'get_content') ) ) { |
|
264 | + if ( is_callable( array( $this, 'get_content' ) ) ) { |
|
265 | 265 | $value = $this->get_content( $value ); |
266 | 266 | } |
267 | 267 | |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | */ |
335 | 335 | public function _filter_sortable_fields( $not_sortable ) { |
336 | 336 | |
337 | - if( ! $this->is_sortable ) { |
|
338 | - $not_sortable[] = $this->name; |
|
337 | + if ( ! $this->is_sortable ) { |
|
338 | + $not_sortable[ ] = $this->name; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $not_sortable; |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | */ |
353 | 353 | function add_entry_meta( $entry_meta ) { |
354 | 354 | |
355 | - if( ! isset( $entry_meta["{$this->entry_meta_key}"] ) ) { |
|
355 | + if ( ! isset( $entry_meta[ "{$this->entry_meta_key}" ] ) ) { |
|
356 | 356 | |
357 | 357 | $added_meta = array( |
358 | 358 | 'label' => $this->label, |
@@ -361,13 +361,13 @@ discard block |
||
361 | 361 | ); |
362 | 362 | |
363 | 363 | if ( $this->entry_meta_update_callback && is_callable( $this->entry_meta_update_callback ) ) { |
364 | - $added_meta['update_entry_meta_callback'] = $this->entry_meta_update_callback; |
|
364 | + $added_meta[ 'update_entry_meta_callback' ] = $this->entry_meta_update_callback; |
|
365 | 365 | } |
366 | 366 | |
367 | - $entry_meta["{$this->entry_meta_key}"] = $added_meta; |
|
367 | + $entry_meta[ "{$this->entry_meta_key}" ] = $added_meta; |
|
368 | 368 | |
369 | 369 | } else { |
370 | - gravityview()->log->error( 'Entry meta already set: {meta_key}', array( 'meta_key' => $this->entry_meta_key, 'data' => $entry_meta["{$this->entry_meta_key}"] ) ); |
|
370 | + gravityview()->log->error( 'Entry meta already set: {meta_key}', array( 'meta_key' => $this->entry_meta_key, 'data' => $entry_meta[ "{$this->entry_meta_key}" ] ) ); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | return $entry_meta; |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | 'date_display' => array( |
397 | 397 | 'type' => 'text', |
398 | 398 | 'label' => __( 'Override Date Format', 'gravityview' ), |
399 | - 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview'), '<a href="https://codex.wordpress.org/Formatting_Date_and_Time">', '</a>' ), |
|
399 | + 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview' ), '<a href="https://codex.wordpress.org/Formatting_Date_and_Time">', '</a>' ), |
|
400 | 400 | /** |
401 | 401 | * @filter `gravityview_date_format` Override the date format with a [PHP date format](https://codex.wordpress.org/Formatting_Date_and_Time) |
402 | 402 | * @param[in,out] null|string $date_format Date Format (default: null) |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | |
422 | 422 | $options = $this->field_support_options(); |
423 | 423 | |
424 | - if( isset( $options[ $key ] ) ) { |
|
424 | + if ( isset( $options[ $key ] ) ) { |
|
425 | 425 | $field_options[ $key ] = $options[ $key ]; |
426 | 426 | } |
427 | 427 | |
@@ -485,11 +485,11 @@ discard block |
||
485 | 485 | $connected_form = \GV\Utils::_POST( 'form_id' ); |
486 | 486 | |
487 | 487 | // Otherwise, get the Form ID from the Post page |
488 | - if( empty( $connected_form ) ) { |
|
488 | + if ( empty( $connected_form ) ) { |
|
489 | 489 | $connected_form = gravityview_get_form_id( get_the_ID() ); |
490 | 490 | } |
491 | 491 | |
492 | - if( empty( $connected_form ) ) { |
|
492 | + if ( empty( $connected_form ) ) { |
|
493 | 493 | gravityview()->log->error( 'Form not found for form ID "{form_id}"', array( 'form_id' => $connected_form ) ); |
494 | 494 | return false; |
495 | 495 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function get_content( $output, $entry = array(), $field_settings = array(), $field = array() ) { |
60 | 60 | |
61 | 61 | /** Overridden by a template. */ |
62 | - if( ! empty( $field['field_path'] ) ) { return $output; } |
|
62 | + if ( ! empty( $field[ 'field_path' ] ) ) { return $output; } |
|
63 | 63 | |
64 | 64 | return $this->get_string_from_value( $output ); |
65 | 65 | } |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | switch ( intval( $value ) ) { |
79 | 79 | case self::ONE_TIME_PAYMENT: |
80 | 80 | default: |
81 | - $return = __('One-Time Payment', 'gravityview'); |
|
81 | + $return = __( 'One-Time Payment', 'gravityview' ); |
|
82 | 82 | break; |
83 | 83 | |
84 | 84 | case self::SUBSCRIPTION: |
85 | - $return = __('Subscription', 'gravityview'); |
|
85 | + $return = __( 'Subscription', 'gravityview' ); |
|
86 | 86 | break; |
87 | 87 | } |
88 | 88 |
@@ -72,7 +72,7 @@ |
||
72 | 72 | * |
73 | 73 | * @param mixed $value The value in. |
74 | 74 | * |
75 | - * @return mixed The value out. |
|
75 | + * @return string The value out. |
|
76 | 76 | */ |
77 | 77 | public function get_value( $value ) { |
78 | 78 | return $this->get_string_from_value( $value ); |
@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | |
24 | 24 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
25 | 25 | |
26 | - unset ( $field_options['search_filter'] ); |
|
26 | + unset ( $field_options[ 'search_filter' ] ); |
|
27 | 27 | |
28 | - if( 'edit' === $context ) { |
|
28 | + if ( 'edit' === $context ) { |
|
29 | 29 | return $field_options; |
30 | 30 | } |
31 | 31 | |
32 | - $this->add_field_support('link_to_post', $field_options ); |
|
32 | + $this->add_field_support( 'link_to_post', $field_options ); |
|
33 | 33 | |
34 | 34 | // @since 1.5.4 |
35 | - $this->add_field_support('dynamic_data', $field_options ); |
|
35 | + $this->add_field_support( 'dynamic_data', $field_options ); |
|
36 | 36 | |
37 | 37 | return $field_options; |
38 | 38 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $url = $title = $caption = $description = ''; |
60 | 60 | |
61 | 61 | // If there's a |:| match, process. Otherwise, empty array! |
62 | - if( preg_match( '/\|\:\|/', $value ) ) { |
|
62 | + if ( preg_match( '/\|\:\|/', $value ) ) { |
|
63 | 63 | list( $url, $title, $caption, $description ) = array_pad( explode( '|:|', $value ), 4, false ); |
64 | 64 | } |
65 | 65 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function get_field_input( $form, $value = '', $entry = null, GF_Field_Post_Image $field ) { |
90 | 90 | |
91 | - $id = (int) $field->id; |
|
92 | - $form_id = $form['id']; |
|
91 | + $id = (int)$field->id; |
|
92 | + $form_id = $form[ 'id' ]; |
|
93 | 93 | $input_name = "input_{$id}"; |
94 | 94 | $field_id = sprintf( 'input_%d_%d', $form_id, $id ); |
95 | 95 | $img_name = null; |
@@ -97,16 +97,16 @@ discard block |
||
97 | 97 | // Convert |:| to associative array |
98 | 98 | $img_array = self::explode_value( $value ); |
99 | 99 | |
100 | - if( ! empty( $img_array['url'] ) ) { |
|
100 | + if ( ! empty( $img_array[ 'url' ] ) ) { |
|
101 | 101 | |
102 | - $img_name = basename( $img_array['url'] ); |
|
102 | + $img_name = basename( $img_array[ 'url' ] ); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Set the $uploaded_files value so that the .ginput_preview renders, and the file upload is hidden |
106 | 106 | * @see GF_Field_Post_Image::get_field_input See the `<span class='ginput_preview'>` code |
107 | 107 | * @see GFFormsModel::get_temp_filename See the `rgget( $input_name, self::$uploaded_files[ $form_id ] );` code |
108 | 108 | */ |
109 | - if( empty( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
109 | + if ( empty( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
110 | 110 | GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $img_name; |
111 | 111 | } |
112 | 112 | } |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | * @hack |
136 | 136 | */ |
137 | 137 | if ( null !== $img_name ) { |
138 | - $current_file = sprintf( "<input name='%s' id='%s' type='hidden' value='%s' />", $input_name, $field_id, esc_url_raw( $img_array['url'] ) ); |
|
139 | - $gf_post_image_field_output = str_replace('<span class=\'ginput_preview\'>', '<span class=\'ginput_preview\'>'.$current_file, $gf_post_image_field_output ); |
|
138 | + $current_file = sprintf( "<input name='%s' id='%s' type='hidden' value='%s' />", $input_name, $field_id, esc_url_raw( $img_array[ 'url' ] ) ); |
|
139 | + $gf_post_image_field_output = str_replace( '<span class=\'ginput_preview\'>', '<span class=\'ginput_preview\'>' . $current_file, $gf_post_image_field_output ); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | return $gf_post_image_field_output; |